Refs #13307: Item List must use package_search in place of package_list
Task-Url: https://support.d4science.org/issues/13307 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-publishing/gcat@177049 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
d05ebe2045
commit
8f27af53e0
|
@ -78,7 +78,11 @@ public class CKANPackage extends CKAN {
|
||||||
public static final String EXTRAS_KEY_VALUE_SYSTEM_TYPE = "system:type";
|
public static final String EXTRAS_KEY_VALUE_SYSTEM_TYPE = "system:type";
|
||||||
public static final String EXTRAS_VALUE_KEY = "value";
|
public static final String EXTRAS_VALUE_KEY = "value";
|
||||||
|
|
||||||
public static final String SEARCHABLE_KEY = "searchable";
|
// The 'results' array is included in the 'result' object for package_search
|
||||||
|
private static final String RESULTS_KEY = "results";
|
||||||
|
protected static final String SEARCHABLE_KEY = "searchable";
|
||||||
|
protected static final String INCLUDE_PRIVATE_KEY = "include_private";
|
||||||
|
// protected static final String INCLUDE_DRAFTS_KEY = "include_drafts";
|
||||||
|
|
||||||
public static final String GROUPS_KEY = "groups";
|
public static final String GROUPS_KEY = "groups";
|
||||||
public static final String TAGS_KEY = "tags";
|
public static final String TAGS_KEY = "tags";
|
||||||
|
@ -231,13 +235,36 @@ public class CKANPackage extends CKAN {
|
||||||
if(offset < 0) {
|
if(offset < 0) {
|
||||||
offset = 0;
|
offset = 0;
|
||||||
}
|
}
|
||||||
parameters.put(START_KEY, String.valueOf(offset));
|
parameters.put(START_KEY, String.valueOf(offset*limit));
|
||||||
|
|
||||||
String organizationName = getOrganizationName();
|
String organizationName = getOrganizationName();
|
||||||
String organizationQueryString = String.format(ORGANIZATION_FILTER_TEMPLATE, organizationName);
|
String organizationQueryString = String.format(ORGANIZATION_FILTER_TEMPLATE, organizationName);
|
||||||
parameters.put(Q_KEY, organizationQueryString);
|
parameters.put(Q_KEY, organizationQueryString);
|
||||||
|
|
||||||
return sendGetRequest(LIST, parameters);
|
parameters.put(INCLUDE_PRIVATE_KEY, String.valueOf(true));
|
||||||
|
|
||||||
|
// By default not including draft
|
||||||
|
// parameters.put(INCLUDE_DRAFTS_KEY, String.valueOf(false));
|
||||||
|
|
||||||
|
sendGetRequest(LIST, parameters);
|
||||||
|
|
||||||
|
ArrayNode results = (ArrayNode) result.get(RESULTS_KEY);
|
||||||
|
|
||||||
|
ArrayNode arrayNode = mapper.createArrayNode();
|
||||||
|
for(JsonNode node : results) {
|
||||||
|
try {
|
||||||
|
String id = node.get(ID_KEY).asText();
|
||||||
|
arrayNode.add(id);
|
||||||
|
}catch (Exception e) {
|
||||||
|
try {
|
||||||
|
logger.error("Unable to get the ID of {}. the result will not be included in the result", mapper.writeValueAsString(node));
|
||||||
|
}catch (Exception ex) {
|
||||||
|
logger.error("", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return getAsString(arrayNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void rollbackManagedResources() {
|
protected void rollbackManagedResources() {
|
||||||
|
|
Loading…
Reference in New Issue