Package org.apache.slide.content

Examples of org.apache.slide.content.NodeRevisionDescriptor


        try {
            Content content = token.getContentHelper();
            NodeRevisionDescriptors revisionDescriptors =
                content.retrieve(slideToken, path);
            if (revisionDescriptors.hasRevisions()) {
                NodeRevisionDescriptor revisionDescriptor =
                    content.retrieve(slideToken, revisionDescriptors);
                return isCollection(revisionDescriptor);
            } else {
                return true;
            }
View Full Code Here


                NodeRevisionDescriptors revisionDescriptors =
                    content.retrieve(slideToken, resourcePath);
               
                NodeRevisionNumber revisionNumber =
                    revisionDescriptors.getLatestRevision();
                NodeRevisionDescriptor oldRevisionDescriptor = null;
                if (revisionNumber != null) {
                    try {
                        oldRevisionDescriptor = content.retrieve
                            (slideToken, revisionDescriptors);
                    } catch (RevisionDescriptorNotFoundException e) {
                    }
                }
                if (WebdavUtils.isCollection(oldRevisionDescriptor)) {
                    int statusCode = WebdavStatus.SC_METHOD_NOT_ALLOWED;
                    sendError( statusCode, getClass().getName()+".mustNotBeCollection" );
                    throw new WebdavException( statusCode );
                }
               
                NodeRevisionDescriptor revisionDescriptor = null;
                if (oldRevisionDescriptor == null) {
                    revisionDescriptor = new NodeRevisionDescriptor();
                } else {
                    revisionDescriptor = oldRevisionDescriptor;
                    revisionDescriptor.setContentLength(-1);
                }
               
                ResourceInfo resourceInfo =
                    new ResourceInfo(resourcePath, revisionDescriptor);
               
                // Checking If headers
                if (!checkIfHeaders(req, resp, resourceInfo)) {
                    return;
                }
               
                ResourceKind resourceKind = AbstractResourceKind.determineResourceKind(token, resourcePath, revisionDescriptor);
               
                versioningHelper.isWriteLocked(slideToken, revisionDescriptors);
               
                // check preconditions
                ViolatedPrecondition violatedPrecondition = getPreconditionViolation(revisionDescriptors, revisionDescriptor, resourceKind);
                if (violatedPrecondition != null) {
                    throw new PreconditionViolationException(violatedPrecondition, resourcePath);
                }
               
                // Changed for DeltaV --start--
                boolean mustCheckIn = false;
                if( Configuration.useVersionControl() &&
                       (resourceKind instanceof CheckedInVersionControlled) &&
                   versioningHelper.mustCheckoutAutoVersionedVCR(revisionDescriptors, revisionDescriptor) ) {
                   
                    versioningHelper.checkout(revisionDescriptors, revisionDescriptor, false, false, true );
                    mustCheckIn = versioningHelper.mustCheckinAutoVersionedVCR(slideToken, revisionDescriptors, revisionDescriptor);
                }
                // Changed for DeltaV --end--
               
                NodeRevisionContent revisionContent =
                    new NodeRevisionContent();
                //revisionContent.setContent(req.getReader());
               
                revisionContent.setContent(req.getInputStream());
               
                // Get content length
                int contentLength = req.getContentLength();
                if (contentLength == (-1)) {
                  contentLength = revisionContent.getContentBytes().length;
                }
                revisionDescriptor.setContentLength(contentLength);
               
                // Last modification date
                revisionDescriptor.setLastModified(new Date());
               
                // Etag generation
                revisionDescriptor.setETag(PropertyHelper.computeEtag(resourcePath, revisionDescriptor) );
               
                // Get content type (allow content-type to be updated here)
                String contentType = req.getContentType();
                if (contentType == null) {
                    contentType = getConfig().getServletContext()
                        .getMimeType(resourcePath);
                }
                if (contentType == null) {
                    contentType = getConfig().getDefaultMimeType();
                }
                revisionDescriptor.setContentType(contentType);
               
                // Normally assume the 'getcontentlanguage'
                // is set, however, before we clear the
                // 'resourcetype' need to check for the case when a
                // 'lock-null' is created just before the initial PUT. In
                // that case need to add the missing properties.
                if (isLockNull(revisionDescriptor)) {
                    //              if (revisionDescriptor.getResourceType().equals("<lock-null/>")) {
                    isLockedNullResource = true;
                    revisionDescriptor.setContentLanguage("en");
                   
                    // Changed for DeltaV --start--
                    if( Configuration.useVersionControl() ) {
                        // Workspace
                        versioningHelper.setWorkspaceProperty( resourcePath, revisionDescriptor );
                    }
                    // Changed for DeltaV --end--
                }
               
                // Resource type
                revisionDescriptor.setResourceType("");
               
                // Owner
                if ( isLockedNullResource ) {
                    // set the owner when updating a lock-null resource
                    String creator = ((SubjectNode)security.getPrincipal(slideToken)).getPath().lastSegment();
                    revisionDescriptor.setCreationUser(creator);
                    revisionDescriptor.setOwner(creator);
                }
               
                content.store(slideToken, resourcePath, revisionDescriptor,
                              revisionContent);
               
                // Changed for DeltaV --start--
                // check if the resource should be put under version-control
                if ( isLockedNullResource ) {
                    if ( Configuration.useVersionControl() && isAutoVersionControl(resourcePath) && !isExcludedForVersionControl(resourcePath) ) {
                        versioningHelper.versionControl(resourcePath);
                    }
                }
                if( Configuration.useVersionControl() && mustCheckIn) {
                    versioningHelper.checkin(revisionDescriptors, revisionDescriptor, false, false, true ); //forkOk=false, keepCheckedOut=false
                }
                // Changed for DeltaV --end--
               
               
                // ETag header
                resp.setHeader("ETag", revisionDescriptor.getETag() );
               
                resp.setStatus(WebdavStatus.SC_NO_CONTENT);
               
            } catch (LinkedObjectNotFoundException e) {
                int statusCode = getErrorCode( e );
                sendError( statusCode, e );
                throw new WebdavException( statusCode );
            } catch (ObjectNotFoundException e) {
                SubjectNode subject = new SubjectNode();
                // Creating an object
                structure.create(slideToken, subject, resourcePath);
               
                NodeRevisionDescriptor revisionDescriptor =
                    new NodeRevisionDescriptor(req.getContentLength());
               
                ResourceInfo resourceInfo =
                    new ResourceInfo(resourcePath, revisionDescriptor);
                resourceInfo.exists = false;
               
                // Checking If headers
                if (!checkIfHeaders(req, resp, resourceInfo)) {
                    int statusCode = WebdavStatus.SC_PRECONDITION_FAILED;
                    sendError( statusCode, "Check If Header failed" );
                    throw new WebdavException( statusCode );
                }
               
                //NodeProperty property = null;
               
                // Creation date
               
                // Resource type
                revisionDescriptor.setResourceType("");
               
                // Source
                revisionDescriptor.setSource("");
               
                // Get content language
                revisionDescriptor.setContentLanguage("en");
               
                // Get content type
                String contentType = req.getContentType();
                if (contentType == null) {
                    contentType = getConfig().getServletContext()
                        .getMimeType(resourcePath);
                }
                if (contentType == null) {
                    contentType = getConfig().getDefaultMimeType();
                }
                revisionDescriptor.setContentType(contentType);
               
                // Last modification date
                revisionDescriptor.setLastModified(new Date());
               
                // Etag generation
                revisionDescriptor.setETag(PropertyHelper.computeEtag(resourcePath, revisionDescriptor));
               
                // Creation date
                revisionDescriptor.setCreationDate(new Date());
               
                // Owner
                String creator = ((SubjectNode)security.getPrincipal(slideToken)).getPath().lastSegment();
                revisionDescriptor.setCreationUser(creator);
                revisionDescriptor.setOwner(creator);
               
                // Added for DeltaV --start--
                if( Configuration.useVersionControl() ) {
                    // Workspace
                    versioningHelper.setWorkspaceProperty( resourcePath, revisionDescriptor );
                }
                // Added for DeltaV --end--
               
                if (isMsProprietarySupport()) {
                    NodeProperty property = null;
                    // Is hidden
                    property = new NodeProperty("ishidden", "0", "MICROSOFT");
                    revisionDescriptor.setProperty(property);
                   
                    // Is collection
                    property = new NodeProperty("iscollection", "0",
                                                "MICROSOFT");
                    revisionDescriptor.setProperty(property);
                   
                    // Is read only
                    property = new NodeProperty("isreadonly", "0",
                                                "MICROSOFT");
                    revisionDescriptor.setProperty(property);
                   
                    // Last accessed
                    property = new NodeProperty("lastaccessed",
                                                    (new Date()).toString(),
                                                "MICROSOFT");
                    revisionDescriptor.setProperty(property);
                   
                }
               
                // Creating revisionDescriptor associated with the object
                NodeRevisionContent revisionContent =
                    new NodeRevisionContent();
                revisionContent.setContent(req.getInputStream());
               
                // Get content length
                int contentLength = req.getContentLength();
                if (contentLength == -1) {
                    contentLength = revisionContent.getContentBytes().length;
                }
                revisionDescriptor.setContentLength(contentLength);
               
                content.create(slideToken, resourcePath, revisionDescriptor,
                               revisionContent);
               
                // check if the resource should be put under version-control
                if ( Configuration.useVersionControl() && isAutoVersionControl(resourcePath) && !isExcludedForVersionControl(resourcePath) ) {
                    versioningHelper.versionControl(resourcePath);
                }
               
                // ETag header
                resp.setHeader("ETag", revisionDescriptor.getETag() );
               
                resp.setStatus(WebdavStatus.SC_CREATED);
               
            }
        }
