private void removingProperties() { String path = "/props/t1/r1"; Resource r1 = registry.newResource(); try { r1.setContent("r1 content"); r1.setProperty("p1", "v1"); r1.setProperty("p2", "v2"); registry.put(path, r1); Resource r1e1 = registry.get(path); r1e1.setContent("r1 content"); r1e1.removeProperty("p1"); registry.put(path, r1e1); Resource r1e2 = registry.get(path); assertEquals("Property is not removed.", r1e2.getProperty("p1"), null); assertNotNull("Wrong property is removed.", r1e2.getProperty("p2")); deleteResources("/props"); log.info("removingProperties - Passed"); } catch (RegistryException e) { log.error("removingProperties RegistryException thrown :" + e.getMessage()); Assert.fail("removingProperties RegistryException thrown :" + e.getMessage()); } }
public void testResourcePropertyVersioning() throws Exception { Resource r1 = registry.newResource(); r1.setContent("content 1"); r1.addProperty("p1", "v1"); registry.put("/v4/r1", r1); Resource r1v2 = registry.get("/v4/r1"); r1v2.addProperty("p2", "v2"); registry.put("/v4/r1", r1v2); registry.put("/v4/r1", r1v2); String[] r1Versions = registry.getVersions("/v4/r1"); Resource r1vv1 = registry.get(r1Versions[1]); assertEquals( "r1's first version should contain a property p1 with value v1", r1vv1.getProperty("p1"), "v1"); Resource r1vv2 = registry.get(r1Versions[0]); assertEquals( "r1's second version should contain a property p1 with value v1", r1vv2.getProperty("p1"), "v1"); assertEquals( "r1's second version should contain a property p2 with value v2", r1vv2.getProperty("p2"), "v2"); }
public void ResourceCopyTest() throws RegistryException { Resource r1 = registry.newResource(); r1.setProperty("test", "copy"); r1.setContent("c"); registry.put("/test1/copy/c1/copy1", r1); Collection c1 = registry.newCollection(); registry.put("/test1/move", c1); registry.copy("/test1/copy/c1/copy1", "/test1/copy/c2/copy2"); Resource newR1 = registry.get("/test1/copy/c2/copy2"); assertEquals( "Copied resource should have a property named 'test' with value 'copy'.", newR1.getProperty("test"), "copy"); Resource oldR1 = registry.get("/test1/copy/c1/copy1"); assertEquals( "Original resource should have a property named 'test' with value 'copy'.", oldR1.getProperty("test"), "copy"); String newContent = new String((byte[]) newR1.getContent()); String oldContent = new String((byte[]) oldR1.getContent()); assertEquals("Contents are not equal in copied resources", newContent, oldContent); }
/** * Remove trusted service * * @param groupName Group name * @param serviceName Service name * @param trustedService Trusted service name * @throws org.wso2.carbon.security.SecurityConfigException */ private void removeTrustedService(String groupName, String serviceName, String trustedService) throws SecurityConfigException { Registry registry; String resourcePath; Resource resource; try { resourcePath = RegistryResources.SERVICE_GROUPS + groupName + RegistryResources.SERVICES + serviceName + "/trustedServices"; registry = getConfigSystemRegistry(); if (registry != null) { if (registry.resourceExists(resourcePath)) { resource = registry.get(resourcePath); if (resource.getProperty(trustedService) != null) { resource.removeProperty(trustedService); } registry.put(resourcePath, resource); } } } catch (Exception e) { String error = "Error occurred while removing trusted service for STS"; log.error(error, e); throw new SecurityConfigException(error, e); } }
@Test(groups = {"wso2.greg"}) public void rootLevelCollectionRename() throws Exception { Resource r1 = registry.newResource(); r1.setProperty("test", "rename"); r1.setContent("some text"); registry.put("/rename34k/c1/dummy", r1); registry.rename("/rename34k", "/rename44k"); boolean failed = false; try { registry.get("/rename34k/c1/dummy"); } catch (Exception e) { failed = true; } assertTrue( failed, "Resource should not be " + "accessible from the old path after renaming the parent."); Resource newR1 = registry.get("/rename44k/c1/dummy"); assertEquals( newR1.getProperty("test"), "rename", "Resource should contain a property with name test and value rename."); }
@Test( groups = {"wso2.greg"}, description = "Metadata search by available Updater Name not", dependsOnMethods = "searchResourceByUpdater") public void searchResourceByUpdaterNot() throws SearchAdminServiceRegistryExceptionException, RemoteException, RegistryException { CustomSearchParameterBean searchQuery = new CustomSearchParameterBean(); SearchParameterBean paramBean = new SearchParameterBean(); paramBean.setUpdater(userName); ArrayOfString[] paramList = paramBean.getParameterList(); searchQuery.setParameterValues(paramList); // to set updatedRangeNegate ArrayOfString updaterNameNegate = new ArrayOfString(); updaterNameNegate.setArray(new String[] {"updaterNameNegate", "on"}); searchQuery.addParameterValues(updaterNameNegate); AdvancedSearchResultsBean result = searchAdminServiceClient.getAdvancedSearchResults(searchQuery); Assert.assertNotNull(result.getResourceDataList(), "No Record Found"); Assert.assertTrue( (result.getResourceDataList().length > 0), "No Record Found. set valid Updater name"); for (ResourceData resource : result.getResourceDataList()) { Resource regResource = registry.get(resource.getResourcePath()); if (regResource.getProperty("registry.link") == null) { Assert.assertFalse( regResource.getLastUpdaterUserName().contains(userName), "searched updater name not contain on actual Updater Name :" + resource.getResourcePath()); } } }
public void GeneralCollectionRenameTest() throws RegistryException { 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 (RegistryException 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"); }
public boolean removeDomainMappingFromRegistry(String actualHost) throws Exception { boolean successfullyRemoved; try { registry.beginTransaction(); String hostResourcePath = CartridgeConstants.DomainMappingInfo.HOSTINFO; if (registry.resourceExists(hostResourcePath)) { Resource hostResource = registry.get(hostResourcePath); Collection hostInfoCollection; if (hostResource instanceof Collection) { hostInfoCollection = (Collection) hostResource; } else { throw new Exception("Resource is not a collection " + hostResourcePath); } String[] paths = hostInfoCollection.getChildren(); for (String path : paths) { Resource domainMapping = registry.get(path); String actualHostInRegistry = domainMapping.getProperty(CartridgeConstants.DomainMappingInfo.ACTUAL_HOST); if (actualHostInRegistry != null && actualHost.equalsIgnoreCase(actualHostInRegistry)) { registry.delete(path); } } } registry.commitTransaction(); successfullyRemoved = true; } catch (RegistryException e) { registry.rollbackTransaction(); log.error("Unable to remove the mapping", e); throw e; } return successfullyRemoved; }
/** * Method to obtain the custom UI media types. * * @param configSystemRegistry a configuration system registry instance. * @return a String of custom UI media types, in the format name:type,name:type,... * @throws RegistryException if the operation failed. */ public static String getCustomUIMediaTypeMappings(Registry configSystemRegistry) throws RegistryException { RegistryContext registryContext = configSystemRegistry.getRegistryContext(); if (getCustomUIMediaTypeMappings(registryContext) != null) { return getCustomUIMediaTypeMappings(registryContext); } Resource resource; String mediaTypeString = null; String resourcePath = MIME_TYPE_COLLECTION + RegistryConstants.PATH_SEPARATOR + RESOURCE_MIME_TYPE_INDEX; // TODO: Adding the media types should ideally be done by the handler associated with the // media type if (!configSystemRegistry.resourceExists(resourcePath)) { getResourceMediaTypeMappings(configSystemRegistry); } if (!configSystemRegistry.resourceExists( resourcePath + RegistryConstants.PATH_SEPARATOR + CUSTOM_UI_MIME_TYPE_INDEX)) { resource = configSystemRegistry.newResource(); resource.setProperty("profiles", "application/vnd.wso2-profiles+xml"); // resource.setProperty("service", "application/vnd.wso2-service+xml"); resource.setDescription( "This resource contains the media Types associated with " + "custom user interfaces on the Registry. Add, Edit or Delete properties to " + "Manage Media Types."); configSystemRegistry.put( resourcePath + RegistryConstants.PATH_SEPARATOR + CUSTOM_UI_MIME_TYPE_INDEX, resource); } else { resource = configSystemRegistry.get( resourcePath + RegistryConstants.PATH_SEPARATOR + CUSTOM_UI_MIME_TYPE_INDEX); } Properties properties = resource.getProperties(); if (properties.size() > 0) { Set<Object> keySet = properties.keySet(); for (Object key : keySet) { if (key instanceof String) { String ext = (String) key; if (RegistryUtils.isHiddenProperty(ext)) { continue; } String value = resource.getProperty(ext); String mediaTypeMapping = ext + ":" + value; if (mediaTypeString == null) { mediaTypeString = mediaTypeMapping; } else { mediaTypeString = mediaTypeString + "," + mediaTypeMapping; } } } } registryContext.setCustomUIMediaTypes(mediaTypeString); return mediaTypeString; }
public void testSimpleLifecycle() throws Exception { final String RESOURCE = "/r1"; final String LIFECYCLE = "simpleLifecycle"; RegistryContext context = registry.getRegistryContext(); context.selectDBConfig("h2-db"); context.addAspect(LIFECYCLE, new SimpleLifecycle(), MultitenantConstants.SUPER_TENANT_ID); String[] aspects = registry.getAvailableAspects(); assertTrue(aspects.length > 0); boolean found = false; for (String aspect : aspects) { if (aspect.equals(LIFECYCLE)) { found = true; } } assertTrue("Lifecycle not found in available aspects", found); Resource resource = registry.newResource(); resource.setDescription("My thing"); registry.put(RESOURCE, resource); registry.associateAspect(RESOURCE, LIFECYCLE); resource = registry.get(RESOURCE); assertNotNull(resource); String propValue = resource.getProperty(SimpleLifecycle.STATE_PROP); assertNotNull(propValue); assertEquals("Wrong initial state!", SimpleLifecycle.INIT, propValue); String[] actions = registry.getAspectActions(RESOURCE, LIFECYCLE); assertNotNull("No available actions", actions); assertEquals("Wrong # of available actions", 1, actions.length); assertEquals("Wrong available action", SimpleLifecycle.ACTION, actions[0]); registry.invokeAspect(RESOURCE, LIFECYCLE, SimpleLifecycle.ACTION); resource = registry.get(RESOURCE); // OK, now we should be in the next state propValue = resource.getProperty(SimpleLifecycle.STATE_PROP); assertNotNull(propValue); assertEquals("Wrong state!", SimpleLifecycle.FINAL, propValue); }
public String[] getAvailableActions(RequestContext context) { Resource r = context.getResource(); String state = r.getProperty(STATE_PROP); if (INIT.equals(state)) { return actions; } return null; }
public void propertyAssertion(String policy_path) throws RegistryException { Resource resource; try { resource = registry.get(policy_path); assertEquals(resource.getProperty("creator"), "Aaaa", "WSDL Property - WSI creator"); assertEquals(resource.getProperty("version"), "1.0.0", "WSDL Property - WSI version"); } catch (RegistryException e) { log.error("Failed to Assert Properties :" + e); throw new RegistryException("Failed to Assert Properties :" + e); } }
public void CollectionCopyTest() throws RegistryException { Resource r1 = registry.newResource(); r1.setProperty("test", "copy"); r1.setContent("c"); registry.put("/test1/copy/copy3/c3/resource1", r1); Collection c1 = registry.newCollection(); registry.put("/test1/move", c1); registry.copy("/test1/copy/copy3", "/test1/newc/copy3"); Resource newR1 = registry.get("/test1/newc/copy3/c3/resource1"); assertEquals( "Copied resource should have a property named 'test' with value 'copy'.", newR1.getProperty("test"), "copy"); Resource oldR1 = registry.get("/test1/copy/copy3/c3/resource1"); assertEquals( "Original resource should have a property named 'test' with value 'copy'.", oldR1.getProperty("test"), "copy"); }
public DomainMapping getMapping(String hostName) { DomainMapping domainMapping; try { if (governanceRegistry.resourceExists(HOST_INFO + hostName)) { resource = governanceRegistry.get(HOST_INFO + hostName); domainMapping = new DomainMapping(hostName); domainMapping.setActualHost(resource.getProperty(ACTUAL_HOST)); return domainMapping; } } catch (RegistryException e) { log.info("Error while getting registry resource"); throw new RuntimeException(e); } return null; }
private void rootLevelProperties() { Resource root; try { root = registry.get("/"); root.addProperty("p1", "v1"); registry.put("/", root); Resource rootb = registry.get("/"); assertEquals( "Root should have a property named p1 with value v1", rootb.getProperty("p1"), "v1"); log.info("rootLevelProperties() -Passed"); } catch (RegistryException e) { log.error("rootLevelProperties RegistryException thrown :" + e.getMessage()); Assert.fail("rootLevelProperties RegistryException thrown :" + e.getMessage()); } }
public void invoke(RequestContext context, String action) throws RegistryException { if (!ACTION.equals(action)) { throw new RegistryException("Wrong action"); } Resource r = context.getResource(); String state = r.getProperty(STATE_PROP); if (state == null) { throw new RegistryException("No state property"); } if (!INIT.equals(state)) { throw new RegistryException("Invalid state '" + state + "'"); } r.setProperty(STATE_PROP, FINAL); context.getRegistry().put(r.getPath(), r); }
private void singleValuedProperties() { String path = "/propTest/r2"; Resource r2 = registry.newResource(); try { r2.setContent("Some content for r2"); r2.addProperty("p1", "p1v1"); registry.put(path, r2); Resource r2b = registry.get(path); String p1Value = r2b.getProperty("p1"); assertEquals("Property p1 of /propTest/r2 should contain the value p1v1", p1Value, "p1v1"); deleteResources("/propTest"); log.info("singleValuedProperties - Passed"); } catch (RegistryException e) { log.error("singleValuedProperties RegistryException thrown :" + e.getMessage()); Assert.fail("singleValuedProperties RegistryException thrown :" + e.getMessage()); } }
/** * @param ppid * @return * @throws IdentityException */ public String getOAuthConsumerSecret(String consumerKey) throws IdentityException { String path = null; Resource resource = null; if (log.isDebugEnabled()) { log.debug("Retreiving user for OAuth consumer key " + consumerKey); } try { path = RegistryConstants.PROFILES_PATH + consumerKey; if (registry.resourceExists(path)) { resource = registry.get(path); return resource.getProperty(IdentityRegistryResources.OAUTH_CONSUMER_PATH); } else { return null; } } catch (RegistryException e) { log.error("Error while retreiving user for OAuth consumer key " + consumerKey, e); throw IdentityException.error( "Error while retreiving user for OAuth consumer key " + consumerKey, e); } }
public void RootLevelResourceRenameTest() throws RegistryException { Resource r1 = registry.newResource(); r1.setProperty("test", "rename"); r1.setContent("some text"); registry.put("/rename2", r1); registry.rename("/rename2", "/rename4"); boolean failed = false; try { registry.get("/rename2"); } catch (RegistryException e) { failed = true; } assertTrue("Resource should not be accessible from the old path after renaming.", failed); Resource newR1 = registry.get("/rename4"); assertEquals( "Resource should contain a property with name test and value rename.", newR1.getProperty("test"), "rename"); }
@Test(groups = {"wso2.greg"}) public void generalResourceRename() throws Exception { Resource r1 = registry.newResource(); r1.setProperty("test", "rename"); r1.setContent("some text"); registry.put("/tests/rename1", r1); registry.rename("/tests/rename1", "rename2"); boolean failed = false; try { registry.get("/tests/rename1"); } catch (Exception e) { failed = true; } assertTrue(failed, "Resource should not be accessible from the old path after renaming."); Resource newR1 = registry.get("/tests/rename2"); assertEquals( newR1.getProperty("test"), "rename", "Resource should contain a property with name test and value rename."); }
public String importWADLToRegistry( RequestContext requestContext, String commonLocation, boolean skipValidation) throws RegistryException { ResourcePath resourcePath = requestContext.getResourcePath(); String wadlName = RegistryUtils.getResourceName(resourcePath.getPath()); String version = requestContext.getResource().getProperty(RegistryConstants.VERSION_PARAMETER_NAME); if (version == null) { version = CommonConstants.WADL_VERSION_DEFAULT_VALUE; requestContext.getResource().setProperty(RegistryConstants.VERSION_PARAMETER_NAME, version); } String uri = requestContext.getSourceURL(); if (!skipValidation) { validateWADL(uri); } Registry registry = requestContext.getRegistry(); Resource resource = registry.newResource(); if (resource.getUUID() == null) { resource.setUUID(UUID.randomUUID().toString()); } resource.setMediaType(wadlMediaType); resource.setProperties(requestContext.getResource().getProperties()); ByteArrayOutputStream outputStream; OMElement wadlElement; try { InputStream inputStream = new URL(uri).openStream(); outputStream = new ByteArrayOutputStream(); int nextChar; while ((nextChar = inputStream.read()) != -1) { outputStream.write(nextChar); } outputStream.flush(); wadlElement = AXIOMUtil.stringToOM(new String(outputStream.toByteArray())); // to validate XML wadlElement.toString(); } catch (Exception e) { // This exception is unexpected because the WADL already validated throw new RegistryException( "Unexpected error occured " + "while reading the WADL at" + uri, e); } String wadlNamespace = wadlElement.getNamespace().getNamespaceURI(); String namespaceSegment = CommonUtil.derivePathFragmentFromNamespace(wadlNamespace).replace("//", "/"); OMElement grammarsElement = wadlElement.getFirstChildWithName(new QName(wadlNamespace, "grammars")); String wadlBaseUri = uri.substring(0, uri.lastIndexOf("/") + 1); if (grammarsElement != null) { grammarsElement.detach(); wadlElement.addChild(resolveImports(grammarsElement, wadlBaseUri, version)); } String actualPath; if (commonLocation != null) { actualPath = commonLocation + namespaceSegment + version + "/" + wadlName; } else { actualPath = RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH + commonWADLLocation + namespaceSegment + version + "/" + wadlName; } if (resource.getProperty(CommonConstants.SOURCE_PROPERTY) == null) { resource.setProperty(CommonConstants.SOURCE_PROPERTY, CommonConstants.SOURCE_AUTO); } resource.setContent(wadlElement.toString()); requestContext.setResourcePath(new ResourcePath(actualPath)); registry.put(actualPath, resource); addImportAssociations(actualPath); if (createService) { OMElement serviceElement = RESTServiceUtils.createRestServiceArtifact( wadlElement, wadlName, version, RegistryUtils.getRelativePath(requestContext.getRegistryContext(), actualPath)); String servicePath = RESTServiceUtils.addServiceToRegistry(requestContext, serviceElement); addDependency(servicePath, actualPath); String endpointPath = createEndpointElement(requestContext, wadlElement, version); if (endpointPath != null) { addDependency(servicePath, endpointPath); } } return actualPath; }
/** * Method to obtain the resource media types. * * @param configSystemRegistry a configuration system registry instance. * @return a String of resource media types, in the format extension:type,extension:type,... * @throws RegistryException if the operation failed. */ public static String getResourceMediaTypeMappings(Registry configSystemRegistry) throws RegistryException { RegistryContext registryContext = configSystemRegistry.getRegistryContext(); if (getResourceMediaTypeMappings(registryContext) != null) { return getResourceMediaTypeMappings(registryContext); } Resource resource; String mediaTypeString = null; String resourcePath = MIME_TYPE_COLLECTION + RegistryConstants.PATH_SEPARATOR + RESOURCE_MIME_TYPE_INDEX; if (!configSystemRegistry.resourceExists(resourcePath)) { resource = configSystemRegistry.newCollection(); } else { resource = configSystemRegistry.get(resourcePath); Properties properties = resource.getProperties(); if (properties.size() > 0) { Set<Object> keySet = properties.keySet(); for (Object key : keySet) { if (key instanceof String) { String ext = (String) key; if (RegistryUtils.isHiddenProperty(ext)) { continue; } String value = resource.getProperty(ext); String mediaTypeMapping = ext + ":" + value; if (mediaTypeString == null) { mediaTypeString = mediaTypeMapping; } else { mediaTypeString = mediaTypeString + "," + mediaTypeMapping; } } } } registryContext.setResourceMediaTypes(mediaTypeString); return mediaTypeString; } BufferedReader reader; try { File mimeFile = getMediaTypesFile(); reader = new BufferedReader(new InputStreamReader(new FileInputStream(mimeFile))); } catch (Exception e) { String msg = "Failed to read the the media type definitions file. Only a limited " + "set of media type definitions will be populated. "; log.error(msg, e); mediaTypeString = "txt:text/plain,jpg:image/jpeg,gif:image/gif"; registryContext.setResourceMediaTypes(mediaTypeString); return mediaTypeString; } try { while (reader.ready()) { String mediaTypeData = reader.readLine().trim(); if (mediaTypeData.startsWith("#")) { // ignore the comments continue; } if (mediaTypeData.length() == 0) { // ignore the blank lines continue; } // mime.type file delimits media types:extensions by tabs. if there is no // extension associated with a media type, there are no tabs in the line. so we // don't need such lines. if (mediaTypeData.indexOf('\t') > 0) { String[] parts = mediaTypeData.split("\t+"); if (parts.length == 2 && parts[0].length() > 0 && parts[1].length() > 0) { // there can multiple extensions associated with a single media type. in // that case, extensions are delimited by a space. String[] extensions = parts[1].trim().split(" "); for (String extension : extensions) { if (extension.length() > 0) { String mediaTypeMapping = extension + ":" + parts[0]; resource.setProperty(extension, parts[0]); if (mediaTypeString == null) { mediaTypeString = mediaTypeMapping; } else { mediaTypeString = mediaTypeString + "," + mediaTypeMapping; } } } } } } resource.setDescription( "This collection contains the media Types available for " + "resources on the Registry. Add, Edit or Delete properties to Manage Media " + "Types."); Resource collection = configSystemRegistry.newCollection(); collection.setDescription( "This collection lists the media types available on the " + "Registry Server. Before changing an existing media type, please make sure " + "to alter existing resources/collections and related configuration details."); configSystemRegistry.put(MIME_TYPE_COLLECTION, collection); configSystemRegistry.put(resourcePath, resource); } catch (IOException e) { String msg = "Could not read the media type mappings file from the location: "; throw new RegistryException(msg, e); } finally { try { reader.close(); } catch (IOException ignore) { } } registryContext.setResourceMediaTypes(mediaTypeString); return mediaTypeString; }
public void put(RequestContext requestContext) throws RegistryException { Resource resource = requestContext.getResource(); Object content = resource.getContent(); String contentString; if (content instanceof String) { contentString = (String) content; } else { contentString = RegistryUtils.decodeBytes((byte[]) content); } OMElement payload; try { payload = AXIOMUtil.stringToOM(contentString); } catch (XMLStreamException e) { String msg = "Unable to serialize resource content"; log.error(msg, e); throw new RegistryException(msg, e); } OMNamespace namespace = payload.getNamespace(); String namespaceURI = namespace.getNamespaceURI(); OMElement definition = payload.getFirstChildWithName(new QName(namespaceURI, "definition")); OMElement projectPath = definition.getFirstChildWithName(new QName(namespaceURI, "projectPath")); String projectMetadataPath = null; if (projectPath != null) { projectMetadataPath = RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH + projectPath.getText(); } Resource metadataResource = requestContext.getRegistry().get(projectMetadataPath); String remainingWork = metadataResource.getProperty("Remaining Work"); String scheduledWork = metadataResource.getProperty("Scheduled Work"); String actualWork = metadataResource.getProperty("Actual Work"); String remainingCost = metadataResource.getProperty("Remaining Cost"); String scheduledCost = metadataResource.getProperty("Scheduled Cost"); String actualCost = metadataResource.getProperty("Actual Cost"); String duration = metadataResource.getProperty("Duration"); String startDate = metadataResource.getProperty("Start Date"); String endDate = metadataResource.getProperty("Finish Date"); OMFactory factory = payload.getOMFactory(); OMElement work = payload.getFirstChildWithName(new QName(namespaceURI, "work")); if (work == null) { work = factory.createOMElement("work", namespace, payload); } OMElement remainingWorkElement = work.getFirstChildWithName(new QName(namespaceURI, "remaining")); if (remainingWorkElement == null) { remainingWorkElement = factory.createOMElement("remaining", namespace, work); } remainingWorkElement.setText(remainingWork); OMElement actualWorkElement = work.getFirstChildWithName(new QName(namespaceURI, "actual")); if (actualWorkElement == null) { actualWorkElement = factory.createOMElement("actual", namespace, work); } actualWorkElement.setText(remainingWork); OMElement scheduledWorkElement = work.getFirstChildWithName(new QName(namespaceURI, "scheduled")); if (scheduledWorkElement == null) { scheduledWorkElement = factory.createOMElement("scheduled", namespace, work); } scheduledWorkElement.setText(remainingWork); OMElement cost = payload.getFirstChildWithName(new QName(namespaceURI, "cost")); if (cost == null) { cost = factory.createOMElement("cost", namespace, payload); } OMElement remainingCostElement = cost.getFirstChildWithName(new QName(namespaceURI, "remaining")); if (remainingCostElement == null) { remainingCostElement = factory.createOMElement("remaining", namespace, cost); } remainingCostElement.setText(remainingCost); OMElement actualCostElement = cost.getFirstChildWithName(new QName(namespaceURI, "actual")); if (actualCostElement == null) { actualCostElement = factory.createOMElement("actual", namespace, cost); } actualCostElement.setText(remainingCost); OMElement scheduledCostElement = cost.getFirstChildWithName(new QName(namespaceURI, "scheduled")); if (scheduledCostElement == null) { scheduledCostElement = factory.createOMElement("scheduled", namespace, cost); } scheduledCostElement.setText(remainingCost); OMElement timeline = payload.getFirstChildWithName(new QName(namespaceURI, "timeline")); if (timeline == null) { timeline = factory.createOMElement("timeline", namespace, payload); } OMElement durationElement = timeline.getFirstChildWithName(new QName(namespaceURI, "duration")); if (durationElement == null) { durationElement = factory.createOMElement("duration", namespace, timeline); } durationElement.setText(duration); OMElement startDateElement = timeline.getFirstChildWithName(new QName(namespaceURI, "startDate")); if (startDateElement == null) { startDateElement = factory.createOMElement("startDate", namespace, timeline); } startDateElement.setText(startDate); OMElement endDateElement = timeline.getFirstChildWithName(new QName(namespaceURI, "endDate")); if (endDateElement == null) { endDateElement = factory.createOMElement("endDate", namespace, timeline); } endDateElement.setText(endDate); resource.setContent(payload.toString()); }
public String addWadlToRegistry( RequestContext requestContext, Resource resource, String resourcePath, boolean skipValidation) throws RegistryException { String wadlName = RegistryUtils.getResourceName(resourcePath); String version = requestContext.getResource().getProperty(RegistryConstants.VERSION_PARAMETER_NAME); if (version == null) { version = CommonConstants.WADL_VERSION_DEFAULT_VALUE; requestContext.getResource().setProperty(RegistryConstants.VERSION_PARAMETER_NAME, version); } OMElement wadlElement; String wadlContent; Object resourceContent = resource.getContent(); if (resourceContent instanceof String) { wadlContent = (String) resourceContent; } else { wadlContent = new String((byte[]) resourceContent); } try { XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(wadlContent)); StAXOMBuilder builder = new StAXOMBuilder(reader); wadlElement = builder.getDocumentElement(); } catch (XMLStreamException e) { // This exception is unexpected because the WADL already validated String msg = "Unexpected error occured " + "while reading the WADL at " + resourcePath + "."; log.error(msg); throw new RegistryException(msg, e); } String wadlNamespace = wadlElement.getNamespace().getNamespaceURI(); String namespaceSegment = CommonUtil.derivePathFragmentFromNamespace(wadlNamespace).replace("//", "/"); String actualPath = getChrootedWadlLocation(requestContext.getRegistryContext()) + namespaceSegment + version + "/" + wadlName; OMElement grammarsElement = wadlElement.getFirstChildWithName(new QName(wadlNamespace, "grammars")); if (StringUtils.isNotBlank(requestContext.getSourceURL())) { String uri = requestContext.getSourceURL(); if (!skipValidation) { validateWADL(uri); } if (resource.getUUID() == null) { resource.setUUID(UUID.randomUUID().toString()); } String wadlBaseUri = uri.substring(0, uri.lastIndexOf("/") + 1); if (grammarsElement != null) { // This is to avoid evaluating the grammars import when building AST grammarsElement.detach(); wadlElement.addChild(resolveImports(grammarsElement, wadlBaseUri, version)); } } else { if (!skipValidation) { File tempFile = null; BufferedWriter bufferedWriter = null; try { tempFile = File.createTempFile(wadlName, null); bufferedWriter = new BufferedWriter(new FileWriter(tempFile)); bufferedWriter.write(wadlElement.toString()); bufferedWriter.flush(); } catch (IOException e) { String msg = "Error occurred while reading the WADL File"; log.error(msg, e); throw new RegistryException(msg, e); } finally { if (bufferedWriter != null) { try { bufferedWriter.close(); } catch (IOException e) { String msg = "Error occurred while closing File writer"; log.warn(msg, e); } } } validateWADL(tempFile.toURI().toString()); try { delete(tempFile); } catch (IOException e) { String msg = "An error occurred while deleting the temporary files from local file system."; log.warn(msg, e); throw new RegistryException(msg, e); } } if (grammarsElement != null) { grammarsElement = resolveImports(grammarsElement, null, version); wadlElement.addChild(grammarsElement); } } requestContext.setResourcePath(new ResourcePath(actualPath)); if (resource.getProperty(CommonConstants.SOURCE_PROPERTY) == null) { resource.setProperty(CommonConstants.SOURCE_PROPERTY, CommonConstants.SOURCE_AUTO); } registry.put(actualPath, resource); addImportAssociations(actualPath); if (getCreateService()) { OMElement serviceElement = RESTServiceUtils.createRestServiceArtifact( wadlElement, wadlName, version, RegistryUtils.getRelativePath(requestContext.getRegistryContext(), actualPath)); String servicePath = RESTServiceUtils.addServiceToRegistry(requestContext, serviceElement); registry.addAssociation(servicePath, actualPath, CommonConstants.DEPENDS); registry.addAssociation(actualPath, servicePath, CommonConstants.USED_BY); String endpointPath = createEndpointElement(requestContext, wadlElement, version); if (endpointPath != null) { registry.addAssociation(servicePath, endpointPath, CommonConstants.DEPENDS); registry.addAssociation(endpointPath, servicePath, CommonConstants.USED_BY); } } return resource.getPath(); }
/** * method to get stored accounts from registry * * @param registry Registry * @return list of AccountInfo * @throws IssueTrackerException thrown if unable to obtain resources from registry */ public static List<AccountInfo> getAccounts(Registry registry) throws IssueTrackerException { List<AccountInfo> accounts = new ArrayList<AccountInfo>(); try { // check whether resources exist at the registry path if (registry.resourceExists(IssueTrackerConstants.ISSUE_TRACKERS_RESOURCE_PATH)) { // get the collection Collection collection = (Collection) registry.get(IssueTrackerConstants.ISSUE_TRACKERS_RESOURCE_PATH); if (null != collection) { // get paths of resources in the collection String[] paths = collection.getChildren(); // for each resource construct the corresponding AccountInfo instance and add it to the // list for (String path : paths) { AccountInfo accountInfo = new AccountInfo(); GenericCredentials credentials = new GenericCredentials(); if (registry.resourceExists(path)) { Resource resource = registry.get(path); List<String> accountPropertySet = resource.getPropertyValues(IssueTrackerConstants.ACCOUNT_KEY); accountInfo.setKey(accountPropertySet.get(accountPropertySet.size() - 1)); List<String> urlPropertySet = resource.getPropertyValues(IssueTrackerConstants.ISSUE_TRACKER_URL); String url = urlPropertySet.get(urlPropertySet.size() - 1); List<String> usernamePropertySet = resource.getPropertyValues(IssueTrackerConstants.ACCOUNT_LOGIN_USERNAME); String username = usernamePropertySet.get(usernamePropertySet.size() - 1); List<String> emailPropertySet = resource.getPropertyValues(IssueTrackerConstants.ACCOUNT_EMAIL); String email = emailPropertySet.get(emailPropertySet.size() - 1); List<String> uidPropertySet = resource.getPropertyValues(IssueTrackerConstants.ACCOUNT_UID); String uid = uidPropertySet.get(uidPropertySet.size() - 1); List<String> hasSupportPropertySet = resource.getPropertyValues(IssueTrackerConstants.HAS_SUPPORT_ACCOUNT); String hasSupport = hasSupportPropertySet.get(usernamePropertySet.size() - 1); List<String> passwordPropertySet; passwordPropertySet = resource.getPropertyValues( IssueTrackerConstants.ACCOUNT_PASSWORD_HIDDEN_PROPERTY); // for users with older accounts hidden password property does not exist. for them, // have to get the older property // until the account is edited. if (null == passwordPropertySet) { passwordPropertySet = resource.getPropertyValues(IssueTrackerConstants.ACCOUNT_PASSWORD); } String password = ""; if (null != passwordPropertySet) { String encryptedPassword = passwordPropertySet.get(passwordPropertySet.size() - 1); password = new String( CryptoUtil.getDefaultCryptoUtil() .base64DecodeAndDecrypt(encryptedPassword)); } String isAutoReportingEnabled = resource.getProperty(IssueTrackerConstants.AUTO_REPORTING); if (null != isAutoReportingEnabled && IssueTrackerConstants.IS_AUTO_REPORTING_ENABLED.equals( isAutoReportingEnabled)) { accountInfo.setAutoReportingEnable(true); AutoReportingSettings settings = new AutoReportingSettings(); String projectName = resource.getProperty(IssueTrackerConstants.AUTO_REPORTING_PROJECT); settings.setProjectName(projectName); String priority = resource.getProperty(IssueTrackerConstants.AUTO_REPORTING_PRIORITY); settings.setPriority(priority); String type = resource.getProperty(IssueTrackerConstants.AUTO_REPORTING_ISSUE_TYPE); settings.setIssueType(type); accountInfo.setAutoReportingSettings(settings); } else { accountInfo.setAutoReportingEnable(false); } if (!"".equals(url) && !"".equals(username) && !"".equals(password)) { credentials.setUrl(url); credentials.setUsername(username); credentials.setPassword(password); accountInfo.setCredentials(credentials); accountInfo.setEmail(email); accountInfo.setUid(uid); accountInfo.setHasSupportAccount(Boolean.getBoolean(hasSupport)); accounts.add(accountInfo); } } } } } } catch (RegistryException e) { ExceptionHandler.handleException("Error getting resources from registry", e, log); } catch (CryptoException e) { ExceptionHandler.handleException("Error decrypting password", e, log); } return accounts; }
public void put(RequestContext requestContext) throws RegistryException { WSDLProcessor wsdl = null; if (!CommonUtil.isUpdateLockAvailable()) { return; } CommonUtil.acquireUpdateLock(); try { Registry registry = requestContext.getRegistry(); Resource resource = requestContext.getResource(); if (resource == null) { throw new RegistryException("The resource is not available."); } String originalServicePath = requestContext.getResourcePath().getPath(); String resourceName = RegistryUtils.getResourceName(originalServicePath); OMElement serviceInfoElement, previousServiceInfoElement = null; Object resourceContent = resource.getContent(); String serviceInfo; if (resourceContent instanceof String) { serviceInfo = (String) resourceContent; } else { serviceInfo = RegistryUtils.decodeBytes((byte[]) resourceContent); } try { XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(serviceInfo)); StAXOMBuilder builder = new StAXOMBuilder(reader); serviceInfoElement = builder.getDocumentElement(); } catch (Exception e) { String msg = "Error in parsing the service content of the service. " + "The requested path to store the service: " + originalServicePath + "."; log.error(msg); throw new RegistryException(msg, e); } // derive the service path that the service should be saved. String serviceName = CommonUtil.getServiceName(serviceInfoElement); String serviceNamespace = CommonUtil.getServiceNamespace(serviceInfoElement); String servicePath = ""; if (serviceInfoElement.getChildrenWithLocalName("newServicePath").hasNext()) { Iterator OmElementIterator = serviceInfoElement.getChildrenWithLocalName("newServicePath"); while (OmElementIterator.hasNext()) { OMElement next = (OMElement) OmElementIterator.next(); servicePath = next.getText(); break; } } else { if (registry.resourceExists(originalServicePath)) { // Fixing REGISTRY-1790. Save the Service to the given original // service path if there is a service already exists there servicePath = originalServicePath; } else { servicePath = RegistryUtils.getAbsolutePath( registry.getRegistryContext(), registry.getRegistryContext().getServicePath() + (serviceNamespace == null ? "" : CommonUtil.derivePathFragmentFromNamespace(serviceNamespace)) + serviceName); } } String serviceVersion = org.wso2.carbon.registry.common.utils.CommonUtil.getServiceVersion(serviceInfoElement); if (serviceVersion.length() == 0) { serviceVersion = defaultServiceVersion; CommonUtil.setServiceVersion(serviceInfoElement, serviceVersion); resource.setContent(serviceInfoElement.toString()); } // saving the artifact id. String serviceId = resource.getUUID(); if (serviceId == null) { // generate a service id serviceId = UUID.randomUUID().toString(); resource.setUUID(serviceId); } if (registry.resourceExists(servicePath)) { Resource oldResource = registry.get(servicePath); String oldContent; Object content = oldResource.getContent(); if (content instanceof String) { oldContent = (String) content; } else { oldContent = RegistryUtils.decodeBytes((byte[]) content); } OMElement oldServiceInfoElement = null; if (serviceInfo.equals(oldContent)) { // TODO: This needs a better solution. This fix was put in place to avoid // duplication of services under /_system/governance, when no changes were made. // However, the fix is not perfect and needs to be rethought. Perhaps the logic // below can be reshaped a bit, or may be we don't need to compare the // difference over here with a little fix to the Governance API end. - Janaka. // We have fixed this assuming that the temp path where services are stored is under // /_system/governance/[serviceName] // Hence if we are to change that location, then we need to change the following code // segment as well String tempPath = RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH + RegistryConstants.PATH_SEPARATOR + resourceName; if (!originalServicePath.equals(tempPath)) { String path = RegistryUtils.getRelativePathToOriginal( servicePath, RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH); ArtifactManager.getArtifactManager().getTenantArtifactRepository().addArtifact(path); return; } requestContext.setProcessingComplete(true); return; } if ("true".equals(resource.getProperty("registry.DefinitionImport"))) { resource.removeProperty("registry.DefinitionImport"); try { XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(oldContent)); StAXOMBuilder builder = new StAXOMBuilder(reader); oldServiceInfoElement = builder.getDocumentElement(); CommonUtil.setServiceName( oldServiceInfoElement, CommonUtil.getServiceName(serviceInfoElement)); CommonUtil.setServiceNamespace( oldServiceInfoElement, CommonUtil.getServiceNamespace(serviceInfoElement)); CommonUtil.setDefinitionURL( oldServiceInfoElement, CommonUtil.getDefinitionURL(serviceInfoElement)); CommonUtil.setEndpointEntries( oldServiceInfoElement, CommonUtil.getEndpointEntries(serviceInfoElement)); CommonUtil.setServiceVersion( oldServiceInfoElement, org.wso2.carbon.registry.common.utils.CommonUtil.getServiceVersion( serviceInfoElement)); serviceInfoElement = oldServiceInfoElement; resource.setContent(serviceInfoElement.toString()); resource.setDescription(oldResource.getDescription()); } catch (Exception e) { String msg = "Error in parsing the service content of the service. " + "The requested path to store the service: " + originalServicePath + "."; log.error(msg); throw new RegistryException(msg, e); } } try { previousServiceInfoElement = AXIOMUtil.stringToOM(oldContent); } catch (XMLStreamException e) { String msg = "Error in parsing the service content of the service. " + "The requested path to store the service: " + originalServicePath + "."; log.error(msg); throw new RegistryException(msg, e); } } else if ("true".equals(resource.getProperty("registry.DefinitionImport"))) { resource.removeProperty("registry.DefinitionImport"); } // CommonUtil.addGovernanceArtifactEntryWithAbsoluteValues( // CommonUtil.getUnchrootedSystemRegistry(requestContext), // serviceId, servicePath); String definitionURL = CommonUtil.getDefinitionURL(serviceInfoElement); if (previousServiceInfoElement != null) { String oldDefinition = CommonUtil.getDefinitionURL(previousServiceInfoElement); if ((!"".equals(oldDefinition) && "".equals(definitionURL)) || (!"".endsWith(oldDefinition) && !oldDefinition.equals(definitionURL))) { try { registry.removeAssociation(servicePath, oldDefinition, CommonConstants.DEPENDS); registry.removeAssociation(oldDefinition, servicePath, CommonConstants.USED_BY); EndpointUtils.removeEndpointEntry(oldDefinition, serviceInfoElement, registry); resource.setContent( RegistryUtils.decodeBytes((serviceInfoElement.toString()).getBytes())); } catch (RegistryException e) { throw new RegistryException( "Failed to remove endpoints from Service UI : " + serviceName, e); } } } boolean alreadyAdded = false; if (definitionURL != null && (definitionURL.startsWith("http://") || definitionURL.startsWith("https://"))) { String definitionPath; if (definitionURL.toLowerCase().endsWith("wsdl")) { wsdl = buildWSDLProcessor(requestContext); RequestContext context = new RequestContext( registry, requestContext.getRepository(), requestContext.getVersionRepository()); context.setResourcePath( new ResourcePath(RegistryConstants.PATH_SEPARATOR + serviceName + ".wsdl")); context.setSourceURL(definitionURL); context.setResource(new ResourceImpl()); definitionPath = wsdl.addWSDLToRegistry( context, definitionURL, null, false, false, disableWSDLValidation, disableSymlinkCreation); } else if (definitionURL.toLowerCase().endsWith("wadl")) { WADLProcessor wadlProcessor = buildWADLProcessor(requestContext); wadlProcessor.setCreateService(false); RequestContext context = new RequestContext( registry, requestContext.getRepository(), requestContext.getVersionRepository()); context.setResourcePath( new ResourcePath(RegistryConstants.PATH_SEPARATOR + serviceName + ".wadl")); context.setSourceURL(definitionURL); context.setResource(new ResourceImpl()); definitionPath = wadlProcessor.importWADLToRegistry(context, null, disableWADLValidation); } else { throw new RegistryException( "Invalid service definition found. " + "Please enter a valid WSDL/WADL URL"); } if (definitionPath == null) { return; } definitionURL = RegistryUtils.getRelativePath(requestContext.getRegistryContext(), definitionPath); CommonUtil.setDefinitionURL(serviceInfoElement, definitionURL); resource.setContent(RegistryUtils.decodeBytes((serviceInfoElement.toString()).getBytes())); // updating the wsdl/wadl url ((ResourceImpl) resource).prepareContentForPut(); persistServiceResource(registry, resource, servicePath); alreadyAdded = true; // and make the associations registry.addAssociation(servicePath, definitionPath, CommonConstants.DEPENDS); registry.addAssociation(definitionPath, servicePath, CommonConstants.USED_BY); } else if (definitionURL != null && definitionURL.startsWith(RegistryConstants.ROOT_PATH)) { // it seems definitionUrl is a registry path.. String definitionPath = RegistryUtils.getAbsolutePath(requestContext.getRegistryContext(), definitionURL); if (!definitionPath.startsWith( RegistryUtils.getAbsolutePath( requestContext.getRegistryContext(), RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH))) { definitionPath = RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH + definitionPath; } boolean addItHere = false; if (!registry.resourceExists(definitionPath)) { String msg = "Associating service to a non-existing WSDL. wsdl url: " + definitionPath + ", " + "service path: " + servicePath + "."; log.error(msg); throw new RegistryException(msg); } if (!registry.resourceExists(servicePath)) { addItHere = true; } else { Association[] dependencies = registry.getAssociations(servicePath, CommonConstants.DEPENDS); boolean dependencyFound = false; if (dependencies != null) { for (Association dependency : dependencies) { if (definitionPath.equals(dependency.getDestinationPath())) { dependencyFound = true; } } } if (!dependencyFound) { addItHere = true; } } if (addItHere) { // add the service right here.. ((ResourceImpl) resource).prepareContentForPut(); persistServiceResource(registry, resource, servicePath); alreadyAdded = true; // and make the associations registry.addAssociation(servicePath, definitionPath, CommonConstants.DEPENDS); registry.addAssociation(definitionPath, servicePath, CommonConstants.USED_BY); } } if (!alreadyAdded) { // we are adding the resource anyway. ((ResourceImpl) resource).prepareContentForPut(); persistServiceResource(registry, resource, servicePath); } /* if (!servicePath.contains(registry.getRegistryContext().getServicePath())) { if (defaultEnvironment == null) { String serviceDefaultEnvironment = registry.getRegistryContext().getServicePath(); String relativePath = serviceDefaultEnvironment.replace(RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH, ""); relativePath = relativePath.replace(CommonUtil.derivePathFragmentFromNamespace(serviceNamespace),""); defaultEnvironment = relativePath; } String currentRelativePath = servicePath.substring(0, servicePath.indexOf(CommonUtil.derivePathFragmentFromNamespace(serviceNamespace))); currentRelativePath = currentRelativePath.replace(RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH,""); String endpointEnv = EndpointUtils.getEndpointLocation(); String[] pathSegments = defaultEnvironment.split(RegistryConstants.PATH_SEPARATOR); for (String pathSegment : pathSegments) { endpointEnv = endpointEnv.replace(pathSegment,""); currentRelativePath = currentRelativePath.replace(pathSegment,""); } while(endpointEnv.startsWith(RegistryConstants.PATH_SEPARATOR)){ endpointEnv = endpointEnv.replaceFirst(RegistryConstants.PATH_SEPARATOR,""); } environment = currentRelativePath + endpointEnv; } */ EndpointUtils.saveEndpointsFromServices( servicePath, serviceInfoElement, registry, CommonUtil.getUnchrootedSystemRegistry(requestContext)); String symlinkLocation = RegistryUtils.getAbsolutePath( requestContext.getRegistryContext(), requestContext.getResource().getProperty(RegistryConstants.SYMLINK_PROPERTY_NAME)); if (!servicePath.equals(originalServicePath)) { // we are creating a sym link from service path to original service path. Resource serviceResource = requestContext.getRegistry().get(RegistryUtils.getParentPath(originalServicePath)); String isLink = serviceResource.getProperty("registry.link"); String mountPoint = serviceResource.getProperty("registry.mountpoint"); String targetPoint = serviceResource.getProperty("registry.targetpoint"); String actualPath = serviceResource.getProperty("registry.actualpath"); if (isLink != null && mountPoint != null && targetPoint != null) { symlinkLocation = actualPath + RegistryConstants.PATH_SEPARATOR; } if (symlinkLocation != null) { requestContext .getSystemRegistry() .createLink(symlinkLocation + resourceName, servicePath); } } // in this flow the resource is already added. marking the process completed.. requestContext.setProcessingComplete(true); if (wsdl != null && CommonConstants.ENABLE.equals( System.getProperty(CommonConstants.UDDI_SYSTEM_PROPERTY))) { AuthToken authToken = UDDIUtil.getPublisherAuthToken(); if (authToken == null) { return; } // creating the business service info bean BusinessServiceInfo businessServiceInfo = new BusinessServiceInfo(); // Following lines removed for fixing REGISTRY-1898. // businessServiceInfo.setServiceName(serviceName.trim()); // businessServiceInfo.setServiceNamespace(serviceNamespace.trim()); // // businessServiceInfo.setServiceEndpoints(CommonUtil.getEndpointEntries(serviceInfoElement)); // // businessServiceInfo.setDocuments(CommonUtil.getDocLinks(serviceInfoElement)); businessServiceInfo.setServiceDescription( CommonUtil.getServiceDescription(serviceInfoElement)); WSDLInfo wsdlInfo = wsdl.getMasterWSDLInfo(); businessServiceInfo.setServiceWSDLInfo(wsdlInfo); UDDIPublisher publisher = new UDDIPublisher(); publisher.publishBusinessService(authToken, businessServiceInfo); } String path = RegistryUtils.getRelativePathToOriginal( servicePath, RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH); ArtifactManager.getArtifactManager().getTenantArtifactRepository().addArtifact(path); } finally { CommonUtil.releaseUpdateLock(); } }