cancel
Showing results for 
Search instead for 
Did you mean: 

how to solve this problem from jpotts first edition tutorial

himfire
Champ in-the-making
Champ in-the-making
I have downloaded the source code for the first edition of jpotts tutorial . this error has comes out to me and I don't know how to solve it can some one help me ?
I have done it in eclipse ?




Buildfile: /home/control/workspace/try2/advanced-workflow-article/build.xml
setup:
    [mkdir] Created dir: /home/control/workspace/try2/advanced-workflow-article/build
compile:
    [mkdir] Created dir: /home/control/workspace/try2/advanced-workflow-article/bin
    [javac] /home/control/workspace/try2/advanced-workflow-article/build.xml:51: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
    [javac] Compiling 12 source files to /home/control/workspace/try2/advanced-workflow-article/bin
    [javac] warning: [options] bootstrap class path not set in conjunction with -source 1.5
    [javac] /home/control/workspace/try2/advanced-workflow-article/src/com/someco/scripts/GetReview.java:7: error: package org.alfresco.web.scripts does not exist
    [javac] import org.alfresco.web.scripts.WebScriptRequest;
    [javac]                                ^
    [javac] /home/control/workspace/try2/advanced-workflow-article/src/com/someco/scripts/GetReview.java:8: error: package org.alfresco.web.scripts does not exist
    [javac] import org.alfresco.web.scripts.WebScriptStatus;
    [javac]                                ^
    [javac] /home/control/workspace/try2/advanced-workflow-article/src/com/someco/scripts/GetReview.java:16: error: package org.alfresco.web.scripts does not exist
    [javac] public class GetReview extends org.alfresco.web.scripts.DeclarativeWebScript {
    [javac]                                                        ^
    [javac] /home/control/workspace/try2/advanced-workflow-article/src/com/someco/scripts/GetReview.java:23: error: cannot find symbol
    [javac]    protected Map<String, Object> executeImpl(WebScriptRequest req, WebScriptStatus status) {
    [javac]                                              ^
    [javac]   symbol:   class WebScriptRequest
    [javac]   location: class GetReview
    [javac] /home/control/workspace/try2/advanced-workflow-article/src/com/someco/scripts/GetReview.java:23: error: cannot find symbol
    [javac]    protected Map<String, Object> executeImpl(WebScriptRequest req, WebScriptStatus status) {
    [javac]                                                                    ^
    [javac]   symbol:   class WebScriptStatus
    [javac]   location: class GetReview
    [javac] /home/control/workspace/try2/advanced-workflow-article/src/com/someco/scripts/PostRating.java:7: error: package org.alfresco.web.scripts does not exist
    [javac] import org.alfresco.web.scripts.WebScriptRequest;
    [javac]                                ^
    [javac] /home/control/workspace/try2/advanced-workflow-article/src/com/someco/scripts/PostRating.java:8: error: package org.alfresco.web.scripts does not exist
    [javac] import org.alfresco.web.scripts.WebScriptStatus;
    [javac]                                ^
    [javac] /home/control/workspace/try2/advanced-workflow-article/src/com/someco/scripts/PostRating.java:19: error: package org.alfresco.web.scripts does not exist
    [javac] public class PostRating extends org.alfresco.web.scripts.DeclarativeWebScript {
    [javac]                                                         ^
    [javac] /home/control/workspace/try2/advanced-workflow-article/src/com/someco/scripts/PostRating.java:26: error: cannot find symbol
    [javac]    protected Map<String, Object> executeImpl(WebScriptRequest req, WebScriptStatus status) {
    [javac]                                              ^
    [javac]   symbol:   class WebScriptRequest
    [javac]   location: class PostRating
    [javac] /home/control/workspace/try2/advanced-workflow-article/src/com/someco/scripts/PostRating.java:26: error: cannot find symbol
    [javac]    protected Map<String, Object> executeImpl(WebScriptRequest req, WebScriptStatus status) {
    [javac]                                                                    ^
    [javac]   symbol:   class WebScriptStatus
    [javac]   location: class PostRating
    [javac] /home/control/workspace/try2/advanced-workflow-article/src/com/someco/behavior/Rating.java:136: error: cannot find symbol
    [javac]       String currentUser = AuthenticationUtil.getCurrentUserName();
    [javac]                                              ^
    [javac]   symbol:   method getCurrentUserName()
    [javac]   location: class AuthenticationUtil
    [javac] /home/control/workspace/try2/advanced-workflow-article/src/com/someco/behavior/Rating.java:139: error: cannot find symbol
    [javac]          AuthenticationUtil.setCurrentUser("admin");
    [javac]                            ^
    [javac]   symbol:   method setCurrentUser(String)
    [javac]   location: class AuthenticationUtil
    [javac] /home/control/workspace/try2/advanced-workflow-article/src/com/someco/behavior/Rating.java:171: error: cannot find symbol
    [javac]       if (switchUser) AuthenticationUtil.setCurrentUser(currentUser);
    [javac]                                         ^
    [javac]   symbol:   method setCurrentUser(String)
    [javac]   location: class AuthenticationUtil
    [javac] /home/control/workspace/try2/advanced-workflow-article/src/com/someco/scripts/GetReview.java:22: error: method does not override or implement a method from a supertype
    [javac]    @Override
    [javac]    ^
    [javac] /home/control/workspace/try2/advanced-workflow-article/src/com/someco/scripts/PostRating.java:25: error: method does not override or implement a method from a supertype
    [javac]    @Override
    [javac]    ^
    [javac] 15 errors
    [javac] 1 warning

BUILD FAILED
/home/control/workspace/try2/advanced-workflow-article/build.xml:51: Compile failed; see the compiler error output for details.

Total time: 7 seconds
6 REPLIES 6

jpotts
World-Class Innovator
World-Class Innovator
The problem is that the package names changed after the tutorial was written. Try changing your imports to:
import org.springframework.extensions.webscripts.DeclarativeWebScript;
import org.springframework.extensions.webscripts.Status;
import org.springframework.extensions.webscripts.WebScriptRequest;
Jeff

himfire
Champ in-the-making
Champ in-the-making
ok thanks very much

I have those problem not solved .can you help me?




Buildfile: /home/control/workspace/try2/advanced-workflow-article/build.xml
setup:
compile:
    [javac] /home/control/workspace/try2/advanced-workflow-article/build.xml:51: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
    [javac] Compiling 12 source files to /home/control/workspace/try2/advanced-workflow-article/bin
    [javac] warning: [options] bootstrap class path not set in conjunction with -source 1.5
    [javac] /home/control/workspace/try2/advanced-workflow-article/src/com/someco/scripts/GetReview.java:25: error: cannot find symbol
    [javac]    protected Map<String, Object> executeImpl(WebScriptRequest req, WebScriptStatus status) {
    [javac]                                                                    ^
    [javac]   symbol:   class WebScriptStatus
    [javac]   location: class GetReview
    [javac] /home/control/workspace/try2/advanced-workflow-article/src/com/someco/scripts/PostRating.java:26: error: cannot find symbol
    [javac]    protected Map<String, Object> executeImpl(WebScriptRequest req, WebScriptStatus status) {
    [javac]                                                                    ^
    [javac]   symbol:   class WebScriptStatus
    [javac]   location: class PostRating
    [javac] /home/control/workspace/try2/advanced-workflow-article/src/com/someco/behavior/Rating.java:136: error: cannot find symbol
    [javac]       String currentUser = AuthenticationUtil.getCurrentUserName();
    [javac]                                              ^
    [javac]   symbol:   method getCurrentUserName()
    [javac]   location: class AuthenticationUtil
    [javac] /home/control/workspace/try2/advanced-workflow-article/src/com/someco/behavior/Rating.java:139: error: cannot find symbol
    [javac]          AuthenticationUtil.setCurrentUser("admin");
    [javac]                            ^
    [javac]   symbol:   method setCurrentUser(String)
    [javac]   location: class AuthenticationUtil
    [javac] /home/control/workspace/try2/advanced-workflow-article/src/com/someco/behavior/Rating.java:171: error: cannot find symbol
    [javac]       if (switchUser) AuthenticationUtil.setCurrentUser(currentUser);
    [javac]                                         ^
    [javac]   symbol:   method setCurrentUser(String)
    [javac]   location: class AuthenticationUtil
    [javac] /home/control/workspace/try2/advanced-workflow-article/src/com/someco/scripts/PostRating.java:38: error: cannot find symbol
    [javac]          NodeRef curNode = new NodeRef("workspace://SpacesStore/" + id);   
    [javac]          ^
    [javac]   symbol:   class NodeRef
    [javac]   location: class PostRating
    [javac] /home/control/workspace/try2/advanced-workflow-article/src/com/someco/scripts/PostRating.java:38: error: cannot find symbol
    [javac]          NodeRef curNode = new NodeRef("workspace://SpacesStore/" + id);   
    [javac]                                ^
    [javac]   symbol:   class NodeRef
    [javac]   location: class PostRating
    [javac] Note: Some input files use or override a deprecated API.
    [javac] Note: Recompile with -Xlint:deprecation for details.
    [javac] 7 errors
    [javac] 1 warning

BUILD FAILED
/home/control/workspace/try2/advanced-workflow-article/build.xml:51: Compile failed; see the compiler error output for details.

Total time: 3 seconds

himfire
Champ in-the-making
Champ in-the-making
thanks for the reply


Q1:After I have done from any thing and come with successful in execution by using the ant . what should I do to make it run in the alfresco ?

Q2:And when I red the tutorial there is difference between the tutorial and the source code . i.e : in the tutorial as I have understood from it . that I should place my workflow in some directory and do some steps to get my workflow done . but the source code I should ant into eclipse the folder then some procedures happen . how can I understand the difference between those two steps?

I hope I get it right

jpotts
World-Class Innovator
World-Class Innovator
The tutorial covers several examples. I don't know which one you are on, but the general way to start and advanced workflow is covered on pages 36 - 38.

All of my examples assume you are editing files within a project in Eclipse. I use Ant to deploy those files from the Eclipse project structure to an exploded Alfresco WAR.

When using jBPM, I find it is often handy to deploy the workflow directly to the repository from the Graphical Process Designer Eclipse plug-in's "Deploy" tab. But that is not necessary. At the time that tutorial was written, the process deployer servlet was always available. It has since been disabled by default, so you have to turn it on if you want to use this. Be aware that it creates a security hole so do not enable it in production.

I strongly recommend that you also follow the example of creating and editing files within some folder structure (an Eclipse project, if you'd like, or something else) separate from the Alfresco code. Then, use Ant to deploy the code to Alfresco.

While developing, it is often faster to use Ant to deploy the files to the exploded WAR. When you are ready to go to production it is probably a better idea to have your Ant build create an AMP that you apply to the Alfresco WAR using the MMT.

Jeff

himfire
Champ in-the-making
Champ in-the-making
thanks for the reply

but sorry just to learn I will shy . the question is how can I solve this problem that listed below:


Buildfile: /home/control/workspace/try2/advanced-workflow-article/build.xml
setup:
compile:
    [javac] /home/control/workspace/try2/advanced-workflow-article/build.xml:51: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
    [javac] Compiling 12 source files to /home/control/workspace/try2/advanced-workflow-article/bin
    [javac] warning: [options] bootstrap class path not set in conjunction with -source 1.5
    [javac] /home/control/workspace/try2/advanced-workflow-article/src/com/someco/scripts/GetReview.java:25: error: cannot find symbol
    [javac]    protected Map<String, Object> executeImpl(WebScriptRequest req, WebScriptStatus status) {
    [javac]                                                                    ^
    [javac]   symbol:   class WebScriptStatus
    [javac]   location: class GetReview
    [javac] /home/control/workspace/try2/advanced-workflow-article/src/com/someco/scripts/PostRating.java:26: error: cannot find symbol
    [javac]    protected Map<String, Object> executeImpl(WebScriptRequest req, WebScriptStatus status) {
    [javac]                                                                    ^
    [javac]   symbol:   class WebScriptStatus
    [javac]   location: class PostRating
    [javac] /home/control/workspace/try2/advanced-workflow-article/src/com/someco/behavior/Rating.java:136: error: cannot find symbol
    [javac]       String currentUser = AuthenticationUtil.getCurrentUserName();
    [javac]                                              ^
    [javac]   symbol:   method getCurrentUserName()
    [javac]   location: class AuthenticationUtil
    [javac] /home/control/workspace/try2/advanced-workflow-article/src/com/someco/behavior/Rating.java:139: error: cannot find symbol
    [javac]          AuthenticationUtil.setCurrentUser("admin");
    [javac]                            ^
    [javac]   symbol:   method setCurrentUser(String)
    [javac]   location: class AuthenticationUtil
    [javac] /home/control/workspace/try2/advanced-workflow-article/src/com/someco/behavior/Rating.java:171: error: cannot find symbol
    [javac]       if (switchUser) AuthenticationUtil.setCurrentUser(currentUser);
    [javac]                                         ^
    [javac]   symbol:   method setCurrentUser(String)
    [javac]   location: class AuthenticationUtil
    [javac] /home/control/workspace/try2/advanced-workflow-article/src/com/someco/scripts/PostRating.java:38: error: cannot find symbol
    [javac]          NodeRef curNode = new NodeRef("workspace://SpacesStore/" + id);  
    [javac]          ^
    [javac]   symbol:   class NodeRef
    [javac]   location: class PostRating
    [javac] /home/control/workspace/try2/advanced-workflow-article/src/com/someco/scripts/PostRating.java:38: error: cannot find symbol
    [javac]          NodeRef curNode = new NodeRef("workspace://SpacesStore/" + id);  
    [javac]                                ^
    [javac]   symbol:   class NodeRef
    [javac]   location: class PostRating
    [javac] Note: Some input files use or override a deprecated API.
    [javac] Note: Recompile with -Xlint:deprecation for details.
    [javac] 7 errors
    [javac] 1 warning

BUILD FAILED
/home/control/workspace/try2/advanced-workflow-article/build.xml:51: Compile failed; see the compiler error output for details.

jpotts
World-Class Innovator
World-Class Innovator
For the WebScriptStatus problem, change the import from whatever it is now to:
import org.springframework.extensions.webscripts.Status;

And then change the method declaration to:
executeImpl(WebScriptRequest req, Status status)

That Rating.java code looks fairly old. Here's an updated class:
package com.someco.behavior;

import java.util.List;

import org.alfresco.repo.node.NodeServicePolicies;
import org.alfresco.repo.policy.Behaviour;
import org.alfresco.repo.policy.JavaBehaviour;
import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.transaction.TransactionService;
import org.apache.log4j.Logger;

import com.someco.model.SomeCoModel;

public class Rating
   implements NodeServicePolicies.OnDeleteNodePolicy,
            NodeServicePolicies.OnCreateNodePolicy {

   // Dependencies
    private NodeService nodeService;
    private PolicyComponent policyComponent;
    private TransactionService transactionService;
   
    // Behaviours
    private Behaviour onCreateNode;
    private Behaviour onDeleteNode;
   
    private Logger logger = Logger.getLogger(Rating.class);
   
    public void init() {
       if (logger.isDebugEnabled()) logger.debug("Initializing rateable behaviors");
       
        // Create behaviours
        this.onCreateNode = new JavaBehaviour(this, "onCreateNode", NotificationFrequency.TRANSACTION_COMMIT);
        this.onDeleteNode = new JavaBehaviour(this, "onDeleteNode", NotificationFrequency.TRANSACTION_COMMIT);

        // Bind behaviours to node policies
        this.policyComponent.bindClassBehaviour(QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateNode"), SomeCoModel.TYPE_SC_RATING, this.onCreateNode);
        this.policyComponent.bindClassBehaviour(QName.createQName(NamespaceService.ALFRESCO_URI, "onDeleteNode"), SomeCoModel.TYPE_SC_RATING, this.onDeleteNode);
    }
   
   public void onCreateNode(ChildAssociationRef childAssocRef) {
      if (logger.isDebugEnabled()) logger.debug("Inside onCreateNode");      
      addRating(childAssocRef);
   }

      
   public void onDeleteNode(ChildAssociationRef childAssocRef, boolean isNodeArchived) {
      if (logger.isDebugEnabled()) logger.debug("Inside onDeleteNode");
      recalculateAverage(childAssocRef.getParentRef());
   }

   /**
    * This method adds the rating identified by the target of the specified reference.
    * @param childAssocRef
    */
   public void addRating(ChildAssociationRef childAssocRef) {

      if (logger.isDebugEnabled()) logger.debug("Inside addRating");
      
      // get the parent node
      NodeRef parentRef = childAssocRef.getParentRef();
      NodeRef childRef = childAssocRef.getChildRef();
      
      if (!nodeService.exists(parentRef) || !nodeService.exists(childRef)) {
         logger.debug("One of the nodes no longer exists.");
         return;
      }
      
      // check the parent to make sure it has the right aspect
      if (nodeService.hasAspect(parentRef, SomeCoModel.ASPECT_SC_RATEABLE)) {
         // continue, this is what we want
      } else {
         if (logger.isDebugEnabled()) logger.debug("Rating's parent ref did not have rateable aspect.");
         return;
      }
   
      Integer total = (Integer)nodeService.getProperty(parentRef, SomeCoModel.PROP_TOTAL_RATING);
      if (total == null) total = 0;
      Integer count = (Integer)nodeService.getProperty(parentRef, SomeCoModel.PROP_RATING_COUNT);
      if (count == null) count = 0;
      Integer rating = (Integer)nodeService.getProperty(childRef, SomeCoModel.PROP_RATING);
      if (rating == null) rating = 0;

      Double average = 0d;
      
      total = total + rating;
      count = count + 1;
      average = total / new Double(count);
      
      setParentProperties(parentRef, average, total, count);
      
      return;

   }

   protected void setParentProperties(final NodeRef parentRef, final Double average, final int total, final int count) {
      AuthenticationUtil.runAs(new RunAsWork<String>() {
         @SuppressWarnings("synthetic-access")
         public String doWork() throws Exception {
            // store the average on the parent node
            nodeService.setProperty(parentRef, SomeCoModel.PROP_AVERAGE_RATING, average);
            nodeService.setProperty(parentRef, SomeCoModel.PROP_TOTAL_RATING, total);
            nodeService.setProperty(parentRef, SomeCoModel.PROP_RATING_COUNT, count);      
      
            if (logger.isDebugEnabled()) logger.debug("Property set");
            return "";
         }
      },
      "admin");
   }
   
   /**
    * This method is used to do a full recalculation of the average by iterating over all
    * ratings.
    * @param nodeRef
    */
   public void recalculateAverage(NodeRef parentRef) {
      if (logger.isDebugEnabled()) logger.debug("Inside computeAverage");
      
      // check the parent to make sure it has the right aspect
      if (nodeService.hasAspect(parentRef, SomeCoModel.ASPECT_SC_RATEABLE)) {
         // continue, this is what we want
      } else {
         if (logger.isDebugEnabled()) logger.debug("Rating's parent ref did not have rateable aspect.");
         return;
      }
      
      // get the parent node's children
      List<ChildAssociationRef> children = nodeService.getChildAssocs(parentRef);
      
      Double average = 0d;
      int total = 0;
      // This actually happens when the last rating is deleted
      if (children.size() == 0) {
         // No children so no work to do
         if (logger.isDebugEnabled()) logger.debug("No children found");         
      } else {
         // iterate through the children to compute the total
         
         for (ChildAssociationRef child : children) {
            if (!nodeService.exists(child.getChildRef())) {
               logger.debug("Child node no longer exists.");
               continue;
            }

            int rating = (Integer)nodeService.getProperty(child.getChildRef(), SomeCoModel.PROP_RATING);
            total += rating;
         }
                  
         // compute the average
         average = total / (children.size() / 1.0d);
      
         if (logger.isDebugEnabled()) logger.debug("Computed average:" + average);         
      }
      
      setParentProperties(parentRef, average, total, children.size());
      
      if (logger.isDebugEnabled()) logger.debug("Property set");
      
      return;
   }

   public NodeService getNodeService() {
      return nodeService;
   }


   public void setNodeService(NodeService nodeService) {
      this.nodeService = nodeService;
   }


   public PolicyComponent getPolicyComponent() {
      return policyComponent;
   }


   public void setPolicyComponent(PolicyComponent policyComponent) {
      this.policyComponent = policyComponent;
   }
   
   public TransactionService getTransactionService() {
      return transactionService;
   }

   public void setTransactionService(TransactionService transactionService) {
      this.transactionService = transactionService;
   }
}

I'm not sure why your PostRating.java compile is failing on NodeRef. Make sure you have the following import:
import org.alfresco.service.cmr.repository.NodeRef;

If you are following along with the first-edition tutorials, you may find that the code that accompanied the Alfresco Developer Guide is more up-to-date. The book used many of the first-edition tutorials and in some cases made improvements to the code. The code was also maintained for many releases after the book was published. The code is tagged by chapter and by Alfresco release. So, for example, the workflow chapter is Chapter 7. You may have to check out the code to see all of the tags. Google Code won't let you browse all of them through the UI.

Jeff