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
b6d08bf8ac
commit
25a0b996e6
|
@ -23,6 +23,12 @@ public class Item extends GCatClient implements org.gcube.gcat.api.interfaces.It
|
|||
super(enforcedServiceURL, ITEMS);
|
||||
}
|
||||
|
||||
/**
|
||||
* List the item in the organization correspondent to the current VRE.
|
||||
*
|
||||
* If the client is entitled to run at VO or ROOT level the method return all the item in all the organization
|
||||
* in the catalogue. To filter per organization used the method {@link #list(int, int, String)}
|
||||
*/
|
||||
@Override
|
||||
public String list(int limit, int offset) throws WebApplicationException {
|
||||
Map<String, String> queryParams = new HashMap<>();
|
||||
|
@ -31,6 +37,17 @@ public class Item extends GCatClient implements org.gcube.gcat.api.interfaces.It
|
|||
return super.list(queryParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* List the item of a specific organization.
|
||||
* This API is only available if the client is entitles to run at VO and ROOT level.
|
||||
*/
|
||||
public String list(int limit, int offset, String organizationName) throws WebApplicationException {
|
||||
Map<String, String> queryParams = new HashMap<>();
|
||||
queryParams.put(GCatConstants.LIMIT_PARAMETER, String.valueOf(limit));
|
||||
queryParams.put(GCatConstants.OFFSET_PARAMETER, String.valueOf(offset));
|
||||
queryParams.put(GCatConstants.ORGANIZATION_PARAMETER, organizationName);
|
||||
return super.list(queryParams);
|
||||
}
|
||||
|
||||
public String create(String json, boolean socialPost) {
|
||||
try {
|
||||
|
|
|
@ -71,7 +71,6 @@ public class ItemTest extends ContextTest {
|
|||
*/
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void completeTest() throws IOException {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
|
@ -85,7 +84,6 @@ public class ItemTest extends ContextTest {
|
|||
JsonNode licenseJsonNode = licences.get(0);
|
||||
String licenseID = licenseJsonNode.get(ID_KEY).asText();
|
||||
|
||||
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put(NAME_KEY, NAME_VALUE);
|
||||
map.put(TITLE_KEY, TITLE_VALUE);
|
||||
|
@ -98,7 +96,6 @@ public class ItemTest extends ContextTest {
|
|||
tags.add(tag);
|
||||
map.put(TAGS_KEY, tags);
|
||||
|
||||
|
||||
List<Map<String,Object>> extras = new ArrayList<>();
|
||||
Map<String,Object> type = new HashMap<>();
|
||||
type.put(KEY_KEY, TYPE_KEY_VALUE);
|
||||
|
@ -134,11 +131,11 @@ public class ItemTest extends ContextTest {
|
|||
Assert.assertTrue(gotTitle.compareTo(TITLE_VALUE) == 0);
|
||||
|
||||
boolean privateValue = jsonNode.get(PRIVATE_KEY).asBoolean();
|
||||
Assert.assertTrue(privateValue==PRIVATE_VALUE);
|
||||
Assert.assertTrue(privateValue == PRIVATE_VALUE);
|
||||
|
||||
String gotLicenseID = jsonNode.get(LICENSE_ID_KEY).asText();
|
||||
Assert.assertTrue(gotLicenseID.compareTo(licenseID) == 0);
|
||||
}catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
item.delete(NAME_VALUE, true);
|
||||
throw e;
|
||||
}
|
||||
|
@ -154,8 +151,22 @@ public class ItemTest extends ContextTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void safeTest() throws IOException {
|
||||
public void listOnVOTest() throws Exception {
|
||||
ContextTest.setContextByName("/gcube/devNext");
|
||||
|
||||
Item item = new Item();
|
||||
String itemsString = item.list(10, 0, "bionym");
|
||||
logger.debug("Got list {}", itemsString);
|
||||
|
||||
/*
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JavaType listType = mapper.getTypeFactory().constructCollectionType(ArrayList.class, String.class);
|
||||
List<String> items = mapper.readValue(itemsString, listType);
|
||||
*/
|
||||
}
|
||||
|
||||
@Test
|
||||
public void safeTest() throws Exception {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JavaType listType = mapper.getTypeFactory().constructCollectionType(ArrayList.class, String.class);
|
||||
|
||||
|
@ -181,7 +192,7 @@ public class ItemTest extends ContextTest {
|
|||
Item item = new Item();
|
||||
String itemsString = item.list(200, 0);
|
||||
List<String> items = mapper.readValue(itemsString, listType);
|
||||
while(items.size()>0) {
|
||||
while(items.size() > 0) {
|
||||
for(String itemName : items) {
|
||||
item.purge(itemName);
|
||||
Thread.sleep(50);
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
/token.properties
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE xml>
|
||||
<configuration>
|
||||
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{0}: %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
|
||||
<logger name="org.gcube" level="ERROR" />
|
||||
<logger name="org.gcube.gcat" level="TRACE" />
|
||||
|
||||
<root level="WARN">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
|
||||
</configuration>
|
Loading…
Reference in New Issue