lenya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From andr...@apache.org
Subject cvs commit: cocoon-lenya/src/java/org/apache/lenya/cms/workflow/impl WorkflowFactoryImpl.java
Date Fri, 30 May 2003 14:57:30 GMT
andreas     2003/05/30 07:57:30

  Modified:    src/java/org/apache/lenya/cms/workflow/impl
                        WorkflowFactoryImpl.java
  Log:
  added Workflowable
  
  Revision  Changes    Path
  1.2       +29 -77    cocoon-lenya/src/java/org/apache/lenya/cms/workflow/impl/WorkflowFactoryImpl.java
  
  Index: WorkflowFactoryImpl.java
  ===================================================================
  RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/workflow/impl/WorkflowFactoryImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- WorkflowFactoryImpl.java	28 May 2003 15:08:20 -0000	1.1
  +++ WorkflowFactoryImpl.java	30 May 2003 14:57:30 -0000	1.2
  @@ -11,9 +11,9 @@
   import org.apache.lenya.cms.ac.User;
   import org.apache.lenya.cms.publication.Document;
   import org.apache.lenya.cms.publication.DocumentType;
  +import org.apache.lenya.cms.publication.DocumentTypeBuilder;
   import org.apache.lenya.cms.publication.Publication;
   import org.apache.lenya.cms.workflow.*;
  -import org.apache.lenya.cms.workflow.Situation;
   import org.apache.lenya.cms.workflow.Workflow;
   import org.apache.lenya.cms.workflow.WorkflowFactory;
   import org.apache.lenya.xml.DocumentHelper;
  @@ -29,71 +29,50 @@
       public static final String WORKFLOW_DIRECTORY =
           "config/workflow".replace('/', File.separatorChar);
   
  -    public static final String DOCTYPE_DIRECTORY =
  -        "config/doctypes".replace('/', File.separatorChar);
  -
       /** Creates a new instance of WorkflowFactory */
  -    public WorkflowFactoryImpl(
  -        Publication publication,
  -        Document document,
  -        User user) {
  -
  -        assert publication != null;
  -        this.publication = publication;
  +    public WorkflowFactoryImpl(Document document, User user) {
   
           assert document != null;
           this.document = document;
  -
  +        
           assert user != null;
  -        this.user = user;
  -    }
  -
  -    private Publication publication;
  -
  -    private Document document;
  -
  -    private User user;
  -
  -    public static WorkflowFactoryImpl newInstance(
  -        Publication publication,
  -        Document document,
  -        User user) {
  -        return new WorkflowFactoryImpl(publication, document, user);
  +        situation = new CMSSituation(user);
       }
   
  -    /* (non-Javadoc)
  -     * @see org.apache.lenya.cms.workflow.WorkflowFactory#createSituation()
  -     */
  -    public Situation buildSituation() throws WorkflowBuildException {
  -        return new CMSSituation(getUser());
  +    public static WorkflowFactoryImpl newInstance(Document document, User user) {
  +        return new WorkflowFactoryImpl(document, user);
       }
   
  -    private Workflow workflow;
  -
       public static final String WORKFLOW_ELEMENT = "workflow";
       public static final String SRC_ATTRIBUTE = "src";
  -
       /* (non-Javadoc)
        * @see org.apache.lenya.cms.workflow.WorkflowFactory#createWorkflow()
        */
  -    public Workflow buildWorkflow() throws WorkflowBuildException {
   
  -        if (this.workflow != null) {
  -            return this.workflow;
  +    private Document document;
  +    private User user;
  +
  +    private WorkflowDocument workflowDocument;
  +    private Situation situation;
  +
  +    public Workflowable buildWorkflowable() throws WorkflowBuildException {
  +        if (workflowDocument == null) {
  +            workflowDocument = new WorkflowDocument(document);
           }
  +        return workflowDocument;
  +    }
   
  -        DocumentType documentType = getDocument().getType();
  -        String name = documentType.getName();
  +    protected static Workflow buildWorkflow(Publication publication, DocumentType documentType)
  +        throws WorkflowBuildException {
   
           File doctypesDirectory =
  -            new File(publication.getDirectory(), DOCTYPE_DIRECTORY);
  -        File doctypeFile = new File(doctypesDirectory, name + ".xml");
  +            new File(publication.getDirectory(), DocumentTypeBuilder.DOCTYPE_DIRECTORY);
  +        File doctypeFile = new File(doctypesDirectory, documentType.getName() + ".xml");
   
           Workflow workflow;
   
           try {
  -            org.w3c.dom.Document xmlDocument =
  -                DocumentHelper.readDocument(doctypeFile);
  +            org.w3c.dom.Document xmlDocument = DocumentHelper.readDocument(doctypeFile);
   
               NamespaceHelper helper =
                   new NamespaceHelper(
  @@ -103,11 +82,10 @@
               Element root = xmlDocument.getDocumentElement();
   
               Element workflowElement =
  -                (Element) root
  -                    .getElementsByTagNameNS(
  -                        DocumentType.NAMESPACE,
  -                        WORKFLOW_ELEMENT)
  -                    .item(0);
  +                (Element) root.getElementsByTagNameNS(
  +                    DocumentType.NAMESPACE,
  +                    WORKFLOW_ELEMENT).item(
  +                    0);
   
               String source = workflowElement.getAttribute(SRC_ATTRIBUTE);
               assert source != null;
  @@ -121,40 +99,14 @@
           } catch (Exception e) {
               throw new WorkflowBuildException(e);
           }
  -
  -        this.workflow = workflow;
           return workflow;
       }
   
  -    /**
  -     * @return
  -     */
  -    public Document getDocument() {
  -        return document;
  -    }
  -
  -    /**
  -     * @return
  -     */
  -    public Publication getPublication() {
  -        return publication;
  -    }
  -
  -    /**
  -     * @return
  -     */
  -    public User getUser() {
  -        return user;
  -    }
  -
       /* (non-Javadoc)
  -     * @see org.apache.lenya.cms.workflow.WorkflowFactory#buildInstance()
  +     * @see org.apache.lenya.cms.workflow.WorkflowFactory#buildSituation()
        */
  -    public WorkflowInstance buildInstance() throws WorkflowBuildException {
  -        // TODO build instance depending on document
  -        WorkflowInstanceImpl instance =
  -            new WorkflowInstanceImpl(buildWorkflow());
  -        return instance;
  +    public Situation buildSituation() throws WorkflowBuildException {
  +        return situation;
       }
   
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: lenya-cvs-unsubscribe@cocoon.apache.org
For additional commands, e-mail: lenya-cvs-help@cocoon.apache.org


Mime
View raw message