From 04a86e0280f516f69bc06f87b8a261327c22aa8b Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Tue, 18 Apr 2023 11:21:24 +0200 Subject: [PATCH] Incremented logs --- .../engine/mongo/ProfiledMongoManager.java | 22 ++-- .../service/rest/ProfiledDocuments.java | 122 ++++++++++++++++++ 2 files changed, 135 insertions(+), 9 deletions(-) diff --git a/geoportal-service/src/main/java/org/gcube/application/geoportal/service/engine/mongo/ProfiledMongoManager.java b/geoportal-service/src/main/java/org/gcube/application/geoportal/service/engine/mongo/ProfiledMongoManager.java index d1933ea..3070256 100644 --- a/geoportal-service/src/main/java/org/gcube/application/geoportal/service/engine/mongo/ProfiledMongoManager.java +++ b/geoportal-service/src/main/java/org/gcube/application/geoportal/service/engine/mongo/ProfiledMongoManager.java @@ -156,13 +156,15 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI< protected Project unlockAndUpdate(Project proj) throws InvalidLockException, ProjectNotFoundException, JsonProcessingException, InvalidUserRoleException, UnauthorizedAccess { - log.trace("Unlocking for update {} lock is {} ", proj.getId(), proj.getLock()); + log.info("Unlocking for update {} lock is {} ", proj.getId(), proj.getLock()); // find one and update Lock oldLock = proj.getLock(); proj.setLock(null); Document filter = new Document(mongoIDFieldName(), asId(proj.getId())).append(Project.LOCK + "." + Lock.ID, oldLock.getId()); + + log.info("Filter document is {} ", filter.toJson()); Object obj = getCollection().findOneAndReplace( // filter by id and missing lock @@ -181,13 +183,15 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI< protected Project unlockAndPatch(Project proj) throws InvalidLockException, ProjectNotFoundException, JsonProcessingException, InvalidUserRoleException, UnauthorizedAccess { - log.trace("Unlocking for patching {} lock is {} ", proj.getId(), proj.getLock()); + log.info("Unlocking for patching {} lock is {} ", proj.getId(), proj.getLock()); // find one and update Lock oldLock = proj.getLock(); proj.setLock(null); Document filter = new Document(mongoIDFieldName(), asId(proj.getId())).append(Project.LOCK + "." + Lock.ID, oldLock.getId()); + + log.info("Filter document is {} ", filter.toJson()); Object obj = getCollection().findOneAndUpdate( // filter by id and missing lock @@ -367,7 +371,7 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI< toUpdate.setTheDocument(toSet); toUpdate.getLifecycleInformation().cleanState(); - toUpdate = onPatch(toUpdate); + toUpdate = onUpdate(toUpdate); return unlockAndPatch(toUpdate); } catch (Throwable t) { log.error("Unexpected exception ", t); @@ -517,12 +521,12 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI< return triggerEvent(toUpdate, EventExecutionRequest.Events.ON_INIT_DOCUMENT, null); } - private Project onPatch(Project toUpdate) throws EventException { - UserUtils.AuthenticatedUser u = UserUtils.getCurrent(); - toUpdate.getInfo().setLastEditInfo(u.asInfo()); - toUpdate.setVersion(toUpdate.getVersion().withIncPatch()); - return triggerEvent(toUpdate, EventExecutionRequest.Events.ON_UPDATE_DOCUMENT, null); - } +// private Project onPatch(Project toUpdate) throws EventException { +// UserUtils.AuthenticatedUser u = UserUtils.getCurrent(); +// toUpdate.getInfo().setLastEditInfo(u.asInfo()); +// toUpdate.setVersion(toUpdate.getVersion().withIncPatch()); +// return triggerEvent(toUpdate, EventExecutionRequest.Events.ON_UPDATE_DOCUMENT, null); +// } @Override public void delete(String id, boolean force) diff --git a/geoportal-service/src/main/java/org/gcube/application/geoportal/service/rest/ProfiledDocuments.java b/geoportal-service/src/main/java/org/gcube/application/geoportal/service/rest/ProfiledDocuments.java index 94a82f2..477be75 100644 --- a/geoportal-service/src/main/java/org/gcube/application/geoportal/service/rest/ProfiledDocuments.java +++ b/geoportal-service/src/main/java/org/gcube/application/geoportal/service/rest/ProfiledDocuments.java @@ -34,6 +34,13 @@ import com.webcohesion.enunciate.metadata.rs.RequestHeaders; import lombok.extern.slf4j.Slf4j; +/** + * The Class ProfiledDocuments. + * @author created by Fabio Sinibaldi + * @author maintainer - Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Apr 18, 2023 + */ @Path(InterfaceConstants.Methods.PROJECTS+"/{"+InterfaceConstants.Parameters.UCID +"}") @Slf4j @RequestHeaders({ @@ -44,6 +51,12 @@ public class ProfiledDocuments { private ProfiledMongoManager manager; + /** + * Instantiates a new profiled documents. + * + * @param profileID the profile ID + * @throws ConfigurationException the configuration exception + */ public ProfiledDocuments(@PathParam(InterfaceConstants.Parameters.UCID) String profileID) throws ConfigurationException { log.info("Accessing profile "+profileID); manager=new GuardedMethod(){ @@ -54,6 +67,12 @@ public class ProfiledDocuments { }.execute().getResult(); } + /** + * Gets the configuration. + * + * @param profileID the profile ID + * @return the configuration + */ @GET @Path(InterfaceConstants.Methods.CONFIGURATION_PATH) @Produces(MediaType.APPLICATION_JSON) @@ -68,6 +87,12 @@ public class ProfiledDocuments { } + /** + * Creates the new. + * + * @param d the d + * @return the project + */ @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @@ -84,6 +109,13 @@ public class ProfiledDocuments { } + /** + * Update. + * + * @param documentId the document id + * @param d the d + * @return the project + */ @PUT @Path("{"+InterfaceConstants.Parameters.PROJECT_ID+"}") @Consumes(MediaType.APPLICATION_JSON) @@ -98,6 +130,13 @@ public class ProfiledDocuments { }.execute().getResult(); } + /** + * Patch. + * + * @param documentId the document id + * @param d the d + * @return the project + */ @PATCH @Path("{"+InterfaceConstants.Parameters.PROJECT_ID+"}") @Consumes(MediaType.APPLICATION_JSON) @@ -113,6 +152,13 @@ public class ProfiledDocuments { } + /** + * Delete. + * + * @param id the id + * @param force the force + * @return the boolean + */ @DELETE @Produces(MediaType.APPLICATION_JSON) @Path("{"+InterfaceConstants.Parameters.PROJECT_ID+"}") @@ -129,6 +175,13 @@ public class ProfiledDocuments { }.execute().getResult(); } + /** + * Register file set. + * + * @param id the id + * @param request the request + * @return the project + */ @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @@ -182,6 +235,13 @@ public class ProfiledDocuments { } + /** + * Perform step. + * + * @param id the id + * @param request the request + * @return the project + */ @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @@ -201,6 +261,12 @@ public class ProfiledDocuments { }.execute().getResult(); } + /** + * Force unlock. + * + * @param id the id + * @return the project + */ @PUT @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @@ -217,6 +283,13 @@ public class ProfiledDocuments { }.execute().getResult(); } + /** + * Sets the access policy. + * + * @param id the id + * @param toSet the to set + * @return the project + */ @PUT @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @@ -235,6 +308,11 @@ public class ProfiledDocuments { //********************************** READ + /** + * List. + * + * @return the iterable + */ @GET @Produces(MediaType.APPLICATION_JSON) public Iterable list() { @@ -245,6 +323,12 @@ public class ProfiledDocuments { }.execute().getResult(); } + /** + * Gets the by id. + * + * @param id the id + * @return the by id + */ // BY ID @GET @Produces(MediaType.APPLICATION_JSON) @@ -259,6 +343,12 @@ public class ProfiledDocuments { } + /** + * Search. + * + * @param filter the filter + * @return the string + */ @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @@ -274,6 +364,12 @@ public class ProfiledDocuments { }.execute().getResult(); } + /** + * Query. + * + * @param queryString the query string + * @return the iterable + */ @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @@ -289,6 +385,14 @@ public class ProfiledDocuments { // Relationships + /** + * Gets the relationship chain. + * + * @param id the id + * @param relationshipId the relationship id + * @param deep the deep + * @return the relationship chain + */ @GET @Produces(MediaType.APPLICATION_JSON) @Path("{"+InterfaceConstants.Methods.RELATIONSHIP+"}/{"+InterfaceConstants.Parameters.PROJECT_ID+"}" + @@ -309,6 +413,15 @@ public class ProfiledDocuments { } + /** + * Sets the relation. + * + * @param id the id + * @param relationshipId the relationship id + * @param targetId the target id + * @param targetUCD the target UCD + * @return the project + */ @PUT @Produces(MediaType.APPLICATION_JSON) @Path("{"+InterfaceConstants.Methods.RELATIONSHIP+"}/{"+InterfaceConstants.Parameters.PROJECT_ID+"}" + @@ -333,6 +446,15 @@ public class ProfiledDocuments { } + /** + * Delete relation. + * + * @param id the id + * @param relationshipId the relationship id + * @param targetId the target id + * @param targetUCD the target UCD + * @return the project + */ @DELETE @Produces(MediaType.APPLICATION_JSON) @Path("{"+InterfaceConstants.Methods.RELATIONSHIP+"}/{"+InterfaceConstants.Parameters.PROJECT_ID+"}" +