org.apache.chemistry.opencmis.commons.spi.Holder Java Examples

The following examples show how to use org.apache.chemistry.opencmis.commons.spi.Holder. 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: LDCmisService.java    From document-management-software with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public ObjectList getContentChanges(String repositoryId, Holder<String> changeLogToken, Boolean includeProperties,
		String filter, Boolean includePolicyIds, Boolean includeAcl, BigInteger maxItems,
		ExtensionsData extension) {
	log.debug("getContentChanges " + changeLogToken.getValue() + "|" + filter + " | "
			+ new Date(Long.parseLong(changeLogToken.getValue())));

	validateSession();

	try {
		ObjectList ret = getRepository().getContentChanges(changeLogToken,
				maxItems != null ? (int) maxItems.doubleValue() : 2000);
		return ret;
	} catch (Throwable t) {
		log.error(t.getMessage(), t);
		throw t;
	}
}
 
Example #3
Source File: ConformanceCmisServiceWrapper.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public ObjectList getContentChanges(String repositoryId, Holder<String> changeLogToken, Boolean includeProperties,
        String filter, Boolean includePolicyIds, Boolean includeAcl, BigInteger maxItems, ExtensionsData extension) {
    checkRepositoryId(repositoryId);
    includeProperties = getDefaultFalse(includeProperties);
    includePolicyIds = getDefaultFalse(includePolicyIds);
    includeAcl = getDefaultFalse(includeAcl);
    maxItems = getMaxItems(maxItems);

    try {
        return getWrappedService().getContentChanges(repositoryId, changeLogToken, includeProperties, filter,
                includePolicyIds, includeAcl, maxItems, extension);
    } catch (Exception e) {
        throw createCmisException(e);
    }
}
 
Example #4
Source File: CMISTransactionAwareHolderInterceptor.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public Object invoke(MethodInvocation invocation) throws Throwable
{
    Class<?>[] parameterTypes = invocation.getMethod().getParameterTypes();
    Object[] arguments = invocation.getArguments();
    for (int i = 0; i < parameterTypes.length; i++)
    {
        if (Holder.class.isAssignableFrom(parameterTypes[i]) && arguments[i] != null)
        {
            TransactionAwareHolder txnHolder = new TransactionAwareHolder(((Holder) arguments[i]));
            arguments[i] = txnHolder;
        }
    }
    return invocation.proceed();
}
 
Example #5
Source File: PublicApiAlfrescoCmisService.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Overridden to capture content upload for publishing to analytics service.
 */
@Override
public void setContentStream(String repositoryId, Holder<String> objectId,
            Boolean overwriteFlag, Holder<String> changeToken, ContentStream contentStream,
            ExtensionsData extension)
{
    FileFilterMode.setClient(Client.cmis);
    try
    {
        super.setContentStream(repositoryId, objectId, overwriteFlag, changeToken, contentStream, extension);
    }
    finally
    {
        FileFilterMode.clearClient();
    }
}
 
Example #6
Source File: CmisServiceBridge.java    From spring-content with Apache License 2.0 6 votes vote down vote up
@Transactional
public void setContentStream(CmisRepositoryConfiguration config,
		Holder<String> objectId,
		Boolean overwriteFlag,
		Holder<String> changeToken,
		ContentStream contentStream,
		ExtensionsData extension) {

	Object object = getObjectInternal(config, objectId.getValue(), Collections.EMPTY_SET, false, IncludeRelationships.NONE,
			"", false, false, extension);
	if (object != null) {
		config.cmisDocumentStorage().setContent(object, contentStream.getStream());

		// re-fetch to ensure we have the latest
		object = getObjectInternal(config, objectId.getValue(), Collections.EMPTY_SET, false, IncludeRelationships.NONE,
				"", false, false, extension);

		if (BeanUtils.hasFieldWithAnnotation(object, MimeType.class)) {
			BeanUtils.setFieldWithAnnotation(object, MimeType.class, contentStream.getMimeType());
		}

		config.cmisDocumentRepository().save(object);
	}
}
 
Example #7
Source File: ContentCmisService.java    From spring-content with Apache License 2.0 6 votes vote down vote up
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) {

	bridge.checkIn(config,
			objectId.getValue(),
			major,
			properties,
			contentStream,
			checkinComment,
			policies,
			addAces,
			removeAces,
			extension);
}
 
Example #8
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 #9
Source File: IbisObjectService.java    From iaf with Apache License 2.0 6 votes vote down vote up
@Override
public void moveObject(String repositoryId, Holder<String> objectId,
		String targetFolderId, String sourceFolderId,
		ExtensionsData extension) {

	if(!eventDispatcher.contains(CmisEvent.MOVE_OBJECT)) {
		objectService.moveObject(repositoryId, objectId, targetFolderId, sourceFolderId, extension);
	}
	else {
		XmlBuilder cmisXml = new XmlBuilder("cmis");
		cmisXml.addSubElement(buildXml("repositoryId", repositoryId));
		if(objectId != null)
			cmisXml.addSubElement(buildXml("objectId", objectId.getValue()));
		cmisXml.addSubElement(buildXml("targetFolderId", targetFolderId));
		cmisXml.addSubElement(buildXml("sourceFolderId", sourceFolderId));

		eventDispatcher.trigger(CmisEvent.MOVE_OBJECT, cmisXml.toXML(), callContext);
	}
}
 
Example #10
Source File: ConformanceCmisServiceWrapper.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void moveObject(String repositoryId, Holder<String> objectId, String targetFolderId, String sourceFolderId,
        ExtensionsData extension) {
    checkRepositoryId(repositoryId);
    checkHolderId("Object Id", objectId);
    checkId("Target Folder Id", targetFolderId);

    try {
        getWrappedService().moveObject(repositoryId, objectId, targetFolderId, sourceFolderId, extension);
    } catch (Exception e) {
        throw createCmisException(e);
    }
}
 
Example #11
Source File: ConformanceCmisServiceWrapper.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void deleteContentStream(String repositoryId, Holder<String> objectId, Holder<String> changeToken,
        ExtensionsData extension) {
    checkRepositoryId(repositoryId);
    checkHolderId("Object Id", objectId);

    try {
        getWrappedService().deleteContentStream(repositoryId, objectId, changeToken, extension);
    } catch (Exception e) {
        throw createCmisException(e);
    }
}
 
Example #12
Source File: CmisRepository.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
/**
 * CMIS setContentStream and deleteContentStream.
 */
public void setContentStream(CallContext context, Holder<String> objectId, Boolean overwriteFlag, ContentStream contentStream) {
	log.debug("setContentStream({}, {})", objectId, overwriteFlag);

	if (objectId == null) {
		throw new CmisInvalidArgumentException("Id is not valid!");
	}

	// check overwrite
	// boolean owf = (overwriteFlag == null ? true : overwriteFlag.booleanValue());
	// if (!owf && file.length() > 0) {
	// throw new CmisContentAlreadyExistsException("Content already exists!");
	// }

	try {
		if (!OKMDocument.getInstance().isValid(null, objectId.getValue())) {
			throw new CmisStreamNotSupportedException("Not a document");
		}

		if (!OKMDocument.getInstance().isCheckedOut(null, objectId.getValue())) {
			OKMDocument.getInstance().checkout(null, objectId.getValue());
		}

		new DbDocumentModule().checkin(null, objectId.getValue(), contentStream.getStream(), contentStream.getLength(), "CMIS Client",
				null);
	} catch (Exception e) {
		throw new CmisStorageException("Could not write content: " + e.getMessage(), e);
	}
}
 
Example #13
Source File: ConformanceCmisServiceWrapper.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void setContentStream(String repositoryId, Holder<String> objectId, Boolean overwriteFlag,
        Holder<String> changeToken, ContentStream contentStream, ExtensionsData extension) {
    checkRepositoryId(repositoryId);
    checkHolderId("Object Id", objectId);
    overwriteFlag = getDefaultTrue(overwriteFlag);
    checkContentStream(contentStream);

    try {
        getWrappedService().setContentStream(repositoryId, objectId, overwriteFlag, changeToken, contentStream,
                extension);
    } catch (Exception e) {
        throw createCmisException(e);
    }
}
 
Example #14
Source File: ConformanceCmisServiceWrapper.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void appendContentStream(String repositoryId, Holder<String> objectId, Holder<String> changeToken,
        ContentStream contentStream, boolean isLastChunk, ExtensionsData extension) {
    checkRepositoryId(repositoryId);
    checkHolderId("Object Id", objectId);
    checkContentStream(contentStream);

    try {
        getWrappedService().appendContentStream(repositoryId, objectId, changeToken, contentStream, isLastChunk,
                extension);
    } catch (Exception e) {
        throw createCmisException(e);
    }
}
 
Example #15
Source File: ConformanceCmisServiceWrapper.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void updateProperties(String repositoryId, Holder<String> objectId, Holder<String> changeToken,
        Properties properties, ExtensionsData extension) {
    checkRepositoryId(repositoryId);
    checkHolderId("Object Id", objectId);
    checkProperties(properties);

    try {
        getWrappedService().updateProperties(repositoryId, objectId, changeToken, properties, extension);
    } catch (Exception e) {
        throw createCmisException(e);
    }
}
 
Example #16
Source File: ConformanceCmisServiceWrapper.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) {
    checkRepositoryId(repositoryId);
    checkHolderId("Object Id", objectId);
    major = getDefaultTrue(major);

    try {
        getWrappedService().checkIn(repositoryId, objectId, major, properties, contentStream, checkinComment,
                policies, addAces, removeAces, extension);
    } catch (Exception e) {
        throw createCmisException(e);
    }
}
 
Example #17
Source File: ConformanceCmisServiceWrapper.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Throws an exception if the given holder or id is {@code null} or empty.
 */
protected void checkHolderId(String name, Holder<String> holder) {
    if (holder == null) {
        throw new CmisInvalidArgumentException(name + " must be set!");
    }

    checkId(name, holder.getValue());
}
 
Example #18
Source File: AlfrescoCmisServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void checkOut(
        String repositoryId, final Holder<String> objectId, ExtensionsData extension,
        final Holder<Boolean> contentCopied)
{
    checkRepositoryId(repositoryId);

    CMISNodeInfo info = getOrCreateNodeInfo(objectId.getValue(), "Object");

    // Check for current version
    if (info.isVariant(CMISObjectVariant.CURRENT_VERSION))
    {
        // Good
    }
    else if (info.isVariant(CMISObjectVariant.VERSION))
    {
        throw new CmisInvalidArgumentException("Can't check out an old version of a document");
    }
    else {   
        throw new CmisInvalidArgumentException("Only documents can be checked out! Object was a " + info.getObjectVariant().toString());
    }

    // get object
    final NodeRef nodeRef = info.getNodeRef();

    if (!((DocumentTypeDefinition) info.getType().getTypeDefinition(false)).isVersionable())
    {
        throw new CmisConstraintException("Document is not versionable!");
    }
    
    // check out
    NodeRef pwcNodeRef = connector.getCheckOutCheckInService().checkout(nodeRef);
    CMISNodeInfo pwcNodeInfo = createNodeInfo(pwcNodeRef);
    objectId.setValue(pwcNodeInfo.getObjectId());

    if (contentCopied != null)
    {
        contentCopied.setValue(connector.getFileFolderService().getReader(pwcNodeRef) != null);
    }
}
 
Example #19
Source File: AlfrescoCmisServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void updateProperties(
        String repositoryId, Holder<String> objectId, Holder<String> changeToken,
        final Properties properties, ExtensionsData extension)
{
    checkRepositoryId(repositoryId);

    final CMISNodeInfo info = getOrCreateNodeInfo(objectId.getValue(), "Object");

    if (info.isVariant(CMISObjectVariant.ASSOC))
    {
        throw new CmisInvalidArgumentException("Relationship properties cannot be updated!");
    }
    else
    {
        if (info.isVariant(CMISObjectVariant.VERSION))
        {
            throw new CmisInvalidArgumentException("Document is not the latest version!");
        }

        final NodeRef nodeRef = info.getNodeRef();

        connector.setProperties(nodeRef, info.getType(), properties, new String[0]);
        
        objectId.setValue(connector.createObjectId(nodeRef));

    	boolean isObjectInfoRequired = getContext().isObjectInfoRequired();
        if (isObjectInfoRequired)
        {
            getObjectInfo(repositoryId, objectId.getValue(), "*", IncludeRelationships.NONE);
        }

        connector.getActivityPoster().postFileFolderUpdated(info.isFolder(), nodeRef);
    }
}
 
Example #20
Source File: CMISTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void setProperiesToObject(CmisService cmisService, String repositoryId, String objectIdStr, String propertyStr, BigInteger bigIntValue) throws CmisConstraintException{
    Properties properties = cmisService.getProperties(repositoryId, objectIdStr, null, null);
    PropertyIntegerImpl pd = (PropertyIntegerImpl)properties.getProperties().get(propertyStr);
    pd.setValue(bigIntValue);
    
    Collection<PropertyData<?>> propsList = new ArrayList<PropertyData<?>>();
    propsList.add(pd);
    
    Properties newProps = new PropertiesImpl(propsList);
    
    cmisService.updateProperties(repositoryId, new Holder<String>(objectIdStr), null, newProps, null);
}
 
Example #21
Source File: ConformanceCmisServiceWrapper.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void checkOut(String repositoryId, Holder<String> objectId, ExtensionsData extension,
        Holder<Boolean> contentCopied) {
    checkRepositoryId(repositoryId);
    checkHolderId("Object Id", objectId);

    try {
        getWrappedService().checkOut(repositoryId, objectId, extension, contentCopied);
    } catch (Exception e) {
        throw createCmisException(e);
    }
}
 
Example #22
Source File: CmisServiceBridge.java    From spring-content with Apache License 2.0 5 votes vote down vote up
@Transactional
public void deleteContentStream(CmisRepositoryConfiguration config,
		Holder<String> objectId,
		Holder<String> changeToken,
		ExtensionsData extension) {

	Object object = getObjectInternal(config, objectId.getValue(), Collections.EMPTY_SET, false, IncludeRelationships.NONE,
			"", false, false, extension);

	if (object != null) {
		config.cmisDocumentStorage().unsetContent(object);
		config.cmisDocumentRepository().save(object);
	}
}
 
Example #23
Source File: ContentCmisService.java    From spring-content with Apache License 2.0 5 votes vote down vote up
public void deleteContentStream(String repositoryId, Holder<String> objectId, Holder<String> changeToken, ExtensionsData extension) {

		bridge.deleteContentStream(config,
				objectId,
				changeToken,
				extension);
	}
 
Example #24
Source File: ContentCmisService.java    From spring-content with Apache License 2.0 5 votes vote down vote up
public void updateProperties(String repositoryId,
		Holder<String> objectId,
		Holder<String> changeToken,
		Properties properties,
		ExtensionsData extension) {

	bridge.updateProperties(config,
			objectId.getValue(),
			(changeToken != null) ? changeToken.getValue() : null,
			properties,
			extension);
}
 
Example #25
Source File: ContentCmisService.java    From spring-content with Apache License 2.0 5 votes vote down vote up
@Override
public void checkOut(String repositoryId,
		Holder<String> objectId,
		ExtensionsData extension,
		Holder<Boolean> contentCopied) {

	bridge.checkOut(config,
			objectId.getValue(),
			extension,
			(contentCopied != null) ? contentCopied.getValue() : false);
}
 
Example #26
Source File: FilterCmisService.java    From iaf with Apache License 2.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) {
	getVersioningService().checkIn(repositoryId, objectId, major, properties, contentStream, checkinComment,
			policies, addAces, removeAces, extension);
}
 
Example #27
Source File: IbisDiscoveryService.java    From iaf with Apache License 2.0 5 votes vote down vote up
@Override
public ObjectList getContentChanges(String repositoryId,
		Holder<String> changeLogToken, Boolean includeProperties,
		String filter, Boolean includePolicyIds, Boolean includeAcl,
		BigInteger maxItems, ExtensionsData extension) {
	// TODO Auto-generated method stub
	return discoveryService.getContentChanges(repositoryId, changeLogToken, includeProperties, filter, includePolicyIds, includeAcl, maxItems, extension);
}
 
Example #28
Source File: IbisObjectService.java    From iaf with Apache License 2.0 5 votes vote down vote up
@Override
public void setContentStream(String repositoryId, Holder<String> objectId,
		Boolean overwriteFlag, Holder<String> changeToken,
		ContentStream contentStream, ExtensionsData extension) {
	// TODO Auto-generated method stub
	objectService.setContentStream(repositoryId, objectId, overwriteFlag, changeToken, contentStream, extension);
}
 
Example #29
Source File: IbisObjectService.java    From iaf with Apache License 2.0 5 votes vote down vote up
@Override
public void deleteContentStream(String repositoryId,
		Holder<String> objectId, Holder<String> changeToken,
		ExtensionsData extension) {
	// TODO Auto-generated method stub
	objectService.deleteContentStream(repositoryId, objectId, changeToken, extension);
}
 
Example #30
Source File: IbisObjectService.java    From iaf with Apache License 2.0 5 votes vote down vote up
@Override
public void appendContentStream(String repositoryId,
		Holder<String> objectId, Holder<String> changeToken,
		ContentStream contentStream, boolean isLastChunk,
		ExtensionsData extension) {
	// TODO Auto-generated method stub
	objectService.appendContentStream(repositoryId, objectId, changeToken, contentStream, isLastChunk, extension);
}