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 class
BaseSynchroService.FileInfoPathComparator
-
Field Summary
Fields Modifier and Type Field Description static Logger
logger
static String
SERVLET_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 void
applyAction(BaseSynchroContext context, String path, AbstractSynchroContext.SynchroAction action)
Apply the action required for the path.protected void
applyActions(BaseSynchroContext context)
CallAbstractSynchroService.applyAction(AbstractSynchroContext, String, SynchroAction)
for each path with a required action.protected String
buildConflictPath(String path)
File
buildLocalFile(String relativePath)
File
buildLocalFile(FileInfo fileInfo)
String
buildURL(String url)
protected boolean
copyDistantToLocal(BaseSynchroContext context, FileInfo distantInfo)
protected boolean
copyLocalToDistant(BaseSynchroContext context, FileInfo localInfo)
protected boolean
copyLocalToDistant(BaseSynchroContext context, FileInfo localInfo, int retry)
protected void
deleteDistantDirectories(BaseSynchroContext context)
protected boolean
deleteDistantFile(BaseSynchroContext context, FileInfo distantInfo)
protected void
deleteLocalDirectories(BaseSynchroContext context)
protected boolean
deleteLocalFile(BaseSynchroContext context, FileInfo localInfo)
File
getBaseFolderFile()
String
getDistantName()
Get the name of the distant side.HttpClientService
getHttpClientService()
protected void
initializeContext(BaseSynchroContext context, Object previousState)
Initialize the context.boolean
isManageDeletedFiles()
boolean
isRefreshAll()
boolean
isSplitBigFiles()
protected FileInfo
moveLocalFile(BaseSynchroContext context, FileInfo localInfo, String newPath)
BaseSynchroContext
newSynchroContext()
Instanciate a context for ONE synchro run.protected void
onActionsApplied(BaseSynchroContext context)
Called when all actions are applied.protected void
onFatalException(BaseSynchroContext context, SynchroFatalException ex)
Called when anSynchroFatalException
is thrown during the synchro process.protected void
onNonFatalException(BaseSynchroContext context, SynchroNonFatalException ex, String currentFilePath)
Called when anSynchroNonFatalException
is thrown during the synchro process.protected void
onUncaughtException(BaseSynchroContext context, Throwable ex)
Called when an exception is thrown during the synchro process.void
pushContext(String context)
boolean
sendCommand(String paramName, String paramValue)
void
sendRefresh()
void
setManageDeletedFiles(boolean manageDeletedFiles)
void
setRefreshAll(boolean refreshAll)
void
setSplitBigFiles(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:AbstractSynchroService
Get the name of the distant side.- Specified by:
getDistantName
in classAbstractSynchroService<BaseSynchroContext>
- Returns:
- the ditant name
-
getHttpClientService
public HttpClientService getHttpClientService()
-
newSynchroContext
public BaseSynchroContext newSynchroContext()
Description copied from class:AbstractSynchroService
Instanciate a context for ONE synchro run.- Specified by:
newSynchroContext
in classAbstractSynchroService<BaseSynchroContext>
- Returns:
- an instance of
AbstractSynchroContext
specialized for the currentAbstractSynchroService
implementation.
-
initializeContext
protected void initializeContext(BaseSynchroContext context, Object previousState) throws SynchroFatalException
Description copied from class:AbstractSynchroService
Initialize the context. It's the first method that can thrown synchro exception.- Overrides:
initializeContext
in classAbstractSynchroService<BaseSynchroContext>
- Throws:
SynchroFatalException
-
applyActions
protected void applyActions(BaseSynchroContext context)
Description copied from class:AbstractSynchroService
CallAbstractSynchroService.applyAction(AbstractSynchroContext, String, SynchroAction)
for each path with a required action.- Overrides:
applyActions
in classAbstractSynchroService<BaseSynchroContext>
- Parameters:
context
- the currentAbstractSynchroContext
-
applyAction
protected void applyAction(BaseSynchroContext context, String path, AbstractSynchroContext.SynchroAction action) throws SynchroNonFatalException
Description copied from class:AbstractSynchroService
Apply the action required for the path.- Specified by:
applyAction
in 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:AbstractSynchroService
Called when all actions are applied.- Overrides:
onActionsApplied
in classAbstractSynchroService<BaseSynchroContext>
- Parameters:
context
- the currentAbstractSynchroContext
-
onNonFatalException
protected void onNonFatalException(BaseSynchroContext context, SynchroNonFatalException ex, String currentFilePath)
Description copied from class:AbstractSynchroService
Called when anSynchroNonFatalException
is thrown during the synchro process. Only the current file will be skipped.- Overrides:
onNonFatalException
in classAbstractSynchroService<BaseSynchroContext>
- Parameters:
context
- the currentAbstractSynchroContext
-
onFatalException
protected void onFatalException(BaseSynchroContext context, SynchroFatalException ex)
Description copied from class:AbstractSynchroService
Called when anSynchroFatalException
is thrown during the synchro process. This is fatal for ONE run.- Overrides:
onFatalException
in classAbstractSynchroService<BaseSynchroContext>
- Parameters:
context
- the currentAbstractSynchroContext
-
onUncaughtException
protected void onUncaughtException(BaseSynchroContext context, Throwable ex)
Description copied from class:AbstractSynchroService
Called when an exception is thrown during the synchro process. This is fatal for ONE run.- Overrides:
onUncaughtException
in classAbstractSynchroService<BaseSynchroContext>
- Parameters:
context
- the currentAbstractSynchroContext
. Can benull
if the exception is thrown during the call ofAbstractSynchroService.newSynchroContext()
.
-
isRefreshAll
public boolean isRefreshAll()
-
setRefreshAll
public void setRefreshAll(boolean refreshAll)
-
-