diff --git a/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/ServiceClass.java b/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/ServiceClass.java index d235e9a4..eb513173 100644 --- a/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/ServiceClass.java +++ b/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/ServiceClass.java @@ -550,10 +550,10 @@ public Response storeGraph(@DefaultValue("unnamed") @QueryParam("name") String n Check if user has a limit regarding number of graph or covers and throw an error if the limit is violated. */ - if (userLimitsHandler.reachedGraphCountLimit(username)){ - requestHandler.log(Level.WARNING, "user: " + username + " reached graph count limit."); - return requestHandler.writeError(Error.INTERNAL, "Graph count limit reached. Delete a graph before generating a new one, or contact administrator to adjust limits."); - } + //if (userLimitsHandler.reachedGraphCountLimit(username)){ + // requestHandler.log(Level.WARNING, "user: " + username + " reached graph count limit."); + // return requestHandler.writeError(Error.INTERNAL, "Graph count limit reached. Delete a graph before generating a new one, or contact administrator to adjust limits."); + //} File graphDir = new File("tmp" + File.separator + username); if (!graphDir.exists()) { @@ -915,16 +915,12 @@ public Response getMultiplexGraph(@DefaultValue("GRAPH_ML") @QueryParam("outputF return requestHandler.writeError(Error.PARAMETER_INVALID, "Specified graph output format does not exist."); } - System.out.println("serviceclass: format"); - System.out.println(format); MultiplexGraph graph = database.getMultiplexGraph(username, graphIdStr); - System.out.println("serviceclass: graph.name"); - System.out.println(graph.getName()); if (graph == null) return requestHandler.writeError(Error.PARAMETER_INVALID, "Graph does not exist: graph key " + graphIdStr); - generalLogger.getLogger().log(Level.INFO, "user " + username + ": get cover " + graphIdStr + " in format " + graphOutputFormatStr ); + generalLogger.getLogger().log(Level.INFO, "user " + username + ": get multiplex graph " + graphIdStr + " in format " + graphOutputFormatStr ); return Response.ok(requestHandler.writeMultiplexGraph(graph, format)).build(); } catch (Exception e) { requestHandler.log(Level.SEVERE, "", e); @@ -952,7 +948,7 @@ public Response getMultiplexGraph(@DefaultValue("GRAPH_ML") @QueryParam("outputF @ApiOperation(tags = {"delete"}, value = "Delete Graph", notes = "Deletes a graph.") public Response deleteGraph(@PathParam("graphId") String graphIdStr) { try { - + System.out.println("ServiceClass: deleteGraph"); String username = ((UserAgent) Context.getCurrent().getMainAgent()).getLoginName(); try { database.deleteGraph(username, graphIdStr, threadHandler); //done @@ -990,18 +986,21 @@ public Response deleteGraph(@PathParam("graphId") String graphIdStr) { @ApiOperation(tags = {"delete"}, value = "Delete Graph", notes = "Deletes a graph.") public Response deleteMultiplexGraph(@PathParam("graphId") String graphIdStr) { try { - + System.out.println("ServiceClass: 1"); String username = ((UserAgent) Context.getCurrent().getMainAgent()).getLoginName(); try { - database.deleteMultiplexGraph(username, graphIdStr, threadHandler); //done - + database.deleteMultiplexGraph(username, graphIdStr, threadHandler); + System.out.println("ServiceClass: 2"); } catch (Exception e) { if(e.getMessage() != null) { requestHandler.writeError(Error.INTERNAL, "Graph could not be deleted: " + e.getMessage()); + System.out.println("ServiceClass: 3"); } requestHandler.writeError(Error.INTERNAL, "Graph not found"); + System.out.println("ServiceClass: 4"); } generalLogger.getLogger().log(Level.INFO, "user " + username + ": delete graph " + graphIdStr); + System.out.println("ServiceClass: 5"); return Response.ok(requestHandler.writeConfirmationXml()).build(); } catch (Exception e) { requestHandler.log(Level.SEVERE, "", e); @@ -1046,10 +1045,10 @@ public Response createCover(@PathParam("graphId") String graphIdStr, /* Check if user has a limit regarding covers and throw an error if the limit is violated. */ - if (userLimitsHandler.reachedCoverCountLimit(username)){ - requestHandler.log(Level.WARNING, "user: " + username + " reached cover count limit."); - return requestHandler.writeError(Error.INTERNAL, "Cover count limit reached. Delete a cover before generating a new one, or contact administrator to adjust limits."); - } + //if (userLimitsHandler.reachedCoverCountLimit(username)){ + // requestHandler.log(Level.WARNING, "user: " + username + " reached cover count limit."); + // return requestHandler.writeError(Error.INTERNAL, "Cover count limit reached. Delete a cover before generating a new one, or contact administrator to adjust limits."); + //} CoverInputFormat format; try { @@ -2295,14 +2294,14 @@ public Response runGroundTruthBenchmark(@DefaultValue("unnamed") @QueryParam("co /* Check if user has a limit regarding number of graph or covers and throw an error if the limit is violated. */ - if (userLimitsHandler.reachedGraphCountLimit(username)){ - requestHandler.log(Level.WARNING, "user: " + username + " reached graph count limit."); - return requestHandler.writeError(Error.INTERNAL, "Graph count limit reached. Delete a graph before generating a new one, or contact administrator to adjust limits."); - } - if (userLimitsHandler.reachedCoverCountLimit(username)){ - requestHandler.log(Level.WARNING, "user: " + username + " reached cover count limit."); - return requestHandler.writeError(Error.INTERNAL, "Cover count limit reached. Delete a cover before generating a new one, or contact administrator to adjust limits."); - } + //if (userLimitsHandler.reachedGraphCountLimit(username)){ + // requestHandler.log(Level.WARNING, "user: " + username + " reached graph count limit."); + // return requestHandler.writeError(Error.INTERNAL, "Graph count limit reached. Delete a graph before generating a new one, or contact administrator to adjust limits."); + //} + //if (userLimitsHandler.reachedCoverCountLimit(username)){ + // requestHandler.log(Level.WARNING, "user: " + username + " reached cover count limit."); + // return requestHandler.writeError(Error.INTERNAL, "Cover count limit reached. Delete a cover before generating a new one, or contact administrator to adjust limits."); + //} GraphCreationType benchmarkType; @@ -3327,12 +3326,33 @@ public Response getAlgorithmCompatibleGraphTypes(@PathParam("CoverCreationType") @ApiOperation(tags = {"names"}, value = "Algorithms information", notes = "Returns all algorithm type names.") public Response getAlgorithmNames() { try { + System.out.println("ServiceClass: getAlgorithmNames: " + requestHandler.writeAlgorithmNames()); return Response.ok(requestHandler.writeAlgorithmNames()).build(); } catch (Exception e) { requestHandler.log(Level.SEVERE, "", e); return requestHandler.writeError(Error.INTERNAL, "Internal system error."); } } + + /** + * Returns all algorithm type names. + * + * @return The types in a names xml. Or an error xml. + */ + @GET + @Path("multiplexalgorithms") + @Produces(MediaType.TEXT_XML) + @ApiResponses(value = { @ApiResponse(code = 200, message = "Success"), + @ApiResponse(code = 401, message = "Unauthorized") }) + @ApiOperation(tags = {"names"}, value = "Algorithms information", notes = "Returns all algorithm type names.") + public Response getMultiplexAlgorithmNames() { + try { + return Response.ok(requestHandler.writeMultiplexAlgorithmNames()).build(); + } catch (Exception e) { + requestHandler.log(Level.SEVERE, "", e); + return requestHandler.writeError(Error.INTERNAL, "Internal system error."); + } + } /** * Returns all centrality measure names. diff --git a/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/graphs/CustomGraph.java b/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/graphs/CustomGraph.java index e383c573..3c68f935 100644 --- a/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/graphs/CustomGraph.java +++ b/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/graphs/CustomGraph.java @@ -1683,6 +1683,10 @@ public static CustomGraph load(String key, ArangoDatabase db, String transId) { ArangoCollection collection = db.collection(collectionName); DocumentReadOptions readOpt = new DocumentReadOptions().streamTransactionId(transId); AqlQueryOptions queryOpt = new AqlQueryOptions().streamTransactionId(transId); + System.out.println("Graph load: collection: " + collection); + System.out.println("Graph load: key: " + key); + System.out.println("Graph load: BaseDocument.class: " + BaseDocument.class); + System.out.println("Graph load: readOpt: " + readOpt); BaseDocument bd = collection.getDocument(key, BaseDocument.class, readOpt); if (bd != null) { diff --git a/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/graphs/MultiplexGraph.java b/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/graphs/MultiplexGraph.java index cc91015c..943513ae 100644 --- a/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/graphs/MultiplexGraph.java +++ b/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/graphs/MultiplexGraph.java @@ -290,7 +290,11 @@ public static MultiplexGraph load(String key, ArangoDatabase db, String transId) MultiplexGraph graph = null; ArangoCollection collection = db.collection(collectionName); DocumentReadOptions readOpt = new DocumentReadOptions().streamTransactionId(transId); - AqlQueryOptions queryOpt = new AqlQueryOptions().streamTransactionId(transId); + //AqlQueryOptions queryOpt = new AqlQueryOptions().streamTransactionId(transId); + System.out.println("MultiplexGraph load: collection: " + collection); + System.out.println("MultiplexGraph load: key: " + key); + System.out.println("MultiplexGraph load: BaseDocument.class: " + BaseDocument.class); + System.out.println("MultiplexGraph load: readOpt: " + readOpt); BaseDocument bd = collection.getDocument(key, BaseDocument.class, readOpt); if (bd != null) { diff --git a/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/utils/Database.java b/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/utils/Database.java index 349c5790..5215ccbe 100644 --- a/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/utils/Database.java +++ b/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/utils/Database.java @@ -296,8 +296,6 @@ private MultiplexGraph getMultiplexGraph(String key) { db.abortStreamTransaction(transId); throw e; } - System.out.println("Database getMultiplexGraph(key): graph.name"); - System.out.println(graph.getName()); return graph; } @@ -435,7 +433,6 @@ public ArrayList getGraphMetaDataEfficiently(String username, i * @return the list of graphs */ public ArrayList getMultiplexGraphMetaDataOfLayersEfficiently(String username, String key){ - System.out.println("key in database:" + key); String transId = getTransactionId(MultiplexGraph.class, false); ObjectMapper objectMapper = new ObjectMapper(); // needed to instantiate CustomGraphMeta from JSON ArrayList customGraphMetas = new ArrayList(); @@ -708,6 +705,7 @@ public void deleteMultiplexGraph(String username, String graphKey, ThreadHandler threadHandler.interruptBenchmark(id); List coverList = getCovers(username, graphKey); + System.out.println("Database: 1 : coverlist : " + coverList); for (Cover cover : coverList) { try { deleteCover(cover, threadHandler); @@ -715,10 +713,8 @@ public void deleteMultiplexGraph(String username, String graphKey, ThreadHandler throw e; } } - + System.out.println("Database: 2 : coverlist : " + coverList); try { - MultiplexGraph graph = getMultiplexGraph(username, graphKey); - String transId = this.getTransactionId(null, true); DocumentReadOptions readOpt = new DocumentReadOptions().streamTransactionId(transId); DocumentDeleteOptions deleteOpt = new DocumentDeleteOptions().streamTransactionId(transId); @@ -1991,9 +1987,10 @@ else if(c == SimulationSeriesGroup.class){ } else if(c == MultiplexGraph.class) { collections = new String[] {collectionNames.get(0),collectionNames.get(1),collectionNames.get(2),collectionNames.get(3),collectionNames.get(4),collectionNames.get(13)}; + System.out.println("Database: getTransactionId: " + collections); } else { - collections = collectionNames.subList(0, 13).toArray(new String[10]); + collections = collectionNames.subList(0, 14).toArray(new String[10]); } StreamTransactionEntity tx; if(write) { diff --git a/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/utils/RequestHandler.java b/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/utils/RequestHandler.java index ccc59363..041f928e 100644 --- a/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/utils/RequestHandler.java +++ b/rest_ocd_services/src/main/java/i5/las2peer/services/ocd/utils/RequestHandler.java @@ -22,6 +22,7 @@ import i5.las2peer.services.ocd.adapters.graphOutput.GraphOutputAdapterFactory; import i5.las2peer.services.ocd.adapters.graphOutput.GraphOutputFormat; import i5.las2peer.services.ocd.adapters.metaOutput.*; +import i5.las2peer.services.ocd.algorithms.ABACUSAlgorithm; import i5.las2peer.services.ocd.centrality.data.CentralityMap; import i5.las2peer.services.ocd.centrality.data.CentralityMeasureType; import i5.las2peer.services.ocd.centrality.data.CentralityMeta; @@ -680,8 +681,6 @@ public String writeMultiplexGraph(MultiplexGraph graph, GraphOutputFormat output Writer writer = new StringWriter(); adapter.setWriter(writer); adapter.writeGraph(graph); - System.out.println("Requesthandler: writeMultiplexGraph"); - System.out.println(writer.toString()); return writer.toString(); } @@ -880,6 +879,7 @@ public String writeAlgorithmNames() throws ParserConfigurationException { Element namesElt = doc.createElement("Names"); for(CoverCreationType e : CoverCreationType.class.getEnumConstants()) { if(e.correspondsAlgorithm()) { + System.out.println("requestHandler.writeAlgorithmNames()" + e.getDisplayName()); Element nameElt = doc.createElement("Name"); nameElt.appendChild(doc.createTextNode(e.name())); nameElt.setAttribute("displayName", e.getDisplayName()); @@ -889,6 +889,29 @@ public String writeAlgorithmNames() throws ParserConfigurationException { doc.appendChild(namesElt); return writeDoc(doc); } + + /** + * Creates an XML document containing all ocd algorithm names. + * @return The document. + * @throws ParserConfigurationException if parsing failed + */ + public String writeMultiplexAlgorithmNames() throws ParserConfigurationException { + Document doc = getDocument(); + Element namesElt = doc.createElement("Names"); + for(CoverCreationType e : CoverCreationType.class.getEnumConstants()) { + if(e.correspondsAlgorithm()) { + if(e.getDisplayName() == "ABACUS Algorithm") { + System.out.println("requestHandler.writeMultiplexAlgorithmNames()" + e.getDisplayName()); + Element nameElt = doc.createElement("Name"); + nameElt.appendChild(doc.createTextNode(e.name())); + nameElt.setAttribute("displayName", e.getDisplayName()); + namesElt.appendChild(nameElt); + } + } + } + doc.appendChild(namesElt); + return writeDoc(doc); + } /** * Creates an XML document containing all centrality measure names. diff --git a/time_seed.dat b/time_seed.dat index 1bcd5a21..a9033fc2 100644 --- a/time_seed.dat +++ b/time_seed.dat @@ -1 +1 @@ -21113101 \ No newline at end of file +21113242 \ No newline at end of file