Ard Schrijvers pushed to branch feature/projectdocs at cms-community / hippo-repository
Commits: 2e5ed3cf by Ard Schrijvers at 2017-10-18T11:12:15+02:00 REPO-1835 Do not override default implementation in a sub interface (ever) The DocumentWorkflow extends Workflow. That DocumentWorkflow redefines #hints() with other javadoc is imho already bad practice but has been like this for a long time Now that we've added #hints(initialPayload) to Workflow with a default implementation, we should never redefine this method in a sub interface with a different javadoc: I understand we might want different javadoc, but overriding in an interface a default implementation can result in havoc: If your implementation implements both interfaces, it becomes really spooky which default method is used. Most probably the subinterface hides the super interface hints completely, but it is quite delicate and there might be subtle issues. When a sub interface redefines the same method but now without default impl, I really don't know what the end result is, but frankly, I don't want to know because it is a pattern we should always avoid - - - - - 2 changed files: - api/src/main/java/org/hippoecm/repository/api/Workflow.java - builtin/src/main/java/org/onehippo/repository/documentworkflow/DocumentWorkflow.java Changes: ===================================== api/src/main/java/org/hippoecm/repository/api/Workflow.java ===================================== --- a/api/src/main/java/org/hippoecm/repository/api/Workflow.java +++ b/api/src/main/java/org/hippoecm/repository/api/Workflow.java @@ -63,26 +63,13 @@ public interface Workflow extends Remote, Serializable { Map<String, Serializable> hints() throws WorkflowException, RemoteException, RepositoryException; /** - * The hints method is not an actual workflow call, but a method by which information can be retrieved from the - * workflow. All implementations must implement this call as a pure function, no modification may be made, nor no - * state may be maintained and and in principle no additional lookups of data is allowed. This allows for caching - * the result as long as the document on which the workflow operates isn't modified. By convention, keys that are - * names or signatures of methods implemented by the workflow provide information to the application program whether - * the workflow method is available this time, or will result in a WorkflowException. The value for these keys will - * often be a {@link java.lang.Boolean} to indicate the enabled status of the method.<p/> Non-standard keys in this - * map should be prefixed with the implementation package name using dot seperations. + * See {@link #hints()} only now with an {@code initialPayload} + * @param initialPayload supplies information that is not available on the document + * @see #hints() * - * @param initializationPayload a map containing user context information relevant for the workflow - * @return a map containing hints given by the workflow, the data in this map may be considered valid until the - * document itself changes - * @throws org.hippoecm.repository.api.WorkflowException thrown in case the implementing workflow encounters an - * error, this exception should normally never be thrown by - * implementations for the hints method. - * @throws java.rmi.RemoteException a connection error with the repository - * @throws javax.jcr.RepositoryException a generic error communicating with the repository */ @WorkflowAction(loggable = false, mutates = false) - default Map<String, Serializable> hints(Map<String, Serializable> initializationPayload) throws WorkflowException, RemoteException, RepositoryException { + default Map<String, Serializable> hints(Map<String, Serializable> initialPayload) throws WorkflowException, RemoteException, RepositoryException { return hints(); } ===================================== builtin/src/main/java/org/onehippo/repository/documentworkflow/DocumentWorkflow.java ===================================== --- a/builtin/src/main/java/org/onehippo/repository/documentworkflow/DocumentWorkflow.java +++ b/builtin/src/main/java/org/onehippo/repository/documentworkflow/DocumentWorkflow.java @@ -77,18 +77,6 @@ public interface DocumentWorkflow extends Workflow, EditableWorkflow, CopyWorkfl @Override Map<String, Serializable> hints() throws WorkflowException, RemoteException, RepositoryException; - - /** - * See {@link #hints()} only now with an {@code initialPayload} - * @param initialPayload supplies information that is not available on the document - * @see #hints() - * - */ - @WorkflowAction(loggable = false, mutates = false) - default Map<String, Serializable> hints(Map<String, Serializable> initialPayload) throws WorkflowException, RemoteException, RepositoryException { - return hints(); - } - // Operations previously provided through BasicReviewedActionsWorkflow, now provided on Document handle level /** View it on GitLab: https://code.onehippo.org/cms-community/hippo-repository/commit/2e5ed3cf19d936b1dc0bbe54fd7a01e6d60458b1 --- View it on GitLab: https://code.onehippo.org/cms-community/hippo-repository/commit/2e5ed3cf19d936b1dc0bbe54fd7a01e6d60458b1 You're receiving this email because of your account on code.onehippo.org.
_______________________________________________ Hippocms-svn mailing list Hippocms-svn@lists.onehippo.org https://lists.onehippo.org/mailman/listinfo/hippocms-svn