org.wso2.carbon.registry.core.Registry.newCollection()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(16.8k)|赞(0)|评价(0)|浏览(171)

本文整理了Java中org.wso2.carbon.registry.core.Registry.newCollection方法的一些代码示例,展示了Registry.newCollection的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Registry.newCollection方法的具体详情如下:
包路径:org.wso2.carbon.registry.core.Registry
类名称:Registry
方法名:newCollection

Registry.newCollection介绍

暂无

代码示例

代码示例来源:origin: org.apache.stratos/org.apache.stratos.adc.mgt

public RegistryManager() {
  try {
    if (!registry.resourceExists(CartridgeConstants.DomainMappingInfo.HOSTINFO)) {
      registry.put(CartridgeConstants.DomainMappingInfo.HOSTINFO,
                registry.newCollection());
    }
  } catch (RegistryException e) {
    String msg =
           "Error while accessing registry or initializing domain mapping registry path\n";
    log.error(msg + e.getMessage());
  }
}

代码示例来源:origin: org.wso2.carbon.business-process/org.wso2.carbon.bpel

/**
 * This repository persist the BPEL package versions inside the BPEL Package collection
 * under the child collection 'versions'. The collection name is same as directory with version
 * attached to it's name(Example: HelloWorld-3).
 * <p/>
 * For the 'HelloWorld' BPEL package, extracted BPEL package will be stored in a registry
 * location like '<config_registry_root>/bpel/packages/HelloWorld/versions/HelloWorld-3'.
 *
 * @param deploymentContext containing information on current BPEL deployment.
 * @throws RegistryException if an error occurred during import of file system content to
 *                           registry.
 */
private void createCollectionWithBPELPackageWithoutContentForCurrentVersion(
    BPELDeploymentContext deploymentContext) throws RegistryException {
  String collectionLocation = BPELPackageRepositoryUtils.getResourcePathForBPELPackageContent(deploymentContext);
  Collection collection = configRegistry.newCollection();
  configRegistry.put(collectionLocation, collection);
}

代码示例来源:origin: org.wso2.greg/org.wso2.carbon.governance.samples.shutterbug

public void init() {
  try {
    Registry registry =  Utils.getRegistryService().getSystemRegistry();
    if (!registry.resourceExists(shutterbugHome)) {
      Collection col = registry.newCollection();
      registry.put(shutterbugHome, col);
    }
  } catch (Exception e) {
    log.error("An error occured while initializing the Shutterbug Collection Handler", e);
  }
}

代码示例来源:origin: org.wso2.carbon.registry/org.wso2.carbon.registry.extensions

/**
 * Creates a collection in the given common location.
 *
 * @param commonLocation        location to create the collection.
 * @throws RegistryException    If fails to create a collection at given location.
 */
private void createCollection(String commonLocation) throws RegistryException {
  Registry systemRegistry = CommonUtil.getUnchrootedSystemRegistry(requestContext);
  //Creating a collection if not exists.
  if (!systemRegistry.resourceExists(commonLocation)) {
    systemRegistry.put(commonLocation, systemRegistry.newCollection());
  }
}

代码示例来源:origin: org.wso2.carbon.registry/org.wso2.carbon.registry.extensions

/**
 * For each schema found in schemas, change corresponding schemaInfo's ProposedRegistryURL based on
 * commonSchemaLocation and mangled targetNamespace
 * @param commonSchemaLocation the location to store schemas
 * @throws RegistryException if the operation failed.
 */
