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


Java Resource.setProperty方法代码示例

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


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

示例1: addVersionToHistory

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
private void addVersionToHistory(String nodePath, String nodeVersion) {
    try {

        String confPath = RegistryJCRSpecificStandardLoderUtil.
                getSystemConfigVersionPath((RegistrySession) session);
        Resource resource = ((RegistrySession) session).getUserRegistry().get(confPath);

        if (resource.getProperty(nodePath) != null) {
            resource.getPropertyValues(nodePath).add(nodeVersion);
        } else {
            List<String> list = new ArrayList<String>();
            list.add(nodeVersion);
            resource.setProperty(nodePath, list);
        }
        ((RegistrySession) session).getUserRegistry().put(confPath, resource);

    } catch (RegistryException e) {
        e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
    }

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

示例2: addScripts

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
public static void addScripts(String state, Resource resource, List<ScriptBean> scriptList, String aspectName) {
    if (scriptList != null) {
        for (ScriptBean scriptBean : scriptList) {
            if (scriptBean.isConsole()) {
                List<String> items = new ArrayList<String>();
                items.add(scriptBean.getScript());
                items.add(scriptBean.getFunctionName());

                String resourcePropertyNameForScript =
                        LifecycleConstants.REGISTRY_CUSTOM_LIFECYCLE_CHECKLIST_JS_SCRIPT_CONSOLE + aspectName + "." + state
                                + "." + scriptBean.getEventName();
                resource.setProperty(resourcePropertyNameForScript, items);
            }
        }
    }
}
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:17,代码来源:Utils.java

示例3: setTaskMetadataProp

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
@Override
public void setTaskMetadataProp(String taskName, String key, String value) throws TaskException {
    try {
        PrivilegedCarbonContext.startTenantFlow();
        PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(
                MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, true);
        Resource res = this.getTaskMetadataPropResource(taskName);
        res.setProperty(key, value);
        getRegistry().put(res.getPath(), res);
    } catch (RegistryException e) {
        throw new TaskException("Error in setting task metadata properties: " + e.getMessage(),
                Code.UNKNOWN, e);
    } finally {
        PrivilegedCarbonContext.endTenantFlow();
    }
}
 
开发者ID:wso2,项目名称:carbon-commons,代码行数:17,代码来源:RegistryBasedTaskRepository.java

示例4: testGeneralCollectionRename

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

        Resource r1 = registry.newResource();
        r1.setProperty("test", "rename");
        r1.setContent("some text");
        registry.put("/c2/rename3/c1/dummy", r1);

        registry.rename("/c2/rename3", "rename4");

        boolean failed = false;
        try {
            Resource originalR1 = registry.get("/c2/rename3/c1/dummy");
        } catch (Exception e) {
            failed = true;
        }
        assertTrue("Resource should not be " +
                "accessible from the old path after renaming the parent.", failed);

        Resource newR1 = registry.get("/c2/rename4/c1/dummy");
        assertEquals("Resource should contain a property with name test and value rename.",
                newR1.getProperty("test"), "rename");
    }
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:23,代码来源:RenameTest.java

示例5: associateAspect

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
/**
 * Method to associate an aspect with a given resource on the registry.
 *
 * @param path     the path of the resource.
 * @param aspect   the aspect to add.
 * @param registry the registry instance on which the resource is available.
 * @throws RegistryException if the operation failed.
 */
public static void associateAspect(String path, String aspect, Registry registry)
        throws RegistryException {

    try {
        registry.associateAspect(path, aspect);

        Resource resource = registry.get(path);
        if(resource.getAspects().size() == 1) {
            // Since this is the first life-cycle we make it default
            resource.setProperty("registry.LC.name", aspect);
            registry.put(path, resource);
        }

    } catch (RegistryException e) {

        String msg = "Failed to associate aspect with the resource " +
                path + ". " + e.getMessage();
        log.error(msg, e);
        throw new RegistryException(msg, e);
    }
}
 
开发者ID:wso2,项目名称:carbon-governance,代码行数:30,代码来源:GovernanceUtils.java

示例6: testResourceMoveToRoot

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

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

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

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

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

示例7: setProperty

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
public Property setProperty(String s, boolean b) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
        RegistryJCRItemOperationUtil.checkRetentionPolicy(registrySession,getPath());
        RegistryJCRItemOperationUtil.checkRetentionHold(registrySession, getPath());

        registrySession.sessionPending();
        validatePropertyModifyPrivilege(s);

        Resource res = null;
        try {
            res = registrySession.getUserRegistry().newResource();
            res.setContent(String.valueOf(b));
            res.setProperty("registry.jcr.property.type", "boolean");
            registrySession.getUserRegistry().put(nodePath + "/" + s, res);
            property = new RegistryProperty(nodePath + "/" + s, registrySession, s,b);

        } catch (RegistryException e) {
            String msg = "failed to resolve the path of the given node or violation of repository syntax " + this;
            log.debug(msg);
            throw new RepositoryException(msg, e);
        }

        isModified = true;
