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()); } }
/** * 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); }
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); } }
/** * 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()); } }
/** * 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 {
/** * 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 {
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); } }
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."); } }
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 = ""; }
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); } }
@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"); } }
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); } }
@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"); } }
@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"); } }
@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"); } }
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); }
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"); } }
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; } }
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; } }
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); } }