/** * update the path after moving the resource. * * @throws GovernanceException if an error occurred. */ public void updatePath() throws GovernanceException { path = GovernanceUtils.getArtifactPath(registry, id); }
/** * update the path after moving the resource. * * @param artifactId id of the artifact * @throws GovernanceException if an error occurred. */ public void updatePath(String artifactId) throws GovernanceException { path = GovernanceUtils.getArtifactPath(registry, artifactId); }
/** * Returns the path of the artifact, need to save the artifact before * getting the path. * * @return here we return the path of the artifact. * @throws GovernanceException if an error occurred. */ @Override public String getPath() throws GovernanceException { if (path == null) { path = GovernanceUtils.getArtifactPath(registry, id); } return path; }
/** * Method to obtain a governance artifact on the registry. * * @param registry the registry instance. * @param artifactId the identifier of the artifact. * @return the artifact. * @throws GovernanceException if the operation failed. */ public static GovernanceArtifact retrieveGovernanceArtifactById(Registry registry, String artifactId) throws GovernanceException { String artifactPath = getArtifactPath(registry, artifactId); if (artifactPath == null) { String msg = "Governance artifact is not found for id: " + artifactId + "."; if (log.isDebugEnabled()) { log.debug(msg); } return null; } return retrieveGovernanceArtifactByPath(registry, artifactPath); }
String path = GovernanceUtils.getArtifactPath(governanceSystemRegistry, artifactId); Association[] associations = governanceSystemRegistry.getAssociations(path, "depends"); for(Association association : associations){
/** * Detach the current artifact from the provided artifact. Both the artifacts should be saved, * before calling this method. * * @param artifactId the artifact id of the attached artifact * @throws GovernanceException throws if the operation failed. */ public void detach(String artifactId) throws GovernanceException { checkRegistryResourceAssociation(); // uses the path from the getter to make sure the used overloaded method String path = getPath(); String artifactPath = GovernanceUtils.getArtifactPath(registry, artifactId); if (artifactPath == null) { String msg = "Attached to artifact is not associated with a registry path."; log.error(msg); throw new GovernanceException(msg); } try { registry.removeAssociation(path, artifactPath, GovernanceConstants.DEPENDS); registry.removeAssociation(artifactPath, path, GovernanceConstants.USED_BY); } catch (RegistryException e) { String msg = "Error in detaching the artifact. source id: " + id + ", path: " + path + ", target id: " + artifactId + ", target path:" + artifactPath + "."; log.error(msg, e); throw new GovernanceException(msg, e); } }
/** * Create an Endpoint * * @param endpointUrl * Endpoint url * @param registry * Registry space to save the endpoint * @return Path of the created resource * @throws org.wso2.carbon.appmgt.api.AppManagementException * If an error occurs while adding the endpoint */ public static String createEndpoint(String endpointUrl, Registry registry) throws AppManagementException { try { EndpointManager endpointManager = new EndpointManager(registry); Endpoint endpoint = endpointManager.newEndpoint(endpointUrl); endpointManager.addEndpoint(endpoint); return GovernanceUtils.getArtifactPath(registry, endpoint.getId()); } catch (RegistryException e) { String msg = "Failed to import endpoint " + endpointUrl + " to registry "; log.error(msg, e); throw new AppManagementException(msg, e); } }
/** * Method to remove a governance artifact from the registry. * * @param registry the registry instance. * @param artifactId the identifier of the artifact. * @throws GovernanceException if the operation failed. */ public static void removeArtifact(Registry registry, String artifactId) throws GovernanceException { try { String path = getArtifactPath(registry, artifactId); if (registry.resourceExists(path)) { deleteLifecycleHistoryFile(path, registry); registry.delete(path); } ArtifactCache artifactCache = ArtifactCacheManager.getCacheManager().getTenantArtifactCache(((UserRegistry) registry).getTenantId()); if (artifactCache != null && path != null) { artifactCache.invalidateArtifact(path); } } catch (RegistryException e) { String msg = "Error in deleting the the artifact id:" + artifactId + "."; log.error(msg, e); throw new GovernanceException(msg, e); } }
@Override public LCStateBean getLifeCycleStateBean(String artifactId, String artifactLC) throws LifeCycleException { try { UserRegistry registry = (UserRegistry) getGovernanceUserRegistry(); UserRealm userRealm = registry.getUserRealm(); String[] roleNames = userRealm.getUserStoreManager().getRoleListOfUser(registry.getUserName()); String path = GovernanceUtils.getArtifactPath(registry, artifactId); if (path != null) { removeCache(registry, path); Resource resource = registry.get(path); LCStateBean lifeCycleStateBean = getCheckListItems(resource, artifactLC, roleNames, registry); GovernanceArtifact governanceArtifact = GovernanceUtils.retrieveGovernanceArtifactById(registry, artifactId); Map<String, String> currentStateDurationData = governanceArtifact .getCurrentStateDuration(artifactId, artifactLC); if (currentStateDurationData != null && !currentStateDurationData.isEmpty()) { lifeCycleStateBean .setLifeCycleCurrentStateDuration(currentStateDurationData.get("currentStateDuration")); lifeCycleStateBean .setLifeCycleCurrentStateDurationColour(currentStateDurationData.get("durationColour")); } return lifeCycleStateBean; } else { throw new LifeCycleException("Unable to find the artifact " + artifactId); } } catch (UserStoreException | RegistryException e) { throw new LifeCycleException(e); } }
UserRealm userRealm = registry.getUserRealm(); String[] rolesList = userRealm.getUserStoreManager().getRoleListOfUser(registry.getUserName()); String path = GovernanceUtils.getArtifactPath(registry, artifactId); if (path != null) { Resource resource = registry.get(path);
/** * Fetches the given service artifact on the registry. * * @param serviceId the identifier of the service artifact. * * @return the service artifact. * @throws GovernanceException if the operation failed. */ public Service getService(String serviceId) throws GovernanceException { GovernanceArtifact governanceArtifact; String path = GovernanceUtils.getArtifactPath(registry, serviceId); ArtifactCache cache = ArtifactCacheManager.getCacheManager().getTenantArtifactCache(((UserRegistry)registry).getTenantId()); if (cache != null) { governanceArtifact = cache.getArtifact(path); if (governanceArtifact != null) { return new ServiceImpl(governanceArtifact) {}; } } governanceArtifact = manager.getGovernanceArtifact(serviceId); if (governanceArtifact == null) { return null; } if (cache != null) { cache.addArtifact(governanceArtifact.getPath(), governanceArtifact); } return new ServiceImpl(governanceArtifact) {}; }
mobileApp.setDescription(artifact.getAttribute(AppMConstants.API_OVERVIEW_DESCRIPTION)); String artifactPath = GovernanceUtils.getArtifactPath(registry, artifact.getId()); Set<String> tags = new HashSet<String>(); org.wso2.carbon.registry.core.Tag[] tag = registry.getTags(artifactPath);
artifactId = artifact.getId(); changeLifeCycleStatus(AppMConstants.MOBILE_ASSET_TYPE, artifactId, APPLifecycleActions.CREATE.getStatus()); String artifactPath = GovernanceUtils.getArtifactPath(registry, artifact.getId()); Set<String> tagSet = mobileApp.getTags(); if (tagSet != null) {
String artifactPath = GovernanceUtils.getArtifactPath(registry, updateApiArtifact.getId()); artifactManager.updateGenericArtifact(updateApiArtifact); }else{
GenericArtifact artifact = AppManagerUtil.createAPIArtifactContent(genericArtifact, api); artifactManager.addGenericArtifact(artifact); String artifactPath = GovernanceUtils.getArtifactPath(registry, artifact.getId()); String providerPath = AppManagerUtil.getAPIProviderPath(api.getId());
private void updateWebAppRegistryArtifact(WebApp webApp) throws RegistryException, AppManagementException { GenericArtifactManager artifactManager = getArtifactManager(registry, AppMConstants.WEBAPP_ASSET_TYPE); GenericArtifact updatedWebAppArtifact = buildRegistryArtifact(artifactManager, AppMConstants.WEBAPP_ASSET_TYPE, webApp); updatedWebAppArtifact.setId(webApp.getUUID()); artifactManager.updateGenericArtifact(updatedWebAppArtifact); // Apply tags String artifactPath = GovernanceUtils.getArtifactPath(registry, webApp.getUUID()); if (webApp.getTags() != null) { for (String tag : webApp.getTags()) { registry.applyTag(artifactPath, tag); } } // Set resources permissions based on app visibility. if (webApp.getAppVisibility() == null) { AppManagerUtil.setResourcePermissions(webApp.getId().getProviderName(), AppMConstants.API_GLOBAL_VISIBILITY, webApp.getAppVisibility(), artifactPath); } else { AppManagerUtil.setResourcePermissions(webApp.getId().getProviderName(), AppMConstants.API_RESTRICTED_VISIBILITY, webApp.getAppVisibility(), artifactPath); } }
private String saveWebAppRegistryArtifact(WebApp webApp) throws RegistryException, AppManagementException { String artifactId = null; GenericArtifactManager artifactManager = getArtifactManager(registry, AppMConstants.WEBAPP_ASSET_TYPE); GenericArtifact appArtifact = buildRegistryArtifact(artifactManager, AppMConstants.WEBAPP_ASSET_TYPE, webApp); artifactManager.addGenericArtifact(appArtifact); artifactId = appArtifact.getId(); // Set the life cycle for the persisted artifact GenericArtifact persistedArtifact = artifactManager.getGenericArtifact(artifactId); persistedArtifact.invokeAction(AppMConstants.LifecycleActions.CREATE, AppMConstants.WEBAPP_LIFE_CYCLE); // Apply tags String artifactPath = GovernanceUtils.getArtifactPath(registry, artifactId); if (webApp.getTags() != null) { for (String tag : webApp.getTags()) { registry.applyTag(artifactPath, tag); } } // Set resources permissions based on app visibility. if (webApp.getAppVisibility() != null) { AppManagerUtil.setResourcePermissions(webApp.getId().getProviderName(), AppMConstants.API_RESTRICTED_VISIBILITY, webApp.getAppVisibility(), artifactPath); } // Add registry associations. String providerPath = AppManagerUtil.getAPIProviderPath(webApp.getId()); registry.addAssociation(providerPath, artifactPath, AppMConstants.PROVIDER_ASSOCIATION); return artifactId; }
artifactId = artifact.getId(); changeLifeCycleStatus(AppMConstants.WEBAPP_LIFE_CYCLE, artifactId, APPLifecycleActions.CREATE.getStatus()); String artifactPath = GovernanceUtils.getArtifactPath(registry, artifact.getId());
mobileApp.setUUID(artifactId); changeLifeCycleStatus(AppMConstants.MOBILE_ASSET_TYPE, artifactId, APPLifecycleActions.CREATE.getStatus()); String artifactPath = GovernanceUtils.getArtifactPath(registry, artifact.getId()); Set<String> tagSet = mobileApp.getTags(); if (tagSet != null) {
GenericArtifact artifact = artifactManager.getGenericArtifact(apiArtifactId); GenericArtifact updateApiArtifact = AppManagerUtil.createAPIArtifactContent(artifact, api); String artifactPath = GovernanceUtils.getArtifactPath(registry, updateApiArtifact.getId()); org.wso2.carbon.registry.core.Tag[] oldTags = registry.getTags(artifactPath); if (oldTags != null) {