private void updateSchemaPaths(String commonSchemaLocation, String version, RequestContext requestContext) throws RegistryException {
  /* i.e. ROOT/commonSchemaLocation */
  if (!systemRegistry.resourceExists(commonSchemaLocation)) {
    systemRegistry.put(commonSchemaLocation, systemRegistry.newCollection());
  }
  for (SchemaInfo schemaInfo: schemas.values()) {
    XmlSchema schema = schemaInfo.getSchema();
    String targetNamespace = schema.getTargetNamespace();
    if ((targetNamespace == null) || ("".equals(targetNamespace))) {
      targetNamespace = "unqualified";
    }
    String schemaLocation = getSchemaLocation(requestContext, schemaInfo, targetNamespace, commonSchemaLocation, version);
    schemaInfo.setProposedRegistryURL(schemaLocation);
  }
}
private void updateSchemaPaths(String commonSchemaLocation,String version,List dependencies, RequestContext requestContext) throws RegistryException {

代码示例来源:origin: org.wso2.carbon.governance/org.wso2.carbon.governance.registry.extensions

/**
 * For each schema found in schemas, change corresponding schemaInfo's ProposedRegistryURL based on
 * commonSchemaLocation and mangled targetNamespace
 * @param commonSchemaLocation the location to store schemas
 * @throws org.wso2.carbon.registry.core.exceptions.RegistryException if the operation failed.
 */
private void updateSchemaPaths(String commonSchemaLocation) throws RegistryException {
  /* i.e. ROOT/commonSchemaLocation */
  if (!systemRegistry.resourceExists(commonSchemaLocation)) {
    systemRegistry.put(commonSchemaLocation, systemRegistry.newCollection());
  }
  for (SchemaInfo schemaInfo: schemas.values()) {
    XmlSchema schema = schemaInfo.getSchema();
    String targetNamespace = schema.getTargetNamespace();
    if ((targetNamespace == null) || ("".equals(targetNamespace))) {
      targetNamespace = "unqualified";
    }
    String schemaLocation = commonSchemaLocation + schemaInfo.getProposedResourceName();
    schemaInfo.setProposedRegistryURL(schemaLocation);
  }
}
private void updateSchemaPaths(String commonSchemaLocation,String version,List dependencies) throws RegistryException {

代码示例来源:origin: org.wso2.carbon/org.wso2.carbon.bam.core

public void updateDataRetentionPeriod(TimeRange timeRange) throws BAMException {
  try {
    Collection configCollection;
    if (registry.resourceExists(BAMRegistryResources.GLOBAL_CONFIG_PATH)) {
      configCollection = (Collection)registry.get(BAMRegistryResources.GLOBAL_CONFIG_PATH);
    } else {
      configCollection = registry.newCollection();
    }
    configCollection.setProperty(BAMRegistryResources.DATA_RETENTION_PROPERTY, timeRange.toString());
    registry.put(BAMRegistryResources.GLOBAL_CONFIG_PATH, configCollection);
  } catch (RegistryException e) {
    String msg = "Could not save the data retention policy in registry";
    log.error(msg);
    throw new BAMException(msg, e);
  }
}

代码示例来源:origin: org.wso2.carbon.governance/org.wso2.carbon.mashup.javascript.hostobjects.registry

public static Scriptable jsFunction_newCollection(Context cx, Scriptable thisObj,
                         Object[] arguments,
                         Function funObj) throws CarbonException {
  RegistryHostObject registryHostObject = (RegistryHostObject) thisObj;
  if (arguments.length == 0) {
    if (registryHostObject.registry != null) {
      try {
        Collection collection = registryHostObject.registry.newCollection();
        CollectionHostObject collectionHostobject = (CollectionHostObject) cx.newObject(
            registryHostObject, "Collection", new Object[]{collection});
        return collectionHostobject;
      } catch (RegistryException e) {
        throw new CarbonException("Error occurred while creating a new Collection.", e);
      }
    } else {
      throw new CarbonException("Registry has not initialized.");
    }
  } else {
    throw new CarbonException("newCollection() Method doesn't accept arguments.");
  }
}

代码示例来源:origin: org.wso2.carbon.registry/org.wso2.carbon.registry.extensions

public WSDLProcessor(RequestContext requestContext) {
  this.registry = requestContext.getRegistry();
  try {
    this.systemRegistry = CommonUtil.getUnchrootedSystemRegistry(requestContext);
    if (!systemRegistry.resourceExists(
        getChrootedSchemaLocation(requestContext.getRegistryContext()))) {
      systemRegistry.put(getChrootedSchemaLocation(requestContext.getRegistryContext()),
          systemRegistry.newCollection());
    }
    if (!systemRegistry.resourceExists(
        getChrootedWSDLLocation(requestContext.getRegistryContext()))) {
      systemRegistry.put(getChrootedWSDLLocation(requestContext.getRegistryContext()),
          systemRegistry.newCollection());
    }
  } catch (RegistryException ignore) {
    this.systemRegistry = null;
  }
  i = 0;
  associations = new ArrayList<Association>();
  visitedWSDLs = new ArrayList<String>();
  processedWSDLs = new ArrayList<String>();
  schemaProcessor = buildSchemaProcessor(requestContext, null);
  wsdls = new LinkedHashMap<String, WSDLInfo>();
  resourceName = "";
}

代码示例来源:origin: org.wso2.carbon/org.wso2.carbon.bam.core

public void updateDataArchivalPeriod(TimeRange timeRange) throws BAMException {
  try {
    Collection configCollection;
    if (registry.resourceExists(BAMRegistryResources.GLOBAL_CONFIG_PATH)) {
      configCollection = (Collection)registry.get(BAMRegistryResources.GLOBAL_CONFIG_PATH);
    } else {
      configCollection = registry.newCollection();
    }
    configCollection.setProperty(BAMRegistryResources.DATA_RETENTION_PROPERTY, timeRange.toString());
    configCollection.setProperty(BAMRegistryResources.DATA_ARCHIVAL_PROPERTY, timeRange.toString());
    registry.put(BAMRegistryResources.GLOBAL_CONFIG_PATH, configCollection);
  } catch (RegistryException e) {
    String msg = "Could not save the data retention policy in registry";
    log.error(msg, e);
    throw new BAMException(msg, e);
  }
}

代码示例来源:origin: org.wso2.carbon.identity.framework/org.wso2.carbon.identity.entitlement

@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");
  }
}

