Testing
This commit is contained in:
parent
9954a653f7
commit
cdff7547a5
|
@ -14,8 +14,8 @@ public class GCubeTest {
|
||||||
// InterfaceConstants.SERVICE_CLASS="Application";
|
// InterfaceConstants.SERVICE_CLASS="Application";
|
||||||
// InterfaceConstants.SERVICE_NAME="GeoPortal";
|
// InterfaceConstants.SERVICE_NAME="GeoPortal";
|
||||||
|
|
||||||
// testContext = "/pred4s/preprod/preVRE";
|
testContext = "/pred4s/preprod/preVRE";
|
||||||
testContext= "/gcube/devsec/devVRE";
|
// testContext= "/gcube/devsec/devVRE";
|
||||||
|
|
||||||
System.out.println("TEST CONTEXT = "+testContext);
|
System.out.println("TEST CONTEXT = "+testContext);
|
||||||
return testContext;
|
return testContext;
|
||||||
|
|
|
@ -90,36 +90,37 @@ public class ExportConcessioniAsProjects {
|
||||||
AtomicLong warnCount = new AtomicLong(0);
|
AtomicLong warnCount = new AtomicLong(0);
|
||||||
AtomicLong errCount = new AtomicLong(0);
|
AtomicLong errCount = new AtomicLong(0);
|
||||||
|
|
||||||
ExecutorService service = Executors.newFixedThreadPool(3);
|
ExecutorService service = Executors.newFixedThreadPool(1);
|
||||||
|
|
||||||
long startProcess = System.currentTimeMillis();
|
long startProcess = System.currentTimeMillis();
|
||||||
|
|
||||||
importFolder.getRelationshipMap().forEach((s,l)->{
|
importFolder.getRelationshipMap().forEach((s,l)->{
|
||||||
|
|
||||||
AtomicReference<Boolean> isSetOk = new AtomicReference<>(true);
|
AtomicReference<Boolean> publish = new AtomicReference<>(true);
|
||||||
|
AtomicReference<Boolean> delete = new AtomicReference<>(false);
|
||||||
// Check if exists
|
// Check if exists
|
||||||
Concessione c = l.get(0);
|
Concessione c = l.get(0);
|
||||||
try {
|
try {
|
||||||
List<Project> existing= getExisting(c,client);
|
List<Project> existing= getExisting(c,client);
|
||||||
if(existing.isEmpty()) {
|
if(existing.isEmpty()) log.info("Not Found {}",c.getNome());
|
||||||
log.info("Not Found");
|
else {
|
||||||
}else {
|
// found projects, check status
|
||||||
existing.forEach(project -> {
|
existing.forEach(project -> {
|
||||||
if (!project.getLifecycleInformation().getLastOperationStatus().equals(LifecycleInformation.Status.OK))
|
if (!project.getLifecycleInformation().getLastOperationStatus().equals(LifecycleInformation.Status.OK))
|
||||||
isSetOk.set(false);
|
delete.set(true);
|
||||||
});
|
});
|
||||||
if(!isSetOk.get()){
|
if(delete.get()){
|
||||||
log.debug("Deleting error set for {}",c.getNome());
|
log.debug("Deleting error set for {}",c.getNome());
|
||||||
for (Project project : existing) {
|
for (Project project : existing) {
|
||||||
client.deleteById(project.getId());
|
client.deleteById(project.getId());
|
||||||
}
|
}
|
||||||
}
|
}else publish.set(false);
|
||||||
}
|
}
|
||||||
}catch(NullPointerException e){}
|
}catch(NullPointerException e){}
|
||||||
catch (Throwable t){throw new RuntimeException("Unexpected Exception while checking for "+c.getNome());}
|
catch (Throwable t){throw new RuntimeException("Unexpected Exception while checking for "+c.getNome());}
|
||||||
|
|
||||||
|
log.info("Project name {} publish : {}",s,publish);
|
||||||
if(!isSetOk.get()) {
|
if(publish.get()) {
|
||||||
String relationshipTarget = null;
|
String relationshipTarget = null;
|
||||||
for (Concessione concessione : l) {
|
for (Concessione concessione : l) {
|
||||||
|
|
||||||
|
@ -426,7 +427,7 @@ public class ExportConcessioniAsProjects {
|
||||||
private static List<Project> getExisting(Concessione c,Projects client) throws RemoteException, JsonProcessingException, NullPointerException {
|
private static List<Project> getExisting(Concessione c,Projects client) throws RemoteException, JsonProcessingException, NullPointerException {
|
||||||
try {
|
try {
|
||||||
QueryRequest req = new QueryRequest();
|
QueryRequest req = new QueryRequest();
|
||||||
String queryString = String.format("{\"_theDocument.nome\" :{\"$eq\" : \"%1$s\"}}", c.getNome());
|
String queryString = String.format("{\"_theDocument.nome\" :{\"$eq\" : %1$s}}", quote(c.getNome()));
|
||||||
log.debug("Query String is {}", queryString);
|
log.debug("Query String is {}", queryString);
|
||||||
req.setFilter(Document.parse(queryString));
|
req.setFilter(Document.parse(queryString));
|
||||||
AtomicInteger count = new AtomicInteger(0);
|
AtomicInteger count = new AtomicInteger(0);
|
||||||
|
@ -446,4 +447,59 @@ public class ExportConcessioniAsProjects {
|
||||||
throw t;
|
throw t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static String quote(String string) {
|
||||||
|
if (string == null || string.length() == 0) {
|
||||||
|
return "\"\"";
|
||||||
|
}
|
||||||
|
|
||||||
|
char c = 0;
|
||||||
|
int i;
|
||||||
|
int len = string.length();
|
||||||
|
StringBuilder sb = new StringBuilder(len + 4);
|
||||||
|
String t;
|
||||||
|
|
||||||
|
sb.append('"');
|
||||||
|
for (i = 0; i < len; i += 1) {
|
||||||
|
c = string.charAt(i);
|
||||||
|
switch (c) {
|
||||||
|
case '\\':
|
||||||
|
case '"':
|
||||||
|
sb.append('\\');
|
||||||
|
sb.append(c);
|
||||||
|
break;
|
||||||
|
case '/':
|
||||||
|
// if (b == '<') {
|
||||||
|
sb.append('\\');
|
||||||
|
// }
|
||||||
|
sb.append(c);
|
||||||
|
break;
|
||||||
|
case '\b':
|
||||||
|
sb.append("\\b");
|
||||||
|
break;
|
||||||
|
case '\t':
|
||||||
|
sb.append("\\t");
|
||||||
|
break;
|
||||||
|
case '\n':
|
||||||
|
sb.append("\\n");
|
||||||
|
break;
|
||||||
|
case '\f':
|
||||||
|
sb.append("\\f");
|
||||||
|
break;
|
||||||
|
case '\r':
|
||||||
|
sb.append("\\r");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (c < ' ') {
|
||||||
|
t = "000" + Integer.toHexString(c);
|
||||||
|
sb.append("\\u" + t.substring(t.length() - 4));
|
||||||
|
} else {
|
||||||
|
sb.append(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sb.append('"');
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue