Class AbstractContentEximService
java.lang.Object
org.onehippo.forge.content.exim.repository.jaxrs.AbstractContentEximService
- Direct Known Subclasses:
ContentEximExportService
,ContentEximImportService
,ContentEximProcessStatusService
AbstractContentEximService.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final String
Zip Entry name prefix for the binary attachments.protected static final String
The whole execution log file entry name.protected static final String
Zip Entry name of the summary log for binaries.protected static final String
Zip Entry name of the summary log for documents.protected static final String
Stop signal file's relative path under the zip creating base folder.protected static final Credentials
System session credentials.protected static final String
Prefix of the temporary folder or files. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected 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 Session
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, jakarta.ws.rs.core.SecurityContext securityContext, jakarta.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 Session
Return the JCR session given by the DaemonModule.protected com.fasterxml.jackson.databind.ObjectMapper
Return the default Jackson ObjectMapper instance.protected org.onehippo.forge.content.exim.repository.jaxrs.ProcessMonitor
getQueriedNodePaths
(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
(jakarta.ws.rs.core.SecurityContext securityContext, jakarta.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
Convert theContentMigrationRecord
instance to aResultItem
instance.protected void
setDaemonSession
(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 Details
-
SYSTEM_CREDENTIALS
System session credentials. -
TEMP_PREFIX
Prefix of the temporary folder or files. e.g, temporary folder in zip content creation.- See Also:
-
EXIM_EXECUTION_LOG_REL_PATH
The whole execution log file entry name.- See Also:
-
EXIM_SUMMARY_BINARIES_LOG_REL_PATH
Zip Entry name of the summary log for binaries.- See Also:
-
EXIM_SUMMARY_DOCUMENTS_LOG_REL_PATH
Zip Entry name of the summary log for documents.- See Also:
-
BINARY_ATTACHMENT_REL_PATH
Zip Entry name prefix for the binary attachments.- See Also:
-
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:
-
-
Constructor Details
-
AbstractContentEximService
public AbstractContentEximService()Default constructor.
-
-
Method Details
-
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
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
Set the JCR session, supposed to be set by the DaemonModule.- Parameters:
daemonSession
- the JCR session given by the DaemonModule
-
createSession
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:
LoginException
- if impersonation with system credentials failsRepositoryException
- 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
Convert theContentMigrationRecord
instance to aResultItem
instance.- Parameters:
record
- aContentMigrationRecord
instance- Returns:
- a converted
ResultItem
instance
-
getQueriedNodePaths
protected Set<String> getQueriedNodePaths(Session session, String statement, String language) throws 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:
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(jakarta.ws.rs.core.SecurityContext securityContext, jakarta.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, jakarta.ws.rs.core.SecurityContext securityContext, jakarta.servlet.http.HttpServletRequest request) Fill basic info fromsecurityContext
andrequest
inprocess
.- Parameters:
process
- processsecurityContext
- security contextrequest
- servlet request
-
createTeeLogger
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
-