org.nuiton.wikitty.publication.synchro
Class WikittyPublicationFileSystem

java.lang.Object
  extended by org.nuiton.wikitty.publication.AbstractWikittyFileService
      extended by org.nuiton.wikitty.publication.synchro.WikittyPublicationFileSystem
All Implemented Interfaces:
WikittyService

public class WikittyPublicationFileSystem
extends AbstractWikittyFileService


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.nuiton.wikitty.WikittyService
WikittyService.ServiceListenerType
 
Field Summary
protected  List<String> directoryNameBlackList
          List of directory name that does'nt have to be harvest exampe : .svn, .git
protected  File homeFile
          The working directory of the wikitty service
protected  String label
          The initial label of the wikitties, and the path to the first wikitties of the working directory
static String META_CURRENT_LABEL
          Property key to store the current label in a wikittyProperty meta file.
static String META_PREFIX_KEY_CHECKSUM
          property key used in the metaPropertyFile to store the wikitty's content checksum
static String META_PREFIX_KEY_ID
          property key used in the metaPropertyFile to store the wikitty's id
static String META_PREFIX_KEY_VERSION
          property key used in the metaPropertyFile to store the wikitty's version
protected  MimeTypePubHelper mimeHelper
          the mimeType Handler used to determine mimeType for file extension and if file have to be converted as wikittyPubText or WikittyPubData
static String PROPERTY_DIRECTORY
          the file name of the property directory
protected  boolean recursion
          if recursion is chose
 
Constructor Summary
WikittyPublicationFileSystem(org.nuiton.util.ApplicationConfig app)
          Default constructor, call by a factory
 
Method Summary
 void addWikittyServiceListener(WikittyListener listener, WikittyService.ServiceListenerType type)
           
 boolean canDelete(String securityToken, String wikittyId)
           
 boolean canRead(String securityToken, String wikittyId)
           
 boolean canWrite(String securityToken, Wikitty wikitty)
           
protected  void checkModifications(File child)
          Check with the corresponding checksum if the file have been modified since the last check.
 WikittyEvent clear(String securityToken)
           
 WikittyEvent delete(String securityToken, Collection<String> ids)
           
 WikittyEvent deleteExtension(String securityToken, Collection<String> extNames)
           
 WikittyEvent deleteTree(String securityToken, String treeNodeId)
           
 boolean exists(String securityToken, String wikittyId)
           
 TreeNodeResult<String> findTreeNode(String securityToken, String wikittyId, int depth, boolean count, Criteria filter)
           
 List<String> getAllExtensionIds(String securityToken)
           
 List<String> getAllExtensionsRequires(String securityToken, String extensionName)
           
protected  Map<String,Wikitty> getAllWikitties()
          Method that must be implemented by the extended service.
 File getHomeFile()
           
 String getLabel()
           
static PropertiesExtended getWikittyPublicationProperties(File starts, String name)
          Simply return the propertyExtended corresponding that can be found in starts/.wp/ directory.
 org.apache.commons.collections.BidiMap harvestLocalWikitties(File starts, boolean recursivly)
           
protected  void harvestNewCheckModificationsAndDeleted(File starts, String label)
          Check on local file if there new file that have to be converted into wikitty, check wikitty if they have been modified, and check if some wikitty were deleted and update property
 List<File> harvestPropertyDirectory(File starts, boolean recursivly)
          Method that create a list of the properties directory
 boolean isDeleted(String securityToken, String wikittyId)
           
 boolean isRecursion()
           
 String login(String login, String password)
           
 void logout(String securityToken)
           
 void removeWikittyServiceListener(WikittyListener listener, WikittyService.ServiceListenerType type)
           
 WikittyEvent replay(String securityToken, List<WikittyEvent> events, boolean force)
           
