Fixing revealed bugs

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@133608 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2016-10-26 16:28:00 +00:00
parent a6b896ef74
commit a0d1bd8be4
4 changed files with 21 additions and 14 deletions

View File

@ -9,6 +9,7 @@ import org.gcube.informationsystem.resourceregistry.dbinitialization.DatabaseEnv
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx;
import com.orientechnologies.orient.core.metadata.security.ORestrictedOperation;
import com.orientechnologies.orient.core.metadata.security.ORole;
import com.orientechnologies.orient.core.metadata.security.OSecurity;
@ -138,9 +139,8 @@ public class SecurityContext {
logger.trace(
"Going to remove Security Context (roles and users) with UUID {}",
contextID);
OSecurity oSecurity = orientGraph.getRawGraph().getMetadata()
.getSecurity();
ODatabaseDocumentTx oDatabaseDocumentTx = orientGraph.getRawGraph();
OSecurity oSecurity = oDatabaseDocumentTx.getMetadata().getSecurity();
String user = SecurityContextMapper.getSecurityRoleOrUserName(
SecurityContextMapper.PermissionMode.READER,
@ -185,10 +185,9 @@ public class SecurityContext {
logger.error("{} was not dropped successfully", role);
}
if (commit) {
orientGraph.commit();
}
oSecurity.close(false);
oDatabaseDocumentTx.commit();
oDatabaseDocumentTx.close();
logger.trace(
"Security Context (roles and users) with UUID {} successfully removed",

View File

@ -11,6 +11,7 @@ import org.gcube.informationsystem.resourceregistry.dbinitialization.DatabaseInt
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.orientechnologies.orient.client.remote.OStorageRemote;
import com.tinkerpop.blueprints.impls.orient.OrientGraph;
import com.tinkerpop.blueprints.impls.orient.OrientGraphFactory;
@ -43,6 +44,9 @@ public abstract class SecurityContextMapper {
DatabaseEnvironment.CHANGED_ADMIN_PASSWORD)
.setupPool(1, 10);
factory.setConnectionStrategy(OStorageRemote.CONNECTION_STRATEGY
.ROUND_ROBIN_CONNECT.toString());
for (PermissionMode p : PermissionMode.values()) {
Map<String, OrientGraphFactory> map = new HashMap<>();
map.put(null, factory);
@ -121,6 +125,8 @@ public abstract class SecurityContextMapper {
factory = new OrientGraphFactory(DatabaseEnvironment.DB_URI,
username, password).setupPool(1, 10);
factory.setConnectionStrategy(OStorageRemote.CONNECTION_STRATEGY
.ROUND_ROBIN_CONNECT.toString());
permissionSecurityContextFactories.put(contextID, factory);
}

View File

@ -27,6 +27,7 @@ import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery;
import com.tinkerpop.blueprints.Direction;
import com.tinkerpop.blueprints.Edge;
import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.blueprints.impls.orient.OrientEdge;
import com.tinkerpop.blueprints.impls.orient.OrientGraph;
import com.tinkerpop.blueprints.impls.orient.OrientVertex;
@ -142,11 +143,14 @@ public class ContextManagementImpl implements ContextManagement {
OrientVertex context = orientGraph.addVertex("class:"
+ Context.NAME);
context.setProperty(Context.NAME_PROPERTY, name);
context.save();
HeaderUtility.addHeader(context, uuid);
if (parentContextUUID != null) {
orientGraph.addEdge(null, parent, context, IsParentOf.NAME);
OrientEdge edge = orientGraph.addEdge(null, parent, context, IsParentOf.NAME);
HeaderUtility.addHeader(edge, null);
edge.save();
}
SecurityContext.addToSecurityContext(orientGraph, context,

View File

@ -219,7 +219,6 @@ public class EntityManagementImpl implements EntityManagement {
return null;
}
public static Map<String, Object> getPropertyMap(JsonNode jsonNode,
Set<String> ignoreKeys) throws JsonProcessingException, IOException{
@ -815,7 +814,6 @@ public class EntityManagementImpl implements EntityManagement {
return jsonObject.toString();
}
@Override
public String createResource(String resourceType, String jsonRepresentation)
throws ResourceRegistryException {