//        property.setValue(b);
        return property;
    }
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:26,代码来源:RegistryNode.java

示例8: populateStatusProperties

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
/**
 * @param statusHolders
 * @param resource
 */
private void populateStatusProperties(StatusHolder[] statusHolders, Resource resource) {
    if (statusHolders != null) {
        for (StatusHolder statusHolder : statusHolders) {
            if (statusHolder != null) {
                List<String> list = new ArrayList<String>();
                list.add(statusHolder.getType());
                list.add(statusHolder.getTimeInstance());
                list.add(statusHolder.getUser());
                list.add(statusHolder.getKey());
                list.add(Boolean.toString(statusHolder.isSuccess()));
                if (statusHolder.getMessage() != null) {
                    list.add(statusHolder.getMessage());
                } else {
                    list.add("");
                }
                if (statusHolder.getTarget() != null) {
                    list.add(statusHolder.getTarget());
                } else {
                    list.add("");
                }
                if (statusHolder.getTargetAction() != null) {
                    list.add(statusHolder.getTargetAction());
                } else {
                    list.add("");
                }
                if (statusHolder.getVersion() != null) {
                    list.add(statusHolder.getVersion());
                } else {
                    list.add("");
                }
                resource.setProperty(UUID.randomUUID().toString(), list);
            }
        }
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:40,代码来源:SimplePAPStatusDataHandler.java

示例9: setAttributesAsProperties

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
/**
 * This helper method creates properties object which contains the policy meta data.
 *
 * @param attributeDTOs List of AttributeDTO
 * @param resource      registry resource
 */
public static void setAttributesAsProperties(AttributeDTO[] attributeDTOs, Resource resource) {

    int attributeElementNo = 0;
    if (attributeDTOs != null) {
        for (AttributeDTO attributeDTO : attributeDTOs) {
            resource.setProperty("policyMetaData" + attributeElementNo,
                    attributeDTO.getCategory() + "," +
                            attributeDTO.getAttributeValue() + "," +
                            attributeDTO.getAttributeId() + "," +
                            attributeDTO.getAttributeDataType());
            attributeElementNo++;
        }
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:21,代码来源:EntitlementUtil.java

示例10: populateProperties

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
private void populateProperties(PublisherDataHolder holder,
                                PublisherDataHolder oldHolder, Resource resource) {

    PublisherPropertyDTO[] propertyDTOs = holder.getPropertyDTOs();
    for (PublisherPropertyDTO dto : propertyDTOs) {
        if (dto.getId() != null && dto.getValue() != null && dto.getValue().trim().length() > 0) {
            ArrayList<String> list = new ArrayList<String>();
            if (dto.isSecret()) {
                PublisherPropertyDTO propertyDTO = null;
                if (oldHolder != null) {
                    propertyDTO = oldHolder.getPropertyDTO(dto.getId());
                }
                if (propertyDTO == null || !propertyDTO.getValue().equalsIgnoreCase(dto.getValue())) {
                    try {
                        String encryptedValue = CryptoUtil.getDefaultCryptoUtil().
                                encryptAndBase64Encode(dto.getValue().getBytes());
                        dto.setValue(encryptedValue);
                    } catch (CryptoException e) {
                        log.error("Error while encrypting secret value of subscriber. " +
                                "Secret would not be persist.", e);
                        continue;
                    }
                }
            }
            list.add(dto.getValue());
            list.add(dto.getDisplayName());
            list.add(Integer.toString(dto.getDisplayOrder()));
            list.add(Boolean.toString(dto.isRequired()));
            list.add(Boolean.toString(dto.isSecret()));
            resource.setProperty(dto.getId(), list);
        }
    }
    resource.setProperty(PublisherDataHolder.MODULE_NAME, holder.getModuleName());
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:35,代码来源:PolicyPublisher.java

示例11: setPolicyData

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
@Override
public void setPolicyData(String policyId, PolicyStoreDTO policyDataDTO) throws EntitlementException {

    Registry registry = getGovernanceRegistry();
    try {
        String path = policyDataCollection + policyId;
        Resource resource;
        if (registry.resourceExists(path)) {
            resource = registry.get(path);
        } else {
            resource = registry.newCollection();
        }

        if (policyDataDTO.isSetActive()) {
            resource.setProperty("active", Boolean.toString(policyDataDTO.isActive()));
        }
        if (policyDataDTO.isSetOrder()) {
            int order = policyDataDTO.getPolicyOrder();
            if (order > 0) {
                resource.setProperty("order", Integer.toString(order));
            }
        }
        registry.put(path, resource);
    } catch (RegistryException e) {
        log.error("Error while updating Policy data in policy store ", e);
        throw new EntitlementException("Error while updating Policy data in policy store");
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:29,代码来源:DefaultPolicyDataStore.java

示例12: setAttributesAsProperties

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
/**
 * This helper method creates properties object which contains the policy meta data.
 *
 * @param attributeDTOs List of AttributeDTO
 * @param resource      registry resource
 */
private void setAttributesAsProperties(AttributeDTO[] attributeDTOs, Resource resource) {

    int attributeElementNo = 0;
    if (attributeDTOs != null) {
        for (AttributeDTO attributeDTO : attributeDTOs) {
            resource.setProperty(KEY_VALUE_POLICY_META_DATA + attributeElementNo,
                                 attributeDTO.getCategory() + "," +
                                 attributeDTO.getAttributeValue() + "," +
                                 attributeDTO.getAttributeId() + "," +
                                 attributeDTO.getAttributeDataType());
            attributeElementNo++;
        }
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:21,代码来源:RegistryPolicyStoreManageModule.java

示例13: write

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
@Override
public void write(int tenantId, Properties props, String resourcePath)
        throws IdentityMgtConfigException {

    if(log.isDebugEnabled()) {
        log.debug("Writing data to registry path : " + resourcePath);
    }
    
    RegistryService registry = IdentityMgtServiceComponent.getRegistryService();
    try {
        UserRegistry userReg = registry.getConfigSystemRegistry(tenantId);
        Resource resource = userReg.newResource();
        Set<String> names = props.stringPropertyNames();
        // Only key value pairs exists and no multiple values exists a key.
        for (String keyName : names) {
            List<String> value = new ArrayList<String>();
            String valueStr = props.getProperty(keyName);
            
            if(log.isDebugEnabled()) {
                log.debug("Write key : " + keyName + " value : " + value);
            }
            
            // This is done due to casting to List in JDBCRegistryDao
            value.add(valueStr);
            resource.setProperty(keyName, value);
        }
        userReg.put(resourcePath, resource);

    } catch (RegistryException e) {
        throw new IdentityMgtConfigException(
                "Error occurred while writing data to registry path : " + resourcePath, e);
    }

}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:35,代码来源:RegistryConfigWriter.java

示例14: run

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

        long time1 = System.nanoTime();
        long timePerThread = 0;
        //RemoteRegistry registry = null;
        Resource resource = null;
        try {
            //System.setProperty("javax.net.ssl.trustStore", "G:\\testing\\wso2registry-SNAPSHOT\\resources\\security\\client-truststore.jks");
            //System.setProperty("javax.net.ssl.trustStorePassword", "wso2carbon");
            //System.setProperty("javax.net.ssl.trustStoreType", "JKS");
            //registry = new RemoteRegistry(new URL("https://10.100.1.136:9443/registry/"), "admin", "admin");
            //registry = new RemoteRegistry(new URL("https://10.100.1.235:9443/registry/"), "admin", "admin");
            Resource resource1 = registry.newResource();
            resource1.setContent("ABC");
            registry.put("/ama/test/path", resource1);
            for (int i = 0; i < iterations; i++) {
                long start = System.nanoTime();
                Resource res = registry.newResource();
                res.setContent("abc");
                registry.put("/test/" + i, res);
                System.out.println("Updated " + i);
                resource = registry.get("/ama/test/path");
                resource.setContent("updated");
                resource.setProperty("abc", "abc");
                registry.put("/ama/test/path", resource);
                resource.discard();
                long end = System.nanoTime();
                timePerThread += (end - start);

                Thread.sleep(100);
            }
            long averageTime = timePerThread / (iterations * 1000000);
            System.out.println("CSV-avg-time-per-thread," + threadName + "," + averageTime);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:39,代码来源:Worker5.java

示例15: updateLogger

import org.wso2.carbon.registry.core.Resource; //导入方法依赖的package包/类
public void updateLogger(String loggerName, String loggerLevel,
                         boolean aditivity) throws Exception {
    try {
        registry.beginTransaction();
        Resource loggerResource;
        String loggerResourcePath = LoggingConstants.LOGGERS + loggerName;
        if (registry.resourceExists(loggerResourcePath)) {
            loggerResource = registry.get(loggerResourcePath);
            loggerResource.setProperty(
                    LoggingConstants.LoggerProperties.LOG_LEVEL,
                    loggerLevel);
            loggerResource.setProperty(
                    LoggingConstants.LoggerProperties.ADDITIVITY,
                    Boolean.toString(aditivity));
            registry.put(loggerResourcePath, loggerResource);
        } else {
            loggerResource = registry.newResource();
            loggerResource.addProperty(
                    LoggingConstants.LoggerProperties.NAME, loggerName);
            loggerResource.addProperty(
                    LoggingConstants.LoggerProperties.LOG_LEVEL,
                    loggerLevel);
            loggerResource.addProperty(
                    LoggingConstants.LoggerProperties.ADDITIVITY,
                    Boolean.toString(aditivity));
            registry.put(loggerResourcePath, loggerResource);
        }
        registry.commitTransaction();
    } catch (Exception e) {
        registry.rollbackTransaction();
        log.error("Unable to update the logger", e);
        throw e;
    }
}
 
开发者ID:wso2,项目名称:carbon-commons,代码行数:35,代码来源:RegistryManager.java


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