Package org.apache.slide.content

Examples of org.apache.slide.content.Content


       
        UriHandler uriHandler = UriHandler.getUriHandler(resourcePath);
        String uri = null;
        NodeRevisionDescriptors revisionDescriptors = null;
        NodeRevisionDescriptor revisionDescriptor = null;
        Content contentHelper = nsaToken.getContentHelper();
       
        if (uriHandler.isVersionUri()) {
            uri = uriHandler.getAssociatedHistoryUri();
            NodeRevisionNumber revisionNumber = new NodeRevisionNumber(uriHandler.getVersionName());
            revisionDescriptors = contentHelper.retrieve(sToken, uri);
            revisionDescriptor = contentHelper.retrieve(sToken, revisionDescriptors, revisionNumber);
        }
        else if (uriHandler.isHistoryUri()) {
            uri = uriHandler.getAssociatedHistoryUri();
            NodeRevisionNumber revisionNumber = new NodeRevisionNumber("0.0");
            revisionDescriptors = contentHelper.retrieve(sToken, uri);
            revisionDescriptor = contentHelper.retrieve(sToken, revisionDescriptors, revisionNumber);
        }
        else {
            uri = resourcePath;
            revisionDescriptors = contentHelper.retrieve(sToken, uri);
            revisionDescriptor = contentHelper.retrieve(sToken, revisionDescriptors);
        }
        return getProperty(propertyName, revisionDescriptors, revisionDescriptor, contextPath, servletPath);
    }
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();
       
        // XXX guarantees that reading and writing of history counting property
        // is atomic. This is necessary as part of the fix to the problem described in
        // bug #26913. While the history counter is incremented no other tx can be allowed
        // to access the counter, that's why a write lock that is valid until commit is needed.
        // As this requires locking going through to the store and must thus tunnel caching
        // the other part of the fix is a HACK in ExtendedStore
        synchronized (HISTORY_LOCK) {
            NodeRevisionDescriptors hpathNrds =
                content.retrieve( sToken, hpath );
           
            NodeRevisionDescriptor hpathNrd =
                content.retrieve( sToken, hpathNrds );
           
            NodeProperty nextHnProp = hpathNrd.getProperty(I_NEXT_HISTORY_NAME,
                                                           NamespaceCache.SLIDE_URI);
            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();
       
        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

        throws IOException, SlideException {
       
        res.setContentType("text/html; charset=\"UTF-8\"");
       
        // get the helpers
        Content content = nat.getContentHelper();
        Lock lock = nat.getLockHelper();
        Security security = nat.getSecurityHelper();
        Structure structure = nat.getStructureHelper();
       
        SlideToken slideToken = WebdavUtils.getSlideToken(req);
        String resourcePath = WebdavUtils.getRelativePath(req, config);
        ObjectNode object = structure.retrieve(slideToken, resourcePath);
        String name = object.getUri();
       
        // Number of characters to trim from the beginnings of filenames
        int trim = name.length();
        if (!name.endsWith("/"))
            trim += 1;
        if (name.equals("/"))
            trim = 1;
       
        PrintWriter writer = new PrintWriter(res.getWriter());
       
        // Render the page header
        writer.print("<html>\r\n");
        writer.print("<head>\r\n");
        writer.print("<meta http-equiv=\"Content-type\" content=\"text/html; charset=UTF-8\" >\r\n");
        writer.print("</meta>\r\n");
        writer.print("<title>");
        writer.print
            (Messages.format
                 ("org.apache.slide.webdav.GetMethod.directorylistingfor",
                  name));
        writer.print("</title>\r\n</head>\r\n");
        writer.print("<body bgcolor=\"white\">\r\n");
        writer.print("<table width=\"90%\" cellspacing=\"0\"" +
                         " cellpadding=\"5\" align=\"center\">\r\n");
       
        // Render the in-page title
        writer.print("<tr><td colspan=\"3\"><font size=\"+2\">\r\n<strong>");
        writer.print
            (Messages.format
                 ("org.apache.slide.webdav.GetMethod.directorylistingfor",
                  name));
        writer.print("</strong>\r\n</font></td></tr>\r\n");
       
        // Render the link to our parent (if required)
        String parentDirectory = name;
        if (parentDirectory.endsWith("/")) {
            parentDirectory =
                parentDirectory.substring(0, parentDirectory.length() - 1);
        }
        String scope = config.getScope();
        parentDirectory = parentDirectory.substring(scope.length());
        if (parentDirectory.lastIndexOf("/") >= 0) {
            parentDirectory = parentDirectory.substring(0, parentDirectory.lastIndexOf("/"));
            writer.print("<tr><td colspan=\"5\" bgcolor=\"#ffffff\">\r\n");
            writer.print("<a href=\"");
            writer.print(WebdavUtils.getAbsolutePath("", req, config));
            if (parentDirectory.equals(""))
                parentDirectory = "/";
            writer.print(parentDirectory);   // I18N chars
            writer.print("\">");
            writer.print(Messages.format
                             ("org.apache.slide.webdav.GetMethod.parent",
                              parentDirectory));
            writer.print("</a>\r\n");
            writer.print("</td></tr>\r\n");
        }
       
        Enumeration permissionsList = null;
        Enumeration locksList = null;
        try {
            permissionsList =
                security.enumeratePermissions(slideToken, object.getUri());
            locksList = lock.enumerateLocks(slideToken, object.getUri(), false);
        } catch (SlideException e) {
            // Any security based exception will be trapped here
            // Any locking based exception will be trapped here
        }
       
        // Displaying ACL info
        if (org.apache.slide.util.Configuration.useIntegratedSecurity()) {
            displayPermissions(permissionsList, writer, false);
        }
       
        // Displaying lock info
        displayLocks(locksList, writer, false);
       
        writer.print("<tr><td colspan=\"5\" bgcolor=\"#ffffff\">");
        writer.print("&nbsp;");
        writer.print("</td></tr>\r\n");
       
        // Render the column headings
        writer.print("<tr bgcolor=\"#cccccc\">\r\n");
        writer.print("<td align=\"left\" colspan=\"3\">");
        writer.print("<font size=\"+1\"><strong>");
        writer.print(Messages.message
                         ("org.apache.slide.webdav.GetMethod.filename"));
        writer.print("</strong></font></td>\r\n");
        writer.print("<td align=\"center\"><font size=\"+1\"><strong>");
        writer.print(Messages.message
                         ("org.apache.slide.webdav.GetMethod.size"));
        writer.print("</strong></font></td>\r\n");
        writer.print("<td align=\"right\"><font size=\"+1\"><strong>");
        writer.print(Messages.message
                         ("org.apache.slide.webdav.GetMethod.lastModified"));
        writer.print("</strong></font></td>\r\n");
        writer.print("</tr>\r\n");
       
        Enumeration resources = object.enumerateChildren();
        boolean shade = false;
       
        while (resources.hasMoreElements()) {
            String currentResource = (String) resources.nextElement();
            NodeRevisionDescriptor currentDescriptor = null;
            permissionsList = null;
            locksList = null;
            try {
                NodeRevisionDescriptors revisionDescriptors =
                    content.retrieve(slideToken, currentResource);
                // Retrieve latest revision descriptor
                currentDescriptor =
                    content.retrieve(slideToken, revisionDescriptors);
            } catch (SlideException e) {
                // Silent exception : Objects without any revision are
                // considered collections, and do not have any attributes
                // Any security based exception will be trapped here
                // Any locking based exception will be trapped here
View Full Code Here

     * @param      uri the uri of the resource that has been unlocked.
     * @throws     SlideException
     */
    public void afterUnlock(String uri) throws SlideException {
        // Check whether the resource must be checked-in due to auto-versioning semantics.
        Content content = token.getContentHelper();
        NodeRevisionDescriptors revisionDescriptors =
            content.retrieve(slideToken, uri);
        NodeRevisionDescriptor revisionDescriptor =
            content.retrieve(slideToken, revisionDescriptors);
        ResourceKind resourceKind = AbstractResourceKind.determineResourceKind(token, uri, revisionDescriptor);
        if( Configuration.useVersionControl() &&
               (resourceKind instanceof CheckedOutVersionControlled) ) {
            NodeProperty checkinLocktokenProperty =
                revisionDescriptor.getProperty(DeltavConstants.I_CHECKIN_LOCKTOKEN,
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

                                String password) throws Exception {
       
        String usersPath = nat.getNamespaceConfig().getUsersPath();
        String userUri = usersPath + "/" + userId;
       
        Content content = nat.getContentHelper();
       
        try {
            NodeRevisionDescriptors revisions = content.retrieve(ROOT,userUri);
            NodeRevisionDescriptor revision = content.retrieve(ROOT,revisions);
            NodeProperty property = revision.getProperty(
                "password",NodeProperty.SLIDE_NAMESPACE);
           
            return property.getValue().equals(password);
        }
View Full Code Here

        String usersPath = nat.getNamespaceConfig().getUsersPath();
        String userUri = usersPath + "/" + username;
       
        SlideToken slideToken = new SlideTokenImpl(new CredentialsToken(caller));
        Structure structure = nat.getStructureHelper();
        Content content = nat.getContentHelper();
       
        try {
           
            nat.begin();
           
            ObjectNode user = new SubjectNode();
            structure.create(slideToken,user,userUri);
           
            // create the user descriptor
            NodeRevisionDescriptor descriptor = new NodeRevisionDescriptor();
            descriptor.setCreationDate(new Date());
            descriptor.setLastModified(new Date());
            descriptor.setProperty(new NodeProperty(
                "password",password,NodeProperty.SLIDE_NAMESPACE));
            content.create(slideToken,userUri,descriptor,null);
           
            nat.commit();
        }
        catch (Exception e) {
            try {
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

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.