org.apache.chemistry.opencmis.commons.definitions.TypeDefinition Java Examples
The following examples show how to use
org.apache.chemistry.opencmis.commons.definitions.TypeDefinition.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LDRepository.java From document-management-software with GNU Lesser General Public License v3.0 | 7 votes |
/** * Create dispatch for AtomPub * * @param context call context * @param properties the properties * @param folderId identifier of the parent folder * @param contentStream stream of the document to create * @param versioningState state of the version * @param objectInfos informations * * @return the newly created object */ public ObjectData create(CallContext context, Properties properties, String folderId, ContentStream contentStream, VersioningState versioningState, ObjectInfoHandler objectInfos) { debug("create " + folderId); validatePermission(folderId, context, Permission.WRITE); String typeId = getTypeId(properties); TypeDefinition type = types.getType(typeId); if (type == null) throw new CmisObjectNotFoundException("Type '" + typeId + "' is unknown!"); String objectId = null; if (type.getBaseTypeId() == BaseTypeId.CMIS_DOCUMENT) { objectId = createDocument(context, properties, folderId, contentStream, versioningState); return compileObjectType(context, getDocument(objectId), null, false, false, objectInfos); } else if (type.getBaseTypeId() == BaseTypeId.CMIS_FOLDER) { objectId = createFolder(context, properties, folderId); return compileObjectType(context, getFolder(objectId), null, false, false, objectInfos); } else { throw new CmisObjectNotFoundException("Cannot create object of type '" + typeId + "'!"); } }
Example #2
Source File: TypeManager.java From document-management-software with GNU Lesser General Public License v3.0 | 6 votes |
/** * Gathers the type descendants tree * * @param depth depth specifications * @param tc the container * @param includePropertyDefinitions if the property definitions must be included * * @return the definition container */ private TypeDefinitionContainer getTypesDescendants(int depth, TypeDefinitionContainer tc, boolean includePropertyDefinitions) { TypeDefinitionContainerImpl result = new TypeDefinitionContainerImpl(); TypeDefinition type = copyTypeDefintion(tc.getTypeDefinition()); if (!includePropertyDefinitions) { type.getPropertyDefinitions().clear(); } result.setTypeDefinition(type); if (depth != 0) { if (tc.getChildren() != null) { result.setChildren(new ArrayList<TypeDefinitionContainer>()); for (TypeDefinitionContainer tdc : tc.getChildren()) { result.getChildren() .add(getTypesDescendants(depth < 0 ? -1 : depth - 1, tdc, includePropertyDefinitions)); } } } return result; }
Example #3
Source File: CmisServiceBridge.java From spring-content with Apache License 2.0 | 6 votes |
static ObjectDataImpl toObjectData(CmisRepositoryConfiguration config, CallContext context, TypeDefinition type, Object object, boolean root, Set<String> filter, ObjectInfoHandler objectInfos) { ObjectDataImpl result = new ObjectDataImpl(); ObjectInfoImpl objectInfo = new ObjectInfoImpl(); compileObjectMetadata(objectInfo, type); result.setProperties(compileProperties(config, type, object, root, filter, objectInfo)); result.setAllowableActions(compileAllowableActions(type, object, false, false)); if (context.isObjectInfoRequired()) { objectInfo.setObject(result); objectInfos.addObjectInfo(objectInfo); } return result; }
Example #4
Source File: CmisServiceBridge.java From spring-content with Apache License 2.0 | 6 votes |
public CmisServiceBridge(CmisRepositoryConfiguration cmisRepositoryConfiguration) { this.cmisRepositoryConfiguration = cmisRepositoryConfiguration; for (TypeDefinition typeDef : cmisRepositoryConfiguration.getCmisTypeDefinitionList().getList()) { typeMap.put(typeDef.getId(), typeDef); } DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar(); registrar.setDateTimeFormatter(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")); registrar.registerFormatters(conversionService); conversionService.addConverter(new Converter<Instant, GregorianCalendar>() { @Override public GregorianCalendar convert(Instant source) { ZonedDateTime zdt = ZonedDateTime.ofInstant(source, ZoneId.systemDefault()); return GregorianCalendar.from(zdt); } }); }
Example #5
Source File: Converter.java From document-management-software with GNU Lesser General Public License v3.0 | 6 votes |
/** * Converts a type list * * @param typeList the list to convert * * @return the converted definition list */ public static TypeDefinitionList convert(CmisTypeDefinitionListType typeList) { if (typeList == null) { return null; } TypeDefinitionListImpl result = new TypeDefinitionListImpl(); List<TypeDefinition> types = new ArrayList<TypeDefinition>(); for (CmisTypeDefinitionType typeDefinition : typeList.getTypes()) { types.add(convert(typeDefinition)); } result.setList(types); result.setHasMoreItems(typeList.isHasMoreItems()); result.setNumItems(typeList.getNumItems()); // handle extensions convertExtension(typeList, result); return result; }
Example #6
Source File: Converter.java From document-management-software with GNU Lesser General Public License v3.0 | 6 votes |
/** * Converts a type list * * @param typeList list of types * * @return the CMIS definitions */ public static CmisTypeDefinitionListType convert(TypeDefinitionList typeList) { if (typeList == null) { return null; } CmisTypeDefinitionListType result = new CmisTypeDefinitionListType(); if (typeList.getList() != null) { for (TypeDefinition tdd : typeList.getList()) { result.getTypes().add(convert(tdd)); } } result.setHasMoreItems(convertBoolean(typeList.hasMoreItems(), false)); result.setNumItems(typeList.getNumItems()); // handle extensions convertExtension(typeList, result); return result; }
Example #7
Source File: IbisRepositoryService.java From iaf with Apache License 2.0 | 6 votes |
@Override public TypeDefinition getTypeDefinition(String repositoryId, String typeId, ExtensionsData extension) { if(!eventDispatcher.contains(CmisEvent.GET_TYPE_DEFINITION)) { return repositoryService.getTypeDefinition(repositoryId, typeId, extension); } else { XmlBuilder cmisXml = new XmlBuilder("cmis"); cmisXml.addSubElement(buildXml("repositoryId", repositoryId)); cmisXml.addSubElement(buildXml("typeId", typeId)); Element cmisResult = eventDispatcher.trigger(CmisEvent.GET_TYPE_DEFINITION, cmisXml.toXML(), callContext); Element typesXml = XmlUtils.getFirstChildTag(cmisResult, "typeDefinitions"); return CmisUtils.xml2TypeDefinition(XmlUtils.getFirstChildTag(typesXml, "typeDefinition"), callContext.getCmisVersion()); } }
Example #8
Source File: CmisServiceBridge.java From spring-content with Apache License 2.0 | 6 votes |
static boolean checkAddProperty(Properties properties, TypeDefinition type, Set<String> filter, String id) { if ((properties == null) || (properties.getProperties() == null)) { throw new IllegalArgumentException("Properties must not be null!"); } if (id == null) { throw new IllegalArgumentException("Id must not be null!"); } if (!type.getPropertyDefinitions().containsKey(id)) { throw new IllegalArgumentException("Unknown property: " + id); } String queryName = type.getPropertyDefinitions().get(id).getQueryName(); if ((queryName != null) && (filter != null)) { if (!filter.contains(queryName)) { return false; } else { filter.remove(queryName); } } return true; }
Example #9
Source File: AbstractTypeDefinitionWrapper.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 6 votes |
public TypeDefinition getTypeDefinition(boolean includePropertyDefinitions) { lock.readLock().lock(); try { if (includePropertyDefinitions) { return typeDefInclProperties; } else { return typeDef; } } finally { lock.readLock().unlock(); } }
Example #10
Source File: CmisTypeManager.java From document-management-system with GNU General Public License v2.0 | 6 votes |
/** * Gathers the type descendants tree. */ private TypeDefinitionContainer getTypesDescendants(int depth, TypeDefinitionContainer tc, boolean includePropertyDefinitions) { TypeDefinitionContainerImpl result = new TypeDefinitionContainerImpl(); TypeDefinition type = copyTypeDefintion(tc.getTypeDefinition()); if (!includePropertyDefinitions) { type.getPropertyDefinitions().clear(); } result.setTypeDefinition(type); if (depth != 0) { if (tc.getChildren() != null) { result.setChildren(new ArrayList<TypeDefinitionContainer>()); for (TypeDefinitionContainer tdc : tc.getChildren()) { result.getChildren().add(getTypesDescendants(depth < 0 ? -1 : depth - 1, tdc, includePropertyDefinitions)); } } } return result; }
Example #11
Source File: CmisServiceBridge.java From spring-content with Apache License 2.0 | 5 votes |
static void addPropertyId(PropertiesImpl props, TypeDefinition type, Set<String> filter, String id, String value) { if (!checkAddProperty(props, type, filter, id)) { return; } props.addProperty(new PropertyIdImpl(id, value)); }
Example #12
Source File: CMISTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * ACE-33 * * Cmis Item support */ @Test public void testItems() { withCmisService(new CmisServiceCallback<String>() { @Override public String execute(CmisService cmisService) { List<RepositoryInfo> repositories = cmisService.getRepositoryInfos(null); assertTrue(repositories.size() > 0); RepositoryInfo repo = repositories.get(0); String repositoryId = repo.getId(); TypeDefinition def = cmisService.getTypeDefinition(repositoryId, "cmis:item", null); assertNotNull("the cmis:item type is not defined", def); @SuppressWarnings("unused") TypeDefinition p = cmisService.getTypeDefinition(repositoryId, "I:cm:person", null); assertNotNull("the I:cm:person type is not defined", def); ObjectList result = cmisService.query(repositoryId, "select * from cm:person", Boolean.FALSE, Boolean.TRUE, IncludeRelationships.NONE, "", BigInteger.TEN, BigInteger.ZERO, null); assertTrue("", result.getNumItems().intValue() > 0); return ""; }; }, CmisVersion.CMIS_1_1); }
Example #13
Source File: CmisServiceBridge.java From spring-content with Apache License 2.0 | 5 votes |
static void addPropertyDateTime(PropertiesImpl props, TypeDefinition type, Set<String> filter, String id, GregorianCalendar value) { if (!checkAddProperty(props, type, filter, id)) { return; } props.addProperty(new PropertyDateTimeImpl(id, value)); }
Example #14
Source File: CmisServiceBridge.java From spring-content with Apache License 2.0 | 5 votes |
static void addPropertyBoolean(PropertiesImpl props, TypeDefinition type, Set<String> filter, String id, boolean value) { if (!checkAddProperty(props, type, filter, id)) { return; } props.addProperty(new PropertyBooleanImpl(id, value)); }
Example #15
Source File: CmisServiceBridge.java From spring-content with Apache License 2.0 | 5 votes |
static void addPropertyBigInteger(PropertiesImpl props, TypeDefinition type, Set<String> filter, String id, BigInteger value) { if (!checkAddProperty(props, type, filter, id)) { return; } props.addProperty(new PropertyIntegerImpl(id, value)); }
Example #16
Source File: TypeManager.java From document-management-software with GNU Lesser General Public License v3.0 | 5 votes |
/** * Adds a type to collection with inheriting base type properties * * @param type the type * * @return if the type has been added */ public boolean addType(TypeDefinition type) { if (type == null) { return false; } if (type.getBaseTypeId() == null) { return false; } // find base type TypeDefinition baseType = null; if (type.getBaseTypeId() == BaseTypeId.CMIS_DOCUMENT) { baseType = copyTypeDefintion(types.get(DOCUMENT_TYPE_ID).getTypeDefinition()); } else if (type.getBaseTypeId() == BaseTypeId.CMIS_FOLDER) { baseType = copyTypeDefintion(types.get(FOLDER_TYPE_ID).getTypeDefinition()); } else if (type.getBaseTypeId() == BaseTypeId.CMIS_RELATIONSHIP) { baseType = copyTypeDefintion(types.get(RELATIONSHIP_TYPE_ID).getTypeDefinition()); } else if (type.getBaseTypeId() == BaseTypeId.CMIS_POLICY) { baseType = copyTypeDefintion(types.get(POLICY_TYPE_ID).getTypeDefinition()); } else { return false; } AbstractTypeDefinition newType = (AbstractTypeDefinition) copyTypeDefintion(type); // copy property definition for (PropertyDefinition<?> propDef : baseType.getPropertyDefinitions().values()) { ((AbstractPropertyDefinition<?>) propDef).setIsInherited(true); newType.addPropertyDefinition(propDef); } // add it addTypeInteral(newType); log.info("Added type '" + newType.getId() + "'."); return true; }
Example #17
Source File: CmisTypeManager.java From document-management-system with GNU General Public License v2.0 | 5 votes |
/** * For internal use. */ public TypeDefinition getType(String typeId) { TypeDefinitionContainer tc = types.get(typeId); if (tc == null) { return null; } return tc.getTypeDefinition(); }
Example #18
Source File: CmisTypeManager.java From document-management-system with GNU General Public License v2.0 | 5 votes |
/** * CMIS getTypeDefinition. */ public TypeDefinition getTypeDefinition(CallContext context, String typeId) { TypeDefinitionContainer tc = types.get(typeId); if (tc == null) { throw new CmisObjectNotFoundException("Type '" + typeId + "' is unknown!"); } return copyTypeDefintion(tc.getTypeDefinition()); }
Example #19
Source File: CmisServiceBridge.java From spring-content with Apache License 2.0 | 5 votes |
static void addPropertyString(PropertiesImpl props, TypeDefinition type, Set<String> filter, String id, String value) { if (!checkAddProperty(props, type, filter, id)) { return; } props.addProperty(new PropertyStringImpl(id, value)); }
Example #20
Source File: ConformanceCmisServiceWrapper.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override public TypeDefinition getTypeDefinition(String repositoryId, String typeId, ExtensionsData extension) { checkRepositoryId(repositoryId); checkId("Type Id", typeId); try { return getWrappedService().getTypeDefinition(repositoryId, typeId, extension); } catch (Exception e) { throw createCmisException(e); } }
Example #21
Source File: CmisTypeDefinitionFactoryBean.java From spring-content with Apache License 2.0 | 5 votes |
@Override public TypeDefinition getObject() throws Exception { CmisDocument cmisDocumentMetadata = entityClass.getAnnotation(CmisDocument.class); CmisFolder cmisFolderMetadata = entityClass.getAnnotation(CmisFolder.class); if (cmisDocumentMetadata != null) { return createDocumentTypeDefinition(entityClass, repoClass, storeClass, cmisDocumentMetadata, CmisVersion.CMIS_1_1, null); } else if (cmisFolderMetadata != null) { return createFolderTypeDefinition(entityClass, repoClass, cmisFolderMetadata, CmisVersion.CMIS_1_1, null); } throw new IllegalStateException(format("Unknown type definition: %s", entityClass)); }
Example #22
Source File: CmisServiceBridge.java From spring-content with Apache License 2.0 | 5 votes |
TypeDefinition getType(Object object) { Assert.notNull(object, () -> "object is null"); if (object.getClass().getAnnotation(CmisFolder.class) != null) { return typeMap.get("cmis:folder"); } else if (object.getClass().getAnnotation(CmisDocument.class) != null) { return typeMap.get("cmis:document"); } throw new IllegalStateException(format("invalid type %s", object.getClass())); }
Example #23
Source File: CmisServiceBridge.java From spring-content with Apache License 2.0 | 5 votes |
static void compileObjectMetadata(ObjectInfoImpl objectInfo, TypeDefinition type) { if (type.getId().equals(BaseTypeId.CMIS_FOLDER.value())) { objectInfo.setBaseType(BaseTypeId.CMIS_FOLDER); objectInfo.setTypeId(BaseTypeId.CMIS_FOLDER.value()); objectInfo.setContentType(null); objectInfo.setFileName(null); objectInfo.setHasAcl(true); objectInfo.setHasContent(false); objectInfo.setVersionSeriesId(null); objectInfo.setIsCurrentVersion(true); objectInfo.setRelationshipSourceIds(null); objectInfo.setRelationshipTargetIds(null); objectInfo.setRenditionInfos(null); objectInfo.setSupportsDescendants(true); objectInfo.setSupportsFolderTree(true); objectInfo.setSupportsPolicies(false); objectInfo.setSupportsRelationships(false); objectInfo.setWorkingCopyId(null); objectInfo.setWorkingCopyOriginalId(null); } else { objectInfo.setBaseType(BaseTypeId.CMIS_DOCUMENT); objectInfo.setTypeId(BaseTypeId.CMIS_DOCUMENT.value()); objectInfo.setHasAcl(true); objectInfo.setHasContent(true); objectInfo.setHasParent(true); objectInfo.setVersionSeriesId(null); objectInfo.setIsCurrentVersion(true); objectInfo.setRelationshipSourceIds(null); objectInfo.setRelationshipTargetIds(null); objectInfo.setRenditionInfos(null); objectInfo.setSupportsDescendants(false); objectInfo.setSupportsFolderTree(false); objectInfo.setSupportsPolicies(false); objectInfo.setSupportsRelationships(false); objectInfo.setWorkingCopyId(null); objectInfo.setWorkingCopyOriginalId(null); } }
Example #24
Source File: ConformanceCmisServiceWrapper.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override public TypeDefinition createType(String repositoryId, TypeDefinition type, ExtensionsData extension) { checkRepositoryId(repositoryId); checkTypeDefinition(type); try { return getWrappedService().createType(repositoryId, type, extension); } catch (Exception e) { throw createCmisException(e); } }
Example #25
Source File: ConformanceCmisServiceWrapper.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override public TypeDefinition updateType(String repositoryId, TypeDefinition type, ExtensionsData extension) { checkRepositoryId(repositoryId); checkTypeDefinition(type); try { return getWrappedService().updateType(repositoryId, type, extension); } catch (Exception e) { throw createCmisException(e); } }
Example #26
Source File: ContentCmisService.java From spring-content with Apache License 2.0 | 5 votes |
@Override public TypeDefinition getTypeDefinition(String repositoryId, String typeId, ExtensionsData extension) { return bridge.getTypeDefinition(config, typeId, extension); }
Example #27
Source File: TypeManager.java From document-management-software with GNU Lesser General Public License v3.0 | 5 votes |
/** * For internal use * * @param typeId identifier of the type * * @return the type definition */ public TypeDefinition getType(String typeId) { TypeDefinitionContainer tc = types.get(typeId); if (tc == null) { return null; } return tc.getTypeDefinition(); }
Example #28
Source File: TypeManager.java From document-management-software with GNU Lesser General Public License v3.0 | 5 votes |
/** * CMIS getTypeDefinition * * @param context call context * @param typeId identifier of the type * * @return definition of the type */ public TypeDefinition getTypeDefinition(CallContext context, String typeId) { TypeDefinitionContainer tc = types.get(typeId); if (tc == null) { throw new CmisObjectNotFoundException("Type '" + typeId + "' is unknown!"); } return copyTypeDefintion(tc.getTypeDefinition()); }
Example #29
Source File: CmisUtils.java From iaf with Apache License 2.0 | 5 votes |
public static List<TypeDefinitionContainer> xml2TypeDescendants(Element typeDefinitionsXml, CmisVersion cmisVersion) { List<TypeDefinitionContainer> typeDefinitionList = new ArrayList<TypeDefinitionContainer>(); Collection<Node> typeDescendantList = XmlUtils.getChildTags(typeDefinitionsXml, "typeDescendant"); for (Node node : typeDescendantList) { Element typeDefinition = XmlUtils.getFirstChildTag((Element) node, "typeDefinition"); TypeDefinition typeDef = CmisUtils.xml2TypeDefinition(typeDefinition, cmisVersion); TypeDefinitionContainerImpl typeDefinitionContainer = new TypeDefinitionContainerImpl(typeDef); Element children = XmlUtils.getFirstChildTag((Element) node, "children"); typeDefinitionContainer.setChildren(xml2TypeDescendants(children, cmisVersion)); typeDefinitionList.add(typeDefinitionContainer); } return typeDefinitionList; }
Example #30
Source File: AlfrescoCmisServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override public TypeDefinition getTypeDefinition(String repositoryId, String typeId, ExtensionsData extension) { checkRepositoryId(repositoryId); // find the type TypeDefinitionWrapper tdw = connector.getOpenCMISDictionaryService().findType(typeId); if (tdw == null) { throw new CmisObjectNotFoundException("Type '" + typeId + "' is unknown!"); } // return type definition return tdw.getTypeDefinition(true); }