Search in sources :

Example 1 with NamespaceWithPrefix

use of org.eclipse.winery.repository.rest.resources.apiData.NamespaceWithPrefix in project winery by eclipse.

the class NamespacesResource method getNamespacesAsJSONlist.

/**
 * Returns the list of all namespaces registered with his manager and used at component instances.
 *
 * @return a JSON list containing the non-encoded URIs of each known namespace
 */
@GET
@Produces(MediaType.APPLICATION_JSON)
public List<NamespaceWithPrefix> getNamespacesAsJSONlist(@ApiParam(value = "if set all namespaces are returned otherwise the list will be filtered by disallowed namespaces", required = false) @QueryParam("all") String allNamespaces) {
    Collection<Namespace> namespaces = this.getNamespaces();
    // We now have all namespaces
    // We need to check if the "all" parameter has been set and filter accordingly
    // We need to convert from Namespace to String
    List<NamespaceWithPrefix> namespacesList = new ArrayList<>();
    for (Namespace ns : namespaces) {
        if (allNamespaces == null) {
            if (!Namespaces.getDisallowedNamespaces().contains(ns.getDecoded())) {
                namespacesList.add(new NamespaceWithPrefix(ns, this.namespaceManager.getPrefix(ns.getDecoded())));
            }
        } else {
            namespacesList.add(new NamespaceWithPrefix(ns, this.namespaceManager.getPrefix(ns.getDecoded())));
        }
    }
    Collections.sort(namespacesList);
    return namespacesList;
}
Also used : Namespace(org.eclipse.winery.common.ids.Namespace) NamespaceWithPrefix(org.eclipse.winery.repository.rest.resources.apiData.NamespaceWithPrefix)

Aggregations

Namespace (org.eclipse.winery.common.ids.Namespace)1 NamespaceWithPrefix (org.eclipse.winery.repository.rest.resources.apiData.NamespaceWithPrefix)1