Fixes #13180: Migrate OrientDB from version 2.2.X to 3.0.X
Task-Url: https://support.d4science.org/issues/13180 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@177123 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
1e14003aa8
commit
e7e7cc588e
|
@ -156,7 +156,7 @@ public abstract class ERManagement<ERType extends ER, El extends Element> {
|
|||
if(oClass == null) {
|
||||
if(element != null) {
|
||||
OrientElement orientElement = (OrientElement) element;
|
||||
OMetadata oMetadata = orientElement.getGraph().getRawGraph().getMetadata();
|
||||
OMetadata oMetadata = orientElement.getRecord().getDatabase().getMetadata();
|
||||
OSchema oSchema = oMetadata.getSchema();
|
||||
String type = orientElement.getRecord().getClassName();
|
||||
oClass = oSchema.getClass(type);
|
||||
|
|
|
@ -31,7 +31,6 @@ import org.gcube.informationsystem.resourceregistry.utils.PropagationConstraintO
|
|||
import org.gcube.informationsystem.resourceregistry.utils.Utility;
|
||||
import org.gcube.informationsystem.utils.ISMapper;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
|
|
|
@ -25,10 +25,10 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.orientechnologies.orient.core.db.ODatabaseSession;
|
||||
import com.orientechnologies.orient.core.metadata.security.ORole;
|
||||
import com.orientechnologies.orient.core.metadata.security.OSecurity;
|
||||
import com.orientechnologies.orient.core.metadata.security.OUser;
|
||||
import com.tinkerpop.blueprints.impls.orient.OrientGraph;
|
||||
|
||||
public class ContextManagementTest extends ScopedTest {
|
||||
|
||||
|
@ -40,8 +40,8 @@ public class ContextManagementTest extends ScopedTest {
|
|||
|
||||
protected void assertions(Context pre, Context post, boolean checkParent, boolean create)
|
||||
throws ResourceRegistryException {
|
||||
if (checkParent) {
|
||||
if (pre.getHeader() != null) {
|
||||
if(checkParent) {
|
||||
if(pre.getHeader() != null) {
|
||||
FacetManagementTest.checkHeader(post, pre.getHeader().getUUID(), create);
|
||||
} else {
|
||||
FacetManagementTest.checkHeader(post, null, create);
|
||||
|
@ -49,7 +49,7 @@ public class ContextManagementTest extends ScopedTest {
|
|||
}
|
||||
|
||||
Assert.assertTrue(pre.getName().compareTo(post.getName()) == 0);
|
||||
if (checkParent && pre.getParent() != null && post.getParent() != null) {
|
||||
if(checkParent && pre.getParent() != null && post.getParent() != null) {
|
||||
Context preParent = pre.getParent().getSource();
|
||||
Context postParent = post.getParent().getSource();
|
||||
assertions(preParent, postParent, false, false);
|
||||
|
@ -62,8 +62,8 @@ public class ContextManagementTest extends ScopedTest {
|
|||
ContextUtility.getInstance().addSecurityContext(contextSecurityContext.getUUID().toString(),
|
||||
contextSecurityContext);
|
||||
|
||||
OrientGraph orientGraph = contextSecurityContext.getGraph(PermissionMode.READER);
|
||||
OSecurity oSecurity = orientGraph.getRawGraph().getMetadata().getSecurity();
|
||||
ODatabaseSession oDatabaseSession = contextSecurityContext.getDatabaseSession(PermissionMode.READER);
|
||||
OSecurity oSecurity = oDatabaseSession.getMetadata().getSecurity();
|
||||
|
||||
SecurityContext securityContext = null;
|
||||
if(deleted) {
|
||||
|
@ -72,9 +72,9 @@ public class ContextManagementTest extends ScopedTest {
|
|||
securityContext = ContextUtility.getInstance().getSecurityContextByUUID(uuid);
|
||||
}
|
||||
|
||||
boolean[] booleanArray = new boolean[] { false, true };
|
||||
for (boolean hierarchic : booleanArray) {
|
||||
for (PermissionMode permissionMode : PermissionMode.values()) {
|
||||
boolean[] booleanArray = new boolean[] {false, true};
|
||||
for(boolean hierarchic : booleanArray) {
|
||||
for(PermissionMode permissionMode : PermissionMode.values()) {
|
||||
String role = securityContext.getSecurityRoleOrUserName(permissionMode, SecurityType.ROLE, hierarchic);
|
||||
ORole oRole = oSecurity.getRole(role);
|
||||
Assert.assertEquals(oRole == null, deleted);
|
||||
|
@ -82,20 +82,21 @@ public class ContextManagementTest extends ScopedTest {
|
|||
String user = securityContext.getSecurityRoleOrUserName(permissionMode, SecurityType.USER, hierarchic);
|
||||
OUser oUser = oSecurity.getUser(user);
|
||||
Assert.assertEquals(oUser == null, deleted);
|
||||
if(oUser!=null) {
|
||||
if(oUser != null) {
|
||||
Assert.assertTrue(oUser.hasRole(oRole.getName(), false));
|
||||
}
|
||||
|
||||
if(hierarchic) {
|
||||
SecurityContext parent = null;
|
||||
if(deleted){
|
||||
if(oldParentUUID!=null) {
|
||||
if(deleted) {
|
||||
if(oldParentUUID != null) {
|
||||
parent = ContextUtility.getInstance().getSecurityContextByUUID(oldParentUUID);
|
||||
}
|
||||
}
|
||||
parent = securityContext.getParentSecurityContext();
|
||||
while(parent!=null) {
|
||||
String parentUser = parent.getSecurityRoleOrUserName(permissionMode, SecurityType.USER, hierarchic);
|
||||
while(parent != null) {
|
||||
String parentUser = parent.getSecurityRoleOrUserName(permissionMode, SecurityType.USER,
|
||||
hierarchic);
|
||||
OUser parentOUser = oSecurity.getUser(parentUser);
|
||||
Assert.assertTrue(parentOUser != null);
|
||||
Assert.assertEquals(parentOUser.hasRole(oRole.getName(), false), !deleted);
|
||||
|
@ -145,7 +146,7 @@ public class ContextManagementTest extends ScopedTest {
|
|||
SecurityContext securityContext = ContextUtility.getInstance().getSecurityContextByUUID(uuid);
|
||||
|
||||
UUID oldParentUUID = null;
|
||||
if(securityContext.getParentSecurityContext()!=null) {
|
||||
if(securityContext.getParentSecurityContext() != null) {
|
||||
oldParentUUID = securityContext.getParentSecurityContext().getUUID();
|
||||
}
|
||||
|
||||
|
@ -164,7 +165,7 @@ public class ContextManagementTest extends ScopedTest {
|
|||
try {
|
||||
Context c = create(context);
|
||||
throw new RuntimeException(ISMapper.marshal(c) + " was created successfully. This is not what we expected");
|
||||
} catch (ContextAlreadyPresentException e) {
|
||||
} catch(ContextAlreadyPresentException e) {
|
||||
logger.debug("As expected {} cannot be created.", ISMapper.marshal(context));
|
||||
}
|
||||
}
|
||||
|
@ -173,7 +174,7 @@ public class ContextManagementTest extends ScopedTest {
|
|||
try {
|
||||
Context c = update(context);
|
||||
throw new RuntimeException(ISMapper.marshal(c) + " was updated successfully. This is not what we expected");
|
||||
} catch (ContextAlreadyPresentException e) {
|
||||
} catch(ContextAlreadyPresentException e) {
|
||||
logger.debug("As expected {} cannot be updated.", ISMapper.marshal(context));
|
||||
}
|
||||
}
|
||||
|
@ -183,7 +184,7 @@ public class ContextManagementTest extends ScopedTest {
|
|||
try {
|
||||
delete(context);
|
||||
throw new RuntimeException(contextString + " was deleted successfully. This is not what we expected");
|
||||
} catch (ContextException e) {
|
||||
} catch(ContextException e) {
|
||||
logger.debug("As expected {} cannot be deleted.", contextString);
|
||||
}
|
||||
}
|
||||
|
@ -372,7 +373,6 @@ public class ContextManagementTest extends ScopedTest {
|
|||
// B3______________A5
|
||||
*/
|
||||
|
||||
|
||||
// The following delete are not allowed because they are not child contexts
|
||||
invalidDelete(contextA1);
|
||||
invalidDelete(contextA2);
|
||||
|
@ -385,7 +385,7 @@ public class ContextManagementTest extends ScopedTest {
|
|||
|
||||
try {
|
||||
delete(contextA5);
|
||||
} catch (ContextNotFoundException e) {
|
||||
} catch(ContextNotFoundException e) {
|
||||
logger.debug("The context with uuid {} was not found. (Was already deleted)",
|
||||
contextA5.getHeader().getUUID());
|
||||
}
|
||||
|
@ -409,7 +409,7 @@ public class ContextManagementTest extends ScopedTest {
|
|||
logger.debug("The DB should be now clean");
|
||||
}
|
||||
|
||||
private List<Context> getAll() throws Exception{
|
||||
private List<Context> getAll() throws Exception {
|
||||
ContextManagement contextManagement = new ContextManagement();
|
||||
String allString = contextManagement.all(false);
|
||||
logger.trace(allString);
|
||||
|
@ -437,10 +437,10 @@ public class ContextManagementTest extends ScopedTest {
|
|||
@Test
|
||||
public void testGetAll() throws Exception {
|
||||
List<Context> contexts = getAll();
|
||||
for (Context context : contexts) {
|
||||
for(Context context : contexts) {
|
||||
logger.trace(ISMapper.marshal(context));
|
||||
List<IsParentOf<Context, Context>> children = context.getChildren();
|
||||
for (IsParentOf<Context, Context> child : children) {
|
||||
List<IsParentOf<Context,Context>> children = context.getChildren();
|
||||
for(IsParentOf<Context,Context> child : children) {
|
||||
Assert.assertTrue(child.getSource() == context);
|
||||
Context childContext = child.getTarget();
|
||||
Assert.assertTrue(childContext.getParent().getSource() == context);
|
||||
|
@ -455,7 +455,6 @@ public class ContextManagementTest extends ScopedTest {
|
|||
logger.debug("{}", context);
|
||||
}
|
||||
|
||||
|
||||
// @Test
|
||||
public void deleteContext() throws ResourceRegistryException, IOException {
|
||||
Context context = read(UUID.fromString(""));
|
||||
|
|
Loading…
Reference in New Issue