use of org.apache.chemistry.opencmis.commons.enums.BaseTypeId in project copper-cms by PogeyanOSS.
the class ServletHelpers method postToBaseMessage.
static BaseMessage postToBaseMessage(POSTHttpServletRequestWrapper request, String[] pathFragments, IUserObject userObject) {
PostRequest postRequest = new PostRequest();
ControlParser controlParser = new ControlParser(request);
if (controlParser != null) {
CmisRequestParameter requestParameter = new CmisRequestParameter();
postRequest.setPropertyData(controlParser.getProperties());
postRequest.setAddAcl(requestParameter.createAddAcl(controlParser, postRequest));
postRequest.setRemoveAcl(requestParameter.createRemoveAcl(controlParser, postRequest));
postRequest.setPolicies(requestParameter.createPolicies(controlParser, postRequest));
postRequest.setMultipart(request.isMultiPart());
postRequest.setContentStream(requestParameter.createContentStream(request));
postRequest.setObjectIds(requestParameter.getObjectIds(controlParser, postRequest));
postRequest.setChangeTokens(requestParameter.getChangeTokens(controlParser, postRequest));
postRequest.setAddSecondaryTypes(requestParameter.addSecondaryTypes(controlParser, postRequest));
postRequest.setRemoveSecondaryTypes(requestParameter.getChangeTokens(controlParser, postRequest));
postRequest.setPolicyId(requestParameter.getPolicyId(controlParser, postRequest));
postRequest.setAclPropagation(requestParameter.getAclPropagation(controlParser, postRequest));
}
postRequest.setParameterMap(request.getParameterMap());
postRequest.setBaseUrl((String) request.getAttribute(BrowserConstants.BASE_URL_ATTRIBUTE));
postRequest.setScheme(request.getScheme());
postRequest.setServerName(request.getServerName());
postRequest.setServerPort(request.getServerPort());
postRequest.setContextPath(request.getContextPath());
postRequest.setServletPath(request.getServletPath());
String cmisAction = HttpUtils.getStringParameter(request, BrowserConstants.CONTROL_CMISACTION);
postRequest.setCmisAction(cmisAction);
String objectId = HttpUtils.getStringParameter(request, BrowserConstants.CONTROL_OBJECT_ID);
postRequest.setObjectId(objectId);
if (pathFragments.length > 0) {
postRequest.setRepositoryId(pathFragments[0]);
if (objectId != null) {
ObjectData object = ServletHelpers.getObjectDataFor(pathFragments[0], objectId, pathFragments);
String typeId = getStringPropertyValue(object, PropertyIds.OBJECT_TYPE_ID);
postRequest.setTypeId(typeId);
BaseTypeId baseTypeId = BaseTypeId.fromValue(getStringPropertyValue(object, PropertyIds.BASE_TYPE_ID));
postRequest.setBaseTypeId(baseTypeId);
}
}
String token = HttpUtils.getStringParameter(request, BrowserConstants.CONTROL_TOKEN);
postRequest.setToken(token);
postRequest.setRequestBody(request.getRequestBody());
if (cmisAction == null || cmisAction.length() == 0) {
throw new CmisNotSupportedException("Unknown action");
}
postRequest.setPathFragments(pathFragments);
if (userObject != null) {
postRequest.setUserName(userObject.getUserDN());
postRequest.setUserObject(userObject);
}
BaseMessage bm = BaseMessage.create("", cmisAction, postRequest);
return bm;
}
use of org.apache.chemistry.opencmis.commons.enums.BaseTypeId in project structr by structr.
the class CMISObjectWrapper method wrap.
// ----- public static methods -----
public static CMISObjectWrapper wrap(final GraphObject source, final String propertyFilter, final Boolean includeAllowableActions) throws FrameworkException {
CMISObjectWrapper wrapper = null;
if (source != null) {
final CMISInfo cmisInfo = source.getCMISInfo();
if (cmisInfo != null) {
final BaseTypeId baseTypeId = cmisInfo.getBaseTypeId();
if (baseTypeId != null) {
switch(baseTypeId) {
case CMIS_DOCUMENT:
wrapper = new CMISDocumentWrapper(propertyFilter, includeAllowableActions);
wrapper.initializeFrom(cmisInfo.getDocumentInfo());
break;
case CMIS_FOLDER:
wrapper = new CMISFolderWrapper(propertyFilter, includeAllowableActions);
wrapper.initializeFrom(cmisInfo.getFolderInfo());
break;
case CMIS_ITEM:
wrapper = new CMISItemWrapper(propertyFilter, includeAllowableActions);
wrapper.initializeFrom(cmisInfo.getItemInfo());
break;
case CMIS_POLICY:
wrapper = new CMISPolicyWrapper(propertyFilter, includeAllowableActions);
wrapper.initializeFrom(cmisInfo.getPolicyInfo());
break;
case CMIS_RELATIONSHIP:
wrapper = new CMISRelationshipWrapper(propertyFilter, includeAllowableActions);
wrapper.initializeFrom(cmisInfo.getRelationshipInfo());
break;
case CMIS_SECONDARY:
wrapper = new CMISSecondaryWrapper(propertyFilter, includeAllowableActions);
wrapper.initializeFrom(cmisInfo.getSecondaryInfo());
break;
}
}
}
}
return wrapper;
}
use of org.apache.chemistry.opencmis.commons.enums.BaseTypeId in project structr by structr.
the class CMISRepositoryService method getTypeDescendants.
@Override
public List<TypeDefinitionContainer> getTypeDescendants(String repositoryId, String typeId, BigInteger depth, Boolean includePropertyDefinitions, ExtensionsData extension) {
// important: descendants are ALL children and children of children, i.e. the whole tree
/*
Id typeId: The typeId of an object-type specified in the repository.
- If specified, then the repository MUST return all of descendant types of the specified type.
- If not specified, then the Repository MUST return all types and MUST ignore the value of the depth parameter.
*/
final List<TypeDefinitionContainer> results = new LinkedList<>();
if (typeId != null) {
final BaseTypeId baseTypeId = getBaseTypeId(typeId);
if (baseTypeId != null) {
final TypeDefinition typeDefinition = getTypeDefinition(repositoryId, typeId, extension);
final TypeDefinitionContainer container = getTypeDefinitionContainer(typeDefinition, includePropertyDefinitions);
results.add(container);
} else {
final Class type = StructrApp.getConfiguration().getNodeEntityClass(typeId);
if (type != null) {
final TypeDefinition typeDefinition = extendTypeDefinition(type, includePropertyDefinitions);
if (typeDefinition != null) {
results.add(getTypeDefinitionContainer(typeDefinition, includePropertyDefinitions));
} else {
throw new CmisObjectNotFoundException("Type with ID " + typeId + " does not exist");
}
} else {
throw new CmisObjectNotFoundException("Type with ID " + typeId + " does not exist");
}
}
} else {
results.add(getTypeDefinitionContainer(getDocumentTypeDefinition(BaseTypeId.CMIS_DOCUMENT.value(), includePropertyDefinitions, true), includePropertyDefinitions));
results.add(getTypeDefinitionContainer(getFolderTypeDefinition(BaseTypeId.CMIS_FOLDER.value(), includePropertyDefinitions, true), includePropertyDefinitions));
results.add(getTypeDefinitionContainer(getItemTypeDefinition(BaseTypeId.CMIS_ITEM.value(), includePropertyDefinitions, true), includePropertyDefinitions));
results.add(getTypeDefinitionContainer(getPolicyTypeDefinition(BaseTypeId.CMIS_POLICY.value(), includePropertyDefinitions, true), includePropertyDefinitions));
results.add(getTypeDefinitionContainer(getRelationshipTypeDefinition(BaseTypeId.CMIS_RELATIONSHIP.value(), includePropertyDefinitions, true), includePropertyDefinitions));
results.add(getTypeDefinitionContainer(getSecondaryTypeDefinition(BaseTypeId.CMIS_SECONDARY.value(), includePropertyDefinitions, true), includePropertyDefinitions));
}
return results;
}
use of org.apache.chemistry.opencmis.commons.enums.BaseTypeId in project structr by structr.
the class CMISObjectService method createDocument.
@Override
public String createDocument(final String repositoryId, final Properties properties, final String folderId, final ContentStream contentStream, final VersioningState versioningState, final List<String> policies, final Acl addAces, final Acl removeAces, final ExtensionsData extension) {
final App app = StructrApp.getInstance(securityContext);
File newFile = null;
String uuid = null;
try (final Tx tx = app.tx()) {
final String objectTypeId = getStringValue(properties, PropertyIds.OBJECT_TYPE_ID);
final String fileName = getStringValue(properties, PropertyIds.NAME);
final Class type = typeFromObjectTypeId(objectTypeId, BaseTypeId.CMIS_DOCUMENT, File.class);
// check if type exists
if (type != null) {
// check that base type is cmis:folder
final BaseTypeId baseTypeId = getBaseTypeId(type);
if (baseTypeId != null && BaseTypeId.CMIS_DOCUMENT.equals(baseTypeId)) {
final String mimeType = contentStream != null ? contentStream.getMimeType() : null;
// create file
newFile = FileHelper.createFile(securityContext, new byte[0], mimeType, type, fileName);
if (newFile != null) {
// find and set parent if it exists
if (!CMISInfo.ROOT_FOLDER_ID.equals(folderId)) {
final Folder parent = app.get(Folder.class, folderId);
if (parent != null) {
newFile.setParent(parent);
} else {
throw new CmisObjectNotFoundException("Folder with ID " + folderId + " does not exist");
}
}
uuid = newFile.getUuid();
if (contentStream != null) {
final InputStream inputStream = contentStream.getStream();
if (inputStream != null) {
// copy file and update metadata
try (final OutputStream outputStream = newFile.getOutputStream(false, false)) {
IOUtils.copy(inputStream, outputStream);
}
inputStream.close();
FileHelper.updateMetadata(newFile);
}
}
}
} else {
throw new CmisConstraintException("Cannot create cmis:document of type " + objectTypeId);
}
} else {
throw new CmisObjectNotFoundException("Type with ID " + objectTypeId + " does not exist");
}
tx.success();
} catch (Throwable t) {
throw new CmisRuntimeException("New document could not be created: " + t.getMessage());
}
// start indexing after transaction is finished
if (newFile != null) {
newFile.notifyUploadCompletion();
}
return uuid;
}
use of org.apache.chemistry.opencmis.commons.enums.BaseTypeId in project SearchServices by Alfresco.
the class AlfrescoSolrDataModel method getCMISFunctionEvaluationContext.
public CmisFunctionEvaluationContext getCMISFunctionEvaluationContext(CMISQueryMode mode, CmisVersion cmisVersion, String alternativeDictionary) {
BaseTypeId[] validScopes = (mode == CMISQueryMode.CMS_STRICT) ? CmisFunctionEvaluationContext.STRICT_SCOPES : CmisFunctionEvaluationContext.ALFRESCO_SCOPES;
CmisFunctionEvaluationContext functionContext = new CmisFunctionEvaluationContext();
functionContext.setCmisDictionaryService(getCMISDictionary(alternativeDictionary, cmisVersion));
functionContext.setValidScopes(validScopes);
return functionContext;
}
Aggregations