Package org.apache.slide.content

Examples of org.apache.slide.content.Content


                                 String objectUri,
                                 String subjectUri) throws Exception {
       
        SlideToken slideToken = new SlideTokenImpl(new CredentialsToken(caller));
        Structure structure = nat.getStructureHelper();
        Content content = nat.getContentHelper();
       
        try {
           
            // check if the subject exists
            structure.retrieve(slideToken,subjectUri);
           
            NodeRevisionDescriptors descriptors = content.retrieve(slideToken,objectUri);
            NodeRevisionDescriptor descriptor = content.retrieve(slideToken,descriptors);
            NodeProperty property = descriptor.getProperty("group-member-set","DAV:");
           
            String value = null;
            if (property != null) {
                value = (String) property.getValue();
                if (value.indexOf(subjectUri) != -1) {
                    // user already a member of this group
                    return;
                }
            }
            else {
                value = "";
            }
            value = value + "<D:href xmlns:D='DAV:'>" + subjectUri + "</D:href>";
           
            descriptor.setProperty("group-member-set","DAV:",value);
            nat.begin();
            content.store(slideToken,objectUri,descriptor,null);
            nat.commit();
        }
        catch (ObjectNotFoundException e) {
            // no such user or group
        }
View Full Code Here


                                    String caller,
                                    String objectUri,
                                    String subjectUri) throws Exception {
       
        SlideToken slideToken = new SlideTokenImpl(new CredentialsToken(caller));
        Content content = nat.getContentHelper();
       
        try {
           
            NodeRevisionDescriptors revisions = content.retrieve(slideToken,objectUri);
            NodeRevisionDescriptor revision = content.retrieve(slideToken,revisions);
            NodeProperty property = revision.getProperty("group-member-set","DAV:");
           
            if (property == null) {
                // group has no members
                return;
            }
            String value = (String) property.getValue();
           
            int index = value.indexOf(subjectUri);
            if (index == -1) {
                // subject is not a member of this group
                return;
            }
           
            // looking for the end of </D:href> after subjectUri
            int end = index + subjectUri.length();
            do {
                end++;
            }
            while (value.charAt(end) != '>');
           
            // looking for the start of <D:href> before subjectUri
            int from = index;
            do {
                from--;
            }
            while(value.charAt(from) != '<');
           
            // snip out the user
            String before = value.substring(0,from);
            String after  = value.substring(end+1);
            value = before + after;
           
            revision.setProperty("group-member-set","DAV:",value);
            nat.begin();
            content.store(slideToken,objectUri,revision,null);
            nat.commit();
        }
        catch (ObjectNotFoundException e) {
            // no such user or group
        }
View Full Code Here

       
        String usersPath = nat.getNamespaceConfig().getUsersPath();
        String userUri = usersPath + "/" + username;
       
        SlideToken slideToken = new SlideTokenImpl(new CredentialsToken(caller));
        Content content = nat.getContentHelper();
       
        try {
           
            nat.begin();

            NodeRevisionDescriptors revisions = content.retrieve(slideToken,userUri);
            NodeRevisionDescriptor revision = content.retrieve(slideToken,revisions);
            revision.setLastModified(new Date());
            revision.setProperty(new NodeProperty("password", password, NodeProperty.SLIDE_NAMESPACE));
            content.store(slideToken, userUri, revision, null);
           
            nat.commit();
        }
        catch (Exception e) {
            try {
View Full Code Here

                return false;
        }
        // Added for DeltaV --end--
       
        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;
            }
        } catch(ObjectNotFoundException e) {
View Full Code Here

       
        UriHandler result = null;
        String nsName = nsaToken.getName();
        UriHandler hpathHandler =
            HistoryPathHandler.getResolvedHistoryPathHandler( nsName, uh );
        Content content = nsaToken.getContentHelper();
        String hpath = hpathHandler.toString();
       
        Structure structure = nsaToken.getStructureHelper();
        String uniqueUri = structure.generateUniqueUri(sToken, hpath);

        if (uniqueUri != null) {
            if (UriHandler.useHistoryCollectionHack) {
                // XXX this is a bit silly: first compose it, now analyze it...
                String nextHnStr = uniqueUri.substring(uniqueUri.lastIndexOf('/') + 1);
                // XXX start with (at least) 10 to
                // assure no resources are created directly in history folder
                long nextHnLong = Long.parseLong(nextHnStr) + 10;
                nextHnStr = String.valueOf(nextHnLong);

                // make hpath/1/2/3 out of 1234
                StringBuffer pathBuffer = new StringBuffer(hpath);
                for (int i = 0; i < nextHnStr.length() - 1; i++) {
                    pathBuffer.append('/');
                    pathBuffer.append(nextHnStr.charAt(i));
                    // as we have no information how this number may look like we will have to assure the full
                    // path is created
                    String dir = pathBuffer.toString();
                    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

       
        UriHandler result = null;
        String nsName = nsaToken.getName();
        UriHandler wrpathHandler =
            WorkingresourcePathHandler.getResolvedWorkingresourcePathHandler( nsName, uh );
        Content content = nsaToken.getContentHelper();
        String wrpath = wrpathHandler.toString();
       
        Structure structure = nsaToken.getStructureHelper();
        String uniqueUri = structure.generateUniqueUri(sToken, wrpath);

        if (uniqueUri != null) {
            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

        String groupsPath = nat.getNamespaceConfig().getGroupsPath();
        String groupUri = groupsPath + "/" + groupname;
       
        SlideToken slideToken = new SlideTokenImpl(new CredentialsToken(caller));
        Structure structure = nat.getStructureHelper();
        Content content = nat.getContentHelper();
       
        try {
            nat.begin();
           
            ObjectNode group = new SubjectNode();
            structure.create(slideToken,group,groupUri);
           
            NodeRevisionDescriptor descriptor = new NodeRevisionDescriptor();
            descriptor.setCreationDate(new Date());
            descriptor.setLastModified(new Date());
           
            content.create(slideToken,groupUri,descriptor,null);
           
            nat.commit();
        }
        catch (Exception e) {
            try {
View Full Code Here

        String rolesPath = nat.getNamespaceConfig().getRolesPath();
        String roleUri = rolesPath + "/" + rolename;
       
        SlideToken slideToken = new SlideTokenImpl(new CredentialsToken(caller));
        Structure structure = nat.getStructureHelper();
        Content content = nat.getContentHelper();
       
        try {
            nat.begin();
           
            ObjectNode role = new SubjectNode();
            structure.create(slideToken,role,roleUri);
           
            NodeRevisionDescriptor descriptor = new NodeRevisionDescriptor();
            descriptor.setCreationDate(new Date());
            descriptor.setLastModified(new Date());
           
            content.create(slideToken,roleUri,descriptor,null);
           
            nat.commit();
        }
        catch (Exception e) {
            try {
View Full Code Here

                                 String objectUri,
                                 String subjectUri) throws Exception {
       
        SlideToken slideToken = new SlideTokenImpl(new CredentialsToken(caller));
        Structure structure = nat.getStructureHelper();
        Content content = nat.getContentHelper();
       
        try {
           
            // check if the subject exists
            structure.retrieve(slideToken,subjectUri);
           
            NodeRevisionDescriptors descriptors = content.retrieve(slideToken,objectUri);
            NodeRevisionDescriptor descriptor = content.retrieve(slideToken,descriptors);
            NodeProperty property = descriptor.getProperty("group-member-set","DAV:");
           
            String value = null;
            if (property != null) {
                value = (String) property.getValue();
                if (value.indexOf(subjectUri) != -1) {
                    // user already a member of this group
                    return;
                }
            }
            else {
                value = "";
            }
            value = value + "<D:href xmlns:D='DAV:'>" + subjectUri + "</D:href>";
           
            descriptor.setProperty("group-member-set","DAV:",value);
            nat.begin();
            content.store(slideToken,objectUri,descriptor,null);
            nat.commit();
        }
        catch (ObjectNotFoundException e) {
            // no such user or group
        }
View Full Code Here

                                    String caller,
                                    String objectUri,
                                    String subjectUri) throws Exception {
       
        SlideToken slideToken = new SlideTokenImpl(new CredentialsToken(caller));
        Content content = nat.getContentHelper();
       
        try {
           
            NodeRevisionDescriptors revisions = content.retrieve(slideToken,objectUri);
            NodeRevisionDescriptor revision = content.retrieve(slideToken,revisions);
            NodeProperty property = revision.getProperty("group-member-set","DAV:");
           
            if (property == null) {
                // group has no members
                return;
            }
            String value = (String) property.getValue();
           
            int index = value.indexOf(subjectUri);
            if (index == -1) {
                // subject is not a member of this group
                return;
            }
           
            // looking for the end of </D:href> after subjectUri
            int end = index + subjectUri.length();
            do {
                end++;
            }
            while (value.charAt(end) != '>');
           
            // looking for the start of <D:href> before subjectUri
            int from = index;
            do {
                from--;
            }
            while(value.charAt(from) != '<');
           
            // snip out the user
            String before = value.substring(0,from);
            String after  = value.substring(end+1);
            value = before + after;
           
            revision.setProperty("group-member-set","DAV:",value);
            nat.begin();
            content.store(slideToken,objectUri,revision,null);
            nat.commit();
        }
        catch (ObjectNotFoundException e) {
            // no such user or group
        }
View Full Code Here

TOP

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

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.