org.apache.chemistry.opencmis.commons.data.Properties Java Examples

The following examples show how to use org.apache.chemistry.opencmis.commons.data.Properties. 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 vote down vote up
/**
 * CMIS updateProperties
 * 
 * @param context the call context
 * @param objectId identifier of the object
 * @param properties the properties
 * @param objectInfos informations
 * 
 * @return the updated object
 */
public ObjectData updateProperties(CallContext context, Holder<String> objectId, Properties properties,
		ObjectInfoHandler objectInfos) {
	debug("updateProperties " + objectId);
	validatePermission(objectId.getValue(), context, Permission.WRITE);

	try {
		// get the document or folder
		PersistentObject object = getObject(objectId.getValue());

		// get old properties
		Properties oldProperties = compileProperties(object, null, new ObjectInfoImpl());
		update(object, oldProperties, properties);

		return compileObjectType(context, object, null, false, false, objectInfos);
	} catch (Throwable t) {
		return (ObjectData) catchError(t);
	}
}
 
Example #2
Source File: CmisRepository.java    From document-management-system with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create* dispatch for AtomPub.
 */
public ObjectData create(CallContext context, Properties properties, String folderId, ContentStream contentStream,
                         VersioningState versioningState, ObjectInfoHandler objectInfos) {
	log.debug("create({}, {})", properties, folderId);

	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);
	} else if (type.getBaseTypeId() == BaseTypeId.CMIS_FOLDER) {
		objectId = createFolder(context, properties, folderId);
	} else {
		throw new CmisObjectNotFoundException("Cannot create object of type '" + typeId + "'!");
	}

	return compileObjectType(context, getNode(objectId), null, false, false, objectInfos);
}
 
Example #3
Source File: LDRepository.java    From document-management-software with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Returns the first value of an string property.
 */
private static String getStringProperty(Properties properties, String name) {

	PropertyData<?> property = properties.getProperties().get(name);

	if (property == null) {
		return null;
	}
	if (property instanceof PropertyId) {
		return ((PropertyId) property).getFirstValue();
	}
	if (!(property instanceof PropertyString)) {
		return null;
	}

	return ((PropertyString) property).getFirstValue();
}
 
Example #4
Source File: ContentCmisService.java    From spring-content with Apache License 2.0 6 votes vote down vote up
public String createFolder(String repositoryId,
		Properties properties,
		String folderId,
		List<String> policies,
		Acl addAces,
		Acl removeAces,
		ExtensionsData extension) {

	return bridge.createFolder(config,
			properties,
			folderId,
			policies,
			addAces,
			removeAces,
			extension);
}
 
Example #5
Source File: IbisObjectService.java    From iaf with Apache License 2.0 6 votes vote down vote up
@Override
public String createItem(String repositoryId, Properties properties,
		String folderId, List<String> policies, Acl addAces,
		Acl removeAces, ExtensionsData extension) {

	if(!eventDispatcher.contains(CmisEvent.CREATE_ITEM)) {
		return objectService.createItem(repositoryId, properties, folderId, policies, addAces, removeAces, extension);
	}
	else {
		XmlBuilder cmisXml = new XmlBuilder("cmis");
		cmisXml.addSubElement(buildXml("repositoryId", repositoryId));
		cmisXml.addSubElement(buildXml("folderId", folderId));
		cmisXml.addSubElement(buildXml("policies", policies));

		XmlBuilder propertiesXml = new XmlBuilder("properties");
		for (Iterator<PropertyData<?>> it = properties.getPropertyList().iterator(); it.hasNext();) {
			propertiesXml.addSubElement(CmisUtils.getPropertyXml(it.next()));
		}
		cmisXml.addSubElement(propertiesXml);

		Element result = eventDispatcher.trigger(CmisEvent.CREATE_ITEM, cmisXml.toXML(), callContext);
		return XmlUtils.getChildTagAsString(result, "id");
	}
}
 
Example #6
Source File: Converter.java    From document-management-software with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Converts a properties object
 * 
 * @param properties the object to convert
 * 
 * @return the converted properties object
 */
public static Properties convert(CmisPropertiesType properties) {
	if (properties == null) {
		return null;
	}

	PropertiesImpl result = new PropertiesImpl();

	for (CmisProperty property : properties.getProperty()) {
		result.addProperty(convert(property));
	}

	// handle extensions
	convertExtension(properties, result);

	return result;
}
 
Example #7
Source File: CMISConnector.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public Properties getNodeProperties(CMISNodeInfo info, String filter)
{
    PropertiesImpl result = new PropertiesImpl();

    Set<String> filterSet = splitFilter(filter);

    for (PropertyDefinitionWrapper propDef : info.getType().getProperties())
    {
        if (!propDef.getPropertyId().equals(PropertyIds.OBJECT_ID))
        {
            // don't filter the object id
            if ((filterSet != null) && (!filterSet.contains(propDef.getPropertyDefinition().getQueryName())))
            {
                // skip properties that are not in the filter
                continue;
            }
        }

        Serializable value = propDef.getPropertyAccessor().getValue(info);
        result.addProperty(getProperty(propDef.getPropertyDefinition().getPropertyType(), propDef, value));
    }

    addAspectProperties(info, filter, result);

    return result;
}
 
Example #8
Source File: CMISConnector.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public Properties getAssocProperties(CMISNodeInfo info, String filter)
{
    PropertiesImpl result = new PropertiesImpl();

    Set<String> filterSet = splitFilter(filter);

    for (PropertyDefinitionWrapper propDefWrap : info.getType().getProperties())
    {
        PropertyDefinition<?> propDef = propDefWrap.getPropertyDefinition();
        if ((filterSet != null) && (!filterSet.contains(propDef.getQueryName())))
        {
            // skip properties that are not in the filter
            continue;
        }

        CMISPropertyAccessor cmisPropertyAccessor = propDefWrap.getPropertyAccessor();
        Serializable value = cmisPropertyAccessor.getValue(info);
        PropertyType propType = propDef.getPropertyType();
        PropertyData<?> propertyData = getProperty(propType, propDefWrap, value);
        result.addProperty(propertyData);
    }

    return result;
}
 
Example #9
Source File: CmisServiceBridge.java    From spring-content with Apache License 2.0 6 votes vote down vote up
@Transactional
public void updateProperties(CmisRepositoryConfiguration config,
		String objectId,
		String changeToken,
		Properties properties,
		ExtensionsData extension) {

	Long id = conversionService.convert(objectId, Long.class);

	Optional<Object> object = config.cmisDocumentRepository().findById(id);
	if (object.isPresent()) {
		CmisPropertySetter propSetter = new CmisPropertySetter(properties);
		propSetter.populate(object.get());
		config.cmisDocumentRepository().save(object);
	}
}
 
Example #10
Source File: CMISConnector.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Returns the value of the given property if it exists and is of the
 * correct type.
 */
public String getIdProperty(Properties properties, String propertyId)
{
    if ((properties == null) || (properties.getProperties() == null))
    {
        return null;
    }

    PropertyData<?> property = properties.getProperties().get(propertyId);
    if (!(property instanceof PropertyId))
    {
        return null;
    }

    return ((PropertyId) property).getFirstValue();
}
 
Example #11
Source File: CMISConnector.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public String getNameProperty(Properties properties, String fallback)
{
    String name = getStringProperty(properties, PropertyIds.NAME);
    if ((name == null) || (name.trim().length() == 0))
    {
        if (fallback == null)
        {
            throw new CmisInvalidArgumentException("Property " + PropertyIds.NAME + " must be set!");
        }
        else
        {
            name = fallback;
        }
    }

    return name;
}
 
Example #12
Source File: IbisObjectService.java    From iaf with Apache License 2.0 6 votes vote down vote up
@Override
public void updateProperties(String repositoryId, Holder<String> objectId,
		Holder<String> changeToken, Properties properties,
		ExtensionsData extension) {

	if(!eventDispatcher.contains(CmisEvent.UPDATE_PROPERTIES)) {
		objectService.updateProperties(repositoryId, objectId, changeToken, properties, extension);
	}
	else {
		XmlBuilder cmisXml = new XmlBuilder("cmis");
		cmisXml.addSubElement(buildXml("repositoryId", repositoryId));
		if(objectId != null)
			cmisXml.addSubElement(buildXml("objectId", objectId.getValue()));
		if(changeToken != null)
			cmisXml.addSubElement(buildXml("changeToken", changeToken.getValue()));

		XmlBuilder propertiesXml = new XmlBuilder("properties");
		for (Iterator<PropertyData<?>> it = properties.getPropertyList().iterator(); it.hasNext();) {
			propertiesXml.addSubElement(CmisUtils.getPropertyXml(it.next()));
		}
		cmisXml.addSubElement(propertiesXml);

		eventDispatcher.trigger(CmisEvent.UPDATE_PROPERTIES, cmisXml.toXML(), callContext);
	}
}
 
Example #13
Source File: Converter.java    From document-management-software with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Converts a properties object
 * 
 * @param properties the properties
 * 
 * @return the conversion
 */
public static CmisPropertiesType convert(Properties properties) {
	if (properties == null) {
		return null;
	}

	CmisPropertiesType result = new CmisPropertiesType();

	if (properties.getProperties() != null) {
		for (PropertyData<?> property : properties.getProperties().values()) {
			result.getProperty().add(convert(property));
		}
	}

	// handle extensions
	convertExtension(properties, result);

	return result;
}
 
Example #14
Source File: FavouriteFolder.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static FavouriteFolder getFolder(String id, String guid, Properties props)
{
    FavouriteFolder folder = new FavouriteFolder(id, guid);

    Map<String, PropertyData<?>> properties = props.getProperties();
    folder.setName((String)properties.get(PropertyIds.NAME).getFirstValue());
    folder.setTitle((String)properties.get(ContentModel.PROP_TITLE.toString()).getFirstValue());
    folder.setCreatedBy((String)properties.get(PropertyIds.CREATED_BY).getFirstValue());
    folder.setModifiedBy((String)properties.get(PropertyIds.LAST_MODIFIED_BY).getFirstValue());
    GregorianCalendar modifiedAt = (GregorianCalendar)properties.get(PropertyIds.LAST_MODIFICATION_DATE).getFirstValue();
    folder.setModifiedAt(modifiedAt.getTime());
    GregorianCalendar createdAt = (GregorianCalendar)properties.get(PropertyIds.CREATION_DATE).getFirstValue();
    folder.setCreatedAt(createdAt.getTime());
    //document.setDescription((String)props.get(PropertyIds.DE).getFirstValue());
    return folder;
}
 
Example #15
Source File: FavouriteDocument.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static FavouriteDocument getDocument(String id, String guid, Properties props)
{
    FavouriteDocument document = new FavouriteDocument(id, guid);

    Map<String, PropertyData<?>> properties = props.getProperties();
    document.setName((String)properties.get(PropertyIds.NAME).getFirstValue());
    document.setTitle((String)properties.get(ContentModel.PROP_TITLE.toString()).getFirstValue());
    document.setCreatedBy((String)properties.get(PropertyIds.CREATED_BY).getFirstValue());
    document.setModifiedBy((String)properties.get(PropertyIds.LAST_MODIFIED_BY).getFirstValue());
    GregorianCalendar modifiedAt = (GregorianCalendar)properties.get(PropertyIds.LAST_MODIFICATION_DATE).getFirstValue();
    document.setModifiedAt(modifiedAt.getTime());
    GregorianCalendar createdAt = (GregorianCalendar)properties.get(PropertyIds.CREATION_DATE).getFirstValue();
    document.setCreatedAt(createdAt.getTime());
    //document.setDescription((String)props.get(PropertyIds.DE).getFirstValue());
    document.setMimeType((String)properties.get(PropertyIds.CONTENT_STREAM_MIME_TYPE).getFirstValue());
    document.setSizeInBytes((BigInteger)properties.get(PropertyIds.CONTENT_STREAM_LENGTH).getFirstValue());
    document.setVersionLabel((String)properties.get(PropertyIds.VERSION_LABEL).getFirstValue());
    return document;
}
 
Example #16
Source File: RepoService.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
public FavouriteFolder getFolder(String networkId, final NodeRef nodeRef)
  {
  	return TenantUtil.runAsSystemTenant(new TenantRunAsWork<FavouriteFolder>()
{
	@Override
	public FavouriteFolder doWork() throws Exception
	{
		FavouriteFolder folder = null;

    	QName type = nodeService.getType(nodeRef);
    	if(dictionaryService.isSubClass(type, ContentModel.TYPE_FOLDER))
    	{
    		Properties properties = getProperties(nodeRef);
    		folder = FavouriteFolder.getFolder(nodeRef.getId(), nodeRef.getId(), properties);
    	}
    	else
    	{
    		throw new IllegalArgumentException("Not a folder node");
    	}

    	return folder;
	}
}, networkId);
  }
 
Example #17
Source File: RepoService.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
public FavouriteDocument getDocument(String networkId, final NodeRef nodeRef)
  {
  	return TenantUtil.runAsSystemTenant(new TenantRunAsWork<FavouriteDocument>()
{
	@Override
	public FavouriteDocument doWork() throws Exception
	{
		FavouriteDocument document = null;

    	QName type = nodeService.getType(nodeRef);
    	if(dictionaryService.isSubClass(type, ContentModel.TYPE_CONTENT))
    	{
    		Properties properties = getProperties(nodeRef);
    		document = FavouriteDocument.getDocument(nodeRef.getId(), nodeRef.getId(), properties);
    	}
    	else
    	{
    		throw new IllegalArgumentException("Not a document node");
    	}

    	return document;
	}
}, networkId);
  }
 
Example #18
Source File: PublicApiAlfrescoCmisService.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public String create(String repositoryId, Properties properties, String folderId,
            ContentStream contentStream, VersioningState versioningState,
            List<String> policies, ExtensionsData extension)
{
    FileFilterMode.setClient(Client.cmis);
    try
    {
        return super.create(
                    repositoryId,
                    properties,
                    folderId,
                    contentStream,
                    versioningState,
                    policies,
                    extension);
    }
    finally
    {
        FileFilterMode.clearClient();
    }
}
 
Example #19
Source File: ConformanceCmisServiceWrapper.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public String createRelationship(String repositoryId, Properties properties, List<String> policies, Acl addAces,
        Acl removeAces, ExtensionsData extension) {
    checkRepositoryId(repositoryId);
    checkProperties(properties);
    checkProperty(properties, PropertyIds.OBJECT_TYPE_ID, String.class);
    // checkProperty(properties, PropertyIds.SOURCE_ID, String.class);
    // checkProperty(properties, PropertyIds.TARGET_ID, String.class);

    try {
        return getWrappedService().createRelationship(repositoryId, properties, policies, addAces, removeAces,
                extension);
    } catch (Exception e) {
        throw createCmisException(e);
    }
}
 
Example #20
Source File: IbisObjectService.java    From iaf with Apache License 2.0 6 votes vote down vote up
@Override
public Properties getProperties(String repositoryId, String objectId, String filter, ExtensionsData extension) {

	if(!eventDispatcher.contains(CmisEvent.GET_PROPERTIES)) {
		return objectService.getProperties(repositoryId, objectId, filter, extension);
	}
	else {
		XmlBuilder cmisXml = new XmlBuilder("cmis");
		cmisXml.addSubElement(buildXml("repositoryId", repositoryId));
		cmisXml.addSubElement(buildXml("objectId", objectId));
		cmisXml.addSubElement(buildXml("filter", filter));
		try {

			Element result = eventDispatcher.trigger(CmisEvent.GET_PROPERTIES, cmisXml.toXML(), callContext);

			return CmisUtils.processProperties(result);
		}
		catch(Exception e) {
			log.error("error creating CMIS objectData: " + e.getMessage(), e.getCause());
		}
		return new PropertiesImpl();
	}
}
 
Example #21
Source File: IbisObjectService.java    From iaf with Apache License 2.0 5 votes vote down vote up
@Override
public String createRelationship(String repositoryId,
		Properties properties, List<String> policies, Acl addAces,
		Acl removeAces, ExtensionsData extension) {
	// TODO Auto-generated method stub
	return objectService.createRelationship(repositoryId, properties, policies, addAces, removeAces, extension);
}
 
Example #22
Source File: ConformanceCmisServiceWrapper.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public Properties getProperties(String repositoryId, String objectId, String filter, ExtensionsData extension) {
    checkRepositoryId(repositoryId);
    checkId("Object Id", objectId);

    try {
        return getWrappedService().getProperties(repositoryId, objectId, filter, extension);
    } catch (Exception e) {
        throw createCmisException(e);
    }
}
 
Example #23
Source File: LDRepository.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Gets the type id from a set of properties.
 */
private static String getTypeId(Properties properties) {
	PropertyData<?> typeProperty = properties.getProperties().get(PropertyIds.OBJECT_TYPE_ID);
	if (!(typeProperty instanceof PropertyId)) {
		throw new CmisInvalidArgumentException("Type id must be set!");
	}

	String typeId = ((PropertyId) typeProperty).getFirstValue();
	if (typeId == null) {
		throw new CmisInvalidArgumentException("Type id must be set!");
	}

	return typeId;
}
 
Example #24
Source File: ConformanceCmisServiceWrapper.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public String createItem(String repositoryId, Properties properties, String folderId, List<String> policies,
        Acl addAces, Acl removeAces, ExtensionsData extension) {
    checkRepositoryId(repositoryId);
    checkProperties(properties);
    checkProperty(properties, PropertyIds.OBJECT_TYPE_ID, String.class);

    try {
        return getWrappedService().createItem(repositoryId, properties, folderId, policies, addAces, removeAces,
                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 vote down vote up
@Override
public String createPolicy(String repositoryId, Properties properties, String folderId, List<String> policies,
        Acl addAces, Acl removeAces, ExtensionsData extension) {
    checkRepositoryId(repositoryId);
    checkProperties(properties);
    checkProperty(properties, PropertyIds.OBJECT_TYPE_ID, String.class);

    try {
        return getWrappedService().createPolicy(repositoryId, properties, folderId, policies, addAces, removeAces,
                extension);
    } catch (Exception e) {
        throw createCmisException(e);
    }
}
 
Example #26
Source File: ConformanceCmisServiceWrapper.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public String createFolder(String repositoryId, Properties properties, String folderId, List<String> policies,
        Acl addAces, Acl removeAces, ExtensionsData extension) {
    checkRepositoryId(repositoryId);
    checkProperties(properties);
    checkProperty(properties, PropertyIds.OBJECT_TYPE_ID, String.class);
    checkId("Folder Id", folderId);

    try {
        return getWrappedService().createFolder(repositoryId, properties, folderId, policies, addAces, removeAces,
                extension);
    } catch (Exception e) {
        throw createCmisException(e);
    }
}
 
Example #27
Source File: AbstractCmisServiceWrapper.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void checkIn(String repositoryId, Holder<String> objectId, Boolean major, Properties properties,
        ContentStream contentStream, String checkinComment, List<String> policies, Acl addAces, Acl removeAces,
        ExtensionsData extension) {
    service.checkIn(repositoryId, objectId, major, properties, contentStream, checkinComment, policies, addAces,
            removeAces, extension);
}
 
Example #28
Source File: IbisObjectService.java    From iaf with Apache License 2.0 5 votes vote down vote up
@Override
public String createPolicy(String repositoryId, Properties properties,
		String folderId, List<String> policies, Acl addAces,
		Acl removeAces, ExtensionsData extension) {
	// TODO Auto-generated method stub
	return objectService.createPolicy(repositoryId, properties, folderId, policies, addAces, removeAces, extension);
}
 
Example #29
Source File: LDCmisService.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void checkIn(String repositoryId, Holder<String> objectId, Boolean major, Properties properties,
		ContentStream contentStream, String checkinComment, List<String> policies, Acl addAces, Acl removeAces,
		ExtensionsData extension) {
	validateSession();
	getRepository().checkIn(objectId, major, contentStream, properties, checkinComment);
}
 
Example #30
Source File: ConformanceCmisServiceWrapper.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public String createDocument(String repositoryId, Properties properties, String folderId,
        ContentStream contentStream, VersioningState versioningState, List<String> policies, Acl addAces,
        Acl removeAces, ExtensionsData extension) {
    checkRepositoryId(repositoryId);
    checkProperties(properties);
    checkProperty(properties, PropertyIds.OBJECT_TYPE_ID, String.class);

    try {
        return getWrappedService().createDocument(repositoryId, properties, folderId, contentStream,
                versioningState, policies, addAces, removeAces, extension);
    } catch (Exception e) {
        throw createCmisException(e);
    }
}