Added organization parameter to allow client to specify the target
organization in item listing (in VO and ROOT) refs #17635
This commit is contained in:
parent
56261f96ab
commit
9779afe1e5
|
@ -88,6 +88,8 @@ public class CKANPackage extends CKAN {
|
||||||
protected static final String SEARCHABLE_KEY = "searchable";
|
protected static final String SEARCHABLE_KEY = "searchable";
|
||||||
protected static final String CAPACITY_KEY = "capacity";
|
protected static final String CAPACITY_KEY = "capacity";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// protected static final String INCLUDE_PRIVATE_KEY = "include_private";
|
// protected static final String INCLUDE_PRIVATE_KEY = "include_private";
|
||||||
// protected static final String INCLUDE_DRAFTS_KEY = "include_drafts";
|
// protected static final String INCLUDE_DRAFTS_KEY = "include_drafts";
|
||||||
|
|
||||||
|
@ -195,7 +197,7 @@ public class CKANPackage extends CKAN {
|
||||||
}
|
}
|
||||||
if(organizationID == null || gotOrganization.compareTo(organizationID) != 0) {
|
if(organizationID == null || gotOrganization.compareTo(organizationID) != 0) {
|
||||||
throw new BadRequestException(
|
throw new BadRequestException(
|
||||||
"You can only publish in the Organization associate to the current VRE");
|
"You can only publish in the Organization associated to the current VRE");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -250,8 +252,31 @@ public class CKANPackage extends CKAN {
|
||||||
parameters.put(START_KEY, String.valueOf(offset * limit));
|
parameters.put(START_KEY, String.valueOf(offset * limit));
|
||||||
|
|
||||||
String organizationName = getOrganizationName();
|
String organizationName = getOrganizationName();
|
||||||
String organizationQueryString = String.format(ORGANIZATION_FILTER_TEMPLATE, organizationName);
|
ScopeBean scopeBean = new ScopeBean(ContextUtility.getCurrentContext());
|
||||||
|
|
||||||
|
/*
|
||||||
|
* List is filter per organization only is the request arriving in a VRE.
|
||||||
|
* If the request arrive form a VO or from ROOT the request return the item in all organizations
|
||||||
|
* in the catalog.
|
||||||
|
*/
|
||||||
|
String organizationQueryString = null;
|
||||||
|
if(scopeBean.is(Type.VRE)) {
|
||||||
|
organizationQueryString = String.format(ORGANIZATION_FILTER_TEMPLATE, organizationName);
|
||||||
|
}else {
|
||||||
|
/*
|
||||||
|
* We provide the possibility for the client to get the list of an item in an organization
|
||||||
|
* if the request arrives from a VO o from the ROOT
|
||||||
|
*/
|
||||||
|
MultivaluedMap<String, String> queryParameters = uriInfo.getQueryParameters();
|
||||||
|
if(queryParameters!=null && queryParameters.containsKey(GCatConstants.ORGANIZATION_PARAMETER)) {
|
||||||
|
String org = queryParameters.getFirst(GCatConstants.ORGANIZATION_PARAMETER);
|
||||||
|
organizationQueryString = String.format(ORGANIZATION_FILTER_TEMPLATE, org);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(organizationQueryString!=null) {
|
||||||
parameters.put(Q_KEY, organizationQueryString);
|
parameters.put(Q_KEY, organizationQueryString);
|
||||||
|
}
|
||||||
|
|
||||||
// parameters.put(INCLUDE_PRIVATE_KEY, String.valueOf(true));
|
// parameters.put(INCLUDE_PRIVATE_KEY, String.valueOf(true));
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ public class REST<C extends CKAN> extends BaseREST implements CRUD<Response,Resp
|
||||||
protected C getInstance() {
|
protected C getInstance() {
|
||||||
try {
|
try {
|
||||||
C ckan = reference.newInstance();
|
C ckan = reference.newInstance();
|
||||||
|
ckan.setUriInfo(uriInfo);
|
||||||
return ckan;
|
return ckan;
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
throw new InternalServerErrorException();
|
throw new InternalServerErrorException();
|
||||||
|
@ -40,7 +41,6 @@ public class REST<C extends CKAN> extends BaseREST implements CRUD<Response,Resp
|
||||||
public Response create(String json) {
|
public Response create(String json) {
|
||||||
setCalledMethod("POST /" + COLLECTION_PARAMETER);
|
setCalledMethod("POST /" + COLLECTION_PARAMETER);
|
||||||
C ckan = getInstance();
|
C ckan = getInstance();
|
||||||
ckan.setUriInfo(uriInfo);
|
|
||||||
String ret = ckan.create(json);
|
String ret = ckan.create(json);
|
||||||
|
|
||||||
ResponseBuilder responseBuilder = Response.status(Status.CREATED).entity(ret);
|
ResponseBuilder responseBuilder = Response.status(Status.CREATED).entity(ret);
|
||||||
|
|
Loading…
Reference in New Issue