Tobias Jeger pushed to branch feature/visual-editing-psp1-CHANNELMGR-966 at cms-community / hippo-addon-channel-manager
Commits: 217cbe5f by Tobias Jeger at 2016-11-02T11:43:13+01:00 CHANNELMGR-966 Remove session refresh invocations After discussing the current use of session.refresh() with Ate and Ard, we concluded that we can best document the session to be "invocation scoped", i.e. the session is created before the invocation of a DocumentsService or DocumentTypesService method, and avoid the session.refresh() calls, as they consume quite some performance. - - - - - 5302ccf5 by Tobias Jeger at 2016-11-02T11:43:43+01:00 CHANNELMGR-966 Delete unused error code - - - - - 4 changed files: - content-service/src/main/java/org/onehippo/cms/channelmanager/content/document/DocumentsService.java - content-service/src/main/java/org/onehippo/cms/channelmanager/content/document/DocumentsServiceImpl.java - content-service/src/main/java/org/onehippo/cms/channelmanager/content/documenttype/DocumentTypesService.java - content-service/src/main/java/org/onehippo/cms/channelmanager/content/error/ErrorInfo.java Changes: ===================================== content-service/src/main/java/org/onehippo/cms/channelmanager/content/document/DocumentsService.java ===================================== --- a/content-service/src/main/java/org/onehippo/cms/channelmanager/content/document/DocumentsService.java +++ b/content-service/src/main/java/org/onehippo/cms/channelmanager/content/document/DocumentsService.java @@ -36,7 +36,7 @@ public interface DocumentsService { * If all goes well, the document's content is returned. * * @param uuid UUID of the requested document (handle) - * @param session user-authenticated JCR session for reading from the repository + * @param session user-authenticated, invocation-scoped JCR session * @return JSON-serializable representation of the parts supported for exposing * @throws ErrorWithPayloadException * If creation of the draft failed @@ -48,7 +48,8 @@ public interface DocumentsService { * * @param uuid UUID of the document to be updated * @param document Document containing the to-be-persisted content - * @param session user-authenticated JCR session for writing to the repository + * @param session user-authenticated, invocation-scoped JCR session. + * In case of a bad request, changes may be pending. * @throws ErrorWithPayloadException * If updating the draft failed */ @@ -58,7 +59,7 @@ public interface DocumentsService { * Delete the draft version of a document, such that it is available for others to edit. * * @param uuid UUID of the document for which to delete the draft - * @param session user-authenticated JCR session for writing to the repository + * @param session user-authenticated, invocation-scoped JCR session * @throws ErrorWithPayloadException * If deleting the draft failed */ @@ -68,7 +69,7 @@ public interface DocumentsService { * Read the published variant of a document * * @param uuid UUID of the requested document (handle) - * @param session user-authenticated JCR session for reading from the repository + * @param session user-authenticated, invocation-scoped JCR session * @return JSON-serializable representation of the parts supported for exposing * @throws ErrorWithPayloadException * If retrieval of the live document failed ===================================== content-service/src/main/java/org/onehippo/cms/channelmanager/content/document/DocumentsServiceImpl.java ===================================== --- a/content-service/src/main/java/org/onehippo/cms/channelmanager/content/document/DocumentsServiceImpl.java +++ b/content-service/src/main/java/org/onehippo/cms/channelmanager/content/document/DocumentsServiceImpl.java @@ -97,7 +97,6 @@ public class DocumentsServiceImpl implements DocumentsService { if (writeFields(document, draft, docType)) { persistChangesAndKeepEditing(session, workflow); } else { - cancelPendingChanges(session); throw new BadRequestException(); // TODO: report per-field errors? } } @@ -114,7 +113,6 @@ public class DocumentsServiceImpl implements DocumentsService { try { workflow.disposeEditableInstance(); - session.refresh(false); // TODO: should we use 'true' instead? } catch (WorkflowException | RepositoryException | RemoteException e) { log.warn("Failed to dispose of editable instance", e); throw new InternalServerErrorException(); @@ -181,14 +179,6 @@ public class DocumentsServiceImpl implements DocumentsService { return errors == 0; } - private void cancelPendingChanges(final Session session) { - try { - session.refresh(false); - } catch (RepositoryException e) { - log.warn("Problem cancelling pending changes", e); - } - } - private void persistChangesAndKeepEditing(final Session session, final EditableWorkflow workflow) throws ErrorWithPayloadException { try { @@ -200,8 +190,6 @@ public class DocumentsServiceImpl implements DocumentsService { } try { - session.refresh(true); // TODO: copied from CMS, assume that this makes the changes to the unpublished - // variant visible in this session, discuss the need to do this. workflow.obtainEditableInstance(); } catch (WorkflowException e) { log.warn("User '{}' failed to re-obtain ownership of document", session.getUserID(), e); ===================================== content-service/src/main/java/org/onehippo/cms/channelmanager/content/documenttype/DocumentTypesService.java ===================================== --- a/content-service/src/main/java/org/onehippo/cms/channelmanager/content/documenttype/DocumentTypesService.java +++ b/content-service/src/main/java/org/onehippo/cms/channelmanager/content/documenttype/DocumentTypesService.java @@ -40,7 +40,7 @@ public interface DocumentTypesService { * Read the supported part of a document type into a JSON-serializable representation * * @param id ID of the document type, e.g. "myhippoproject:newsdocument" - * @param userSession user-authenticated JCR session for read-only access + * @param userSession user-authenticated, invocation-scoped JCR session for read-only access * @param locale locale of the current CMS session * @return JSON-serializable representation of the parts supported for exposing * @throws ErrorWithPayloadException ===================================== content-service/src/main/java/org/onehippo/cms/channelmanager/content/error/ErrorInfo.java ===================================== --- a/content-service/src/main/java/org/onehippo/cms/channelmanager/content/error/ErrorInfo.java +++ b/content-service/src/main/java/org/onehippo/cms/channelmanager/content/error/ErrorInfo.java @@ -34,7 +34,6 @@ public class ErrorInfo { } public enum Reason { - UNKNOWN, NOT_HOLDER, HOLDERSHIP_LOST, ALREADY_DELETED View it on GitLab: https://code.onehippo.org/cms-community/hippo-addon-channel-manager/compare/b73509a3a6eda60c5d437c552f984a10de287fdb...5302ccf5503a59469365f9e2d64368010f4f1745
_______________________________________________ Hippocms-svn mailing list Hippocms-svn@lists.onehippo.org https://lists.onehippo.org/mailman/listinfo/hippocms-svn