/** * Method that runs the schema import procedure. * * @param requestContext the request context for the import operation * @param resourcePath the path of the resource * @param validationInfo the validation information * @return the path at which the schema was uploaded to * @throws RegistryException if the operation failed. */ protected String processSchemaImport(RequestContext requestContext, String resourcePath, WSDLValidationInfo validationInfo) throws RegistryException { SchemaProcessor schemaProcessor = buildSchemaProcessor(requestContext, validationInfo); return schemaProcessor .importSchemaToRegistry(requestContext, resourcePath, getChrootedLocation(requestContext.getRegistryContext()), true,disableSymlinkCreation); }
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 = ""; }
/** * Method that runs the schema import procedure. * * @param requestContext the request context for the import operation * @param resourcePath the path of the resource * @param validationInfo the validation information * @param sourceURL url of the source * @return the path at which the schema was uploaded to * @throws org.wso2.carbon.registry.core.exceptions.RegistryException if the operation failed. */ protected String processSchemaImport(RequestContext requestContext, String resourcePath, WSDLValidationInfo validationInfo, String sourceURL) throws RegistryException { SchemaUriProcessor schemaProcessor = buildSchemaProcessor(requestContext, validationInfo); return schemaProcessor .importSchemaToRegistry(requestContext, resourcePath, getChrootedLocation(requestContext.getRegistryContext()), sourceURL); }
public WsdlUriProcessor(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()); } int tenantId = CurrentSession.getTenantId(); String userName = CurrentSession.getUser(); this.governanceUserRegistry = GovernanceRegistryExtensionsDataHolder.getInstance().getRegistryService() .getGovernanceUserRegistry(userName, tenantId); } catch (RegistryException ignore) { this.systemRegistry = null; } i = 0; associations = new ArrayList<Association>(); visitedWSDLs = new ArrayList<String>(); processedWSDLs = new ArrayList<String>(); schemaUriProcessor = buildSchemaProcessor(requestContext, null); wsdls = new LinkedHashMap<String, WSDLInfo>(); resourceName = ""; }
pathExpression = pathExpression.replace("//", "/"); pathExpression = CommonUtil.replaceExpressionOfPath(pathExpression, "version", version); String wadlPath = RegistryUtils.getAbsolutePath(context.getRegistryContext(), pathExpression.replace("//", "/")); String namespaceSegment = CommonUtil.derivePathFragmentFromNamespace( wadlNamespace).replace("//", "/"); String actualPath = getChrootedWadlLocation(context.getRegistryContext()) + namespaceSegment + version + "/" + wadlName; return actualPath;
pathExpression = pathExpression.replace("//", "/"); pathExpression = CommonUtil.replaceExpressionOfPath(pathExpression, "version", version); String wsdlPath = RegistryUtils.getAbsolutePath(context.getRegistryContext(), pathExpression.replace("//", "/")); String wsdlPath = (getChrootedWSDLLocation(context.getRegistryContext()) + CommonUtil.derivePathFragmentFromNamespace( wsdlDefinition.getTargetNamespace())).replace("//", "/");
String pathExpression = Utils.getRxtService().getStoragePath(CommonConstants.REST_SERVICE_MEDIA_TYPE); pathExpression = CommonUtil.replaceExpressionOfPath(pathExpression, "name", serviceName); pathExpression = RegistryUtils.getAbsolutePath(requestContext.getRegistryContext(), CommonUtil .getPathFromPathExpression(pathExpression, data, requestContext.getResource().getProperties())); pathExpression = CommonUtil .getPathFromPathExpression(pathExpression, requestContext.getResource().getProperties(), null); pathExpression = RegistryUtils.getAbsolutePath(requestContext.getRegistryContext(), CommonUtil .replaceExpressionOfPath(pathExpression, "provider", serviceProvider)); String servicePath = pathExpression;
/** * Method that runs the schema upload procedure. * * @param requestContext the request context for the put operation * @param resourcePath the path of the resource * @param validationInfo the validation information * @return the path at which the schema was uploaded to * @throws RegistryException if the operation failed. */ protected String processSchemaUpload(RequestContext requestContext, String resourcePath, WSDLValidationInfo validationInfo) throws RegistryException { String registryPath = null; List<File> tempFiles = makeTempDirStructure(requestContext); try { SchemaProcessor schemaProcessor = buildSchemaProcessor(requestContext, validationInfo); registryPath = schemaProcessor .putSchemaToRegistry(requestContext, resourcePath, getChrootedLocation(requestContext.getRegistryContext()), true,disableSymlinkCreation); } finally { deleteTempFiles(tempFiles); } return registryPath; }
if(processor.processSwagger(inputStream, getChrootedLocation(requestContext.getRegistryContext()), sourceURL) != null) { requestContext.setProcessingComplete(true);
public void rateResource(RequestContext requestContext) throws RegistryException { String path = requestContext.getResourcePath().getPath(); String relativePath = RegistryUtils.getRelativePath(requestContext.getRegistryContext(),path); if (!sendNotifications(requestContext, relativePath)){ return; } int rating = requestContext.getRating(); boolean isNotCollection = !(requestContext.getRepository().get(path) instanceof Collection); RegistryEvent<String> event; if (isNotCollection) { event = new ResourceUpdatedEvent<String>("A rating of " + Integer.toString(rating) + " was given to the resource at " + relativePath + "."); ((ResourceUpdatedEvent)event).setResourcePath(relativePath); } else { event = new CollectionUpdatedEvent<String>("A rating of " + Integer.toString(rating) + " was given to the collection at " + relativePath + "."); ((CollectionUpdatedEvent)event).setResourcePath(relativePath); } event.setParameter("RegistryOperation", "rateResource"); event.setParameter("Rating", Integer.toString(rating)); event.setTenantId(CurrentSession.getCallerTenantId()); try { notify(event, requestContext.getRegistry(), relativePath); } catch (Exception e) { handleException("Unable to send notification for Rate Resource Operation", e); } }
try { return schemaProcessor.importSchemaToRegistry(requestContext, path, getChrootedSchemaLocation(requestContext.getRegistryContext()), true, true); } catch (RegistryException e) { throw new RegistryException("Failed to import the schema" , e);
public void createLink(RequestContext requestContext) throws RegistryException { String path = requestContext.getResourcePath().getPath(); String relativePath = RegistryUtils.getRelativePath(requestContext.getRegistryContext(), path); if (!sendNotifications(requestContext, relativePath)){ return; } String parentPath = RegistryUtils.getParentPath(relativePath); String target = requestContext.getTargetPath(); String relativeTarget = RegistryUtils.getRelativePath(requestContext.getRegistryContext(), target); RegistryEvent<String> event = new CollectionUpdatedEvent<String>("A link to " + relativeTarget + " was created at " + relativePath + "."); event.setParameter("Destination", relativeTarget); event.setParameter("SymbolicLink", relativePath); event.setParameter("RegistryOperation", "createLink"); ((CollectionUpdatedEvent)event).setResourcePath(parentPath); event.setTenantId(CurrentSession.getCallerTenantId()); try { notify(event, requestContext.getRegistry(), parentPath); } catch (Exception e) { handleException("Unable to send notification for Create Link Operation", e); } }
private void addService(OMElement service, RequestContext context)throws RegistryException { Resource resource = registry.newResource(); String tempNamespace = CommonUtil.derivePathFragmentFromNamespace( CommonUtil.getServiceNamespace(service)); String path = getChrootedServiceLocation(registry, context.getRegistryContext()) + tempNamespace + CommonUtil.getServiceName(service); String artifactId = UUID.randomUUID().toString(); resource.setUUID(artifactId); String content = service.toString(); resource.setContent(RegistryUtils.encodeString(content)); resource.setMediaType(RegistryConstants.SERVICE_MEDIA_TYPE); // when saving the resource we are expecting to call the service media type handler, so // we intentionally release the lock here. boolean lockAlreadyAcquired = !CommonUtil.isUpdateLockAvailable(); CommonUtil.releaseUpdateLock(); try { registry.put(path, resource); } finally { if (lockAlreadyAcquired) { CommonUtil.acquireUpdateLock(); } } registry.addAssociation(path, RegistryUtils.getAbsolutePath(registry.getRegistryContext(), CommonUtil.getDefinitionURL(service)), CommonConstants.DEPENDS); registry.addAssociation(RegistryUtils.getAbsolutePath(registry.getRegistryContext(), CommonUtil.getDefinitionURL(service)),path, CommonConstants.USED_BY); }
public void removeLink(RequestContext requestContext) throws RegistryException { String path = requestContext.getResourcePath().getPath(); String relativePath = RegistryUtils.getRelativePath(requestContext.getRegistryContext(), path); if (!sendNotifications(requestContext, relativePath)){ return; } String parentPath = RegistryUtils.getParentPath(relativePath); RegistryEvent<String> event = new CollectionUpdatedEvent<String>("The link at " + relativePath + " was removed."); ((CollectionUpdatedEvent)event).setResourcePath(parentPath); event.setParameter("SymbolicLink", relativePath); event.setParameter("RegistryOperation", "removeLink"); event.setTenantId(CurrentSession.getCallerTenantId()); try { notify(event, requestContext.getRegistry(), parentPath); } catch (Exception e) { handleException("Unable to send notification for Remove Link Operation", e); } }
public void restore(RequestContext requestContext) throws RegistryException { String path = requestContext.getResourcePath().getPath(); String relativePath = RegistryUtils.getRelativePath(requestContext.getRegistryContext(), path); if (!sendNotifications(requestContext, relativePath)){ return; } boolean isNotCollection = !(requestContext.getResource() instanceof Collection); RegistryEvent<String> event; if (isNotCollection) { event = new ResourceUpdatedEvent<String>( "The resource at path " + relativePath + " was restored."); ((ResourceUpdatedEvent) event).setResourcePath(relativePath); } else { event = new CollectionUpdatedEvent<String>( "The collection at path " + relativePath + " was restored."); ((CollectionUpdatedEvent) event).setResourcePath(relativePath); } event.setParameter("RegistryOperation", "restore"); event.setTenantId(CurrentSession.getCallerTenantId()); try { notify(event, requestContext.getRegistry(), relativePath); } catch (Exception e) { handleException("Unable to send notification for Restore Operation", e); } }
public void createVersion(RequestContext requestContext) throws RegistryException { boolean isMountPath = false; String path = requestContext.getResourcePath().getPath(); String relativePath = RegistryUtils.getRelativePath(requestContext.getRegistryContext(),path); if (!sendNotifications(requestContext, relativePath)){ return; } boolean isNotCollection = !(requestContext.getRepository().get(path) instanceof Collection); RegistryEvent<String> event; if (isNotCollection) { event = new ResourceUpdatedEvent<String>("A Checkpoint was created for the resource at path " + relativePath + "."); ((ResourceUpdatedEvent)event).setResourcePath(relativePath); } else { event = new CollectionUpdatedEvent<String>("A Checkpoint was created for the collection at path " + relativePath + "."); ((CollectionUpdatedEvent)event).setResourcePath(relativePath); } event.setParameter("RegistryOperation", "createVersion"); event.setTenantId(CurrentSession.getCallerTenantId()); try { notify(event, requestContext.getRegistry(), relativePath); } catch (Exception e) { handleException("Unable to send notification for Create Version Operation", e); } }
public void removeTag(RequestContext requestContext) throws RegistryException { String path = requestContext.getResourcePath().getPath(); String relativePath = RegistryUtils.getRelativePath(requestContext.getRegistryContext(),path); if (!sendNotifications(requestContext, relativePath)){ return; } String tag = requestContext.getTag(); boolean isNotCollection = !(requestContext.getRepository().get(path) instanceof Collection); RegistryEvent<String> event; if (isNotCollection) { event = new ResourceUpdatedEvent<String>("An attempt was made to remove the tag " + tag + ", applied on resource " + relativePath + "."); ((ResourceUpdatedEvent)event).setResourcePath(relativePath); } else { event = new CollectionUpdatedEvent<String>("An attempt was made to remove the tag " + tag + ", applied on collection " + relativePath + "."); ((CollectionUpdatedEvent)event).setResourcePath(relativePath); } event.setParameter("RegistryOperation", "removeTag"); event.setTenantId(CurrentSession.getCallerTenantId()); try { notify(event, requestContext.getRegistry(), relativePath); } catch (Exception e) { handleException("Unable to send notification for Remove Tag Operation", e); } }
public void applyTag(RequestContext requestContext) throws RegistryException { String path = requestContext.getResourcePath().getPath(); String relativePath = RegistryUtils.getRelativePath(requestContext.getRegistryContext(),path); if (!sendNotifications(requestContext, relativePath)){ return; } String tag = requestContext.getTag(); boolean isNotCollection = !(requestContext.getRepository().get(path) instanceof Collection); RegistryEvent<String> event; if (isNotCollection) { event = new ResourceUpdatedEvent<String>("The tag " + tag + " was applied on resource " + relativePath + "."); ((ResourceUpdatedEvent)event).setResourcePath(relativePath); } else { event = new CollectionUpdatedEvent<String>("The tag " + tag + " was applied on resource " + relativePath + "."); ((CollectionUpdatedEvent)event).setResourcePath(relativePath); } event.setParameter("RegistryOperation", "applyTag"); event.setParameter("TagsAdded", tag); event.setTenantId(CurrentSession.getCallerTenantId()); try { notify(event, requestContext.getRegistry(), relativePath); } catch (Exception e) { handleException("Unable to send notification for Apply Tag Operation", e); } }
public String addComment(RequestContext requestContext) throws RegistryException { String path = requestContext.getResourcePath().getPath(); String relativePath = RegistryUtils.getRelativePath(requestContext.getRegistryContext(),path); if (!sendNotifications(requestContext, relativePath)){ return null; } if (requestContext.getComment() == null) { return null; } String comment = requestContext.getComment().getText(); boolean isNotCollection = !(requestContext.getRepository().get(path) instanceof Collection); RegistryEvent<String> event; if (isNotCollection) { event = new ResourceUpdatedEvent<String>("A comment was added to the resource at " + relativePath + ". Comment: " + comment); ((ResourceUpdatedEvent)event).setResourcePath(relativePath); } else { event = new CollectionUpdatedEvent<String>("A comment was added to the collection at " + relativePath + ". Comment: " + comment); ((CollectionUpdatedEvent)event).setResourcePath(relativePath); } event.setParameter("RegistryOperation", "addComment"); event.setTenantId(CurrentSession.getCallerTenantId()); try { notify(event, requestContext.getRegistry(), relativePath); } catch (Exception e) { handleException("Unable to send notification for Add Comment Operation", e); } return null; }
public void put(RequestContext requestContext) throws RegistryException { String relativePath = RegistryUtils.getRelativePath(requestContext.getRegistryContext(),path); if (!sendNotifications(requestContext, relativePath)){ return;