protected  Wikitty restore(String id, FileSystemWIkittyId fileId)
          Restore the corresponding wikitty identify by the id and is location on the filesytem
 List<Wikitty> restore(String securityToken, List<String> id)
           
 WikittyExtension restoreExtension(String securityToken, String extensionId)
           
 Wikitty restoreVersion(String securityToken, String wikittyId, String version)
           
 void setHomeFile(File homeFile)
           
 void setLabel(String label)
           
 void setRecursion(boolean recursion)
           
 WikittyEvent store(String securityToken, Collection<Wikitty> wikitties, boolean force)
           
 WikittyEvent storeExtension(String securityToken, Collection<WikittyExtension> exts)
           
 void syncSearchEngine(String securityToken)
           
protected  void writeWikittyFileProperties(File towrite, String wikittyID, String wikittyVersion)
          write in properties file property about the file corresponding to a wikitty.
 
Methods inherited from class org.nuiton.wikitty.publication.AbstractWikittyFileService
checkRestriction, findAllByCriteria, findByCriteria, restoreExtensionLastVersion
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

homeFile

protected File homeFile
The working directory of the wikitty service


recursion

protected boolean recursion
if recursion is chose


label

protected String label
The initial label of the wikitties, and the path to the first wikitties of the working directory


META_CURRENT_LABEL

public static String META_CURRENT_LABEL
Property key to store the current label in a wikittyProperty meta file. Usefull to retrieve easily the wikitties and convert file as wikitty.


META_PREFIX_KEY_VERSION

public static String META_PREFIX_KEY_VERSION
property key used in the metaPropertyFile to store the wikitty's version


META_PREFIX_KEY_CHECKSUM

public static String META_PREFIX_KEY_CHECKSUM
property key used in the metaPropertyFile to store the wikitty's content checksum


META_PREFIX_KEY_ID

public static String META_PREFIX_KEY_ID
property key used in the metaPropertyFile to store the wikitty's id


PROPERTY_DIRECTORY

public static String PROPERTY_DIRECTORY
the file name of the property directory


mimeHelper

protected MimeTypePubHelper mimeHelper
the mimeType Handler used to determine mimeType for file extension and if file have to be converted as wikittyPubText or WikittyPubData


directoryNameBlackList

protected List<String> directoryNameBlackList
List of directory name that does'nt have to be harvest exampe : .svn, .git

Constructor Detail

WikittyPublicationFileSystem

public WikittyPublicationFileSystem(org.nuiton.util.ApplicationConfig app)
                             throws URISyntaxException,
                                    IOException
Default constructor, call by a factory

Parameters:
app - application config needed to correctly initialize this. Need wikitty url to be set (with URI format) and option for recursion, @see WikittyPublication for constant
Throws:
URISyntaxException - if serveur url is not in the proper format (URI format)
IOException - if error while creating/reading the wikitty service properties
Method Detail

getHomeFile

public File getHomeFile()

setHomeFile

public void setHomeFile(File homeFile)

isRecursion

public boolean isRecursion()

setRecursion

public void setRecursion(boolean recursion)

getLabel

public String getLabel()

setLabel

public void setLabel(String label)

addWikittyServiceListener

public void addWikittyServiceListener(WikittyListener listener,
                                      WikittyService.ServiceListenerType type)

removeWikittyServiceListener

public void removeWikittyServiceListener(WikittyListener listener,
                                         WikittyService.ServiceListenerType type)

login

public String login(String login,
                    String password)

logout

public void logout(String securityToken)

clear

public WikittyEvent clear(String securityToken)

canWrite

public boolean canWrite(String securityToken,
                        Wikitty wikitty)

canDelete

public boolean canDelete(String securityToken,
                         String wikittyId)

canRead

public boolean canRead(String securityToken,
                       String wikittyId)

exists

public boolean exists(String securityToken,
                      String wikittyId)

isDeleted

public boolean isDeleted(String securityToken,
                         String wikittyId)

replay

public WikittyEvent replay(String securityToken,
                           List<WikittyEvent> events,
                           boolean force)

store

public WikittyEvent store(String securityToken,
                          Collection<Wikitty> wikitties,
                          boolean force)

getAllExtensionIds

public List<String> getAllExtensionIds(String securityToken)

getAllExtensionsRequires

public List<String> getAllExtensionsRequires(String securityToken,
                                             String extensionName)

storeExtension

public WikittyEvent storeExtension(String securityToken,
                                   Collection<WikittyExtension> exts)

deleteExtension

public WikittyEvent deleteExtension(String securityToken,
                                    Collection<String> extNames)

restoreExtension

public WikittyExtension restoreExtension(String securityToken,
                                         String extensionId)

restore

public List<Wikitty> restore(String securityToken,
                             List<String> id)

delete

public WikittyEvent delete(String securityToken,
                           Collection<String> ids)

getAllWikitties

protected Map<String,Wikitty> getAllWikitties()
Description copied from class: AbstractWikittyFileService
Method that must be implemented by the extended service. This must return all the wikitty stored. The result will be use to checkrestriction for a find.

Specified by:
getAllWikitties in class AbstractWikittyFileService
Returns:
a Map with wikittyId as Key and wikitty as value

deleteTree

public WikittyEvent deleteTree(String securityToken,
                               String treeNodeId)

findTreeNode

public TreeNodeResult<String> findTreeNode(String securityToken,
                                           String wikittyId,
                                           int depth,
                                           boolean count,
                                           Criteria filter)

restoreVersion

public Wikitty restoreVersion(String securityToken,
                              String wikittyId,
                              String version)

syncSearchEngine

public void syncSearchEngine(String securityToken)

harvestPropertyDirectory

public List<File> harvestPropertyDirectory(File starts,
                                           boolean recursivly)
Method that create a list of the properties directory

Parameters:
starts - harvested directory
recursivly -
Returns:
list of harvested file

harvestLocalWikitties

public org.apache.commons.collections.BidiMap harvestLocalWikitties(File starts,
                                                                    boolean recursivly)
                                                             throws IOException
Parameters:
starts -
recursivly -
Returns:
Throws:
IOException

getWikittyPublicationProperties

public static PropertiesExtended getWikittyPublicationProperties(File starts,
                                                                 String name)
                                                          throws IOException
Simply return the propertyExtended corresponding that can be found in starts/.wp/ directory. It create the corresponding property file if does'nt exist

Parameters:
starts - the directory that containt a .wp directory containing the property
name - the property file name, use constants
Returns:
the properties extended requested
Throws:
IOException - if error while reading the file

restore

protected Wikitty restore(String id,
                          FileSystemWIkittyId fileId)
                   throws IOException
Restore the corresponding wikitty identify by the id and is location on the filesytem

Parameters:
id - the wikitty id
fileId - the wikitty file system id (his localisation on the wikittyFileSystem)
Returns:
the restored wikitty
Throws:
IOException - if errors while reading the file

harvestNewCheckModificationsAndDeleted

protected void harvestNewCheckModificationsAndDeleted(File starts,
                                                      String label)
                                               throws IOException
Check on local file if there new file that have to be converted into wikitty, check wikitty if they have been modified, and check if some wikitty were deleted and update property

Parameters:
starts - the starting directory
label - the current label, normaly equals to the starting directory
Throws:
IOException - if error while read file, read property

checkModifications

protected void checkModifications(File child)
                           throws IOException
Check with the corresponding checksum if the file have been modified since the last check. If so, it increment the minor version of the wikitty and store the new checksum and version

Parameters:
child - the file need to check if modified
Throws:
IOException

writeWikittyFileProperties

protected void writeWikittyFileProperties(File towrite,
                                          String wikittyID,
                                          String wikittyVersion)
                                   throws IOException
write in properties file property about the file corresponding to a wikitty. If the file does not match a wikitty yet set wikittyID and Wikittyversion to null

Parameters:
towrite - the file
wikittyID - wiitty id, null if wikitty does not exist yet
wikittyVersion - wikitty version, null if wikitty not exist yet
Throws:
IOException


Copyright © 2010-2011 CodeLutin. All Rights Reserved.