Package org.wso2.carbon.registry.core

Examples of org.wso2.carbon.registry.core.ResourceImpl


            }
        }
        resourceVersionDAO.versionResource(resourceDO, keepProperties);
        if (isRenewing) {
            // we add a new copy to the resource table with a newer version
            ResourceImpl renewedResourceImpl = resourceImpl.getShallowCopy();
            if (!(renewedResourceImpl instanceof CollectionImpl)) {
                resourceDAO.addContent(renewedResourceImpl);
            }
            resourceDAO.addResourceWithNoUpdate(renewedResourceImpl);
            if (StaticConfiguration.isVersioningProperties() || !keepProperties) {
View Full Code Here


            throw new AuthorizationFailedException(msg);
        }

        long snapshotID = versionedPath.getVersion();

        ResourceImpl resourceImpl = resourceVersionDAO.get(resourceID, snapshotID);

        if (resourceImpl == null) {
            String msg = "Resource " + versionedPath.getPath() +
                    " does not have a version " + versionedPath.getVersion();
            log.error(msg);
            throw new RegistryException(msg);
        }
        resourceImpl.setDataAccessManager(dataAccessManager);

        resourceImpl.setPath(versionedPath.getPath());
        resourceImpl.setSnapshotID(snapshotID);
        resourceImpl.setMatchingSnapshotID(snapshotID);
        return resourceImpl;
    }
View Full Code Here

            throw new AuthorizationFailedException(msg);
        }

        long snapshotID = versionedPath.getVersion();

        ResourceImpl resourceImpl = resourceVersionDAO.get(resourceID, snapshotID);

        if (resourceImpl == null) {
            String msg = "Resource " + versionedPath.getPath() +
                    " does not have a version " + versionedPath.getVersion();
            log.error(msg);
            throw new RegistryException(msg);
        }

        int contentId = resourceImpl.getDbBasedContentID();
        if (contentId > 0) {
            resourceVersionDAO.fillResourceContentArchived(resourceImpl);
        }
        resourceDAO.fillResourcePropertiesWithNoUpdate(resourceImpl);

        resourceImpl.setDataAccessManager(dataAccessManager);
        resourceImpl.setUserName(CurrentSession.getUser());
        resourceImpl.setTenantId(CurrentSession.getTenantId());
        resourceImpl.setUserRealm(CurrentSession.getUserRealm());

        resourceImpl.setPath(versionedPath.getPath());
        resourceImpl.setSnapshotID(snapshotID);
        resourceImpl.setMatchingSnapshotID(snapshotID);

        return resourceImpl;
    }
View Full Code Here

        ResourcePath resourcePath = requestContext.getResourcePath();

        String ratedUserName = resourcePath.getParameterValue("ratings");
        if (ratedUserName != null) {
            ResourceImpl resourceImpl = resourceDAO.getResourceMetaData(resourcePath.getPath());

            RatingDO ratingDO = ratingsDAO.getRatingDO(resourceImpl, ratedUserName);
            int rating = ratingDO.getRating();
            Date ratedTime = ratingDO.getRatedTime();

            ResourceImpl resource = new ResourceImpl();
            resource.setMediaType(RegistryConstants.RATING_MEDIA_TYPE);
            resource.setContent(rating);
            resource.setAuthorUserName(ratedUserName);
            resource.setPath(resourcePath.getCompletePath());
            if (ratedTime != null) {
                resource.setCreatedTime(ratedTime);
                resource.setLastModified(ratedTime);
            }
            resource.addProperty("resourcePath", resourcePath.getPath());

            return resource;
        }

        return null;
View Full Code Here

        adminRealm.getUserStoreManager()
                .addUser("cu1", "cu1111", new String[]{"rolex"}, null, null);

        UserRegistry cu1Reg = embeddedRegistryService.getUserRegistry("cu1", "cu1111");

        ResourceImpl r1 = new ResourceImpl();
        r1.setContent("r1 content");
        adminReg.put("/CRTest/r1", r1);

        adminRealm.getAuthorizationManager().
                authorizeRole("rolex", "/CRTest/r1", ActionConstants.PUT);

        ResourceImpl r2 = new ResourceImpl();
        r2.setContent("r2 content");
        adminReg.put("/CRTest/r2", r2);

        String c1 =
                adminReg.addComment("/CRTest/r1",
                        new Comment("administrator's comment on /CRTest/r1"));
View Full Code Here

            String userName = queries[1];

            TaggingDO taggingDO = null;
            ResourceIDImpl resourceIDImpl = resourceDAO.getResourceID(path);
            if (resourceIDImpl != null) {
                ResourceImpl resourceImpl = resourceDAO.getResourceMetaData(resourceIDImpl);
                if (resourceImpl != null) {
                    TaggingDO[] taggingDOs = tagsDAO.getTagging(resourceImpl, tagName, userName);
                    taggingDO = taggingDOs[0];
                }
            }


            ResourceImpl resource = new ResourceImpl();
            resource.setMediaType(RegistryConstants.TAG_MEDIA_TYPE);
            resource.setPath(resourcePath.getCompletePath());
            if (taggingDO != null) {
                resource.setContent(taggingDO.getTagName());
                resource.setAuthorUserName(taggingDO.getTaggedUserName());
                final Date taggedTime = taggingDO.getTaggedTime();
                resource.setCreatedTime(taggedTime);
                resource.setLastModified(taggedTime);
                resource.addProperty("resourcePath", taggingDO.getResourcePath());
            }
            requestContext.setProcessingComplete(true);

            return resource;
        }
View Full Code Here

    }

    public Resource newResource() throws RegistryException {
        beginDBQueryLog(2);
        try {
            ResourceImpl resource = new ResourceImpl();
            resource.setAuthorUserName(CurrentSession.getUser());
            return resource;
        } finally {
            endDBQueryLog(2);
        }
    }
View Full Code Here

                    resourcePath = processedPath.getPath();

                    // break the comma separated words into multiple tags
                    String[] tags = tag.split(",");

                    ResourceImpl resource = tagsDAO.getResourceWithMinimumData(resourcePath);
                    if (resource == null) {
                        String msg = "Failed to apply tag " + tag + " on resource " + resourcePath +
                                ". Resource " + resourcePath + " does not exist.";
                        log.error(msg);
                        throw new RegistryException(msg);
                    }

                    String userName = CurrentSession.getUser();

                    if (!AuthorizationUtils.authorize(resource.getPath(), ActionConstants.GET)) {
                        String msg = "Failed to apply tag " + tag + " on resource " + resourcePath +
                                ". User " + userName + " is not authorized to read the resource.";
                        log.error(msg);
                        throw new RegistryException(msg);
                    }
View Full Code Here

                    List<String> pathList = tagsDAO.getPathsWithAnyTag(tags);
                    for (String path : pathList) {
                        TaggedResourcePath taggedResourcePath = new TaggedResourcePath();
                        taggedResourcePath.setResourcePath(path);

                        ResourceImpl resourceImpl = tagsDAO.getResourceWithMinimumData(path);

                        for (String currentTag : tags) {
                            long count = tagsDAO.getTagCount(resourceImpl, currentTag);
                            taggedResourcePath.addTagCount(currentTag, count);
                            taggedPaths.put(currentTag + path, taggedResourcePath);
View Full Code Here

                    path = RegistryUtils.prepareGeneralPath(path);

                    ResourcePath resourcePath = new ResourcePath(path);
                    VersionedPath versionedPath = RegistryUtils.getVersionedPath(resourcePath);
                    ResourceImpl resourceImpl;
                    if (versionedPath.getVersion() == -1) {
                        resourceImpl = tagsDAO.getResourceWithMinimumData(resourcePath.getPath());
                    } else {
                        resourceImpl = (ResourceImpl) versionRepository.getMetaData(versionedPath);
                    }
View Full Code Here

TOP

Related Classes of org.wso2.carbon.registry.core.ResourceImpl

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.