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:
parent
a6b896ef74
commit
a0d1bd8be4
|
@ -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,11 +185,10 @@ public class SecurityContext {
|
|||
logger.error("{} was not dropped successfully", role);
|
||||
}
|
||||
|
||||
oSecurity.close(false);
|
||||
oDatabaseDocumentTx.commit();
|
||||
oDatabaseDocumentTx.close();
|
||||
|
||||
if (commit) {
|
||||
orientGraph.commit();
|
||||
}
|
||||
|
||||
logger.trace(
|
||||
"Security Context (roles and users) with UUID {} successfully removed",
|
||||
contextID);
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -30,7 +31,7 @@ public abstract class SecurityContextMapper {
|
|||
static {
|
||||
try {
|
||||
boolean created = DatabaseIntializator.initGraphDB();
|
||||
|
||||
|
||||
logger.trace("Creating factory for {} connecting as {}",
|
||||
DatabaseEnvironment.DB_URI,
|
||||
DatabaseEnvironment.DEFAULT_ADMIN_USERNAME);
|
||||
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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,16 +143,19 @@ 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,
|
||||
uuidString);
|
||||
|
||||
|
||||
String contextJsonString = Utility.toJsonString(context, true);
|
||||
logger.trace("Creating {}", contextJsonString);
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue