Package org.apache.chemistry.opencmis.commons.impl.jaxb

Examples of org.apache.chemistry.opencmis.commons.impl.jaxb.CmisObjectType


    /**
     * Creates a CMIS object that only contains an id in the property list.
     */
    protected CmisObjectType createIdObject(String objectId) {
        CmisObjectType object = new CmisObjectType();

        CmisPropertiesType properties = new CmisPropertiesType();
        object.setProperties(properties);

        CmisPropertyId idProperty = new CmisPropertyId();
        properties.getProperty().add(idProperty);
        idProperty.setPropertyDefinitionId(PropertyIds.OBJECT_ID);
        idProperty.getValue().add(objectId);
View Full Code Here


    /**
     * Writes an entry that is attached to an object.
     */
    private static void writePolicyEntry(CmisService service, AtomEntry entry, String objectId, ObjectData policy,
            String repositoryId, UrlBuilder baseUrl) throws Exception {
        CmisObjectType resultJaxb = convert(policy);
        if (resultJaxb == null) {
            return;
        }

        ObjectInfo info = service.getObjectInfo(repositoryId, policy.getId());
View Full Code Here

    /**
     * Writes an object.
     */
    public void writeObject(ObjectData object, ObjectInfo info, String contentSrc, String contentType,
            String pathSegment, String relativePathSegment) throws XMLStreamException, JAXBException {
        CmisObjectType objectJaxb = convert(object);
        if (objectJaxb == null) {
            return;
        }

        writeAuthor(info.getCreatedBy());
View Full Code Here

    /**
     * Writes a delete object.
     */
    public void writeDeletedObject(ObjectData object) throws XMLStreamException, JAXBException {
        CmisObjectType objectJaxb = convert(object);
        if (objectJaxb == null) {
            return;
        }

        long now = System.currentTimeMillis();
View Full Code Here

        feed.endDocument();
    }

    private static void writeQueryResultEntry(AtomEntry entry, ObjectData result, String id, GregorianCalendar now)
            throws Exception {
        CmisObjectType resultJaxb = convert(result);
        if (resultJaxb == null) {
            return;
        }

        // start
View Full Code Here

    /**
     * Creates a CMIS object that only contains an id in the property list.
     */
    protected CmisObjectType createIdObject(String objectId) {
        CmisObjectType object = new CmisObjectType();

        CmisPropertiesType properties = new CmisPropertiesType();
        object.setProperties(properties);

        CmisPropertyId idProperty = new CmisPropertyId();
        properties.getProperty().add(idProperty);
        idProperty.setPropertyDefinitionId(PropertyIds.OBJECT_ID);
        idProperty.getValue().add(objectId);
View Full Code Here

        url.addParameter(Constants.PARAM_CHECKIN_COMMENT, checkinComment);
        url.addParameter(Constants.PARAM_MAJOR, major);
        url.addParameter(Constants.PARAM_CHECK_IN, "true");

        // set up object and writer
        CmisObjectType object = new CmisObjectType();
        object.setProperties(convert(properties));
        object.setPolicyIds(convertPolicyIds(policies));

        if (object.getProperties() == null) {
            object.setProperties(new CmisPropertiesType());
        }

        String mediaType = null;
        InputStream stream = null;

        if (contentStream != null) {
            mediaType = contentStream.getMimeType();
            stream = contentStream.getStream();
        }

        final AtomEntryWriter entryWriter = new AtomEntryWriter(object, mediaType, stream);

        // update
        HttpUtils.Response resp = put(url, Constants.MEDIATYPE_ENTRY, new HttpUtils.Output() {
            public void write(OutputStream out) throws Exception {
                entryWriter.write(out);
            }
        });

        // parse new entry
        AtomEntry entry = parse(resp.getStream(), AtomEntry.class);

        // we expect a CMIS entry
        if (entry.getId() == null) {
            throw new CmisConnectionException("Received Atom entry is not a CMIS entry!");
        }

        // set object id
        objectId.setValue(entry.getId());

        Acl originalAces = null;

        lockLinks();
        try {
            // clean up cache
            removeLinks(repositoryId, entry.getId());

            // walk through the entry
            for (AtomElement element : entry.getElements()) {
                if (element.getObject() instanceof AtomLink) {
                    addLink(repositoryId, entry.getId(), (AtomLink) element.getObject());
                } else if (element.getObject() instanceof CmisObjectType) {
                    // extract current ACL
                    object = (CmisObjectType) element.getObject();
                    originalAces = convert(object.getAcl(), object.isExactACL());
                }
            }
        } finally {
            unlockLinks();
        }
View Full Code Here

    /**
     * Writes an entry that is attached to an object.
     */
    private static void writePolicyEntry(CmisService service, AtomEntry entry, String objectId, ObjectData policy,
            String repositoryId, UrlBuilder baseUrl) throws Exception {
        CmisObjectType resultJaxb = convert(policy);
        if (resultJaxb == null) {
            return;
        }

        ObjectInfo info = service.getObjectInfo(repositoryId, policy.getId());
View Full Code Here

        propDec.getValue().add(
                new BigDecimal("3.14159253589793238462643383279502884197"
                        + "169399375105820974944592307816406286208998628034825342117067982148086513"));
        properties.getProperty().add(propDec);

        CmisObjectType object1 = new CmisObjectType();
        object1.setProperties(properties);

        // write the entry
        AtomEntryWriter aew = new AtomEntryWriter(object1, CONTENT_TYPE, new ByteArrayInputStream(CONTENT));
        aew.write(bao);

        byte[] entryContent = bao.toByteArray();
        assertTrue(entryContent.length > 0);

        String entryContentStr = new String(entryContent, "UTF-8");
        System.out.println(entryContentStr);

        // parse it
        AtomPubParser parser = new AtomPubParser(new ByteArrayInputStream(entryContent));
        parser.parse();
        AtomBase parseResult = parser.getResults();

        assertTrue(parseResult instanceof AtomEntry);
        AtomEntry entry = (AtomEntry) parseResult;

        assertNotNull(entry);
        assertTrue(entry.getElements().size() > 0);

        // find the object
        CmisObjectType object2 = null;
        for (AtomElement element : entry.getElements()) {
            if (element.getObject() instanceof CmisObjectType) {
                assertNull(object2);
                object2 = (CmisObjectType) element.getObject();
            }
        }

        assertNotNull(object2);
        assertNotNull(object2.getProperties());

        // compare properteis
        for (CmisProperty property1 : object1.getProperties().getProperty()) {
            boolean found = false;

            for (CmisProperty property2 : object2.getProperties().getProperty()) {
                if (property1.getPropertyDefinitionId().equals(property2.getPropertyDefinitionId())) {
                    found = true;

                    assertEquals(property1, property2);
                    break;
View Full Code Here

    public static CmisObjectType convert(ObjectData object) {
        if (object == null) {
            return null;
        }

        CmisObjectType result = new CmisObjectType();

        result.setAcl(convert(object.getAcl()));
        result.setAllowableActions(convert(object.getAllowableActions()));
        if (object.getChangeEventInfo() != null) {
            CmisChangeEventType changeEventInfo = new CmisChangeEventType();

            changeEventInfo
                    .setChangeType(convert(EnumTypeOfChanges.class, object.getChangeEventInfo().getChangeType()));
            changeEventInfo.setChangeTime(convertCalendar(object.getChangeEventInfo().getChangeTime()));

            convertExtension(object.getChangeEventInfo(), changeEventInfo);

            result.setChangeEventInfo(changeEventInfo);
        }
        result.setExactACL(object.getAcl() == null ? null : object.getAcl().isExact());
        result.setPolicyIds(convert(object.getPolicyIds()));
        result.setProperties(convert(object.getProperties()));
        if (object.getRelationships() != null) {
            for (ObjectData relationship : object.getRelationships()) {
                result.getRelationship().add(convert(relationship));
            }
        }
        if (object.getRenditions() != null) {
            for (RenditionData rendition : object.getRenditions()) {
                result.getRendition().add(convert(rendition));
            }
        }

        // handle extensions
        convertExtension(object, result);
View Full Code Here

TOP

Related Classes of org.apache.chemistry.opencmis.commons.impl.jaxb.CmisObjectType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.