代码示例来源:origin: org.wso2.carbon.registry/org.wso2.carbon.registry.cmis

public RegistryFolder createFolder(RegistryFolder parentFolder, String name, Properties properties) {
  try {
    
    Collection node = repository.newCollection();
    String destinationPath = CommonUtil.getTargetPathOfNode(parentFolder, name);
    repository.put(destinationPath, node);
    Resource resource = repository.get(destinationPath);
    // compile the properties
    RegistryFolder.setProperties(repository, resource, getTypeDefinition(), properties);
    return getGregNode(resource);
  }
  catch (RegistryException e) {
    log.debug(e.getMessage(), e);
    throw new CmisStorageException(e.getMessage(), e);
  }
}

代码示例来源:origin: org.wso2.carbon.identity.framework/org.wso2.carbon.identity.entitlement

@Override
public void setGlobalPolicyAlgorithm(String policyCombiningAlgorithm) throws EntitlementException {
  Registry registry = getGovernanceRegistry();
  try {
    Collection policyCollection;
    if (registry.resourceExists(policyDataCollection)) {
      policyCollection = (Collection) registry.get(policyDataCollection);
    } else {
      policyCollection = registry.newCollection();
    }
    policyCollection.setProperty("globalPolicyCombiningAlgorithm", policyCombiningAlgorithm);
    registry.put(policyDataCollection, policyCollection);
    // performing cache invalidation
    EntitlementEngine.getInstance().invalidatePolicyCache();
  } catch (RegistryException e) {
    log.error("Error while updating Global combing algorithm in policy store ", e);
    throw new EntitlementException("Error while updating combing algorithm in policy store");
  }
}

代码示例来源:origin: wso2/carbon-identity-framework

@Override
public void setGlobalPolicyAlgorithm(String policyCombiningAlgorithm) throws EntitlementException {
  Registry registry = getGovernanceRegistry();
  try {
    Collection policyCollection;
    if (registry.resourceExists(policyDataCollection)) {
      policyCollection = (Collection) registry.get(policyDataCollection);
    } else {
      policyCollection = registry.newCollection();
    }
    policyCollection.setProperty("globalPolicyCombiningAlgorithm", policyCombiningAlgorithm);
    registry.put(policyDataCollection, policyCollection);
    // performing cache invalidation
    EntitlementEngine.getInstance().invalidatePolicyCache();
  } catch (RegistryException e) {
    log.error("Error while updating Global combing algorithm in policy store ", e);
    throw new EntitlementException("Error while updating combing algorithm in policy store");
  }
}

