Package org.apache.slide.content

Examples of org.apache.slide.content.NodeProperty$Kind


                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
View Full Code Here


    if ( !uri.isStoreRoot() ) {
      resourceType += "<principal/>";
    }
    props.put(
      "DAV:resourcetype",
      new NodeProperty( "resourcetype", resourceType, "DAV:", "", false ) );
    props.put(
      "DAV:displayname",
      new NodeProperty( "displayname", (!uri.isStoreRoot() && principalNameAttribute != null?(String)objectNameMap.get(objectName):objectName), "DAV:", "", false ) );
   
    // The storeRoot isn't a real object so it doesn't have any parameters to look up
    if ( !uri.isStoreRoot() ) {
           
      String localFilter = rdnAttribute + "=" + (principalNameAttribute != null?(String)objectNameMap.get(objectName):objectName);
       
      SearchControls controls = new SearchControls();
      controls.setSearchScope( searchScope );
      controls.setReturningAttributes( descriptorAttributes );
     
      try {
        NamingEnumeration results = ctx.search(
          container,
          localFilter,
          controls );

        if ( !results.hasMore() ) {
                    if (ctx != null) {
                        closeContext(ctx);
                    }
          throw new RevisionDescriptorNotFoundException( uri.toString() );
        }
        while ( results.hasMore() ) {
          SearchResult result = null;
          try {
            result = (SearchResult)results.next();
          } catch ( NamingException e ) {
            getLogger().log(
              name + ": Error getting search result with filter: " + localFilter +
              " from container: " + container + ".",
              LOG_CHANNEL, Logger.ERROR );
                        if (ctx != null) {
                            closeContext(ctx);
                        }
            throw new ServiceAccessException( this, e );
          }
         
          NamingEnumeration attributes = result.getAttributes().getAll();
          while ( attributes.hasMore() ) {
            Attribute attribute = (Attribute)attributes.next();
            StringBuffer valueString = new StringBuffer();
            boolean isGms = attribute.getID().equals( groupMemberSet );
            boolean isMva = attribute.size() > 1;
            for ( int i = 0; i < attribute.size(); i++ ) {
              try {
                Object value = attribute.get( i );
                if ( !( value instanceof String ) ) {
                  getLogger().log(
                    name + ": Non-string value found for " +
                    attribute.getID() ".",
                    LOG_CHANNEL,
                    Logger.DEBUG );
                  continue;
                }
                if ( isGms ) {
                  valueString.append( "<D:href xmlns:D='DAV:'>" );
                  valueString.append( usersPath ).append( "/" );
                  String name = parseLdapName(value.toString());
                  if (principalNameAttribute != null) {
                    // lookup LDAP user entry
                    controls.setReturningAttributes(new String[] { principalNameAttribute });
                    NamingEnumeration roleResults =
                      ctx.search(container, rdnAttribute + "=" + name, controls);
                    if (roleResults.hasMore()) {
                      SearchResult userObject = (SearchResult)roleResults.next();
                      name = ((String)userObject.getAttributes().get(principalNameAttribute).get()).toLowerCase();
                    }
                  }
                  valueString.append(name);
                  valueString.append( "</D:href>" );
                } else {
                  if ( isMva ) {
                    valueString.append( "<mva xmlns=\"" )
                      .append( LDAP_NAMESPACE ).append( "\">" );
                    valueString.append( value.toString() );
                    valueString.append( "</mva>" );
                  } else {
                    valueString.append( value.toString() );
                  }
                }
              } catch ( NamingException e ) {
                getLogger().log(
                  name + ": Error fetching next attribute value for attribute " +
                    attribute.getID() + ".",
                  e, LOG_CHANNEL, Logger.DEBUG );
              }
            }
           
            if ( isGms ) {
              getLogger().log(
                name + ": Adding property \"group-member-set\" in namespace " +
                "\"DAV:\" with value of \"" + valueString.toString() + "\" to " +
                uri.toString() + ".",
                LOG_CHANNEL, Logger.DEBUG );
             
              props.put(
                "DAV:group-member-set",
                new NodeProperty(
                  "group-member-set",
                  valueString.toString(),
                  "DAV:" ) );
             
            } else {
              getLogger().log(
                name + ": Adding property \"" + attribute.getID() +
                "\" in namespace \"" + LDAP_NAMESPACE + "\" " +
                "with value of \"" +
                valueString.toString() + "\" to " + uri.toString() + ".",
                LOG_CHANNEL, Logger.DEBUG );
             
              props.put(
                LDAP_NAMESPACE + attribute.getID(),
                new NodeProperty(
                  attribute.getID(),
                  valueString.toString(),
                  LDAP_NAMESPACE ) );
            }
          }
View Full Code Here

        ResourceKind resourceKind = AbstractResourceKind
            .determineResourceKind(token, requestUri,
                revisionDescriptor);
        if (Configuration.useVersionControl()
            && (resourceKind instanceof CheckedOutVersionControlled)) {
          NodeProperty checkinLocktokenProperty = revisionDescriptor
              .getProperty(DeltavConstants.I_CHECKIN_LOCKTOKEN,
                  NamespaceCache.SLIDE_URI);
          if (checkinLocktokenProperty == null) {
            // retry with default (DAV:) namespace which was the
            // former namespace of this property
            checkinLocktokenProperty = revisionDescriptor
                .getProperty(DeltavConstants.I_CHECKIN_LOCKTOKEN);
          }
          if ((checkinLocktokenProperty != null)
              && (checkinLocktokenProperty.getValue() != null)
              && lockId.equals(checkinLocktokenProperty
                  .getValue().toString())) {
            VersioningHelper versionHelper = VersioningHelper
                .getVersioningHelper(slideToken, token, req,
                    resp, config);
            versionHelper.checkin(revisionDescriptors,
View Full Code Here

            if (currentDefaultProperties == null) {
                currentDefaultProperties = new Vector();
                defaultProperties.put(role, currentDefaultProperties);
            }
            currentDefaultProperties.addElement
                (new NodeProperty(name, value, namespace));
        }
    }
View Full Code Here

        if (!Configuration.useBinding(nsaToken.getUri(sToken, vcrUri).getStore())) {
            vcrNrd.setName( utok[utok.length - 1] ); // P_DISPLAYNAME
        }
        vcrNrd.setCreationDate( new Date() ); // P_CREATIONDATE
        setCreationUser(vcrNrd);
        vcrNrd.setProperty( new NodeProperty(P_CHECKED_IN,
                                             pHelp.createHrefValue(evUri)) );
        // set workspace
        setWorkspaceProperty( vcrUri, vcrNrd );
       
        // store
View Full Code Here

    public void setWorkspaceProperty( String rUri, NodeRevisionDescriptor rNrd ) {
        UriHandler rUh = UriHandler.getUriHandler( rUri );
        String wsUri = rUh.getAssociatedWorkspaceUri();
        if( wsUri != null ) {
            rNrd.setProperty(
                new NodeProperty(P_WORKSPACE, pHelp.createHrefValue(wsUri)) );
        }
        else {
            rNrd.removeProperty(P_WORKSPACE);
        }
    }
View Full Code Here

        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
View Full Code Here

            throw new MethodNotAllowedException( rRk );
        }
       
        if( rRk instanceof CheckedInVersionControlled ) {
            // get checked-in VR
            NodeProperty cinProp = rNrd.getProperty( P_CHECKED_IN );
            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 &&
                !(E_CHECKOUT_IGNORE_UNLOCK.equals(getAutoVersionElementName(rNrd)))) {
                NodeLock writeLock = getWriteLock(sToken, rNrds);
                if (writeLock != null) {
                    NodeProperty p =
                        new NodeProperty(I_CHECKIN_LOCKTOKEN,
                                         writeLock.getLockId(),
                                         NamespaceCache.SLIDE_URI);
                    p.setKind( NodeProperty.Kind.PROTECTED );
                    rNrd.setProperty( p );
                }
            }
           
            // update checked-in VR's DAV:checkout-set property
View Full Code Here

                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
View Full Code Here

    protected ViolatedPrecondition getCheckoutPreconditionViolation(NodeRevisionDescriptors cinNrds, NodeRevisionDescriptor cinNrd, boolean isForkOk) throws IllegalArgumentException, IOException, JDOMException, SlideException {
        SlideToken stok = sToken;
       
        ViolatedPrecondition violatedPrecondition = null;
       
        NodeProperty checkoutForkProperty =cinNrd.getProperty(P_CHECKOUT_FORK);
        if (checkoutForkProperty != null
             && !checkoutForkProperty.getValue().toString().equals(""))
        {
            Element checkoutForkElement = pHelp.parsePropertyValue(checkoutForkProperty.getValue().toString());
            if (checkoutForkElement != null) {
               
                // check if the version has successors
                Enumeration successors = cinNrds.getSuccessors(cinNrd.getRevisionNumber());
                if ( (successors != null) && successors.hasMoreElements()) {
                   
                    // check precondition C_CHECKOUT_OF_VERSION_WITH_DESCENDANT_IS_FORBIDDEN
                    if (E_FORBIDDEN.equals(checkoutForkElement.getName()))  {
                        return new ViolatedPrecondition(C_CHECKOUT_OF_VERSION_WITH_DESCENDANT_IS_FORBIDDEN, WebdavStatus.SC_FORBIDDEN);
                    }
                       
                        // check precondition C_CHECKOUT_OF_VERSION_WITH_DESCENDANT_IS_DISCOURAGED
                    else if (E_DISCOURAGED.equals(checkoutForkElement.getName()) && !isForkOk)  {
                        return new ViolatedPrecondition(C_CHECKOUT_OF_VERSION_WITH_DESCENDANT_IS_DISCOURAGED, WebdavStatus.SC_CONFLICT);
                    }
                }
               
                // check if the version is already checked out
                PropertyHelper propertyHelper = PropertyHelper.getPropertyHelper(stok, nsaToken, sConf);
               
                NodeProperty checkoutSetProp = propertyHelper.getProperty(P_CHECKOUT_SET, cinNrds, cinNrd, slideContextPath);
                if( checkoutSetProp != null && checkoutSetProp.getValue() != null ) {
                    XMLValue checkoutSetValue = new XMLValue( checkoutSetProp.getValue().toString() );
                    if (checkoutSetValue.iterator().hasNext()) {
                       
                        // check precondition C_CHECKOUT_OF_CHECKED_OUT_VERSION_IS_FORBIDDEN
                        if (E_FORBIDDEN.equals(checkoutForkElement.getName()))  {
                            return new ViolatedPrecondition(C_CHECKOUT_OF_CHECKED_OUT_VERSION_IS_FORBIDDEN, WebdavStatus.SC_FORBIDDEN);
View Full Code Here

TOP

Related Classes of org.apache.slide.content.NodeProperty$Kind

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.