Merged from branch
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-publishing/gcat-client@179477 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
23bb6996df
commit
148b5b8a78
|
@ -22,7 +22,7 @@
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
|
|
|
@ -1,5 +1,2 @@
|
||||||
eclipse.preferences.version=1
|
eclipse.preferences.version=1
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
|
||||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
|
||||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||||
org.eclipse.jdt.core.compiler.source=1.8
|
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
<ReleaseNotes>
|
<ReleaseNotes>
|
||||||
<Changeset component="org.gcube.data-publishing.gcat-client.1-1-0" date="${buildDate}">
|
<Changeset component="org.gcube.data-publishing.gcat-client.1-1-0" date="${buildDate}">
|
||||||
<Change>Added the possibility to enforce gCat service URL</Change>
|
<Change>Added the possibility to enforce gCat service URL</Change>
|
||||||
|
<Change>Added the possibility to disable social post #16322</Change>
|
||||||
|
<Change>Added the possibility to get a porfile as JSON</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.data-publishing.gcat-client.1-0-0" date="2019-02-26">
|
<Changeset component="org.gcube.data-publishing.gcat-client.1-0-0" date="2019-02-26">
|
||||||
<Change>First Release</Change>
|
<Change>First Release</Change>
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -48,7 +48,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.data-publishing</groupId>
|
<groupId>org.gcube.data-publishing</groupId>
|
||||||
<artifactId>gcat-api</artifactId>
|
<artifactId>gcat-api</artifactId>
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.resources.discovery</groupId>
|
<groupId>org.gcube.resources.discovery</groupId>
|
||||||
|
|
|
@ -121,12 +121,15 @@ abstract class GCatClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String create(String body, String... paths) {
|
protected String create(String body, Map<String, String> queryParams, String... paths) {
|
||||||
try {
|
try {
|
||||||
initRequest();
|
initRequest();
|
||||||
for(String p : paths) {
|
for(String p : paths) {
|
||||||
gxhttpStringRequest.path(p);
|
gxhttpStringRequest.path(p);
|
||||||
}
|
}
|
||||||
|
if(queryParams!=null && queryParams.size()>0) {
|
||||||
|
gxhttpStringRequest.queryParams(queryParams);
|
||||||
|
}
|
||||||
HttpURLConnection httpURLConnection = gxhttpStringRequest.post(body);
|
HttpURLConnection httpURLConnection = gxhttpStringRequest.post(body);
|
||||||
return parseHttpURLConnection(httpURLConnection);
|
return parseHttpURLConnection(httpURLConnection);
|
||||||
}catch (WebApplicationException e) {
|
}catch (WebApplicationException e) {
|
||||||
|
@ -136,6 +139,9 @@ abstract class GCatClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected String create(String body, String... paths) {
|
||||||
|
return create(body, (Map<String, String>) null, paths);
|
||||||
|
}
|
||||||
|
|
||||||
protected String read(String... paths) throws WebApplicationException {
|
protected String read(String... paths) throws WebApplicationException {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -31,6 +31,19 @@ public class Item extends GCatClient implements org.gcube.gcat.api.interfaces.It
|
||||||
return super.list(queryParams);
|
return super.list(queryParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String create(String json, boolean socialPost) {
|
||||||
|
try {
|
||||||
|
Map<String,String> queryParams = new HashMap<>();
|
||||||
|
queryParams.put(GCatConstants.SOCIAL_POST_PARAMETER, String.valueOf(socialPost));
|
||||||
|
return super.create(json, queryParams);
|
||||||
|
}catch (WebApplicationException e) {
|
||||||
|
throw e;
|
||||||
|
}catch (Exception e) {
|
||||||
|
throw new WebApplicationException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String create(String json) {
|
public String create(String json) {
|
||||||
return super.create(json);
|
return super.create(json);
|
||||||
|
|
|
@ -5,6 +5,7 @@ import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
import javax.ws.rs.WebApplicationException;
|
import javax.ws.rs.WebApplicationException;
|
||||||
|
import javax.ws.rs.core.HttpHeaders;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
import org.gcube.gcat.api.GCatConstants;
|
import org.gcube.gcat.api.GCatConstants;
|
||||||
|
@ -27,10 +28,12 @@ public class Profile extends GCatClient implements org.gcube.gcat.api.interfaces
|
||||||
return super.list(null);
|
return super.list(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
protected String createOrUpdate(String name, String xml) {
|
||||||
public String create(String name, String xml) {
|
|
||||||
try {
|
try {
|
||||||
initRequest();
|
initRequest();
|
||||||
|
gxhttpStringRequest.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML);
|
||||||
|
gxhttpStringRequest.header(HttpHeaders.ACCEPT, MediaType.APPLICATION_XML);
|
||||||
|
gxhttpStringRequest.path(name);
|
||||||
HttpURLConnection httpURLConnection = gxhttpStringRequest.put(xml);
|
HttpURLConnection httpURLConnection = gxhttpStringRequest.put(xml);
|
||||||
return parseHttpURLConnection(httpURLConnection);
|
return parseHttpURLConnection(httpURLConnection);
|
||||||
}catch (WebApplicationException e) {
|
}catch (WebApplicationException e) {
|
||||||
|
@ -39,13 +42,26 @@ public class Profile extends GCatClient implements org.gcube.gcat.api.interfaces
|
||||||
throw new WebApplicationException(e);
|
throw new WebApplicationException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String create(String name, String xml) {
|
||||||
|
return createOrUpdate(name, xml);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String read(String name) {
|
public String read(String name) {
|
||||||
|
return read(name, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String read(String name, boolean asJSON) {
|
||||||
try {
|
try {
|
||||||
initRequest();
|
initRequest();
|
||||||
gxhttpStringRequest.path(name);
|
gxhttpStringRequest.path(name);
|
||||||
gxhttpStringRequest.header("Accept", MediaType.APPLICATION_XML);
|
if(asJSON) {
|
||||||
|
gxhttpStringRequest.header(HttpHeaders.ACCEPT, GCatConstants.APPLICATION_JSON_CHARSET_UTF_8);
|
||||||
|
} else {
|
||||||
|
gxhttpStringRequest.header(HttpHeaders.ACCEPT, MediaType.APPLICATION_XML);
|
||||||
|
}
|
||||||
HttpURLConnection httpURLConnection = gxhttpStringRequest.get();
|
HttpURLConnection httpURLConnection = gxhttpStringRequest.get();
|
||||||
return parseHttpURLConnection(httpURLConnection);
|
return parseHttpURLConnection(httpURLConnection);
|
||||||
}catch (WebApplicationException e) {
|
}catch (WebApplicationException e) {
|
||||||
|
@ -55,17 +71,9 @@ public class Profile extends GCatClient implements org.gcube.gcat.api.interfaces
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String read(String name, boolean asJSON) {
|
|
||||||
if(!asJSON) {
|
|
||||||
return read(name);
|
|
||||||
}
|
|
||||||
gxhttpStringRequest.header("Accept", GCatConstants.APPLICATION_JSON_CHARSET_UTF_8);
|
|
||||||
return super.read(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String update(String name, String xml) {
|
public String update(String name, String xml) {
|
||||||
return super.update(xml, name);
|
return createOrUpdate(name, xml);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -5,7 +5,6 @@ package org.gcube.gcat.client;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.gcube.common.authorization.client.Constants;
|
import org.gcube.common.authorization.client.Constants;
|
||||||
|
@ -16,7 +15,6 @@ import org.gcube.common.authorization.library.provider.ClientInfo;
|
||||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||||
import org.gcube.common.authorization.library.utils.Caller;
|
import org.gcube.common.authorization.library.utils.Caller;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
import org.gcube.gcat.client.GCatClientDiscovery;
|
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -24,101 +22,44 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
public class ContextTest {
|
public class ContextTest {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ContextTest.class);
|
private static final Logger logger = LoggerFactory.getLogger(ContextTest.class);
|
||||||
|
|
||||||
protected static final String TOKEN_PROPERTIES_FILENAME = "token.properties";
|
protected static Properties properties;
|
||||||
protected static final String CONFIG_PROPERTIES_FILENAME = "config.properties";
|
protected static final String PROPERTIES_FILENAME = "token.properties";
|
||||||
|
|
||||||
private static final String GCUBE_VARNAME = "GCUBE";
|
public static final String DEFAULT_TEST_SCOPE_NAME;
|
||||||
public static final String GCUBE;
|
|
||||||
|
|
||||||
private static final String GCUBE_DEVNEXT_VARNAME = "GCUBE_DEVNEXT";
|
|
||||||
public static final String GCUBE_DEVNEXT;
|
|
||||||
|
|
||||||
private static final String GCUBE_DEVNEXT_NEXTNEXT_VARNAME = "GCUBE_DEVNEXT_NEXTNEXT";
|
|
||||||
public static final String GCUBE_DEVNEXT_NEXTNEXT;
|
|
||||||
|
|
||||||
public static final String GCUBE_DEVSEC_VARNAME = "GCUBE_DEVSEC";
|
|
||||||
public static final String GCUBE_DEVSEC;
|
|
||||||
|
|
||||||
public static final String GCUBE_DEVSEC_DEVVRE_VARNAME = "GCUBE_DEVSEC_DEVVRE";
|
|
||||||
public static final String GCUBE_DEVSEC_DEVVRE;
|
|
||||||
|
|
||||||
private static final String GCUBE_DEVNEXT_ANOTHER_USER_VARNAME = "GCUBE_DEVNEXT_ANOTHER_USER";
|
|
||||||
public static final String GCUBE_DEVNEXT_ANOTHER_USER;
|
|
||||||
|
|
||||||
public static final String DEFAULT_TEST_SCOPE;
|
|
||||||
|
|
||||||
public static final String GCUBE_PRE_PROD_PREVRE_VARNAME = "GCUBE_PRE_PROD_PREVRE";
|
|
||||||
public static final String GCUBE_PRE_PROD_PREVRE;
|
|
||||||
|
|
||||||
public static final String GCUBE_PRE_PROD_PARTHENOS_REGISTRY_VARNAME = "GCUBE_PRE_PROD_PARTHENOS_REGISTRY";
|
|
||||||
public static final String GCUBE_PRE_PROD_PARTHENOS_REGISTRY;
|
|
||||||
|
|
||||||
public static final String ROOT_VARNAME = "ROOT";
|
|
||||||
public static final String ROOT;
|
|
||||||
|
|
||||||
public static final String FORCED_URL_VARNAME = "FORCED_URL";
|
|
||||||
public static final String FORCED_URL;
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
Properties properties = new Properties();
|
|
||||||
InputStream input = ContextTest.class.getClassLoader().getResourceAsStream(TOKEN_PROPERTIES_FILENAME);
|
|
||||||
|
|
||||||
try {
|
|
||||||
// load the properties file
|
|
||||||
properties.load(input);
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
GCUBE = properties.getProperty(GCUBE_VARNAME);
|
|
||||||
|
|
||||||
GCUBE_DEVNEXT = properties.getProperty(GCUBE_DEVNEXT_VARNAME);
|
|
||||||
GCUBE_DEVNEXT_NEXTNEXT = properties.getProperty(GCUBE_DEVNEXT_NEXTNEXT_VARNAME);
|
|
||||||
|
|
||||||
GCUBE_DEVSEC = properties.getProperty(GCUBE_DEVSEC_VARNAME);
|
|
||||||
GCUBE_DEVSEC_DEVVRE = properties.getProperty(GCUBE_DEVSEC_DEVVRE_VARNAME);
|
|
||||||
|
|
||||||
GCUBE_DEVNEXT_ANOTHER_USER = properties.getProperty(GCUBE_DEVNEXT_ANOTHER_USER_VARNAME);
|
|
||||||
|
|
||||||
GCUBE_PRE_PROD_PARTHENOS_REGISTRY = properties.getProperty(GCUBE_PRE_PROD_PARTHENOS_REGISTRY_VARNAME);
|
|
||||||
GCUBE_PRE_PROD_PREVRE = properties.getProperty(GCUBE_PRE_PROD_PREVRE_VARNAME);
|
|
||||||
ROOT = properties.getProperty(ROOT_VARNAME);
|
|
||||||
|
|
||||||
DEFAULT_TEST_SCOPE = GCUBE_PRE_PROD_PREVRE;
|
|
||||||
|
|
||||||
properties = new Properties();
|
properties = new Properties();
|
||||||
input = ContextTest.class.getClassLoader().getResourceAsStream(CONFIG_PROPERTIES_FILENAME);
|
InputStream input = ContextTest.class.getClassLoader().getResourceAsStream(PROPERTIES_FILENAME);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// load the properties file
|
// load the properties file
|
||||||
properties.load(input);
|
properties.load(input);
|
||||||
} catch (IOException e) {
|
} catch(IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
FORCED_URL = properties.getProperty(FORCED_URL_VARNAME);
|
DEFAULT_TEST_SCOPE_NAME = "/pred4s/preprod/preVRE";
|
||||||
try {
|
|
||||||
GCatClientDiscovery.forceToURL(FORCED_URL);
|
|
||||||
} catch(MalformedURLException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getCurrentScope(String token) throws ObjectNotFound, Exception{
|
public static String getCurrentScope(String token) throws ObjectNotFound, Exception {
|
||||||
AuthorizationEntry authorizationEntry = Constants.authorizationService().get(token);
|
AuthorizationEntry authorizationEntry = Constants.authorizationService().get(token);
|
||||||
String context = authorizationEntry.getContext();
|
String context = authorizationEntry.getContext();
|
||||||
logger.info("Context of token {} is {}", token, context);
|
logger.info("Context of token {} is {}", token, context);
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setContextByName(String fullContextName) throws ObjectNotFound, Exception {
|
||||||
|
String token = ContextTest.properties.getProperty(fullContextName);
|
||||||
|
setContext(token);
|
||||||
|
}
|
||||||
|
|
||||||
public static void setContext(String token) throws ObjectNotFound, Exception{
|
public static void setContext(String token) throws ObjectNotFound, Exception {
|
||||||
SecurityTokenProvider.instance.set(token);
|
SecurityTokenProvider.instance.set(token);
|
||||||
AuthorizationEntry authorizationEntry = Constants.authorizationService().get(token);
|
AuthorizationEntry authorizationEntry = Constants.authorizationService().get(token);
|
||||||
ClientInfo clientInfo = authorizationEntry.getClientInfo();
|
ClientInfo clientInfo = authorizationEntry.getClientInfo();
|
||||||
|
@ -130,12 +71,12 @@ public class ContextTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void beforeClass() throws Exception{
|
public static void beforeClass() throws Exception {
|
||||||
setContext(DEFAULT_TEST_SCOPE);
|
setContextByName(DEFAULT_TEST_SCOPE_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
public static void afterClass() throws Exception{
|
public static void afterClass() throws Exception {
|
||||||
SecurityTokenProvider.instance.reset();
|
SecurityTokenProvider.instance.reset();
|
||||||
ScopeProvider.instance.reset();
|
ScopeProvider.instance.reset();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,9 @@ import java.io.IOException;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import javax.ws.rs.NotFoundException;
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
@ -27,14 +29,14 @@ public class ProfileTest extends ContextTest {
|
||||||
private static Logger logger = LoggerFactory.getLogger(ProfileTest.class);
|
private static Logger logger = LoggerFactory.getLogger(ProfileTest.class);
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void safeTest() throws IOException, ParserConfigurationException, SAXException {
|
public void safeTest() throws Exception {
|
||||||
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
JavaType arrayType = mapper.getTypeFactory().constructCollectionType(ArrayList.class, String.class);
|
JavaType arrayType = mapper.getTypeFactory().constructCollectionType(ArrayList.class, String.class);
|
||||||
|
|
||||||
Profile profile = new Profile();
|
Profile profile = new Profile();
|
||||||
String profilesString = profile.list();
|
String profilesString = profile.list();
|
||||||
logger.debug("Got Profiles {}", profilesString);
|
logger.debug("Got Profiles {}\n", profilesString);
|
||||||
|
|
||||||
List<String> profiles = mapper.readValue(profilesString, arrayType);
|
List<String> profiles = mapper.readValue(profilesString, arrayType);
|
||||||
for(String name : profiles) {
|
for(String name : profiles) {
|
||||||
|
@ -45,18 +47,85 @@ public class ProfileTest extends ContextTest {
|
||||||
InputSource is = new InputSource(new StringReader(xml));
|
InputSource is = new InputSource(new StringReader(xml));
|
||||||
dBuilder.parse(is);
|
dBuilder.parse(is);
|
||||||
|
|
||||||
String retAsXML = profile.read(name, false);
|
String retAsXML = profile.read(name, false);
|
||||||
logger.debug("Got XML (explicit) Profile {}", retAsXML);
|
logger.debug("Got XML (explicit) Profile {}", retAsXML);
|
||||||
is = new InputSource(new StringReader(retAsXML));
|
InputSource is2 = new InputSource(new StringReader(retAsXML));
|
||||||
dBuilder.parse(is);
|
dBuilder.parse(is2);
|
||||||
|
|
||||||
Assert.assertTrue(xml.compareTo(retAsXML) == 0);
|
//Assert.assertTrue(xml.compareTo(retAsXML) == 0);
|
||||||
|
|
||||||
String json = profile.read(name, true);
|
String json = profile.read(name, true);
|
||||||
logger.debug("Got JSON Profile {}", json);
|
logger.debug("Got JSON Profile {}\n", json);
|
||||||
mapper.readTree(json);
|
mapper.readTree(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final String PROFILE_NAME = "TestEmptyProfile";
|
||||||
|
public static final String PROFILE_XML = "<metadataformat type=\"%s\"><metadatafield><fieldName>test</fieldName><mandatory>false</mandatory><dataType>String</dataType><maxOccurs>1</maxOccurs><note>Test Field</note></metadatafield></metadataformat>";
|
||||||
|
|
||||||
|
// @Test
|
||||||
|
public void delete() throws Exception {
|
||||||
|
Profile profile = new Profile();
|
||||||
|
profile.delete(PROFILE_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void list() throws Exception {
|
||||||
|
Profile profile = new Profile();
|
||||||
|
String list = profile.list();
|
||||||
|
logger.debug("Got Profiles {}\n", list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void createDeleteTest() throws Exception {
|
||||||
|
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
JavaType arrayType = mapper.getTypeFactory().constructCollectionType(ArrayList.class, String.class);
|
||||||
|
|
||||||
|
Profile profile = new Profile();
|
||||||
|
profile.create(PROFILE_NAME, String.format(PROFILE_XML, PROFILE_NAME));
|
||||||
|
|
||||||
|
|
||||||
|
String list = profile.list();
|
||||||
|
logger.debug("Got Profiles {}\n", list);
|
||||||
|
|
||||||
|
boolean found = false;
|
||||||
|
int count = 1;
|
||||||
|
|
||||||
|
while(!found) {
|
||||||
|
List<String> profiles = mapper.readValue(list, arrayType);
|
||||||
|
if(profiles.contains(PROFILE_NAME)) {
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
if(count >= 5) {
|
||||||
|
throw new NotFoundException(String.format("%s not found after %d retries", PROFILE_NAME, count));
|
||||||
|
}
|
||||||
|
if(!found) {
|
||||||
|
Thread.sleep(TimeUnit.SECONDS.toMillis(2*count));
|
||||||
|
++count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String xml = profile.read(PROFILE_NAME);
|
||||||
|
|
||||||
|
profile.delete(PROFILE_NAME);
|
||||||
|
|
||||||
|
while(found) {
|
||||||
|
List<String> profiles = mapper.readValue(list, arrayType);
|
||||||
|
if(!profiles.contains(PROFILE_NAME)) {
|
||||||
|
found = false;
|
||||||
|
}
|
||||||
|
if(count >= 5) {
|
||||||
|
throw new Exception(String.format("%s still found after %d retries", PROFILE_NAME, count));
|
||||||
|
}
|
||||||
|
if(found) {
|
||||||
|
Thread.sleep(TimeUnit.SECONDS.toMillis(2*count));
|
||||||
|
++count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
/gcube/preprod/preVRE=3c5b250d-6101-467a-b343-601a495ed4dd-98187548
|
|
|
@ -1,19 +0,0 @@
|
||||||
GCUBE=0b47600a-1c53-4a47-b07b-03851cc28c8a-98187548
|
|
||||||
|
|
||||||
GCUBE_DEVNEXT=577013f6-2d07-4071-af7b-c3c6a064fbda-98187548
|
|
||||||
GCUBE_DEVNEXT_NEXTNEXT=7c66c94c-7f6e-49cd-9a34-909cd3832f3e-98187548
|
|
||||||
|
|
||||||
GCUBE_DEVSEC=a2c82e3a-82ca-4fd9-b37d-f1eb49a22bd5-98187548
|
|
||||||
GCUBE_DEVSEC_DEVVRE=4646ff97-40d1-443c-8cf9-5892957d3d64-98187548
|
|
||||||
|
|
||||||
GCUBE_DEVNEXT_ANOTHER_USER=52b59669-ccde-46d2-a4da-108b9e941f7c-98187548
|
|
||||||
GCUBE_DEVVRE_ANOTHER_USER=f851ba11-bd3e-417a-b2c2-753b02bac506-98187548
|
|
||||||
|
|
||||||
# accountingaggregator
|
|
||||||
# ROOT=18fed2d9-030b-4c77-93af-af2015d945f7-843339462
|
|
||||||
|
|
||||||
# luca.frosini
|
|
||||||
ROOT=cb220668-c7dc-4ed5-9e51-933125d0aa57-843339462
|
|
||||||
|
|
||||||
GCUBE_PRE_PROD_PREVRE=1ba19f5d-5ca1-44d6-a8b0-c081e722327e-98187548
|
|
||||||
GCUBE_PRE_PROD_PARTHENOS_REGISTRY=4ac1fb39-e24e-416e-a98b-ab30e997e745-98187548
|
|
Loading…
Reference in New Issue