代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.identity.entitlement

@Override
public void setGlobalPolicyAlgorithm(String policyCombiningAlgorithm) throws EntitlementException {
  Registry registry = EntitlementServiceComponent.
      getGovernanceRegistry(CarbonContext.getThreadLocalCarbonContext().getTenantId());
  try {
    Collection policyCollection;
    if (registry.resourceExists(policyDataCollection)) {
      policyCollection = (Collection) registry.get(policyDataCollection);
    } else {
      policyCollection = registry.newCollection();
    }
    policyCollection.setMediaType(PDPConstants.REGISTRY_MEDIA_TYPE);
    policyCollection.setProperty("globalPolicyCombiningAlgorithm", policyCombiningAlgorithm);
    registry.put(policyDataCollection, policyCollection);
  } catch (RegistryException e) {
    log.error("Error while updating Global combing algorithm in policy store ", e);
    throw new EntitlementException("Error while updating combing algorithm in policy store");
  }
}

代码示例来源:origin: org.wso2.carbon.registry/org.wso2.carbon.registry.extensions

private static void saveEndpoint(RequestContext context, Registry registry, String url, String associatedPath,
                 Map<String, String> properties, Registry systemRegistry, String environment)
                 throws RegistryException {
  String pathExpression = getEndpointLocation(context, url, systemRegistry, environment);
  String urlToPath = deriveEndpointFromUrl(url);
  String endpointAbsoluteBasePath = RegistryUtils.getAbsolutePath(registry.getRegistryContext(),
      org.wso2.carbon.registry.core.RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH +
      environment);
  if (!systemRegistry.resourceExists(endpointAbsoluteBasePath)) {
    systemRegistry.put(endpointAbsoluteBasePath, systemRegistry.newCollection());
  }
  String relativePath = environment + urlToPath;
  String endpointAbsolutePath = pathExpression;
  saveEndpointValues(context, registry, url, associatedPath, properties, systemRegistry, relativePath,
            endpointAbsolutePath);
}

代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.identity.mgt

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);
      UserIdentityManagementUtil.loadDefaultChallenges();
    }
    Config emailConfigFile = ConfigBuilder.getInstance().loadEmailConfigFile();
    EmailNotificationConfig emailNotificationConfig = new EmailNotificationConfig();
    emailNotificationConfig.setProperties(emailConfigFile.getProperties());
    ConfigBuilder.getInstance().saveConfiguration(StorageType.REGISTRY, MultitenantConstants.SUPER_TENANT_ID,
                           emailNotificationConfig);
  } catch (RegistryException e) {
    log.error("Error while creating registry collection for org.wso2.carbon.identity.mgt component", e);
  } catch (IdentityMgtConfigException e) {
    log.error("Error occurred while saving default email templates in registry for super tenant");
  }
}

代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.security.mgt

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;
  }
}

代码示例来源:origin: org.wso2.carbon.identity.framework/org.wso2.carbon.security.mgt

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;
  }
}

代码示例来源:origin: org.wso2.carbon.devicemgt-plugins/org.wso2.carbon.device.mgt.mobile.impl

public static boolean createRegistryCollection(String path)
    throws MobileDeviceMgtPluginException {
  try {
    if (! MobileDeviceManagementUtil.getConfigurationRegistry().resourceExists(path)) {
      Resource resource = MobileDeviceManagementUtil.getConfigurationRegistry().newCollection();
      MobileDeviceManagementUtil.getConfigurationRegistry().beginTransaction();
      MobileDeviceManagementUtil.getConfigurationRegistry().put(path, resource);
      MobileDeviceManagementUtil.getConfigurationRegistry().commitTransaction();
    }
    return true;
  } catch (MobileDeviceMgtPluginException e) {
    throw new MobileDeviceMgtPluginException(
        "Error occurred while creating a registry collection : " +
        e.getMessage(), e);
  } catch (RegistryException e) {
    throw new MobileDeviceMgtPluginException(
        "Error occurred while creating a registry collection : " +
        e.getMessage(), e);
  }
}

相关文章