public NamespaceWithPrefix(Namespace ns, String prefix) { Objects.requireNonNull(ns); Objects.requireNonNull(prefix); this.namespace = ns.getDecoded(); this.prefix = prefix; }
public List<ComplianceRuleId> getRuleIds(TServiceTemplate serviceTemplate) { List<ComplianceRuleId> complianceRules = new ArrayList<>(); Namespace namespace = new Namespace(serviceTemplate.getTargetNamespace(), false); Collection<Namespace> componentsNamespaces = RepositoryFactory.getRepository().getComponentsNamespaces(ComplianceRuleId.class); List<Namespace> relevantNamespaces = componentsNamespaces.stream() .filter(ns -> namespace.getDecoded().startsWith( ns.getDecoded().split("/compliancerules")[0] ) ).collect(Collectors.toList()); for (Namespace space : relevantNamespaces) { complianceRules.addAll((Collection<? extends ComplianceRuleId>) ((FilebasedRepository) RepositoryFactory.getRepository()).getAllIdsInNamespace(ComplianceRuleId.class, space)); } return complianceRules; }
public NamespaceAndDefinedLocalNamesForAngular(final Namespace namespace, final List<LocalNameForAngular> localNamesForAngular) { Objects.requireNonNull(namespace); Objects.requireNonNull(localNamesForAngular); this.id = namespace.getEncoded(); this.text = namespace.getDecoded(); this.localNamesForAngular = localNamesForAngular; }
/** * Creates a new id based on strings. This constructor is required for @see org.eclipse.winery.repository.resources.AbstractComponentsResource * * @param ns the namespace to be used * @param id the id to be used * @param URLencoded true: both Strings are URLencoded, false: both Strings are not URLencoded */ public DefinitionsChildId(String ns, String id, boolean URLencoded) { this(new Namespace(ns, URLencoded), new XmlId(id, URLencoded)); }
public void forceDelete(Class<? extends DefinitionsChildId> definitionsChildIdClazz, Namespace namespace) { // instantiate new definitions child id with "ID" as id // this is used to get the absolute path DefinitionsChildId id = BackendUtils.getDefinitionsChildId(definitionsChildIdClazz, namespace.getEncoded(), "ID", true); Path path = this.id2AbsolutePath(id); // do not delete the id, delete the complete namespace // patrent folder is the namespace folder path = path.getParent(); FileUtils.forceDelete(path); }
@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof DefinitionsChildId)) return false; // only the same component instances might be equal if (!o.getClass().equals(this.getClass())) { return false; } if (!super.equals(o)) return false; DefinitionsChildId that = (DefinitionsChildId) o; return namespace.equals(that.namespace); }
@Override public int compareTo(GenericId o1) { if (o1 instanceof DefinitionsChildId) { int res = this.getClass().getName().compareTo(o1.getClass().getName()); if (res == 0) { DefinitionsChildId o = (DefinitionsChildId) o1; res = VersionUtils.getNameWithoutVersion(this).compareTo(VersionUtils.getNameWithoutVersion(o)); if (res == 0) { res = VersionUtils.getVersion(this).compareTo(VersionUtils.getVersion(o)); } if (res == 0) { res = this.getNamespace().compareTo(o.getNamespace()); } } return res; } else { // comparing TOSCAcomponentIDs with non-TOSCAcomponentIDs is not // possible throw new IllegalStateException(); } } }
@Override public int hashCode() { int result = super.hashCode(); result = 31 * result + namespace.hashCode(); return result; }
public ArtifactTypeId(QName qname) { this(new Namespace(Objects.requireNonNull(qname).getNamespaceURI(), false), new XmlId(Objects.requireNonNull(qname).getLocalPart(), false)); }
InputStream inputStream = repository.newInputStream(ref); Path path = this.path.resolve(id.getGroup()) .resolve(id.getNamespace().getEncoded()) .resolve(node.getIdFromIdOrNameField()) .resolve(ref.getFileName());
/** * Finds out all imports belonging to the given namespace */ private Set<XSDImportId> getImportsOfNamespace(final Namespace namespace) { Objects.requireNonNull(namespace); // implemented using a straight-forward solution: get ALL XSD definitions and filter out the matching ones Set<XSDImportId> allImports = RepositoryFactory.getRepository().getAllDefinitionsChildIds(XSDImportId.class); return allImports.stream().filter(imp -> imp.getNamespace().equals(namespace)).collect(Collectors.toSet()); }
/** * Collects all the definitions which describe the same component in different versions. * * @param id The {@link DefinitionsChildId} for which all versions should be collected. * @return A set of definitions describing the same component in different versions. */ public static SortedSet<? extends DefinitionsChildId> getOtherVersionDefinitionsFromDefinition(DefinitionsChildId id) { IRepository repository = RepositoryFactory.getRepository(); SortedSet<? extends DefinitionsChildId> allDefinitionsChildIds = repository.getAllDefinitionsChildIds(id.getClass()); final String componentName = VersionUtils.getNameWithoutVersion(id.getXmlId().getDecoded()); allDefinitionsChildIds.removeIf(definition -> { if (definition.getNamespace().compareTo(id.getNamespace()) == 0) { String name = VersionUtils.getNameWithoutVersion(definition); return !name.equals(componentName); } return true; }); return allDefinitionsChildIds; }
/** * required by artifacts.jsp */ public String getNamespace() { return this.resWithNamespace.getNamespace().getDecoded(); }
public Collection<? extends DefinitionsChildId> getAllIdsInNamespace(Class<? extends DefinitionsChildId> clazz, Namespace namespace) { Collection<DefinitionsChildId> result = new HashSet<>(); String rootPathFragment = Util.getRootPathFragment(clazz); Path dir = this.repositoryRoot.resolve(rootPathFragment); dir = dir.resolve(namespace.getEncoded()); if (Files.exists(dir) && Files.isDirectory(dir)) { DirectoryStream<Path> directoryStream = null; try { directoryStream = Files.newDirectoryStream(dir); for (Path path : directoryStream) { Constructor<? extends DefinitionsChildId> constructor = null; constructor = clazz.getConstructor(String.class, String.class, boolean.class); DefinitionsChildId definitionsChildId = constructor.newInstance(namespace.getDecoded(), path.getFileName().toString(), false); result.add(definitionsChildId); } directoryStream.close(); } catch (IOException e) { FilebasedRepository.LOGGER.debug("Cannot close ds", e); } catch (NoSuchMethodException e) { FilebasedRepository.LOGGER.debug("Cannot find constructor", e); } catch (InstantiationException e) { FilebasedRepository.LOGGER.debug("Cannot instantiate object", e); } catch (IllegalAccessException e) { FilebasedRepository.LOGGER.debug("IllegalAccessException", e); } catch (InvocationTargetException e) { FilebasedRepository.LOGGER.debug("InvocationTargetException", e); } } return result; }
/** * Deletes the whole namespace in the component */ public static Response delete(Class<? extends DefinitionsChildId> definitionsChildIdClazz, String namespaceStr) { Namespace namespace = new Namespace(namespaceStr, true); try { RepositoryFactory.getRepository().forceDelete(definitionsChildIdClazz, namespace); } catch (IOException e) { LOGGER.error(e.getMessage(), e); return Response.serverError().entity(e.getMessage()).build(); } return Response.noContent().build(); }
ServiceTemplateId serviceTemplate = (ServiceTemplateId) this.parent.getId(); location = location + "&ns="; location = location + serviceTemplate.getNamespace().getEncoded(); location = location + "&id="; location = location + serviceTemplate.getXmlId().getEncoded();
@GET @Path("alldeclaredelementslocalnames") public List<String> getAllDeclaredElementsLocalNames() { return RepositoryFactory.getRepository().getXsdImportManager().getAllDeclaredElementsLocalNames().stream() .filter(namespaceAndDefinedLocalNames -> namespaceAndDefinedLocalNames.getNamespace().equals(id.getNamespace())) .flatMap(namespaceAndDefinedLocalNames -> namespaceAndDefinedLocalNames.getDefinedLocalNames().stream()) .sorted() .collect(Collectors.toList()); }
default String getPrefix(Namespace namespace) { Objects.requireNonNull(namespace); String ns = namespace.getDecoded(); return this.getPrefix(ns); }
@Path("{namespace}/") @GET @ApiOperation(value = "Returns all available local names of defined elements in this namespace") @Produces(MediaType.APPLICATION_JSON) public List<String> getAllElementLocalNames( @PathParam("namespace") String nsString, @QueryParam(value = "elements") String returnElements, @QueryParam(value = "types") String returnTypes) { // returnElements is not read as either types or elements may be read return RepositoryFactory.getRepository().getXsdImportManager() .getAllDefinedLocalNames(new Namespace(nsString, true), (returnTypes != null)); }
Path path = this.path.resolve(entry.getKey().getGroup()).resolve(entry.getKey().getNamespace().getEncoded()); try { Map<Path, TServiceTemplate> map = new X2YConverter(repository, this.path).convert(entry.getValue(), path, entry.getKey().getQName());