Package org.apache.slide.content

Examples of org.apache.slide.content.NodeRevisionDescriptor


                       
                        // Creating new subject
                        structure.create(slideToken, toLockSubject,
                                         lockInfo_lockSubject);
                       
                        NodeRevisionDescriptor revisionDescriptor =
                            new NodeRevisionDescriptor(0);
                       
                        // Resource type
                        XMLValue lockNull =
                            new XMLValue(new Element(E_LOCKNULL, DNSP));
                        revisionDescriptor.setResourceType(lockNull.toString());
                       
                        // Creating the revision descriptor
                        content.create(slideToken, lockInfo_lockSubject,
                                       revisionDescriptor, null);
                    }
View Full Code Here


            throw new PreconditionViolationException(
                new ViolatedPrecondition(C_MUST_BE_VERSION, WebdavStatus.SC_CONFLICT), resourcePath);
        }
        NodeRevisionNumber evNrn = new NodeRevisionNumber( evUh.getVersionName() );
        NodeRevisionDescriptors rNrds = null;
        NodeRevisionDescriptor rNrd = null;
        NodeRevisionDescriptors vcrNrds = null;
        NodeRevisionDescriptor vcrNrd = null;
        NodeRevisionDescriptors evNrds = null;
        NodeRevisionDescriptor evNrd = null;
       
        try {
            rNrds = content.retrieve( sToken, resourcePath );
            rNrd = content.retrieve( sToken, rNrds );
        }
        catch( ObjectNotFoundException e ) {}; // can be ignored here!
        try {
            evNrds = content.retrieve( sToken, existingVersionPath );
            evNrd = content.retrieve( sToken, evNrds /*, evNrn*/ ); //existingVersionPath
            //redirector should do the job
            //s.t. evNrn is not required
        }
        catch( ObjectNotFoundException e ) {}; // can be ignored here!
       
        ViolatedPrecondition violatedPrecondition =
            getVersionControlPreconditionViolation(resourcePath,
                                                   rNrd,
                                                   rUh,
                                                   existingVersionPath,
                                                   evNrd,
                                                   evUh);
        if (violatedPrecondition != null) {
            throw new PreconditionViolationException(violatedPrecondition,
                                                     resourcePath);
        }
       
        // create the VCR
        String vcrUri = String.valueOf(rUh);
        String evUri = String.valueOf(evUh);
        UriHandler vcrUh = UriHandler.getUriHandler( vcrUri );
        vcrNrd = new NodeRevisionDescriptor(0);
        i = pHelp.createInitialProperties(VersionControlledImpl.getInstance()).iterator();
        while( i.hasNext() )
            vcrNrd.setProperty( (NodeProperty)i.next() );
       
        // Set specific properties
        vcrNrd.setLastModified( new Date() ); //P_GETLASTMODIFIED
        vcrNrd.setContentLength( evNrd.getContentLength() ); // P_GETCONTENTLENGTH
        vcrNrd.setETag( PropertyHelper.computeEtag(vcrUri, vcrNrd))// P_GETETAG
        vcrNrd.setContentType( evNrd.getContentType() ); // P_GETCONTENTTYPE
        vcrNrd.setContentLanguage(evNrd.getContentLanguage()); // P_GETCONTENTLANGUAGE
       
        String[] utok = vcrUh.getUriTokens();
       
        if (!Configuration.useBinding(nsaToken.getUri(sToken, vcrUri).getStore())) {
            vcrNrd.setName( utok[utok.length - 1] ); // P_DISPLAYNAME
View Full Code Here

     */
    public void mkworkspace( String resourcePath ) throws SlideException {
        Iterator i;
       
        UriHandler rUh = UriHandler.getUriHandler( resourcePath );
        NodeRevisionDescriptor rNrd = null;
        try {
            NodeRevisionDescriptors rNrds = content.retrieve( sToken, resourcePath );
            rNrd = content.retrieve( sToken, rNrds );
        }
        catch( ObjectNotFoundException e ) {}; // can be ignored here!
       
        ResourceKind rRk = AbstractResourceKind.determineResourceKind( nsaToken, resourcePath, rNrd );
       
        if( !(rRk instanceof DeltavCompliantUnmappedUrl) ) {
            throw new PreconditionViolationException(
                new ViolatedPrecondition(C_RESOURCE_MUST_BE_NULL, WebdavStatus.SC_CONFLICT), resourcePath);
        }
        if( !rUh.isWorkspaceUri() ) {
            throw new PreconditionViolationException(
                new ViolatedPrecondition(C_WORKSPACE_LOCATION_OK, WebdavStatus.SC_FORBIDDEN), resourcePath);
        }
        if( !rRk.isSupportedMethod(req.getMethod()) ) {
            throw new MethodNotAllowedException( rRk );
        }
       
        // Set initial ws properties
        String wsUri = String.valueOf(rUh);
        NodeRevisionDescriptor wsNrd =
            new NodeRevisionDescriptor(0);
        i = pHelp.createInitialProperties(WorkspaceImpl.getInstance()).iterator();
        while( i.hasNext() )
            wsNrd.setProperty( (NodeProperty)i.next() );
       
        // Set specific properties
        wsNrd.setProperty(
            new NodeProperty(P_WORKSPACE, pHelp.createHrefValue(wsUri)) );
        wsNrd.setLastModified( new Date() ); //P_GETLASTMODIFIED
        wsNrd.setContentLength( 0 ); // P_GETCONTENTLENGTH
        wsNrd.setETag( PropertyHelper.computeEtag(wsUri, wsNrd) ); // P_GETETAG
        if (!Configuration.useBinding(nsaToken.getUri(sToken, wsUri).getStore())) {
            wsNrd.setName( rUh.getWorkspaceName() ); // P_DISPLAYNAME
        }
        wsNrd.setCreationDate( new Date() ); // P_CREATIONDATE
        setCreationUser(wsNrd);
       
        // Create the ws resource
        SubjectNode wsNode = new SubjectNode();
        structure.create( sToken, wsNode, wsUri );
View Full Code Here

    public String checkout( String resourcePath, boolean forkOk, boolean applyToVersion, boolean isAutoVersionCheckout )
        throws SlideException, JDOMException, IOException, PreconditionViolationException  {
       
        UriHandler rUh = UriHandler.getUriHandler( resourcePath );
        NodeRevisionDescriptors rNrds = content.retrieve( sToken, resourcePath );
        NodeRevisionDescriptor rNrd = content.retrieve( sToken, rNrds );
       
        if( rUh.isVersionUri() ) {
            NodeRevisionContent rNrc = content.retrieve( sToken, rNrds, rNrd );
            return checkout( rNrds, rNrd, rNrc, forkOk, null ); // autoUpdateUri=null
        }
View Full Code Here

            String cinHref = getElementValue((String)cinProp.getValue());
            UriHandler cinUriHandler = UriHandler.getUriHandler(cinHref);
            String cinhUri = cinUriHandler.getAssociatedHistoryUri();
            NodeRevisionNumber cinNrn = new NodeRevisionNumber(cinUriHandler.getVersionName());
            NodeRevisionDescriptors cinNrds = content.retrieve(sToken, cinhUri);
            NodeRevisionDescriptor cinNrd = content.retrieve(sToken, cinNrds, cinNrn);
           
            // working resource feature
            if( applyToVersion ) {
                NodeRevisionContent cinNrc = content.retrieve( sToken, cinNrds, cinNrd );
                return checkout( cinNrds, cinNrd, cinNrc, forkOk, rUri ); // autoUpdateUri=rUri
            }
           
            ViolatedPrecondition violatedPrecondition = getCheckoutPreconditionViolation(cinNrds, cinNrd, forkOk);
            if (violatedPrecondition != null) {
                throw new PreconditionViolationException(violatedPrecondition, rNrds.getUri());
            }
           
            NodeRevisionDescriptors vhrNrds = content.retrieve(sToken, cinhUri);
           
            // do the checkout
            backupSpecificLiveProperties(rNrds, rNrd);
            rNrd.removeProperty( cinProp );
            rNrd.setProperty(
                new NodeProperty(P_CHECKED_OUT, cinProp.getValue()) );
            rNrd.setProperty(
                new NodeProperty(P_PREDECESSOR_SET, cinProp.getValue()) );
            NodeProperty property = cinNrd.getProperty(P_CHECKOUT_FORK);
            if (property != null) {
                rNrd.setProperty(property);
            }
            property = cinNrd.getProperty(P_CHECKIN_FORK);
            if (property != null) {
                rNrd.setProperty(property);
            }
           
            if (isAutoVersionCheckout) {
View Full Code Here

            String wrUri = String.valueOf( wrUh );
            SubjectNode wrNode = new SubjectNode();
            structure.create( sToken, wrNode, String.valueOf(wrUh) );
           
            // set WR props
            NodeRevisionDescriptor wrNrd = new NodeRevisionDescriptor();
            i = pHelp.createInitialProperties(WorkingImpl.getInstance()).iterator();
            while( i.hasNext() )
                wrNrd.setProperty( (NodeProperty)i.next() );
            //            content.create( sToken, wrUri, wrNrd, rNrc );
           
            // set specific live props
            wrNrd.setProperty(
                new NodeProperty(P_CHECKED_OUT, pHelp.createHrefValue(rUri)) );
            wrNrd.setProperty(
                new NodeProperty(P_PREDECESSOR_SET, pHelp.createHrefValue(rUri)) );
            NodeProperty coutfProp = rNrd.getProperty(P_CHECKOUT_FORK);
            if( coutfProp != null )
                wrNrd.setProperty( coutfProp );
            NodeProperty cinfProp = rNrd.getProperty(P_CHECKIN_FORK);
            if( cinfProp != null )
                wrNrd.setProperty( cinfProp );
            wrNrd.setContentType(rNrd.getContentType()); // P_GETCONTENTTYPE
            wrNrd.setContentLength( rNrd.getContentLength() ); // P_GETCONTENTLENGTH
            wrNrd.setContentLanguage(rNrd.getContentLanguage()); // P_GETCONTENTLANGUAGE
            wrNrd.setLastModified( new Date() ); //P_GETLASTMODIFIED
            wrNrd.setCreationDate( new Date() ); // P_CREATIONDATE
            setCreationUser(wrNrd);
            wrNrd.setETag( PropertyHelper.computeEtag(wrUri, wrNrd)  ); // P_GETETAG
           
            // set auto-update
            if( autoUpdateUri != null && autoUpdateUri.length() > 0 ) {
                UriHandler autoUpdateUh = new UriHandler( autoUpdateUri );
                wrNrd.setProperty(
                    new NodeProperty(P_AUTO_UPDATE, pHelp.createHrefValue(autoUpdateUri)) );
                wrNrd.setName( autoUpdateUh.getName() );
            }
            else {
                wrNrd.removeProperty( P_AUTO_UPDATE );
                wrNrd.setName( rNrd.getName() );
            }
           
            // Copy dead properties VR -> WR
            j = rNrd.enumerateProperties();
            while( j.hasMoreElements() ) {
                NodeProperty p = (NodeProperty)j.nextElement();
                if( p.isLiveProperty() )
                    continue;
                wrNrd.setProperty( p );
            }
           
            // update version's DAV:checkout-set property
            PropertyHelper.addHrefToProperty(rNrd, P_CHECKOUT_SET, wrUri);
            content.store( sToken, rNrds.getUri(), rNrd, null);
View Full Code Here

     * @param     resourcePath  the path of the resource to uncheckout.
     */
    public void uncheckout(String resourcePath) throws SlideException, JDOMException, IOException, PreconditionViolationException  {
       
        NodeRevisionDescriptors rNrds = content.retrieve( sToken, resourcePath );
        NodeRevisionDescriptor rNrd = content.retrieve( sToken, rNrds );
        uncheckout( rNrds, rNrd);
    }
View Full Code Here

        String coutHref = getElementValue((String)coutProp.getValue());
        UriHandler coutUriHandler = UriHandler.getUriHandler(coutHref);
        String coutUri = coutUriHandler.getAssociatedHistoryUri();
        NodeRevisionNumber coutNrn = new NodeRevisionNumber(coutUriHandler.getVersionName());
        NodeRevisionDescriptors coutNrds = content.retrieve(sToken, coutUri);
        NodeRevisionDescriptor coutNrd = content.retrieve(sToken, coutNrds, coutNrn);
        NodeRevisionContent coutNrc = content.retrieve( sToken, coutNrds, coutNrd );
       
        // update its DAV:checkout-set property
        if (!PropertyHelper.removeHrefFromProperty(coutNrd, P_CHECKOUT_SET, rUri)) {
            StringBuffer b = new StringBuffer("Invalid path");
View Full Code Here

     */
    public String checkin( String resourcePath, boolean forkOk, boolean keepCheckedOut, boolean autoVersion )
        throws SlideException, JDOMException, IOException, PreconditionViolationException  {
       
        NodeRevisionDescriptors rNrds = content.retrieve( sToken, resourcePath );
        NodeRevisionDescriptor rNrd = content.retrieve( sToken, rNrds );
        return checkin( rNrds, rNrd, forkOk, keepCheckedOut, autoVersion );
    }
View Full Code Here

            NodeProperty predSetProp = rNrd.getProperty( P_PREDECESSOR_SET );
            NodeProperty autoUpdProp = rNrd.getProperty( P_AUTO_UPDATE );
           
            // prepare auto-update
            NodeRevisionDescriptors autoUpdNrds = null;
            NodeRevisionDescriptor autoUpdNrd = null;
            if( autoUpdProp != null ) {
                Element autoUpdElm = pHelp.parsePropertyValue( (String)autoUpdProp.getValue() );
                String autoUpdUri = autoUpdElm.getTextTrim();
                autoUpdNrds = content.retrieve( sToken, autoUpdUri );
                autoUpdNrd = content.retrieve( sToken, autoUpdNrds );
            }
           
            // Retrieve VHR
            Element coutElm = pHelp.parsePropertyValue( (String)coutProp.getValue() );
            String vrUriOld = coutElm.getTextTrim();
            UriHandler vrUhOld = UriHandler.getUriHandler( vrUriOld );
            NodeRevisionNumber vrNrnOld = new NodeRevisionNumber( vrUhOld.getVersionName() );
            String vhrUri = vrUhOld.getAssociatedHistoryUri();
            NodeRevisionDescriptors vhrNrds = content.retrieve( sToken, vhrUri );
            NodeRevisionDescriptor vhrNrd = content.retrieve( sToken, vhrNrds ); //vhrUri
            NodeProperty vSetProp = vhrNrd.getProperty( P_VERSION_SET );
           
            // Retrieve old VR
            NodeRevisionDescriptor vrNrdOld =
                content.retrieve( sToken, vhrNrds, vrNrnOld ); // vrUriOld
           
            // update the old VR's DAV:checkout-set property
            if (!PropertyHelper.removeHrefFromProperty(vrNrdOld, P_CHECKOUT_SET, rUri)) {
                StringBuffer b = new StringBuffer("Invalid path");
                PropertyHelper propertyHelper = PropertyHelper.getPropertyHelper(sToken, nsaToken, sConf);
                NodeProperty checkoutSetProp = propertyHelper.getProperty(P_CHECKOUT_SET, vhrNrds, vrNrdOld, req.getContextPath(), null);
                if( checkoutSetProp != null && checkoutSetProp.getValue() != null ) {
                    XMLValue checkoutSetValue = new XMLValue( checkoutSetProp.getValue().toString() );
                    if (checkoutSetValue.iterator().hasNext()) {
                        b.append(" - please use "+checkoutSetValue.getTextValue()+" instead");
                    }
                }
                throw new ConflictException(
                    rUri, new SlideException(b.toString()));
            }
            content.store(sToken, vhrNrds.getUri(), vrNrdOld, null);
           
            // check preconditions
            ViolatedPrecondition violatedPrecondition =
                getCheckinPreconditionViolation( predSetProp, vhrNrds, forkOk, autoUpdNrd );
            if (violatedPrecondition != null) {
                throw new PreconditionViolationException(violatedPrecondition, rUri);
            }
           
            // check forking
            String forkBranch = getForkBranch(predSetProp, vhrNrds, forkOk);
            NodeRevisionDescriptor vrNrdNew = null;
            if (forkBranch != null) {
                // Create a new branch
                NodeRevisionNumber branchedRevisionNumber =
                    content.fork(sToken, vhrNrds.getUri(), forkBranch, vrNrdOld);
                vhrNrds = content.retrieve( sToken, vhrUri );
                vrNrdNew = content.retrieve(sToken, vhrNrds, branchedRevisionNumber);
                vrNrdNew.setContentLength(rNrd.getContentLength());
            }
            else {
                // Create new VR in the MAIN branch
                vrNrdNew = new NodeRevisionDescriptor( rNrd.getContentLength() );
            }
           
            i = pHelp.createInitialProperties(VersionImpl.getInstance()).iterator();
            while( i.hasNext() )
                vrNrdNew.setProperty( (NodeProperty)i.next() );
           
            // Copy dead properties VCR --> VR-new
            j = rNrd.enumerateProperties();
            while( j.hasMoreElements() ) {
                NodeProperty p = (NodeProperty)j.nextElement();
                if( p.isLiveProperty() )
                    continue;
                if( !vrNrdNew.exists(p.getName()) )
                    vrNrdNew.setProperty( p );
            }
            // Copy specific live properties VCR/WR -> VR
            vrNrdNew.setContentType(rNrd.getContentType()); // P_GETCONTENTTYPE
            vrNrdNew.setContentLength(rNrd.getContentLength()); // P_GETCONTENTLENGTH
            vrNrdNew.setContentLanguage( rNrd.getContentLanguage() ); // P_GETCONTENTLANGUAGE
            String comment = (autoVersion ? "CREATED BY AUTO-VERSIONING. " : "");
            if( rNrd.exists(P_COMMENT) )
                comment += (String)rNrd.getProperty(P_COMMENT).getValue();
            vrNrdNew.setProperty(
                new NodeProperty(P_COMMENT, comment) );
           
            vrNrdNew.setProperty( rNrd.getProperty(P_CHECKOUT_FORK) );
            vrNrdNew.setProperty( rNrd.getProperty(P_CHECKIN_FORK) );
           
            NodeRevisionContent rNrc = content.retrieve( sToken, rNrds, rNrd );
           
            if (forkBranch != null) {
                content.store(sToken, vhrUri, vrNrdNew, rNrc);
            }
            else {
                String branch = vrNrdOld.getBranchName();
                content.create( sToken, vhrUri, branch, vrNrdNew, rNrc );
            }
           
            // create new VR node
            String vrUriNew = vhrUri+"/"+vrNrdNew.getRevisionNumber().toString();
            UriHandler vrUhNew = UriHandler.getUriHandler( vrUriNew );
            SubjectNode vrNodeNew = new SubjectNode();
            structure.create( sToken, vrNodeNew, vrUriNew );
           
            // set specific properties
            if( keepCheckedOut ) {
                rNrd.setProperty(
                    new NodeProperty(P_CHECKED_OUT, pHelp.createHrefValue(vrUriNew)) );
                rNrd.setProperty(
                    new NodeProperty(P_PREDECESSOR_SET, "") );
                PropertyHelper.addHrefToProperty(rNrd, P_PREDECESSOR_SET, vrUriNew);
                PropertyHelper.addHrefToProperty(vrNrdNew, P_CHECKOUT_SET, rUri);
            }
            else {
                if( !isWorkingResource ) {
                    rNrd.removeProperty( coutProp );
                    rNrd.setProperty(
                        new NodeProperty(P_CHECKED_IN, pHelp.createHrefValue(vrUriNew)) );
                    rNrd.removeProperty( I_CHECKIN_LOCKTOKEN , NamespaceCache.SLIDE_URI);
                    // retry with default (DAV:) namespace which was the
                    // former namespace of this property
                    rNrd.removeProperty( I_CHECKIN_LOCKTOKEN );
                    rNrd.removeProperty(P_PREDECESSOR_SET);
                    rNrd.removeProperty(P_CHECKOUT_FORK);
                    rNrd.removeProperty(P_CHECKIN_FORK);
                }
            }
           
            vhrNrd.setLastModified( new Date() ); // P_GETLASTMODIFIED
            vhrNrd.setProperty( new NodeProperty(
                                   P_VERSION_SET, ((String)vSetProp.getValue())+pHelp.createHrefValue(vrUriNew)) );
           
            vrNrdNew.setName( rNrd.getName() ); // P_DISPLAYNAME
            vrNrdNew.setCreationDate( new Date() ); // P_CREATIONDATE
            vrNrdNew.setLastModified( new Date() ); // P_GETLASTMODIFIED
            vrNrdNew.setETag( PropertyHelper.computeEtag(vrUriNew, vrNrdNew)  ); // P_GETETAG
            vrNrdNew.setProperty(
                new NodeProperty(P_VERSION_NAME, vrUhNew.getVersionName()) );
            vrNrdNew.setProperty(
                new NodeProperty(P_PREDECESSOR_SET, predSetProp.getValue()) );

            // Store changes
            if( keepCheckedOut || !isWorkingResource ) {
                content.store( sToken, rUri, rNrd, null ); //revisionContent=null
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.