当前位置: 首页>>代码示例>>Java>>正文


Java Resource.getPropertyValues方法代码示例

本文整理汇总了Java中org.wso2.carbon.registry.core.Resource.getPropertyValues方法的典型用法代码示例。如果您正苦于以下问题:Java Resource.getPropertyValues方法的具体用法?Java Resource.getPropertyValues怎么用?Java Resource.getPropertyValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.wso2.carbon.registry.core.Resource的用法示例。


在下文中一共展示了Resource.getPropertyValues方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: delete

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
@Override
public void delete(RequestContext requestContext) throws RegistryException {
	if (!CommonUtil.isUpdateLockAvailable()) {
		return;
	}
	CommonUtil.acquireUpdateLock();
	try {
		Resource resource = requestContext.getRegistry().get(
				requestContext.getResourcePath().getPath());
		List<String> symlinkPaths = resource.getPropertyValues("registry.resource.symlink.path");
           if (symlinkPaths != null && symlinkPaths.size() > 0) {
		for (String symlinkPath : symlinkPaths) {
			if (symlinkPath != null) {
				if (requestContext.getRegistry()
						.resourceExists(symlinkPath)) {
					requestContext.getRegistry().delete(symlinkPath);
				}
			}
		}
       }

	} finally {
		CommonUtil.releaseUpdateLock();
	}
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:26,代码来源:ExtensionsSymLinkHandler.java

示例2: validatePropertyOfResource

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
protected boolean validatePropertyOfResource(Resource resource) {
    if (propertyName != null && propertyValue != null) {
        if (!isMultiValued) {
            return propertyValue.equals(resource.getProperty(propertyName));
        }

        List<String> resourceProperties = resource.getPropertyValues(propertyName);
        if (resourceProperties == null) {
            throw new RuntimeException("Error in lifecycle configuration. " +
                    "Invalid property found: " + propertyName);
        }
        for (String value : resourceProperties) {
            if (propertyValue.equals(value)) {
                return true;
            }
        }
        return false;
    }
    return true;
}
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:21,代码来源:PropertyValueValidator.java

示例3: addHoldsToRegistry

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
public static Hold addHoldsToRegistry(RegistrySession session, String s, String s1, boolean b) throws RepositoryException {
    Resource resource = null;
    try {
        resource = session.getUserRegistry().get(s);
        if (resource.getPropertyValues("org.wso2.carbon.registry.jcr.retention.holds") == null) {
            List list = new ArrayList();
            list.add(s1 + ";" + String.valueOf(b));
            resource.setProperty("org.wso2.carbon.registry.jcr.retention.holds", list);
        } else {
            resource.getPropertyValues("org.wso2.carbon.registry.jcr.retention.holds").
                    add(s1 + ";" + String.valueOf(b));
        }
        session.getUserRegistry().put(s, resource);
    } catch (RegistryException e) {
        throw new RepositoryException("Registry level exception when setting retention policy at " + s);
    }

    return new RegistryHold(s1, b);

}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:21,代码来源:EffectiveRetentionUtil.java

示例4: getHoldsFromRegistry

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
public static Hold[] getHoldsFromRegistry(RegistrySession session, String s) throws RepositoryException {
    Resource resource = null;
    List<Hold> holdList = new ArrayList<Hold>();
    try {
        resource = session.getUserRegistry().get(s);
        List holds = resource.getPropertyValues("org.wso2.carbon.registry.jcr.retention.holds");
        if (holds != null) {
            for (Object hold : holds) {
                String[] vals = hold.toString().split(";");
                holdList.add(new RegistryHold(vals[0], Boolean.valueOf(vals[1])));
            }
        }
    } catch (RegistryException e) {
        throw new RepositoryException("Registry level exception when setting retention policy at " + s);
    }

    return holdList.toArray(new RegistryHold[0]);
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:19,代码来源:EffectiveRetentionUtil.java

示例5: removeHoldFromRegistry

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
public static void removeHoldFromRegistry(RegistrySession session, String s, Hold hold) throws RepositoryException {
    Resource resource = null;
    try {
        resource = session.getUserRegistry().get(s);
        List holds = resource.getPropertyValues("org.wso2.carbon.registry.jcr.retention.holds");
        List<Hold> holdList = new ArrayList<Hold>();
        String refHold = hold.getName() + ";" + hold.isDeep();
        if (holds != null) {
            for (Object _hold : holds) {
                if (_hold.equals(refHold)) {
                    resource.getPropertyValues("org.wso2.carbon.registry.jcr.retention.holds").remove(_hold);
                }
            }
        }
        session.getUserRegistry().put(s, resource);

    } catch (RegistryException e) {
        throw new RepositoryException("Registry level exception when setting retention policy at " + s);
    }

}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:22,代码来源:EffectiveRetentionUtil.java

示例6: getPendingRelationshipRequests

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
/**
 * @param owner The userId of the person whose pending relationship list to be retrieved
 * @return An array of userId strings from whom the owner has received relationship requests
 * @throws org.wso2.carbon.registry.social.api.SocialDataException
 *
 */
public String[] getPendingRelationshipRequests(String owner) throws SocialDataException {
    String[] result = null;
    try {
        registry = getRegistry();
        String resourcePath = SocialImplConstants.USER_REGISTRY_ROOT + owner +
                              SocialImplConstants.PENDING_RELATIONSHIP_REQUEST_PATH;
        Resource registryResource;
        if (registry.resourceExists(resourcePath)) {
            registryResource = registry.get(resourcePath);
            List<String> pendingRequests = registryResource.getPropertyValues(
                    SocialImplConstants.RELATIONSHIP_REQUESTS_PROPERTY);
            if(pendingRequests!=null){
            result = new String[pendingRequests.size()];
            result = pendingRequests.toArray(result);
            }                
        }
    }
    catch (RegistryException e) {
        log.error(e.getMessage(), e);
        throw new SocialDataException(
                "Error while retrieving pending relationship requests for user " + owner, e);
    }
    return result;
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:31,代码来源:RelationshipManagerImpl.java

示例7: testMultiValuedProperties

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
public void testMultiValuedProperties() throws Exception {

        Resource r1 = registry.newResource();
        r1.setContent("Some content for r1");
        r1.addProperty("p1", "p1v1");
        r1.addProperty("p1", "p1v2");
        registry.put("/propTest/r1", r1);

        Resource r1b = registry.get("/propTest/r1");
        List propValues = r1b.getPropertyValues("p1");

        assertTrue("Property p1 of /propTest/r1 should contain the value p1v1",
                propValues.contains("p1v1"));
        //System.out.println(propValues.contains("p1v1"));

        assertTrue("Property p1 of /propTest/r1 should contain the value p1v2",
                propValues.contains("p1v2"));
        //System.out.println(propValues.contains("p1v2"));
    }
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:20,代码来源:PropertiesTest.java

示例8: testEditingMultivaluedProperties

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
public void testEditingMultivaluedProperties() throws Exception {

        Resource r1 = registry.newResource();
        r1.setContent("r1 content");
        r1.addProperty("p1", "v1");
        r1.addProperty("p1", "v2");
        r1.setProperty("test", "value2");
        r1.setProperty("test2", "value2");
        registry.put("/props/t3/r1", r1);

        Resource r1e1 = registry.get("/props/t3/r1");
        r1e1.setContent("r1 content");
        r1e1.editPropertyValue("p1", "v1", "v3");
        List list = r1e1.getPropertyValues("/props/t3/r");

        registry.put("/props/t3/r1", r1e1);

        Resource r1e2 = registry.get("/props/t3/r1");


        assertFalse("Property is not edited.", r1e2.getPropertyValues("p1").contains("v1"));
        assertTrue("Property is not edited.", r1e2.getPropertyValues("p1").contains("v3"));
        assertTrue("Wrong property is removed.", r1e2.getPropertyValues("p1").contains("v2"));


    }
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:27,代码来源:PropertiesTest.java

示例9: removeProperty

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
/**
 * Remove a property from a GREG node
 */
public static void removeProperty(Registry repository,Resource resource, PropertyData<?> propertyData) throws RegistryException {
    String id = propertyData.getId();

    if(resource.getPropertyValues(id) != null ){ //has property
        resource.removeProperty(id);
        repository.put(resource.getPath(), resource);
    }

}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:13,代码来源:CommonUtil.java

示例10: testCollectionmultipleProperties

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
public void testCollectionmultipleProperties() throws Exception {

        try {
            String path = "/m15/m16/m17";
            Resource r1 = registry.newCollection();

            r1.setDescription("This m17 description");
            r1.addProperty("key1", "value1");
            r1.addProperty("key1", "value2");
            r1.addProperty("key1", "value3");
            r1.addProperty("key2", "value1");
            r1.addProperty("key2", "value2");

            registry.put(path, r1);

            Resource r1_actual2 = registry.get(path);

            List propertyValues = r1_actual2.getPropertyValues("key1");
            Object[] valueName = propertyValues.toArray();

            List propertyValuesKey2 = r1_actual2.getPropertyValues("key2");
            Object[] valueNameKey2 = propertyValuesKey2.toArray();

            assertTrue("value1 is not associated with key1", containsString(valueName, "value1"));
            assertTrue("value2 is not associated with key1", containsString(valueName, "value2"));
            assertTrue("value3 is not associated with key1", containsString(valueName, "value3"));
            assertTrue("value1 is not associated with key2",
                    containsString(valueNameKey2, "value1"));
            assertTrue("value2 is not associated with key2",
                    containsString(valueNameKey2, "value2"));

        } catch (Exception e) {
            e.printStackTrace();
        }

    }
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:37,代码来源:TestResources.java

示例11: getProperty

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
public boolean getProperty(String path, String key, String value) throws Exception {
    Resource r3 = registry.newResource();
    try {
        r3 = registry.get(path);
    }
    catch (Exception e) {
        fail((new StringBuilder()).append("Couldn't get file from the path :").append(path).toString());
    }
    List propertyValues = r3.getPropertyValues(key);
    Object valueName[] = propertyValues.toArray();
    boolean propertystatus = containsString(valueName, value);
    return propertystatus;
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:14,代码来源:TestAssociation.java

示例12: populate

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
public static DependenciesBean populate(UserRegistry userRegistry, String path) {

        DependenciesBean dependenciesBean = new DependenciesBean();
        ResourcePath resourcePath = new ResourcePath(path);
        try {
            Association[] asso = CommonUtil.getAssociations(userRegistry,
                    (resourcePath.isCurrentVersion() ?
                            resourcePath.getPath() : resourcePath.getPathWithVersion()));
            Resource resource = userRegistry.get(path);

            AssociationBean[] beans = new AssociationBean[asso.length];
            for (int i = 0; i < beans.length; i++) {
                Association as = asso[i];
                beans[i] = new AssociationBean(as.getSourcePath(), as.getDestinationPath(),
                        as.getAssociationType());

            }
            dependenciesBean.setAssociationBeans(beans);

            dependenciesBean.setVersionView(!resourcePath.isCurrentVersion());
            dependenciesBean.setPathWithVersion(resourcePath.getPathWithVersion());
            List mountPoints = resource.getPropertyValues("registry.mountpoint");
            List targetPoints = resource.getPropertyValues("registry.targetpoint");
//            List paths = resource.getPropertyValues("registry.path");
            List actualPaths = resource.getPropertyValues("registry.actualpath");
            String user = resource.getProperty("registry.user");
            if (resource.getProperty("registry.link") != null) {

                if(mountPoints != null && targetPoints != null) {
//                    String mountPoint = (String)mountPoints.get(0);
//                    String targetPoint = (String)targetPoints.get(0);
//                        String tempPath;
//                        if (targetPoint.equals(RegistryConstants.PATH_SEPARATOR) && !path.equals(mountPoint)) {
//                            tempPath = ((String)paths.get(0)).substring(mountPoint.length());
//                        } else {
//                            tempPath = targetPoint + ((String)paths.get(0)).substring(mountPoint.length());
//                        }
                    String tempPath = (String)actualPaths.get(0);
                    dependenciesBean.setPutAllowed(
                            UserUtil.isPutAllowed(userRegistry.getUserName(), tempPath, userRegistry));
                } else if (user != null) {
                    if (userRegistry.getUserName().equals(user)) {
                        dependenciesBean.setPutAllowed(true);
                    } else {
                        dependenciesBean.setPutAllowed(UserUtil.isPutAllowed(
                                userRegistry.getUserName(), path, userRegistry));
                    }
                    }
            } else {
                dependenciesBean.setPutAllowed(UserUtil.isPutAllowed(userRegistry.getUserName(), path, userRegistry));
            }
            dependenciesBean.setLoggedIn(!RegistryConstants.ANONYMOUS_USER.equals(userRegistry.getUserName()));
        } catch (RegistryException e) {

            String msg = "Failed to get dependencies of resource " +
                    resourcePath + ". " + e.getMessage();
            dependenciesBean.setErrorMessage(msg);
        }

        return dependenciesBean;
    }
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:62,代码来源:DependenciesBeanPopulator.java

示例13: getContent

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
public static ContentBean getContent(String path, UserRegistry registry) throws Exception {

        ResourcePath resourcePath = new ResourcePath(path);
        ContentBean bean = new ContentBean();

        Resource resource = registry.get(path);
        bean.setMediaType(resource.getMediaType());
        bean.setCollection(resource instanceof Collection);
        bean.setLoggedIn(!RegistryConstants.ANONYMOUS_USER.equals(registry.getUserName()));
        bean.setPathWithVersion(resourcePath.getPathWithVersion());
        bean.setAbsent(resource.getProperty("registry.absent"));
        List mountPoints = resource.getPropertyValues("registry.mountpoint");
        List targetPoints = resource.getPropertyValues("registry.targetpoint");
//        List paths = resource.getPropertyValues("registry.path");
        List actualPaths = resource.getPropertyValues("registry.actualpath"); 
        String user = resource.getProperty("registry.user");

        if (resource.getProperty("registry.link") != null) {

            if (mountPoints != null && targetPoints != null) {
//                String mountPoint = (String)mountPoints.get(0);
//                String targetPoint = (String)targetPoints.get(0);
//                String tempPath;
//                if (targetPoint.equals(RegistryConstants.PATH_SEPARATOR) && !childPath.equals(mountPoint)) {
//                    tempPath = ((String)paths.get(0)).substring(mountPoint.length());
//                } else {
//                    tempPath = targetPoint + ((String)paths.get(0)).substring(mountPoint.length());
//                }
                String tempPath = (String)actualPaths.get(0);
                bean.setPutAllowed(
                        UserUtil.isPutAllowed(registry.getUserName(), tempPath, registry));
                bean.setRealPath(tempPath);
            } else if (user != null) {
                // Fix for https://wso2.org/jira/browse/REGISTRY-2495
//                if (registry.getUserName().equals(user)) {
//                    bean.setPutAllowed(true);
//                } else {
                    bean.setPutAllowed(
                        UserUtil.isPutAllowed(registry.getUserName(), path, registry));
//                }
                // Mounted resources should be accessed via the link, and we need not set
                // the real path.
            }
        } else {
            boolean putAllowed = UserUtil.isPutAllowed(registry.getUserName(), path, registry);
            bean.setPutAllowed(putAllowed);
        }

        bean.setVersionView(!resourcePath.isCurrentVersion());
        bean.setContentPath(resourcePath.getCompletePath());
        resource.discard();
        
        return bean;
    }
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:55,代码来源:ContentUtil.java

示例14: populate

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
public static TagBean populate(UserRegistry userRegistry, String path) {
        TagBean tagBean = new TagBean();

        try {
            Resource resource = userRegistry.get(path);
            org.wso2.carbon.registry.core.Tag[] t = userRegistry.getTags(path);
            Tag[] tags = new Tag [t.length];
            Tag tag;
            for(int i=0; i<t.length; i++) {
                tag = new Tag();
                tag.setCategory(t[i].getCategory());
                tag.setTagCount(t[i].getTagCount());
                tag.setTagName(t[i].getTagName());
                tags[i] = tag;
            }
            
            tagBean.setTags(tags);

            ResourcePath resourcePath = new ResourcePath(path);
            tagBean.setPathWithVersion(resourcePath.getPathWithVersion());
            tagBean.setVersionView(!resourcePath.isCurrentVersion());
            List mountPoints = resource.getPropertyValues("registry.mountpoint");
            List targetPoints = resource.getPropertyValues("registry.targetpoint");
//            List paths = resource.getPropertyValues("registry.path");
            List actualPaths = resource.getPropertyValues("registry.actualpath");
            String user = resource.getProperty("registry.user");
            if (resource.getProperty("registry.link") != null) {

                if(mountPoints != null && targetPoints != null) {
//                    String mountPoint = (String)mountPoints.get(0);
//                    String targetPoint = (String)targetPoints.get(0);
//                        String tempPath;
//                        if (targetPoint.equals(RegistryConstants.PATH_SEPARATOR) && !path.equals(mountPoint)) {
//                            tempPath = ((String)paths.get(0)).substring(mountPoint.length());
//                        } else {
//                            tempPath = targetPoint + ((String)paths.get(0)).substring(mountPoint.length());
//                        }
                    String tempPath = (String)actualPaths.get(0);
                    tagBean.setPutAllowed(
                            UserUtil.isPutAllowed(userRegistry.getUserName(), tempPath, userRegistry));
                } else if (user != null) {
                    if (userRegistry.getUserName().equals(user)) {
                        tagBean.setPutAllowed(true);
                    } else {
                        tagBean.setPutAllowed(UserUtil.isPutAllowed(
                                userRegistry.getUserName(), path, userRegistry));
                    }
                }
            } else {
                tagBean.setPutAllowed(UserUtil.isPutAllowed(userRegistry.getUserName(), path, userRegistry));
            }
            tagBean.setLoggedIn(!RegistryConstants.ANONYMOUS_USER.equals(userRegistry.getUserName()));

        } catch (RegistryException e) {

            String msg = "Failed to get tagging information of resource . " + e.getMessage();
            tagBean.setErrorMessage(msg);
        }

        return tagBean;
    }
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:62,代码来源:TagBeanPopulator.java

示例15: populate

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
public static CommentBean populate(UserRegistry userRegistry, String path) {

        CommentBean commentBean = new CommentBean();

        try {
            Resource resource = userRegistry.get(path);
            org.wso2.carbon.registry.core.Comment[] c = userRegistry.getComments(path);
            Comment [] comments = new Comment [c.length];
            Comment comment;
            for (int i=0; i <c.length; i++) {
                comment = new Comment();
                comment.setAuthorUserName(c[i].getAuthorUserName());
                comment.setCommentPath(c[i].getCommentPath());
                comment.setContent(c[i].getContent());
                Calendar createdDate = Calendar.getInstance();
                createdDate.setTime(c[i].getCreatedTime());
                comment.setCreatedTime(createdDate);
                comment.setDescription(c[i].getDescription());
                Calendar lastModifiedDate = Calendar.getInstance();
                // We don't support editing comments as yet.
                lastModifiedDate.setTime(c[i].getCreatedTime());
                comment.setLastModified(lastModifiedDate);
                comment.setMediaType(c[i].getMediaType());
                comment.setResourcePath(c[i].getResourcePath());
                comment.setText(c[i].getText());
                Calendar calendarTime = Calendar.getInstance();
                calendarTime.setTime(c[i].getTime());
                comment.setTime(calendarTime);
                comment.setUser(c[i].getUser());
                comments[i] = comment;
            }

            commentBean.setComments(comments);

            ResourcePath resourcePath = new ResourcePath(path);
            commentBean.setPathWithVersion(resourcePath.getPathWithVersion());
            commentBean.setVersionView(!resourcePath.isCurrentVersion());
            List mountPoints = resource.getPropertyValues("registry.mountpoint");
            List targetPoints = resource.getPropertyValues("registry.targetpoint");
//            List paths = resource.getPropertyValues("registry.path");
            List actualPaths = resource.getPropertyValues("registry.actualpath");
            String user = resource.getProperty("registry.user");
            if (resource.getProperty("registry.link") != null) {

                if(mountPoints != null && targetPoints != null) {
//                    String mountPoint = (String)mountPoints.get(0);
//                    String targetPoint = (String)targetPoints.get(0);
//                        String tempPath;
//                        if (targetPoint.equals(RegistryConstants.PATH_SEPARATOR) && !path.equals(mountPoint)) {
//                            tempPath = ((String)paths.get(0)).substring(mountPoint.length());
//                        } else {
//                            tempPath = targetPoint + ((String)paths.get(0)).substring(mountPoint.length());
//                        }
                    String tempPath = (String)actualPaths.get(0);
                    commentBean.setPutAllowed(
                            UserUtil.isPutAllowed(userRegistry.getUserName(), tempPath, userRegistry));
                } else if (user != null) {
                    if (userRegistry.getUserName().equals(user)) {
                        commentBean.setPutAllowed(true);
                    } else {
                        commentBean.setPutAllowed(UserUtil.isPutAllowed(
                                userRegistry.getUserName(), path, userRegistry));
                    }
                }
            } else {
                commentBean.setPutAllowed(UserUtil.isPutAllowed(userRegistry.getUserName(), path, userRegistry));
            }
            commentBean.setLoggedIn(!RegistryConstants.ANONYMOUS_USER.equals(userRegistry.getUserName()));
        } catch (RegistryException e) {

            String msg = "Failed to get comment information of the resource. " + e.getMessage();

            commentBean.setErrorMessage(msg);
        }

        return commentBean;
    }
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:78,代码来源:CommentBeanPopulator.java


注:本文中的org.wso2.carbon.registry.core.Resource.getPropertyValues方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。