pom fixed (removed jcr useless dependency, fixed http client). Added method to retrieve declared namespaces

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/catalogue-ws@148326 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2017-05-05 13:46:19 +00:00
parent 64396def27
commit 421f8adf5e
4 changed files with 48 additions and 17 deletions

View File

@ -25,7 +25,7 @@
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="owner.project.facets" value="java"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>

30
pom.xml
View File

@ -66,14 +66,6 @@
<artifactId>ckan-util-library</artifactId>
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>
gcubedatacatalogue-metadata-discovery
</artifactId>
<groupId>org.gcube.data-catalogue</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.gcube.core</groupId>
@ -85,12 +77,12 @@
<artifactId>authorization-client</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>home-library-jcr</artifactId>
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
<scope>compile</scope>
</dependency>
<!-- <dependency> -->
<!-- <groupId>org.gcube.common</groupId> -->
<!-- <artifactId>home-library-jcr</artifactId> -->
<!-- <version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version> -->
<!-- <scope>compile</scope> -->
<!-- </dependency> -->
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>common-authorization</artifactId>
@ -156,6 +148,16 @@
<artifactId>geojson-jackson</artifactId>
<version>1.8</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.3</version>
</dependency>
</dependencies>

View File

@ -16,7 +16,7 @@ public class Constants {
public static final String LIST_METHOD = "list";
// this service's resources
public final static String USERS = "api/user";
public final static String USERS = "api/users";
public final static String ORGANIZATIONS = "api/organizations";
public final static String GROUPS = "api/groups";
public final static String ITEMS = "api/items";
@ -75,5 +75,6 @@ public class Constants {
// other capabilities of this services related to gCube Profiles
public static final String PROFILES_NAMES_SHOW = "profile_names/";
public static final String PROFILE_SHOW = "profile/";
public static final String NAMESPACES_SHOW = "namespaces/";
}

View File

@ -11,6 +11,7 @@ import javax.ws.rs.core.MediaType;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.datacatalogue.catalogue.utils.CatalogueUtils;
import org.gcube.datacatalogue.catalogue.utils.Constants;
import org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.NamespaceCategory;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.slf4j.LoggerFactory;
@ -58,7 +59,7 @@ public class ItemProfile {
@Produces({MediaType.APPLICATION_XML, /*MediaType.APPLICATION_JSON*/})
public String showSource(
//@DefaultValue(MediaType.APPLICATION_XML) @HeaderParam("Accept") String accept,
@QueryParam("profile-name") String profileName) throws Exception{
@QueryParam("name") String profileName) throws Exception{
String context = ScopeProvider.instance.get();
logger.debug("Incoming request for context/name " + context+ "/" + profileName);
@ -72,6 +73,33 @@ public class ItemProfile {
return CatalogueUtils.getProfileSource(profileName);
}
@GET
@Path(Constants.NAMESPACES_SHOW)
@Produces(MediaType.APPLICATION_JSON)
@SuppressWarnings("unchecked")
public String showNamespaces() throws Exception{
// get the names as list
JSONObject json = CatalogueUtils.createJSONObjectMin(true, null);
JSONArray namespacesJson = new JSONArray();
try{
List<NamespaceCategory> namespaces = CatalogueUtils.getNamespaceCategories();
for (NamespaceCategory namespaceCategory : namespaces) {
JSONObject obj = new JSONObject();
obj.put("id", namespaceCategory.getId());
obj.put("title", namespaceCategory.getTitle());
obj.put("name", namespaceCategory.getNamespaceCategoryQName());
obj.put("description", namespaceCategory.getDescription());
namespacesJson.add(obj);
}
json.put(CatalogueUtils.RESULT_KEY, namespacesJson);
}catch(Exception e){
json = CatalogueUtils.createJSONObjectMin(false, e.getMessage());
}
return json.toJSONString();
}
}