Package org.javlo.service.syncro
Class BaseSynchroService
- java.lang.Object
-
- org.javlo.service.syncro.AbstractSynchroService<BaseSynchroContext>
-
- org.javlo.service.syncro.BaseSynchroService
-
- Direct Known Subclasses:
ServerSynchroService
public abstract class BaseSynchroService extends AbstractSynchroService<BaseSynchroContext>
Javlo implementation of theAbstractSynchroService.- Author:
- bdumont
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classBaseSynchroService.FileInfoPathComparator
-
Field Summary
Fields Modifier and Type Field Description static Loggerloggerstatic StringSERVLET_RELATIVE_PATH
-
Constructor Summary
Constructors Constructor Description BaseSynchroService(HttpClientService httpClientService, File baseFolderFile)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidapplyAction(BaseSynchroContext context, String path, AbstractSynchroContext.SynchroAction action)Apply the action required for the path.protected voidapplyActions(BaseSynchroContext context)CallAbstractSynchroService.applyAction(AbstractSynchroContext, String, SynchroAction)for each path with a required action.protected StringbuildConflictPath(String path)FilebuildLocalFile(String relativePath)FilebuildLocalFile(FileInfo fileInfo)StringbuildURL(String url)protected booleancopyDistantToLocal(BaseSynchroContext context, FileInfo distantInfo)protected booleancopyLocalToDistant(BaseSynchroContext context, FileInfo localInfo)protected booleancopyLocalToDistant(BaseSynchroContext context, FileInfo localInfo, int retry)protected voiddeleteDistantDirectories(BaseSynchroContext context)protected booleandeleteDistantFile(BaseSynchroContext context, FileInfo distantInfo)protected voiddeleteLocalDirectories(BaseSynchroContext context)protected booleandeleteLocalFile(BaseSynchroContext context, FileInfo localInfo)FilegetBaseFolderFile()StringgetDistantName()Get the name of the distant side.HttpClientServicegetHttpClientService()protected voidinitializeContext(BaseSynchroContext context, Object previousState)Initialize the context.booleanisManageDeletedFiles()booleanisRefreshAll()booleanisSplitBigFiles()protected FileInfomoveLocalFile(BaseSynchroContext context, FileInfo localInfo, String newPath)BaseSynchroContextnewSynchroContext()Instanciate a context for ONE synchro run.protected voidonActionsApplied(BaseSynchroContext context)Called when all actions are applied.protected voidonFatalException(BaseSynchroContext context, SynchroFatalException ex)Called when anSynchroFatalExceptionis thrown during the synchro process.protected voidonNonFatalException(BaseSynchroContext context, SynchroNonFatalException ex, String currentFilePath)Called when anSynchroNonFatalExceptionis thrown during the synchro process.protected voidonUncaughtException(BaseSynchroContext context, Throwable ex)Called when an exception is thrown during the synchro process.voidpushContext(String context)booleansendCommand(String paramName, String paramValue)voidsendRefresh()voidsetManageDeletedFiles(boolean manageDeletedFiles)voidsetRefreshAll(boolean refreshAll)voidsetSplitBigFiles(boolean splitBigFiles)-
Methods inherited from class org.javlo.service.syncro.AbstractSynchroService
defineAction, defineActions, getLocalName, onActionsDefined, onShutdown, synchronize
-
-
-
-
Field Detail
-
logger
public static Logger logger
-
SERVLET_RELATIVE_PATH
public static final String SERVLET_RELATIVE_PATH
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BaseSynchroService
public BaseSynchroService(HttpClientService httpClientService, File baseFolderFile)
-
-
Method Detail
-
isManageDeletedFiles
public boolean isManageDeletedFiles()
-
setManageDeletedFiles
public void setManageDeletedFiles(boolean manageDeletedFiles)
-
isSplitBigFiles
public boolean isSplitBigFiles()
-
setSplitBigFiles
public void setSplitBigFiles(boolean splitBigFiles)
-
getBaseFolderFile
public File getBaseFolderFile()
-
getDistantName
public String getDistantName()
Description copied from class:AbstractSynchroServiceGet the name of the distant side.- Specified by:
getDistantNamein classAbstractSynchroService<BaseSynchroContext>- Returns:
- the ditant name
-
getHttpClientService
public HttpClientService getHttpClientService()
-
newSynchroContext
public BaseSynchroContext newSynchroContext()
Description copied from class:AbstractSynchroServiceInstanciate a context for ONE synchro run.- Specified by:
newSynchroContextin classAbstractSynchroService<BaseSynchroContext>- Returns:
- an instance of
AbstractSynchroContextspecialized for the currentAbstractSynchroServiceimplementation.
-
initializeContext
protected void initializeContext(BaseSynchroContext context, Object previousState) throws SynchroFatalException
Description copied from class:AbstractSynchroServiceInitialize the context. It's the first method that can thrown synchro exception.- Overrides:
initializeContextin classAbstractSynchroService<BaseSynchroContext>- Throws:
SynchroFatalException
-
applyActions
protected void applyActions(BaseSynchroContext context)
Description copied from class:AbstractSynchroServiceCallAbstractSynchroService.applyAction(AbstractSynchroContext, String, SynchroAction)for each path with a required action.- Overrides:
applyActionsin classAbstractSynchroService<BaseSynchroContext>- Parameters:
context- the currentAbstractSynchroContext
-
applyAction
protected void applyAction(BaseSynchroContext context, String path, AbstractSynchroContext.SynchroAction action) throws SynchroNonFatalException
Description copied from class:AbstractSynchroServiceApply the action required for the path.- Specified by:
applyActionin classAbstractSynchroService<BaseSynchroContext>- Parameters:
context- the currentAbstractSynchroContext- Throws:
SynchroNonFatalException
-
copyLocalToDistant
protected boolean copyLocalToDistant(BaseSynchroContext context, FileInfo localInfo) throws SynchroNonFatalException
- Throws:
SynchroNonFatalException
-
copyLocalToDistant
protected boolean copyLocalToDistant(BaseSynchroContext context, FileInfo localInfo, int retry) throws SynchroNonFatalException
- Throws:
SynchroNonFatalException
-
copyDistantToLocal
protected boolean copyDistantToLocal(BaseSynchroContext context, FileInfo distantInfo) throws SynchroNonFatalException
- Throws:
SynchroNonFatalException
-
deleteLocalFile
protected boolean deleteLocalFile(BaseSynchroContext context, FileInfo localInfo)
-
deleteLocalDirectories
protected void deleteLocalDirectories(BaseSynchroContext context)
-
deleteDistantFile
protected boolean deleteDistantFile(BaseSynchroContext context, FileInfo distantInfo)
-
deleteDistantDirectories
protected void deleteDistantDirectories(BaseSynchroContext context)
-
moveLocalFile
protected FileInfo moveLocalFile(BaseSynchroContext context, FileInfo localInfo, String newPath)
-
pushContext
public void pushContext(String context)
-
sendRefresh
public void sendRefresh()
-
onActionsApplied
protected void onActionsApplied(BaseSynchroContext context)
Description copied from class:AbstractSynchroServiceCalled when all actions are applied.- Overrides:
onActionsAppliedin classAbstractSynchroService<BaseSynchroContext>- Parameters:
context- the currentAbstractSynchroContext
-
onNonFatalException
protected void onNonFatalException(BaseSynchroContext context, SynchroNonFatalException ex, String currentFilePath)
Description copied from class:AbstractSynchroServiceCalled when anSynchroNonFatalExceptionis thrown during the synchro process. Only the current file will be skipped.- Overrides:
onNonFatalExceptionin classAbstractSynchroService<BaseSynchroContext>- Parameters:
context- the currentAbstractSynchroContext
-
onFatalException
protected void onFatalException(BaseSynchroContext context, SynchroFatalException ex)
Description copied from class:AbstractSynchroServiceCalled when anSynchroFatalExceptionis thrown during the synchro process. This is fatal for ONE run.- Overrides:
onFatalExceptionin classAbstractSynchroService<BaseSynchroContext>- Parameters:
context- the currentAbstractSynchroContext
-
onUncaughtException
protected void onUncaughtException(BaseSynchroContext context, Throwable ex)
Description copied from class:AbstractSynchroServiceCalled when an exception is thrown during the synchro process. This is fatal for ONE run.- Overrides:
onUncaughtExceptionin classAbstractSynchroService<BaseSynchroContext>- Parameters:
context- the currentAbstractSynchroContext. Can benullif the exception is thrown during the call ofAbstractSynchroService.newSynchroContext().
-
isRefreshAll
public boolean isRefreshAll()
-
setRefreshAll
public void setRefreshAll(boolean refreshAll)
-
-