View Full Code Here

        // Retrieving the list of properties
        Enumeration propertyDefinitions =
            revisionDefinition.getConfigurations("property");
       
        // Now creating the new revision descriptor object
        NodeRevisionDescriptor revisionDescriptor = null;
       
        NodeRevisionDescriptors revisionDescriptors = null;
        try {
            revisionDescriptors = accessToken.getContentHelper().retrieve
                (token, uri);
        } catch (ObjectLockedException e) {
            // Ignore
        }
        if ((revisionDescriptors != null)
            && (revisionDescriptors.hasRevisions())) {
            try {
                revisionDescriptor = accessToken.getContentHelper().retrieve
                    (token, revisionDescriptors);
            } catch (RevisionDescriptorNotFoundException e) {
                // Ignore
            } catch (ObjectLockedException e) {
                // Ignore
            }
        }
        if (revisionDescriptor == null) {
            revisionDescriptor = new NodeRevisionDescriptor(0);
        }
       
        while (propertyDefinitions.hasMoreElements()) {
            Configuration propertyDefinition =
                (Configuration) propertyDefinitions.nextElement();
            String propertyName = propertyDefinition.getAttribute("name");
            String propertyValue = propertyDefinition.getValue();
            String propertyNamespace = propertyDefinition.getAttribute
                ("namespace", NodeProperty.DEFAULT_NAMESPACE);
            NodeProperty property = revisionDescriptor.getProperty
                (propertyName, propertyNamespace);
            if (property == null)
                revisionDescriptor.setProperty(propertyName, propertyNamespace,
                                               propertyValue);
        }
       
        NodeRevisionContent revisionContent = null;
       
View Full Code Here

        ViolatedPrecondition violatedPrecondition = null;

        NodeRevisionDescriptors revisionDescriptors =
            content.retrieve(slideToken, resourcePath);
        NodeRevisionDescriptor revisionDescriptor =
            content.retrieve(slideToken, revisionDescriptors);
        ResourceKind resourceKind = AbstractResourceKind.determineResourceKind(token,
                                                                               revisionDescriptors,
                                                                               revisionDescriptor);
        if ( ! (resourceKind instanceof CheckedInVersionControlled) ) {
View Full Code Here

     * @throws     JDOMException  if creating the JDOM Element fails.
     */
    public List getPropertiesOfObject(RequestedProperties requestedProperties, String uri, String servletContextPath, boolean extendedAllprop) throws SlideException, JDOMException  {
       
        NodeRevisionDescriptors revisionDescriptors = null;
        NodeRevisionDescriptor revisionDescriptor = null;
       
        //boolean isCollection = false;
       
        try {
            revisionDescriptors =
                content.retrieve(sToken, uri);
           
            try {
               
                revisionDescriptor = content.retrieve(sToken,
                                                      revisionDescriptors);
                //isCollection = WebdavUtils.isCollection(revisionDescriptor);
               
               
            } catch (RevisionDescriptorNotFoundException e) {
               
                // The object doesn't have any revision, we create a dummy
                // NodeRevisionDescriptor object
                //isCollection = true;
                revisionDescriptor = new NodeRevisionDescriptor(0);
               
                if (!Configuration.useBinding(nsaToken.getUri(sToken, uri).getStore())) {
                    revisionDescriptor.setName(new UriPath(uri).lastSegment());
                }
            }
           
        } catch (AccessDeniedException e) {
            if (revisionDescriptor == null) {
                revisionDescriptor = new NodeRevisionDescriptor(0);
            }
        }
        //      catch (Exception e) {
        //          // resp.setStatus(getErrorCode(e));
        //          throw new WebdavException(getErrorCode(e)); // abort the TA
View Full Code Here

     * @throws     JDOMException  if creating the JDOM Element fails.
     */
    public List getPropertiesOfObject(RequestedProperties requestedProperties, String uri, NodeRevisionNumber revisionNumber, String servletContextPath, boolean extendedAllprop) throws SlideException, JDOMException {
       
        NodeRevisionDescriptors revisionDescriptors = content.retrieve(sToken, uri);
        NodeRevisionDescriptor revisionDescriptor = content.retrieve(sToken,
                                                                     revisionDescriptors,
                                                                     revisionNumber);
        return getPropertiesOfObject(requestedProperties, revisionDescriptors, revisionDescriptor, servletContextPath, extendedAllprop);
    }
View Full Code Here

     * @param    liveOnly              only live properties
     * @return   a RequestedProperties
     * @throws   SlideException
     */
    public RequestedProperties getAllPropertyNames(String resourcePath, boolean liveOnly) throws SlideException {
        NodeRevisionDescriptor nrd =
            content.retrieve(sToken, content.retrieve(sToken, resourcePath));
        ResourceKind resourceKind = AbstractResourceKind.determineResourceKind(nsaToken, resourcePath, nrd);
        RequestedPropertiesImpl result = (RequestedPropertiesImpl)getAllPropertyNames(resourceKind);
       
        if (!liveOnly) {
            // add this resource's dead properties
            Enumeration props = nrd.enumerateProperties();
            while (props.hasMoreElements()) {
                NodeProperty np = (NodeProperty)props.nextElement();
                if (!result.contains(np)) {
                    result.addProperty(new RequestedPropertyImpl(np.getName(), np.getNamespace()));
                }
View Full Code Here

                result = findAction(aNode.getChildren().iterator(), privilegeName, privilegeNamespace);
            }
            else {
                Uri aUri = token.getUri(slideToken, aUriAsString);
                NodeRevisionDescriptors nrds = aUri.getStore().retrieveRevisionDescriptors(aUri);
                NodeRevisionDescriptor latestNrd = aUri.getStore().retrieveRevisionDescriptor(aUri, nrds.getLatestRevision());
                NodeProperty aNamespaceAsNode = latestNrd.getProperty(AclConstants.P_PRIVILEGE_NAMESPACE, WebdavConstants.S_DAV);
                String aNamespace = aNamespaceAsNode == null ? null : aNamespaceAsNode.getValue().toString();
                String aUriLastSegment = aUriAsString.substring(aUriAsString.lastIndexOf('/') + 1);
                if (aUriLastSegment.equals(privilegeName)
                        && ((aNamespace != null && privilegeNamespace.equals(aNamespace))
                                || (aNamespace == null && privilegeNamespace.equals(WebdavConstants.S_DAV)))) {
View Full Code Here

                    try {
                        structure.retrieve(sToken, dir);
                    } catch (ObjectNotFoundException onfe) {
                        try {
                            structure.create(sToken, new SubjectNode(), dir);
                            content.create(sToken, dir, new NodeRevisionDescriptor(0), null);
                        } catch (ObjectAlreadyExistsException oae) {
                            Domain.warn("Object " + dir + " already exists.");
                        } catch (RevisionAlreadyExistException rae) {
                            Domain.warn("Revision " + dir + " already exists.");
                        }
                    }
                }

                // make hpath/1/2/3/h4 out of 1234
                pathBuffer.append("/h").append(nextHnStr.charAt(nextHnStr.length() - 1));
                String fullPath = pathBuffer.toString();
               
                return new UriHandler(fullPath);
               
            } else {
                return new UriHandler(uniqueUri);
            }
        } else {

            NodeRevisionDescriptors hpathNrds = content.retrieve(sToken, hpath);
            NodeRevisionDescriptor hpathNrd = content.retrieve(sToken, hpathNrds);
            NodeProperty nextHnProp = hpathNrd.getProperty(I_NEXT_HISTORY_NAME, NamespaceCache.SLIDE_URI);

            if (UriHandler.useHistoryCollectionHack) {

                if (nextHnProp == null || nextHnProp.getValue() == null) {
                    // XXX start with historyCollectionHackChildren to assure no
                    // resources are created directly in history folder
                    nextHnProp = new NodeProperty(I_NEXT_HISTORY_NAME, "10", NamespaceCache.SLIDE_URI);
                    nextHnProp.setKind(NodeProperty.Kind.PROTECTED);
                    hpathNrd.setProperty(nextHnProp);
                }

                String nextHnStr = (String) nextHnProp.getValue();
                long nextHnLong = Long.parseLong(nextHnStr);

                if (nextHnLong % 10 == 0) {
                    // create parent collection
                    long dirNum = nextHnLong / 10;
                    char dirChar[] = Long.toString(dirNum).toCharArray();
                    StringBuffer buf = new StringBuffer();
                    for (int i = 0; i < dirChar.length - 1; i++) {
                        buf.append(dirChar[i]);
                        buf.append('/');
                    }
                    buf.append(dirChar[dirChar.length - 1]);
                    String dirPath = hpath + "/" + buf.toString();

                    try {
                        structure.create(sToken, new SubjectNode(), dirPath);
                        //content.create(sToken,dirPath,true);
                        //NodeRevisionDescriptors dnrds =
                        // structure.retrieve(stoken,dirPath);
                        content.create(sToken, dirPath, new NodeRevisionDescriptor(0), null);
                    } catch (ObjectAlreadyExistsException oae) {
                        Domain.warn("Object " + dirPath + " already exists.");
                    } catch (RevisionAlreadyExistException rae) {
                        Domain.warn("Revision " + dirPath + " already exists.");
                    }
                }

                StringBuffer buf = new StringBuffer();
                char nextHnChar[] = nextHnStr.toCharArray();
                for (int i = 0; i < nextHnChar.length - 1; i++) {
                    buf.append(nextHnChar[i]);
                    buf.append('/');
                }
                buf.append('h');
                buf.append(nextHnChar[nextHnChar.length - 1]);

                result = new UriHandler(hpath + "/" + buf.toString());
               
                nextHnProp = new NodeProperty(I_NEXT_HISTORY_NAME, String.valueOf(nextHnLong + 1),
                        NamespaceCache.SLIDE_URI);
                hpathNrd.setProperty(nextHnProp);

            } else {

                if (nextHnProp == null) {
                    // convert to slide namespace if this property is still
                    // in DAV: namespace
                    nextHnProp = hpathNrd.getProperty(I_NEXT_HISTORY_NAME);
                    if (nextHnProp != null) {
                        hpathNrd.removeProperty(nextHnProp);
                        nextHnProp = new NodeProperty(I_NEXT_HISTORY_NAME, nextHnProp.getValue(),
                                NamespaceCache.SLIDE_URI);
                        nextHnProp.setKind(NodeProperty.Kind.PROTECTED);
                        hpathNrd.setProperty(nextHnProp);
                    }
                }
                if (nextHnProp == null || nextHnProp.getValue() == null) {
                    nextHnProp = new NodeProperty(I_NEXT_HISTORY_NAME, I_INITIAL_HISTORY_NAME, NamespaceCache.SLIDE_URI);
                    nextHnProp.setKind(NodeProperty.Kind.PROTECTED);
                    hpathNrd.setProperty(nextHnProp);
                }

                String nextHnStr = (String) nextHnProp.getValue();
                result = new UriHandler(hpath + "/" + nextHnStr);

                long nextHnLong = Long.parseLong(nextHnStr);
                nextHnProp = new NodeProperty(I_NEXT_HISTORY_NAME, String.valueOf(nextHnLong + 1),
                        NamespaceCache.SLIDE_URI);
                hpathNrd.setProperty(nextHnProp);

            }
            content.store(sToken, hpath, hpathNrd, null); //revisionContent = null
            return result;
        }
View Full Code Here

            result = new UriHandler(uniqueUri);
        } else {
            NodeRevisionDescriptors wrpathNrds =
                content.retrieve( sToken, wrpath );
           
            NodeRevisionDescriptor wrpathNrd =
                content.retrieve( sToken, wrpathNrds );
           
            NodeProperty nextWrnProp = wrpathNrd.getProperty(I_NEXT_WORKINGRESOURCE_NAME,
                                                             NamespaceCache.SLIDE_URI);
            if (nextWrnProp == null) {
                // convert to slide namespace if this property is still
                // in DAV: namespace
                nextWrnProp = wrpathNrd.getProperty( I_NEXT_WORKINGRESOURCE_NAME );
                if (nextWrnProp != null) {
                    wrpathNrd.removeProperty(nextWrnProp);
                    nextWrnProp = new NodeProperty(I_NEXT_WORKINGRESOURCE_NAME,
                                                   nextWrnProp.getValue(),
                                                   NamespaceCache.SLIDE_URI);
                    nextWrnProp.setKind( NodeProperty.Kind.PROTECTED );
                    wrpathNrd.setProperty( nextWrnProp );
                }
            }
           
            if( nextWrnProp == null || nextWrnProp.getValue() == null ) {
                nextWrnProp =
                    new NodeProperty(I_NEXT_WORKINGRESOURCE_NAME,
                                     I_INITIAL_WORKINGRESOURCE_NAME,
                                     NamespaceCache.SLIDE_URI );
                nextWrnProp.setKind( NodeProperty.Kind.PROTECTED );
                wrpathNrd.setProperty( nextWrnProp );
            }
           
            String nextWrnStr = (String)nextWrnProp.getValue();
            result = new UriHandler( wrpath+"/"+nextWrnStr );
           
            long nextWrnLong = Long.parseLong( nextWrnStr );
            nextWrnProp = new NodeProperty(I_NEXT_WORKINGRESOURCE_NAME,
                                           String.valueOf(nextWrnLong + 1),
                                           NamespaceCache.SLIDE_URI );
            wrpathNrd.setProperty( nextWrnProp );
           
            content.store( sToken, wrpath, wrpathNrd, null ); //revisionContent = null
        }                     
        return result;
    }
View Full Code Here

TOP

Related Classes of org.apache.slide.content.NodeRevisionDescriptor

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.