Package org.apache.jackrabbit.webdav.property

Examples of org.apache.jackrabbit.webdav.property.DefaultDavProperty


            properties.add(new DefaultDavProperty(DavPropertyName.GETLASTMODIFIED, lastModified));
        }

        public void setETag(String etag) {
            if (etag != null) {
                properties.add(new DefaultDavProperty(DavPropertyName.GETETAG, etag));
            }
        }
View Full Code Here


        }

        public void setProperty(Object propertyName, Object propertyValue) {
            if (propertyName instanceof DavPropertyName) {
                DavPropertyName pName = (DavPropertyName)propertyName;
                properties.add(new DefaultDavProperty(pName, propertyValue));
            }
        }
View Full Code Here

     */
    protected void initProperties() {
        super.initProperties();
        if (exists()) {
            // resource is serialized as system-view (xml)
            properties.add(new DefaultDavProperty(DavPropertyName.GETCONTENTTYPE, "text/xml"));
            Node n = (Node)item;
            // overwrite the default modificationtime if possible
            try {
                if (n.hasProperty(JcrConstants.JCR_LASTMODIFIED)) {
                    setModificationTime(n.getProperty(JcrConstants.JCR_LASTMODIFIED).getLong());
                }
            } catch (RepositoryException e) {
                log.warn("Error while accessing jcr:lastModified property");
            }
            // overwrite the default creation date if possible
            try {
                if (n.hasProperty(JcrConstants.JCR_CREATED)) {
                    long creationTime = n.getProperty(JcrConstants.JCR_CREATED).getValue().getLong();
                    properties.add(new DefaultDavProperty(DavPropertyName.CREATIONDATE,
                        DavConstants.creationDateFormat.format(new Date(creationTime))));
                }
            } catch (RepositoryException e) {
                log.warn("Error while accessing jcr:created property");
            }

            // add node-specific resource properties
            try {
                properties.add(new NodeTypeProperty(JCR_PRIMARYNODETYPE, n.getPrimaryNodeType(), false));
                properties.add(new NodeTypeProperty(JCR_MIXINNODETYPES, n.getMixinNodeTypes(), false));
                properties.add(new DefaultDavProperty(JCR_INDEX, new Integer(n.getIndex()), true));
                addHrefProperty(JCR_REFERENCES, n.getReferences(), true);
                if (n.isNodeType(JcrConstants.MIX_REFERENCEABLE)) {
                    properties.add(new DefaultDavProperty(JCR_UUID, n.getUUID(), true));
                }
            } catch (RepositoryException e) {
                log.error("Failed to retrieve primary nodetype property: " + e.getMessage());
            }
            try {
View Full Code Here

     */
    void setModificationTime(long modificationTime) {
        if (modificationTime > IOUtil.UNDEFINED_TIME) {
            this.modificationTime = modificationTime;
            String lastModified = IOUtil.getLastModified(modificationTime);
            properties.add(new DefaultDavProperty(DavPropertyName.GETLASTMODIFIED, lastModified));
        }
    }
View Full Code Here

    /**
     * Fill the set of default properties
     */
    protected void initProperties() {
        if (getDisplayName() != null) {
            properties.add(new DefaultDavProperty(DavPropertyName.DISPLAYNAME, getDisplayName()));
        }
        if (isCollection()) {
            properties.add(new ResourceType(ResourceType.COLLECTION));
            // Windows XP support
            properties.add(new DefaultDavProperty(DavPropertyName.ISCOLLECTION, "1"));
        } else {
            properties.add(new ResourceType(ResourceType.DEFAULT_RESOURCE));
            // Windows XP support
            properties.add(new DefaultDavProperty(DavPropertyName.ISCOLLECTION, "0"));
        }
        // todo: add etag

        // default last modified
        setModificationTime(new Date().getTime());
        // default creation time
        properties.add(new DefaultDavProperty(DavPropertyName.CREATIONDATE, DavConstants.creationDateFormat.format(new Date(0))));

        // supported lock property
        properties.add(supportedLock);

        // set current lock information. If no lock is applied to this resource,
        // an empty lockdiscovery will be returned in the response.
        properties.add(new LockDiscovery(getLocks()));

        // observation resource
        SubscriptionDiscovery subsDiscovery = subsMgr.getSubscriptionDiscovery(this);
        properties.add(subsDiscovery);

        properties.add(new SupportedMethodSetProperty(getSupportedMethods().split(",\\s")));

  // DeltaV properties
  properties.add(supportedReports);
  // creator-displayname, comment: not value available from jcr
  properties.add(new DefaultDavProperty(DeltaVConstants.CREATOR_DISPLAYNAME, null, true));
  properties.add(new DefaultDavProperty(DeltaVConstants.COMMENT, null, true));

  // 'workspace' property as defined by RFC 3253
  String workspaceHref = getWorkspaceHref();
  if (workspaceHref != null) {
      properties.add(new HrefProperty(DeltaVConstants.WORKSPACE, workspaceHref, true));
View Full Code Here

        } catch (IOException e) {
            // should not occure....
        }

        if (getDisplayName() != null) {
            properties.add(new DefaultDavProperty(DavPropertyName.DISPLAYNAME, getDisplayName()));
        }
        if (isCollection()) {
            properties.add(new ResourceType(ResourceType.COLLECTION));
            // Windows XP support
            properties.add(new DefaultDavProperty(DavPropertyName.ISCOLLECTION, "1"));
        } else {
            properties.add(new ResourceType(ResourceType.DEFAULT_RESOURCE));
            // Windows XP support
            properties.add(new DefaultDavProperty(DavPropertyName.ISCOLLECTION, "0"));
        }

        /* set current lock information. If no lock is set to this resource,
        an empty lockdiscovery will be returned in the response. */
        properties.add(new LockDiscovery(getLock(Type.WRITE, Scope.EXCLUSIVE)));

        /* lock support information: all locks are lockable. */
        SupportedLock supportedLock = new SupportedLock();
        supportedLock.addEntry(Type.WRITE, Scope.EXCLUSIVE);
        properties.add(supportedLock);

        // non-protected JCR properties defined on the underlying jcr node
        try {
            PropertyIterator it = node.getProperties();
            while (it.hasNext()) {
                Property p = it.nextProperty();
                String pName = p.getName();
                PropertyDefinition def = p.getDefinition();
                if (def.isMultiple() || isFilteredItem(p)) {
                    log.debug("Property '" + pName + "' not added to webdav property set (either multivalue or filtered).");
                    continue;
                }
                DavPropertyName name = getDavName(pName, node.getSession());
                String value = p.getValue().getString();
                properties.add(new DefaultDavProperty(name, value, def.isProtected()));
            }
        } catch (RepositoryException e) {
            log.error("Unexpected error while retrieving properties: " + e.getMessage());
        }
        inited = true;
View Full Code Here

                    // DAV:version-history (computed)
                    String vhHref = getLocatorFromItem(n.getVersionHistory()).getHref(true);
                    properties.add(new HrefProperty(VERSION_HISTORY, vhHref, true));

                    // DAV:auto-version property: there is no auto version, explicit CHECKOUT is required.
                    properties.add(new DefaultDavProperty(AUTO_VERSION, null, false));

                    String baseVHref = getLocatorFromItem(n.getBaseVersion()).getHref(true);
                    if (n.isCheckedOut()) {
                        // DAV:checked-out property (protected)
                        properties.add(new HrefProperty(CHECKED_OUT, baseVHref, true));
View Full Code Here

                if (!isMultiple()) {
                    contentType = (type == PropertyType.BINARY) ? "application/octet-stream" : "text/plain";
                } else {
                    contentType = "text/xml";
                }
                properties.add(new DefaultDavProperty(DavPropertyName.GETCONTENTTYPE, contentType));
               

                // add jcr-specific resource properties
                properties.add(new DefaultDavProperty(JCR_TYPE, PropertyType.nameFromValue(type)));
                if (isMultiple()) {
                    properties.add(new ValuesProperty(prop.getValues()));
                    properties.add(new LengthsProperty(prop.getLengths()));
                } else {
                    properties.add(new ValuesProperty(prop.getValue()));
                    long length = prop.getLength();
                    properties.add(new DefaultDavProperty(JCR_LENGTH, String.valueOf(length), true));
                    if (prop.getLength() > IOUtil.UNDEFINED_LENGTH) {
                        properties.add(new DefaultDavProperty(DavPropertyName.GETCONTENTLENGTH, String.valueOf(length)));
                    }
                }
            } catch (RepositoryException e) {
                log.error("Failed to retrieve resource properties: "+e.getMessage());
            }
View Full Code Here

        DavPropertySet properties = new DavPropertySet();

        // set (or reset) fundamental properties
        if ( getDisplayName() != null )
        {
            properties.add( new DefaultDavProperty( DavPropertyName.DISPLAYNAME, getDisplayName() ) );
        }
        if ( isCollection() )
        {
            properties.add( new ResourceType( ResourceType.COLLECTION ) );
            // Windows XP support
            properties.add( new DefaultDavProperty( DavPropertyName.ISCOLLECTION, "1" ) );
        }
        else
        {
            properties.add( new ResourceType( ResourceType.DEFAULT_RESOURCE ) );

            // Windows XP support
            properties.add( new DefaultDavProperty( DavPropertyName.ISCOLLECTION, "0" ) );
        }

        // Need to get the ISO8601 date for properties
        DateTime dt = new DateTime( localResource.lastModified() );
        DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
        String modifiedDate = fmt.print( dt );

        properties.add( new DefaultDavProperty( DavPropertyName.GETLASTMODIFIED, modifiedDate ) );

        properties.add( new DefaultDavProperty( DavPropertyName.CREATIONDATE, modifiedDate ) );

        properties.add( new DefaultDavProperty( DavPropertyName.GETCONTENTLENGTH, localResource.length() ) );

        this.properties = properties;

        return properties;
    }
View Full Code Here

        {
            URLFileName fileName = (URLFileName) getName();
            String urlStr = urlString(fileName);
            DavPropertySet properties = new DavPropertySet();
            DavPropertyNameSet propertyNameSet = new DavPropertyNameSet();
            DavProperty property = new DefaultDavProperty(attrName, value, Namespace.EMPTY_NAMESPACE);
            if (value != null)
            {
                properties.add(property);
            }
            else
            {
                propertyNameSet.add(property.getName()); // remove property
            }

            PropPatchMethod method = new PropPatchMethod(urlStr, properties, propertyNameSet);
            setupMethod(method);
            execute(method);
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.webdav.property.DefaultDavProperty

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.