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


Java Collection类代码示例

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


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

示例1: findDescendantResources

import org.wso2.carbon.registry.core.Collection; //导入依赖的package包/类
@Override
public Set<String> findDescendantResources(String parentResourceId, EvaluationCtx context) throws Exception {
    Set<String> resourceSet = new HashSet<String>();
    registry = EntitlementServiceComponent.getRegistryService().getSystemRegistry(CarbonContext.
            getThreadLocalCarbonContext().getTenantId());
    if (registry.resourceExists(parentResourceId)) {
        Resource resource = registry.get(parentResourceId);
        if (resource instanceof Collection) {
            Collection collection = (Collection) resource;
            String[] resources = collection.getChildren();
            for (String res : resources) {
                resourceSet.add(res);
                getChildResources(res, resourceSet);
            }
        } else {
            return null;
        }
    }
    return resourceSet;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:21,代码来源:DefaultResourceFinder.java

示例2: getChildResources

import org.wso2.carbon.registry.core.Collection; //导入依赖的package包/类
/**
 * This helps to find resources un a recursive manner
 *
 * @param node           attribute value node
 * @param parentResource parent resource Name
 * @return child resource set
 * @throws RegistryException throws
 */
private EntitlementTreeNodeDTO getChildResources(EntitlementTreeNodeDTO node,
                                                 String parentResource) throws RegistryException {

    if (registry.resourceExists(parentResource)) {
        String[] resourcePath = parentResource.split("/");
        EntitlementTreeNodeDTO childNode =
                new EntitlementTreeNodeDTO(resourcePath[resourcePath.length - 1]);
        node.addChildNode(childNode);
        Resource root = registry.get(parentResource);
        if (root instanceof Collection) {
            Collection collection = (Collection) root;
            String[] resources = collection.getChildren();
            for (String resource : resources) {
                getChildResources(childNode, resource);
            }
        }
    }
    return node;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:28,代码来源:CarbonEntitlementDataFinder.java

示例3: addKeystores

import org.wso2.carbon.registry.core.Collection; //导入依赖的package包/类
private void addKeystores() throws RegistryException {
    Registry registry = SecurityServiceHolder.getRegistryService().getGovernanceSystemRegistry();
    try {
        boolean transactionStarted = Transaction.isStarted();
        if (!transactionStarted) {
            registry.beginTransaction();
        }
        if (!registry.resourceExists(SecurityConstants.KEY_STORES)) {
            Collection kstores = registry.newCollection();
            registry.put(SecurityConstants.KEY_STORES, kstores);

            Resource primResource = registry.newResource();
            if (!registry.resourceExists(RegistryResources.SecurityManagement.PRIMARY_KEYSTORE_PHANTOM_RESOURCE)) {
                registry.put(RegistryResources.SecurityManagement.PRIMARY_KEYSTORE_PHANTOM_RESOURCE,
                        primResource);
            }
        }
        if (!transactionStarted) {
            registry.commitTransaction();
        }
    } catch (Exception e) {
        registry.rollbackTransaction();
        throw e;
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:26,代码来源:SecurityDeploymentInterceptor.java

示例4: buildUIPermissionNode

import org.wso2.carbon.registry.core.Collection; //导入依赖的package包/类
private void buildUIPermissionNode(Collection parent, UIPermissionNode parentNode,
                                   Registry registry, Registry tenantRegistry, AuthorizationManager authMan,
                                   String roleName, String userName)
        throws RegistryException, UserStoreException {

    boolean isSelected = false;
    if (roleName != null) {
        isSelected = authMan.isRoleAuthorized(roleName, parentNode.getResourcePath(),
                UserMgtConstants.EXECUTE_ACTION);
    } else if (userName != null) {
        isSelected = authMan.isUserAuthorized(userName, parentNode.getResourcePath(),
                UserMgtConstants.EXECUTE_ACTION);
    }
    if (isSelected) {
        buildUIPermissionNodeAllSelected(parent, parentNode, registry, tenantRegistry);
        parentNode.setSelected(true);
    } else {
        buildUIPermissionNodeNotAllSelected(parent, parentNode, registry, tenantRegistry,
                authMan, roleName, userName);
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:22,代码来源:UserRealmProxy.java

示例5: buildUIPermissionNodeAllSelected

import org.wso2.carbon.registry.core.Collection; //导入依赖的package包/类
private void buildUIPermissionNodeAllSelected(Collection parent, UIPermissionNode parentNode,
                                              Registry registry, Registry tenantRegistry) throws RegistryException,
        UserStoreException {

    String[] children = parent.getChildren();
    UIPermissionNode[] childNodes = new UIPermissionNode[children.length];
    for (int i = 0; i < children.length; i++) {
        String child = children[i];
        Resource resource = null;

        if (registry.resourceExists(child)) {
            resource = registry.get(child);
        } else if (tenantRegistry != null) {
            resource = tenantRegistry.get(child);
        } else {
            throw new RegistryException("Permission resource not found in the registry.");
        }

        childNodes[i] = getUIPermissionNode(resource, true);
        if (resource instanceof Collection) {
            buildUIPermissionNodeAllSelected((Collection) resource, childNodes[i], registry,
                    tenantRegistry);
        }
    }
    parentNode.setNodeList(childNodes);
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:27,代码来源:UserRealmProxy.java

示例6: testResourceMoveFromRoot

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

        Resource r1 = registry.newResource();
        r1.setProperty("test", "move");
        r1.setContent("c");
        registry.put("/move1", r1);

        Collection c1 = registry.newCollection();
        registry.put("/test/move", c1);

        registry.move("/move1", "/test/move/move1");

        Resource newR1 = registry.get("/test/move/move1");
        assertEquals("Moved resource should have a property named 'test' with value 'move'.",
                newR1.getProperty("test"), "move");

        boolean failed = false;
        try {
            Resource oldR1 = registry.get("/move1");
        } catch (Exception e) {
            failed = true;
        }
        assertTrue("Moved resource should not be accessible from the old path.", failed);
    }
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:25,代码来源:TestMove.java

示例7: getGlobalPolicyAlgorithmName

import org.wso2.carbon.registry.core.Collection; //导入依赖的package包/类
@Override
public String getGlobalPolicyAlgorithmName() {

    Registry registry = EntitlementServiceComponent.
            getGovernanceRegistry(CarbonContext.getThreadLocalCarbonContext().getTenantId());
    String algorithm = null;
    try {

        if (registry.resourceExists(policyDataCollection)) {
            Collection collection = (Collection) registry.get(policyDataCollection);
            algorithm = collection.getProperty("globalPolicyCombiningAlgorithm");
        }
    } catch (RegistryException e) {
        if (log.isDebugEnabled()) {
            log.debug(e);
        }
    }

    // set default
    if (algorithm == null) {
        algorithm = "deny-overrides";
    }

    return algorithm;
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:26,代码来源:DefaultPolicyDataStore.java

示例8: init

import org.wso2.carbon.registry.core.Collection; //导入依赖的package包/类
private static void init() {

        Registry registry;
        IdentityMgtConfig.getInstance(realmService.getBootstrapRealmConfiguration());
        recoveryProcessor = new RecoveryProcessor();
        try {
            registry = IdentityMgtServiceComponent.getRegistryService()
                    .getConfigSystemRegistry();
            if (!registry
                    .resourceExists(IdentityMgtConstants.IDENTITY_MANAGEMENT_PATH)) {
                Collection questionCollection = registry.newCollection();
                registry.put(IdentityMgtConstants.IDENTITY_MANAGEMENT_PATH,
                        questionCollection);
                loadDefaultChallenges();
            }
        } catch (RegistryException e) {
            log.error("Error while creating registry collection for org.wso2.carbon.identity.mgt component", e);
        }

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

示例9: deleteOldResourcesIfFound

import org.wso2.carbon.registry.core.Collection; //导入依赖的package包/类
private void deleteOldResourcesIfFound(Registry registry, String userName, String secretKeyPath) {
    try {
        if (registry.resourceExists(secretKeyPath.toLowerCase())) {
            Collection collection = (Collection) registry.get(secretKeyPath.toLowerCase());
            String[] resources = collection.getChildren();
            for (String resource : resources) {
                String[] splittedResource = resource.split("___");
                if (splittedResource.length == 3) {
                    //PRIMARY USER STORE
                    if (resource.contains("___" + userName + "___")) {
                        registry.delete(resource);
                    }
                } else if (splittedResource.length == 2) {
                    //SECONDARY USER STORE. Resource is a collection.
                    deleteOldResourcesIfFound(registry, userName, resource);
                }
            }
        }
    } catch (RegistryException e) {
        log.error("Error while deleting the old confirmation code \n" + e);
    }

}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:24,代码来源:RegistryRecoveryDataStore.java

示例10: createHumanTaskPackageParentCollectionWithProperties

import org.wso2.carbon.registry.core.Collection; //导入依赖的package包/类
/**
 * Create parent collection for human task package using DeploymentUnitDAO
 *
 * @param deploymentUnitDAO
 * @throws RegistryException
 */
private void createHumanTaskPackageParentCollectionWithProperties(DeploymentUnitDAO deploymentUnitDAO)
        throws RegistryException {
    Collection humanPackage = configRegistry.newCollection();
    humanPackage.setProperty(HumanTaskConstants.HUMANTASK_PACKAGE_PROP_LATEST_CHECKSUM, deploymentUnitDAO
            .getChecksum());
    if (log.isDebugEnabled()) {
        log.debug(deploymentUnitDAO.getPackageName() + " updating checksum: " + deploymentUnitDAO
                .getChecksum() + " in registry");
    }
    humanPackage.setProperty(HumanTaskConstants.HUMANTASK_PACKAGE_PROP_STATUS, String.valueOf
            (deploymentUnitDAO.getStatus()));
    humanPackage.setProperty(HumanTaskConstants.HUMANTASK_PACKAGE_PROP_LATEST_VERSION,
                             Long.toString(deploymentUnitDAO.getVersion()));
    configRegistry.put(HumanTaskPackageRepositoryUtils.getResourcePathForHumanTaskPackage
            (deploymentUnitDAO), humanPackage);
}
 
开发者ID:wso2,项目名称:carbon-business-process,代码行数:23,代码来源:HumanTaskPackageRepository.java

示例11: testSetCollectionDetails

import org.wso2.carbon.registry.core.Collection; //导入依赖的package包/类
public void testSetCollectionDetails() throws Exception {
    Collection r1 = registry.newCollection();
    r1.setDescription("C3 collection description");
    r1.setProperty("key1", "value5");
    r1.setProperty("key2", "value3");

    String path_collection = "/c1/c2/c3";

    registry.put(path_collection, r1);

    Resource r1_actual = registry.get("/c1/c2/c3");

    assertTrue(r1_actual instanceof Collection);
    assertEquals("LastUpdatedUser is not Equal", "admin", r1_actual.getLastUpdaterUserName());
    assertEquals("Can not get Resource path", path_collection, r1_actual.getPath());
    assertEquals("Can not get Resource parent path", "/c1/c2", r1_actual.getParentPath());
    assertEquals("Resource description is not equal", r1.getDescription(),
            r1_actual.getDescription());
    assertEquals("Authour is not equal", "admin", r1_actual.getAuthorUserName());
    assertEquals("Resource properties are not equal", r1.getProperty("key1"),
            r1_actual.getProperty("key1"));
    assertEquals("Resource properties are not equal", r1.getProperty("key2"),
            r1_actual.getProperty("key2"));
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:25,代码来源:TestResources.java

示例12: setup

import org.wso2.carbon.registry.core.Collection; //导入依赖的package包/类
@Before
public void setup() throws RegistryException {
    userRegistry = mock(UserRegistry.class);
    Collection resultCollection = new CollectionImpl();
    resultCollection.setContent(new String[]
            {"/_system/config/repository/components/org.wso2.carbon.governance/configuration/restservice"});
    when(userRegistry.executeQuery(anyString(), (Map) anyObject())).thenReturn(resultCollection);
    Resource rxtResource = new ResourceImpl();
    rxtResource.setMediaType("application/xml");
    InputStream is = null;
    try {
        is = RxtUnboundedDataLoadUtilsTest.class.getClassLoader().getResourceAsStream("restservice.rxt");
        rxtResource.setContentStream(is);
        when(userRegistry.get("/_system/config/repository/components/org.wso2.carbon" +
                ".governance/configuration/restservice")).thenReturn(rxtResource);
    } finally {
        if (is != null) {
            try {
                is.close();
            } catch (IOException ignore) {

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

示例13: getSavedReports

import org.wso2.carbon.registry.core.Collection; //导入依赖的package包/类
public ReportConfigurationBean[] getSavedReports()
        throws RegistryException, CryptoException, TaskException {
    Registry registry = getConfigSystemRegistry();
    List<ReportConfigurationBean> output = new LinkedList<ReportConfigurationBean>();
    if (registry.resourceExists(REPORTING_CONFIG_PATH)) {
        Collection collection = (Collection) registry.get(REPORTING_CONFIG_PATH);
        String[] children = collection.getChildren();
        for (String child : children) {
            ReportConfigurationBean bean = getConfigurationBean(child);
            Registry rootRegistry1 = getRootRegistry();
            if (!rootRegistry1.resourceExists(bean.getTemplate())) {
                log.warn("Report template " + bean.getTemplate() + " doesn't exist");
            }
            try {
                RegistryUtils.loadClass(bean.getReportClass());
            } catch (ClassNotFoundException e) {
                log.warn("Report class not found " + bean.getReportClass());
            }
            output.add(bean);
        }
    }
    return output.toArray(new ReportConfigurationBean[output.size()]);
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:24,代码来源:ReportingAdminService.java

示例14: testPutOnPaths

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

        Resource r1 = registry.newResource();
        r1.setContent("some content");
        registry.put("/testkrishantha1/paths2/r1", r1);

        Resource r2 = registry.newResource();
        r2.setContent("another content");
        registry.put("/testkrishantha1/paths2/r2", r2);

        Collection c1 = registry.newCollection();
        registry.put("/testkrishantha1/paths2/c1", c1);

        Collection c2 = registry.newCollection();
        registry.put("/testkrishantha1/paths2/c2", c2);

        assertTrue("Resource not found.", registry.resourceExists("/testkrishantha1/paths2/r1"));
        assertTrue("Resource not found.", registry.resourceExists("/testkrishantha1/paths2/r2"));
        assertTrue("Resource not found.", registry.resourceExists("/testkrishantha1/paths2/c1"));
        assertTrue("Resource not found.", registry.resourceExists("/testkrishantha1/paths2/c2"));
    }
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:22,代码来源:TestPaths.java

示例15: delete

import org.wso2.carbon.registry.core.Collection; //导入依赖的package包/类
@Override
public void delete(RequestContext requestContext) throws RegistryException {
    Resource resource = requestContext.getResource();
    if (resource instanceof Collection) {
        if(!isDeleteLockAvailable()){
            return;
        }
        acquireDeleteLock();
        try {
            deleteRecursively(requestContext.getRegistry(), resource);
            requestContext.setProcessingComplete(true);
        } finally {
            releaseDeleteLock();
        }
    }
}
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:17,代码来源:RecursiveDeleteHandler.java


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