public static String msgAddingDeploymentUnitToRegistryFailed(String name, RegistryException e) { return format("Adding deployment unit {0} to regstry failed;{1}", name, e.getMessage()); }
public MessageContext process(MessageContext requestMessageContext) throws AxisFault { try { GenericArtifactManager artifactManager = new GenericArtifactManager(governanceSystemRegistry, rxtKey); artifactIDs = artifactManager.getAllGenericArtifactIds(); } catch (RegistryException e) { String msg = e.getMessage(); log.error(msg); throw new AxisFault(msg, e); } return getAbstractResponseMessageContext(requestMessageContext); } }
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()); } }
public static void process(String path, long snapshotId, UserRegistry registry) throws Exception { try { registry.removeVersionHistory(path, snapshotId); } catch (RegistryException e) { String msg = "Failed to delete the version of the " + snapshotId + " shapshot of " + path + ". " + ((e.getCause() instanceof SQLException) ? "" : e.getMessage()); log.error(msg, e); throw new RegistryException(msg, e); } } }
public static void process(String pathToDelete, UserRegistry registry) throws Exception { try { if (RegistryConstants.ROOT_PATH.equals(pathToDelete) || RegistryConstants.SYSTEM_COLLECTION_BASE_PATH.equals(pathToDelete) || RegistryConstants.GOVERNANCE_REGISTRY_BASE_PATH.equals(pathToDelete) || RegistryConstants.CONFIG_REGISTRY_BASE_PATH.equals(pathToDelete) || RegistryConstants.LOCAL_REPOSITORY_BASE_PATH.equals(pathToDelete)) { throw new RegistryException("Unable to delete system collection at " + pathToDelete + "."); } registry.delete(pathToDelete); } catch (RegistryException e) { String msg = "Failed to delete " + pathToDelete + ". " + ((e.getCause() instanceof SQLException) ? "" : e.getMessage()); log.error(msg, e); throw new RegistryException(msg, e); } } }
public static void renameResource( String parentPath, String oldResourcePath, String newResourceName, UserRegistry registry) throws Exception { if (!parentPath.endsWith(RegistryConstants.PATH_SEPARATOR)) { parentPath = parentPath + RegistryConstants.PATH_SEPARATOR; } String newResourcePath; if (newResourceName.startsWith(RegistryConstants.ROOT_PATH)) { newResourcePath = newResourceName; } else { newResourcePath = parentPath + newResourceName; } try { registry.rename(oldResourcePath, newResourcePath); } catch (RegistryException e) { String msg = "Failed to rename the resource: " + oldResourcePath + " to name: " + newResourcePath + ". Caused by: " + ((e.getCause() instanceof SQLException) ? "" : e.getMessage()); log.error(msg, e); throw new RegistryException(msg, e); } } }
public static void addRemoteLink ( UserRegistry userRegistry, String parentPath, String name, String instance, String targetPath) throws Exception { String linkResourcePath; if (RegistryConstants.ROOT_PATH.equals(parentPath)) { linkResourcePath = RegistryConstants.ROOT_PATH + name; } else { linkResourcePath = parentPath + RegistryConstants.PATH_SEPARATOR + name; } try { userRegistry.createLink(linkResourcePath, instance, targetPath); } catch (RegistryException e) { String msg = "Failed to add symbolic link to path " + linkResourcePath + ". " + ((e.getCause() instanceof SQLException) ? "" : e.getMessage()); log.error(msg, e); throw new RegistryException(msg, e); } }
/** * Invoke lifecycle action * * @param action lifecycle action tobe invoked * @param parameters extra parameters needed when promoting * @param aspectName aspect name of which the action need to be invoked * @throws org.wso2.carbon.governance.api.exception.GovernanceException * throws if the operation failed. */ public void invokeAction(String action, Map<String, String> parameters, String aspectName) throws GovernanceException { Resource artifactResource = getArtifactResource(); CheckListItemBean[] checkListItemBeans = GovernanceUtils.getAllCheckListItemBeans(artifactResource, this, aspectName); try { if (checkListItemBeans != null) { for (CheckListItemBean checkListItemBean : checkListItemBeans) { parameters.put(checkListItemBean.getOrder() + ".item", checkListItemBean.getValue().toString()); } } registry.invokeAspect(getArtifactPath(), aspectName, action, parameters); } catch (RegistryException e) { String msg = "Invoking lifecycle action \"" + action + "\" failed. " + e.getMessage(); log.error(msg, e); throw new GovernanceException(e.getMessage(), e); } }
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); } }
public NodeType[] getMixinNodeTypes() throws RepositoryException { List<NodeType> nodeTypeList = new ArrayList<NodeType>(); try { Resource resource = registrySession.getUserRegistry().get(nodePath); List<String> mixNames = resource.getPropertyValues("jcr:mixinTypes"); if (mixNames != null) { for (String name : mixNames) { NodeType nt = registrySession.getWorkspace().getNodeTypeManager().getNodeType(name); nodeTypeList.add(nt); } } } catch (RegistryException e) { throw new RepositoryException("Error while getting mix node types from registry " + e.getMessage()); } if (nodeTypeList.size() == 0) { return new NodeType[0]; } else { return nodeTypeList.toArray(new NodeType[0]); } }
public ProfileManager() { RegistryService registryService = JmxTaskServiceComponent.getRegistryService(); TenantRegistryLoader tenantRegistryLoader = JmxTaskServiceComponent.getTenantRegistryLoader(); //get the tenant's registry int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); try { tenantRegistryLoader.loadTenantRegistry(tenantId); registry = registryService.getGovernanceSystemRegistry(tenantId); } catch (RegistryException e) { log.error("Error obtaining the registry " + e.getMessage(), e); } }
public boolean isCheckedOut(String s) throws RepositoryException { try { String propVal1 = ((RegistrySession) session).getUserRegistry().get(s).getProperty("jcr:checkedOut"); String propVal2 = ((RegistrySession) session).getUserRegistry().get(s).getProperty("jcr:isCheckedOut"); if (propVal1.equals("true") || (propVal2.equals("true"))) { return true; } if (propVal1.equals("false") || (propVal2.equals("false"))) { return false; } } catch (NullPointerException e) { // isCheckout is false } catch (RegistryException e) { throw new RepositoryException(e.getMessage()); } return nonVersionableNodeChckoutCheck(s); }
public static SearchResultsBean populate(UserRegistry userRegistry, String searchType, String criteria) { SearchResultsBean searchResultsBean = new SearchResultsBean(); try { if (searchType.equalsIgnoreCase("Tag")) { searchResultsBean.setResourceDataList(searchByTags(criteria, userRegistry)); } else { searchResultsBean.setResourceDataList(searchByContent(criteria, userRegistry)); } } catch (RegistryException e) { String msg = "Failed to generate search results. " + e.getMessage(); searchResultsBean.setErrorMessage(msg); } return searchResultsBean; }
public static String getProperty(UserRegistry registry, String resourcePath, String key) throws RegistryException { try { if (registry.resourceExists(resourcePath)) { Resource resource = registry.get(resourcePath); if (resource != null) { String value = resource.getProperty(key); resource.discard(); return value; } } } catch (RegistryException e) { String msg = "Failed to get the resource information of resource " + resourcePath + " for retrieving a property with key : " + key + ". Error :" + ((e.getCause() instanceof SQLException) ? "" : e.getMessage()); log.error(msg, e); throw e; } return ""; } }
public static String getTextContent(String path, Registry registry) throws Exception { try { if (path != null && path.contains("..")) { path = FilenameUtils.normalize(path); } Resource resource = registry.get(path); byte[] content = (byte[]) resource.getContent(); String contentString = ""; if (content != null) { contentString = RegistryUtils.decodeBytes(content); } resource.discard(); return contentString; } catch (RegistryException e) { String msg = "Could not get the content of the resource " + path + ". Caused by: " + ((e.getCause() instanceof SQLException) ? "" : e.getMessage()); log.error(msg, e); throw new RegistryException(msg, e); } }
public static Registry getUserRegistry(String mashupAuthor, int tenantId) throws CarbonException { if (registryService == null) { throw new CarbonException("Registry is null"); } try { if(registryService.getUserRealm(tenantId).getUserStoreManager().isExistingUser(mashupAuthor)) { return registryService.getGovernanceUserRegistry(mashupAuthor, tenantId); } else { throw new CarbonException("Unable to access Registry, mashup author is not an active user"); } } catch (UserStoreException e) { log.error(e.getMessage(), e); throw new CarbonException(e); }catch (RegistryException e) { log.error(e.getMessage(), e); throw new CarbonException(e); } } }
private InputStream getTemplateResource(String templateName) throws ReportingException { String localPath = "templates/"; String jrXmlPath = ReportConstants.REPORT_BASE_PATH + localPath + templateName + ".jrxml"; Registry registry = null; try { registry = ReportingTemplateComponent.getRegistryService().getConfigSystemRegistry(); } catch (RegistryException e) { throw new ReportingException(e.getMessage(), e); } Resource resource; InputStream reportDefinitionOmStream; try { resource = registry.get(jrXmlPath); reportDefinitionOmStream = resource.getContentStream(); return reportDefinitionOmStream; } catch (RegistryException e) { throw new ReportingException(templateName + " getting failed from registry", e); } }
/** * {@inheritDoc} */ @Override public TopicNode getTopicTree() throws EventBrokerException { try { UserRegistry userRegistry = this.registryService.getGovernanceSystemRegistry(EventBrokerHolder.getInstance().getTenantId()); if (!userRegistry.resourceExists(topicStoragePath)) { userRegistry.put(topicStoragePath, userRegistry.newCollection()); } Resource root = userRegistry.get(this.topicStoragePath); TopicNode rootTopic = new TopicNode("/", "/"); buildTopicTree(rootTopic, (Collection) root, userRegistry); return rootTopic; } catch (RegistryException e) { throw new EventBrokerException(e.getMessage(), e); } }
private void createRootNode() throws RepositoryException { try { if (!userRegistry.resourceExists(RegistryJCRSpecificStandardLoderUtil. getJCRRegistryWorkspaceRoot())) { Resource resource = (CollectionImpl) userRegistry.newCollection(); userRegistry.put(RegistryJCRSpecificStandardLoderUtil. getJCRRegistryWorkspaceRoot(), resource); } if(!userRegistry.resourceExists(WORKSPACE_ROOT)) { Resource resource = (CollectionImpl) userRegistry.newCollection(); resource.setDescription("nt:base"); resource.setProperty("jcr:primaryType", "nt:base"); userRegistry.put(WORKSPACE_ROOT, resource); } } catch (RegistryException e) { throw new RepositoryException("Registry Exception occurred while creating root node " + e.getMessage()); } }
public ContentStream getContentStream(){ // compile data ContentStreamImpl result = new ContentStreamImpl(); result.setFileName(getName()); try { result.setLength(BigInteger.valueOf(getPropertyLength(getNode(), CMISConstants.GREG_DATA))); if(getNode().getContent() != null){ String mimeType = getNode().getProperty(CMISConstants.GREG_MIMETYPE); result.setMimeType(mimeType); //result.setMimeType(getNode().getMediaType()); } else { result.setMimeType(null); } if(getNode().getContent() != null){ InputStream inputStream = getNode().getContentStream(); result.setStream(new BufferedInputStream(inputStream)); // stream closed by consumer } else { result.setStream(null); } } catch (RegistryException e) { throw new CmisRuntimeException(e.getMessage(), e); } return result; }