Class AbstractContentEximService
- java.lang.Object
-
- org.onehippo.forge.content.exim.repository.jaxrs.AbstractContentEximService
-
- Direct Known Subclasses:
ContentEximExportService
,ContentEximImportService
,ContentEximProcessStatusService
public abstract class AbstractContentEximService extends Object
AbstractContentEximService.
-
-
Field Summary
Fields Modifier and Type Field Description protected static String
BINARY_ATTACHMENT_REL_PATH
Zip Entry name prefix for the binary attachments.protected static String
EXIM_EXECUTION_LOG_REL_PATH
The whole execution log file entry name.protected static String
EXIM_SUMMARY_BINARIES_LOG_REL_PATH
Zip Entry name of the summary log for binaries.protected static String
EXIM_SUMMARY_DOCUMENTS_LOG_REL_PATH
Zip Entry name of the summary log for documents.protected static String
STOP_REQUEST_FILE_REL_PATH
Stop signal file's relative path under the zip creating base folder.protected static javax.jcr.Credentials
SYSTEM_CREDENTIALS
System session credentials.protected static String
TEMP_PREFIX
Prefix of the temporary folder or files.
-
Constructor Summary
Constructors Constructor Description AbstractContentEximService()
Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
applyTagContentProperties(org.onehippo.forge.content.pojo.model.ContentNode contentNode, Set<String> tagInfos)
Apply tag field on the content node with givetagInfos
list, each item of which should look like "myhippoproject:tags=a,b,c".protected String
attachmentToString(org.apache.cxf.jaxrs.ext.multipart.Attachment attachment, String charsetName)
Read the CXF attachment JAX-RS argument and convert it to a string.protected javax.jcr.Session
createSession()
Create a new JCR system session by impersonating the JCR session returned fromgetDaemonSession()
.protected org.slf4j.Logger
createTeeLogger(org.slf4j.Logger mainLogger, PrintStream secondOutput)
Create a tee-ing logger.protected void
fillProcessStatusByRequestInfo(ProcessStatus process, javax.ws.rs.core.SecurityContext securityContext, javax.servlet.http.HttpServletRequest request)
Fill basic info fromsecurityContext
andrequest
inprocess
.protected org.apache.cxf.jaxrs.ext.multipart.Attachment
getAttachmentByContentId(List<org.apache.cxf.jaxrs.ext.multipart.Attachment> attachments, String contentId)
Find the attachment inattachments
list by thecontentId
.protected javax.jcr.Session
getDaemonSession()
Return the JCR session given by the DaemonModule.protected com.fasterxml.jackson.databind.ObjectMapper
getObjectMapper()
Return the default Jackson ObjectMapper instance.protected org.onehippo.forge.content.exim.repository.jaxrs.ProcessMonitor
getProcessMonitor()
protected Set<String>
getQueriedNodePaths(javax.jcr.Session session, String statement, String language)
Executes JCR query using the querystatement
in the querylanguage
and collect all the result node paths in a set to return.protected String
getUserPrincipalName(javax.ws.rs.core.SecurityContext securityContext, javax.servlet.http.HttpServletRequest request)
Find user principal's name fromsecurityContext
orrequest
.protected boolean
isBinaryPathIncluded(AntPathMatcher pathMatcher, ExecutionParams params, String path)
Return true if the givenpath
is included in theparam
's binary path includes parameter.protected boolean
isDocumentPathIncluded(AntPathMatcher pathMatcher, ExecutionParams params, String path)
Return true if the givenpath
is included in theparam
's document path includes parameter.protected boolean
isStopRequested(org.apache.commons.vfs2.FileObject baseFolder)
Return true if a stop signal file is found under the base folder.protected void
overrideExecutionParamsByParameters(ExecutionParams params, String batchSizeParam, String throttleParam, String publishOnImportParam, String dataUrlSizeThresholdParam, String docbasePropNamesParam, String documentTagsParam, String binaryTagsParam)
Overrideparams
by the give request parameter values.protected ResultItem
recordToResultItem(ContentMigrationRecord record)
Convert theContentMigrationRecord
instance to aResultItem
instance.protected void
setDaemonSession(javax.jcr.Session daemonSession)
Set the JCR session, supposed to be set by the DaemonModule.protected void
setProcessMonitor(org.onehippo.forge.content.exim.repository.jaxrs.ProcessMonitor processMonitor)
protected String
toJsonString(Object object)
Return a JSON string by stringifying theobject
with the Jackson ObjectMapper.protected void
transferAttachmentToFile(org.apache.cxf.jaxrs.ext.multipart.Attachment attachment, File file)
Transfer attachment content into the givenfile
.
-
-
-
Field Detail
-
SYSTEM_CREDENTIALS
protected static final javax.jcr.Credentials SYSTEM_CREDENTIALS
System session credentials.
-
TEMP_PREFIX
protected static final String TEMP_PREFIX
Prefix of the temporary folder or files. e.g, temporary folder in zip content creation.- See Also:
- Constant Field Values
-
EXIM_EXECUTION_LOG_REL_PATH
protected static final String EXIM_EXECUTION_LOG_REL_PATH
The whole execution log file entry name.- See Also:
- Constant Field Values
-
EXIM_SUMMARY_BINARIES_LOG_REL_PATH
protected static final String EXIM_SUMMARY_BINARIES_LOG_REL_PATH
Zip Entry name of the summary log for binaries.- See Also:
- Constant Field Values
-
EXIM_SUMMARY_DOCUMENTS_LOG_REL_PATH
protected static final String EXIM_SUMMARY_DOCUMENTS_LOG_REL_PATH
Zip Entry name of the summary log for documents.- See Also:
- Constant Field Values
-
BINARY_ATTACHMENT_REL_PATH
protected static final String BINARY_ATTACHMENT_REL_PATH
Zip Entry name prefix for the binary attachments.- See Also:
- Constant Field Values
-
STOP_REQUEST_FILE_REL_PATH
protected static final String STOP_REQUEST_FILE_REL_PATH
Stop signal file's relative path under the zip creating base folder. If this file is found in the process, the export or import process will stop right away.- See Also:
- Constant Field Values
-
-
Method Detail
-
setProcessMonitor
protected void setProcessMonitor(org.onehippo.forge.content.exim.repository.jaxrs.ProcessMonitor processMonitor)
-
getProcessMonitor
protected org.onehippo.forge.content.exim.repository.jaxrs.ProcessMonitor getProcessMonitor()
-
getObjectMapper
protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
Return the default Jackson ObjectMapper instance.- Returns:
- ObjectMapper instance
-
getDaemonSession
protected javax.jcr.Session getDaemonSession()
Return the JCR session given by the DaemonModule. It is not supposed to use this JCR session directly to retrieve or manipulate content. You should usecreateSession()
for that purpose instead.- Returns:
- the JCR session given by the DaemonModule
-
setDaemonSession
protected void setDaemonSession(javax.jcr.Session daemonSession)
Set the JCR session, supposed to be set by the DaemonModule.- Parameters:
daemonSession
- the JCR session given by the DaemonModule
-
createSession
protected javax.jcr.Session createSession() throws javax.jcr.LoginException, javax.jcr.RepositoryException
Create a new JCR system session by impersonating the JCR session returned fromgetDaemonSession()
.- Returns:
- a new JCR system session by impersonating the JCR session returned from
getDaemonSession()
- Throws:
javax.jcr.LoginException
- if impersonation with system credentials failsjavax.jcr.RepositoryException
- if repository exception occurs
-
isStopRequested
protected boolean isStopRequested(org.apache.commons.vfs2.FileObject baseFolder)
Return true if a stop signal file is found under the base folder.- Parameters:
baseFolder
- the base folder where zip content files are created temporarily.- Returns:
- true if a stop signal file is found under the base folder
-
toJsonString
protected String toJsonString(Object object) throws com.fasterxml.jackson.core.JsonProcessingException
Return a JSON string by stringifying theobject
with the Jackson ObjectMapper.- Parameters:
object
- object to stringify- Returns:
- a JSON string by stringifying the
object
with the Jackson ObjectMapper - Throws:
com.fasterxml.jackson.core.JsonProcessingException
- if JSON stringifying fails
-
attachmentToString
protected String attachmentToString(org.apache.cxf.jaxrs.ext.multipart.Attachment attachment, String charsetName) throws IOException
Read the CXF attachment JAX-RS argument and convert it to a string.- Parameters:
attachment
- CXF attachment JAX-RS argumentcharsetName
- charset name used in encoding- Returns:
- string converted from the CXF attachment JAX-RS argument
- Throws:
IOException
- if IO exception occurs
-
transferAttachmentToFile
protected void transferAttachmentToFile(org.apache.cxf.jaxrs.ext.multipart.Attachment attachment, File file) throws IOException
Transfer attachment content into the givenfile
.- Parameters:
attachment
- attachmentfile
- destination file- Throws:
IOException
- if IO exception occurs
-
recordToResultItem
protected ResultItem recordToResultItem(ContentMigrationRecord record)
Convert theContentMigrationRecord
instance to aResultItem
instance.- Parameters:
record
- aContentMigrationRecord
instance- Returns:
- a converted
ResultItem
instance
-
getQueriedNodePaths
protected Set<String> getQueriedNodePaths(javax.jcr.Session session, String statement, String language) throws javax.jcr.RepositoryException
Executes JCR query using the querystatement
in the querylanguage
and collect all the result node paths in a set to return.- Parameters:
session
- JCR sessionstatement
- JCR query statementlanguage
- JCR query language- Returns:
- a set containing all the nodes from the query result
- Throws:
javax.jcr.RepositoryException
- if repository exception occurs
-
overrideExecutionParamsByParameters
protected void overrideExecutionParamsByParameters(ExecutionParams params, String batchSizeParam, String throttleParam, String publishOnImportParam, String dataUrlSizeThresholdParam, String docbasePropNamesParam, String documentTagsParam, String binaryTagsParam)
Overrideparams
by the give request parameter values.- Parameters:
params
-ExecutionParams
instancebatchSizeParam
- batch size request parameter valuethrottleParam
- throttle request parameter valuepublishOnImportParam
- publishOnImport request parameter valuedataUrlSizeThresholdParam
- dataUrlSizeThreshold request parameter valuedocbasePropNamesParam
- docbasePropNames request parameter valuedocumentTagsParam
- documentTags request parameter valuebinaryTagsParam
- binaryTags request parameter value
-
getAttachmentByContentId
protected org.apache.cxf.jaxrs.ext.multipart.Attachment getAttachmentByContentId(List<org.apache.cxf.jaxrs.ext.multipart.Attachment> attachments, String contentId)
Find the attachment inattachments
list by thecontentId
.- Parameters:
attachments
- attachment listcontentId
- content Id- Returns:
- the attachment in
attachments
list found by thecontentId
-
applyTagContentProperties
protected boolean applyTagContentProperties(org.onehippo.forge.content.pojo.model.ContentNode contentNode, Set<String> tagInfos)
Apply tag field on the content node with givetagInfos
list, each item of which should look like "myhippoproject:tags=a,b,c".- Parameters:
contentNode
- content nodetagInfos
- tag info line like "myhippoproject:tags=a,b,c"- Returns:
- true if any tag field is added
-
getUserPrincipalName
protected String getUserPrincipalName(javax.ws.rs.core.SecurityContext securityContext, javax.servlet.http.HttpServletRequest request)
Find user principal's name fromsecurityContext
orrequest
.- Parameters:
securityContext
- security contextrequest
- servlet request- Returns:
- user principal's name from
securityContext
orrequest
-
fillProcessStatusByRequestInfo
protected void fillProcessStatusByRequestInfo(ProcessStatus process, javax.ws.rs.core.SecurityContext securityContext, javax.servlet.http.HttpServletRequest request)
Fill basic info fromsecurityContext
andrequest
inprocess
.- Parameters:
process
- processsecurityContext
- security contextrequest
- servlet request
-
createTeeLogger
protected org.slf4j.Logger createTeeLogger(org.slf4j.Logger mainLogger, PrintStream secondOutput)
Create a tee-ing logger.- Parameters:
mainLogger
- main loggersecondOutput
- output for the second logger- Returns:
- a tee-ing logger
-
isBinaryPathIncluded
protected boolean isBinaryPathIncluded(AntPathMatcher pathMatcher, ExecutionParams params, String path)
Return true if the givenpath
is included in theparam
's binary path includes parameter.- Parameters:
pathMatcher
- AntPathMatcher instanceparams
- Execution paramspath
- binary path- Returns:
- true if the given
path
is included in theparam
's binary path includes parameter
-
isDocumentPathIncluded
protected boolean isDocumentPathIncluded(AntPathMatcher pathMatcher, ExecutionParams params, String path)
Return true if the givenpath
is included in theparam
's document path includes parameter.- Parameters:
pathMatcher
- AntPathMatcher instanceparams
- Execution paramspath
- document path- Returns:
- true if the given
path
is included in theparam
's document path includes parameter
-
-