Package org.alfresco.rm.rest.api.impl
Class FilePlanComponentsApiUtils
- java.lang.Object
-
- org.alfresco.rm.rest.api.impl.FilePlanComponentsApiUtils
-
public class FilePlanComponentsApiUtils extends Object
Utility class that handles common api endpoint tasks- Since:
- 2.6
- Author:
- Ana Bozianu
-
-
Field Summary
Fields Modifier and Type Field Description static List<String>
CONTAINERS_FOR_CLASSIFIABLE_CHILDREN_ALIAS
static String
FILE_PLAN_ALIAS
static String
HOLDS_ALIAS
static String
RM_SITE_ID
static String
TRANSFERS_ALIAS
static List<QName>
TYPES_CAN_CREATE
static String
UNFILED_ALIAS
-
Constructor Summary
Constructors Constructor Description FilePlanComponentsApiUtils()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description NodeRef
createRMNode(NodeRef parentNodeRef, RMNode nodeInfo, Parameters parameters)
Create an RM nodeprotected List<String>
getAllowableOperations(NodeRef nodeRef, QName typeQName)
Helper method that generates allowable operation for the provided nodeBinaryResource
getContent(NodeRef nodeRef, Parameters parameters, boolean recordActivity)
QName
getFilePlanType()
Helper method to obtain file plan type or null if the rm site does not exist.List<FilterProp>
getListChildrenFilterProps(Parameters parameters, Set<String> listFolderChildrenEqualsQueryProperties)
Returns a List of filter properties specified by request parameters.List<Pair<QName,Boolean>>
getSortProperties(Parameters parameters)
TODONodeRef
lookupAndValidateNodeType(String nodeId, QName expectedNodeType)
lookup node and validate typeNodeRef
lookupAndValidateNodeType(String nodeId, QName expectedNodeType, String relativePath)
lookup node by id and relative path and validate typeNodeRef
lookupAndValidateNodeType(String nodeId, QName expectedNodeType, String relativePath, boolean readOnlyRelativePath)
lookup node by id and relative path and validate typeNodeRef
lookupAndValidateRelativePath(NodeRef parentNodeRef, String relativePath, boolean readOnlyRelativePath, QName nodesType)
Helper method that creates a relative path if it doesn't already exist and if relative path is not read only.NodeRef
lookupAndValidateRelativePath(NodeRef parentNodeRef, String relativePath, QName nodesType)
Helper method that creates a relative path if it doesn't already exist The relative path will be build with nodes of the type specified in nodesType If the relative path already exists the method validates if the last element is of type nodesType The method does not validate the type of parentNodeRefNodeRef
lookupByAllowedPlaceholders(String nodeId, List<String> allowedPlaceholders)
Lookup node by placeholder from allowed placeholder listNodeRef
lookupByPlaceholder(String nodeId)
Lookup node by placeholderMap<QName,Serializable>
mapToNodeProperties(Map<String,Object> properties)
Helper method that converts a map of String properties into a map of QName propertiesvoid
postActivity(FileInfo fileInfo, NodeRef parentNodeRef, String activityType)
Posts activities for given fileInfovoid
setActivityPoster(ActivityPoster poster)
void
setAuthenticationUtil(AuthenticationUtil authenticationUtil)
void
setCapabilityService(CapabilityService capabilityService)
void
setContentService(ContentService contentService)
void
setDictionaryService(DictionaryService dictionaryService)
void
setFileFolderService(FileFolderService fileFolderService)
void
setFilePlanService(FilePlanService filePlanService)
void
setMimetypeService(MimetypeService mimetypeService)
void
setNodes(Nodes nodes)
void
setNodeService(NodeService nodeService)
void
setPermissionService(PermissionService permissionService)
void
setRecordService(RecordService recordService)
void
setSites(RMSites sites)
void
updateNode(NodeRef nodeRef, RMNode updateInfo, Parameters parameters)
Utility method that updates a node's name and propertiesvoid
updateTransferContainer(NodeRef nodeRef, TransferContainer transferContainerInfo, Parameters parameters)
Utility method that updates a transfer container's name and propertiesNodeRef
uploadRecord(NodeRef parentNodeRef, UploadInfo uploadInfo, Parameters parameters)
Upload a recordNodeRef
validateAndLookUpContainerNode(String nodeId, List<String> allowedPlaceholders)
look up node by id and validate node type is suitable containerNodeRef
validateRecord(String recordId)
Validates a recordvoid
writeContent(NodeRef nodeRef, String fileName, InputStream stream, boolean guessEncoding)
Write content to file
-
-
-
Field Detail
-
FILE_PLAN_ALIAS
public static final String FILE_PLAN_ALIAS
- See Also:
- Constant Field Values
-
TRANSFERS_ALIAS
public static final String TRANSFERS_ALIAS
- See Also:
- Constant Field Values
-
UNFILED_ALIAS
public static final String UNFILED_ALIAS
- See Also:
- Constant Field Values
-
HOLDS_ALIAS
public static final String HOLDS_ALIAS
- See Also:
- Constant Field Values
-
RM_SITE_ID
public static final String RM_SITE_ID
- See Also:
- Constant Field Values
-
CONTAINERS_FOR_CLASSIFIABLE_CHILDREN_ALIAS
public static final List<String> CONTAINERS_FOR_CLASSIFIABLE_CHILDREN_ALIAS
-
-
Method Detail
-
setNodes
public void setNodes(Nodes nodes)
-
setFileFolderService
public void setFileFolderService(FileFolderService fileFolderService)
-
setFilePlanService
public void setFilePlanService(FilePlanService filePlanService)
-
setNodeService
public void setNodeService(NodeService nodeService)
-
setContentService
public void setContentService(ContentService contentService)
-
setMimetypeService
public void setMimetypeService(MimetypeService mimetypeService)
-
setDictionaryService
public void setDictionaryService(DictionaryService dictionaryService)
-
setCapabilityService
public void setCapabilityService(CapabilityService capabilityService)
-
setPermissionService
public void setPermissionService(PermissionService permissionService)
-
setRecordService
public void setRecordService(RecordService recordService)
-
setAuthenticationUtil
public void setAuthenticationUtil(AuthenticationUtil authenticationUtil)
-
setActivityPoster
public void setActivityPoster(ActivityPoster poster)
-
setSites
public void setSites(RMSites sites)
-
lookupAndValidateNodeType
public NodeRef lookupAndValidateNodeType(String nodeId, QName expectedNodeType) throws EntityNotFoundException
lookup node and validate type- Parameters:
nodeId
-expectedNodeType
-- Returns:
- Throws:
EntityNotFoundException
-
lookupAndValidateNodeType
public NodeRef lookupAndValidateNodeType(String nodeId, QName expectedNodeType, String relativePath) throws EntityNotFoundException
lookup node by id and relative path and validate type- Parameters:
nodeId
-expectedNodeType
-relativePath
-- Returns:
- Throws:
EntityNotFoundException
-
lookupAndValidateNodeType
public NodeRef lookupAndValidateNodeType(String nodeId, QName expectedNodeType, String relativePath, boolean readOnlyRelativePath) throws EntityNotFoundException
lookup node by id and relative path and validate type- Parameters:
nodeId
-expectedNodeType
-relativePath
-- Returns:
- Throws:
EntityNotFoundException
-
validateAndLookUpContainerNode
public NodeRef validateAndLookUpContainerNode(String nodeId, List<String> allowedPlaceholders)
look up node by id and validate node type is suitable container- Parameters:
nodeId
-- Returns:
-
lookupByAllowedPlaceholders
public NodeRef lookupByAllowedPlaceholders(String nodeId, List<String> allowedPlaceholders)
Lookup node by placeholder from allowed placeholder list- Parameters:
nodeId
-allowedPlaceholders
-- Returns:
- NodeRef for corresponding id
-
lookupByPlaceholder
public NodeRef lookupByPlaceholder(String nodeId)
Lookup node by placeholder- Parameters:
nodeId
-- Returns:
- NodeRef for corresponding id
-
getSortProperties
public List<Pair<QName,Boolean>> getSortProperties(Parameters parameters)
TODO- Parameters:
parameters
-- Returns:
-
writeContent
public void writeContent(NodeRef nodeRef, String fileName, InputStream stream, boolean guessEncoding)
Write content to file- Parameters:
nodeRef
- the node to write the content tofileName
- the name of the file (used for guessing the file's mimetype)stream
- the input stream to writeguessEncoding
- whether to guess stream encoding
-
lookupAndValidateRelativePath
public NodeRef lookupAndValidateRelativePath(NodeRef parentNodeRef, String relativePath, QName nodesType)
Helper method that creates a relative path if it doesn't already exist The relative path will be build with nodes of the type specified in nodesType If the relative path already exists the method validates if the last element is of type nodesType The method does not validate the type of parentNodeRef- Parameters:
parentNodeRef
- the first node of the pathrelativePath
- a string representing the relative path in the format "Folder1/Folder2/Folder3"nodesType
- the type of all the containers in the path- Returns:
- the last element of the relative path
-
lookupAndValidateRelativePath
public NodeRef lookupAndValidateRelativePath(NodeRef parentNodeRef, String relativePath, boolean readOnlyRelativePath, QName nodesType)
Helper method that creates a relative path if it doesn't already exist and if relative path is not read only. If relative path is read only an exception will be thrown if the provided relative path does not exist. The relative path will be build with nodes of the type specified in nodesType If the relative path already exists the method validates if the last element is of type nodesType The method does not validate the type of parentNodeRef- Parameters:
parentNodeRef
- the first node of the pathrelativePath
- a string representing the relative path in the format "Folder1/Folder2/Folder3"readOnlyRelativePath
- the flag that indicates if the relativePath should be created if doesn't exist or notnodesType
- the type of all the containers in the path- Returns:
- the last element of the relative path
-
mapToNodeProperties
public Map<QName,Serializable> mapToNodeProperties(Map<String,Object> properties)
Helper method that converts a map of String properties into a map of QName properties- Parameters:
properties
-- Returns:
- a map of properties
-
createRMNode
public NodeRef createRMNode(NodeRef parentNodeRef, RMNode nodeInfo, Parameters parameters)
Create an RM node- Parameters:
parentNodeRef
- the parent of the nodenodeInfo
- the node infos to createparameters
- the object to get the parameters passed into the request- Returns:
- the new node
-
uploadRecord
public NodeRef uploadRecord(NodeRef parentNodeRef, UploadInfo uploadInfo, Parameters parameters)
Upload a record- Parameters:
parentNodeRef
- the parent of the recorduploadInfo
- the infos of the uploaded recordparameters
- the object to get the parameters passed into the request- Returns:
- the new record
-
getListChildrenFilterProps
public List<FilterProp> getListChildrenFilterProps(Parameters parameters, Set<String> listFolderChildrenEqualsQueryProperties)
Returns a List of filter properties specified by request parameters.- Parameters:
parameters
- TheParameters
object to get the parameters passed into the request including: - filter, sort & paging params (where, orderBy, skipCount, maxItems)- Returns:
- The list of
FilterProp
. Can be null.
-
updateNode
public void updateNode(NodeRef nodeRef, RMNode updateInfo, Parameters parameters)
Utility method that updates a node's name and properties- Parameters:
nodeRef
- the node to updateupdateInfo
- information to update the record withparameters
- request parameters
-
validateRecord
public NodeRef validateRecord(String recordId) throws InvalidArgumentException
Validates a record- Parameters:
recordId
- the id of the record to validate- Returns:
- Throws:
InvalidArgumentException
-
getContent
public BinaryResource getContent(NodeRef nodeRef, Parameters parameters, boolean recordActivity)
-
updateTransferContainer
public void updateTransferContainer(NodeRef nodeRef, TransferContainer transferContainerInfo, Parameters parameters)
Utility method that updates a transfer container's name and properties- Parameters:
nodeRef
- the node to updatetransferContainerInfo
- information to update the transfer container withparameters
- request parameters
-
getAllowableOperations
protected List<String> getAllowableOperations(NodeRef nodeRef, QName typeQName)
Helper method that generates allowable operation for the provided node- Parameters:
nodeRef
- the node to get the allowable operations fortypeQName
- the type of the provided nodeRef- Returns:
- a sublist of [
Nodes.OP_DELETE
,Nodes.OP_CREATE
,Nodes.OP_UPDATE
] representing the allowable operations for the provided node
-
getFilePlanType
public QName getFilePlanType()
Helper method to obtain file plan type or null if the rm site does not exist.- Returns:
- file plan type or null
-
-