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 CMSHistory.java
Date Fri, 15 Aug 2003 13:11:59 GMT
andreas     2003/08/15 06:11:59

  Modified:    src/java/org/apache/lenya/cms/workflow CMSHistory.java
  Log:
  adding identity information to history
  
  Revision  Changes    Path
  1.10      +53 -6     cocoon-lenya/src/java/org/apache/lenya/cms/workflow/CMSHistory.java
  
  Index: CMSHistory.java
  ===================================================================
  RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/workflow/CMSHistory.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- CMSHistory.java	5 Aug 2003 16:29:06 -0000	1.9
  +++ CMSHistory.java	15 Aug 2003 13:11:59 -0000	1.10
  @@ -55,6 +55,9 @@
   */
   package org.apache.lenya.cms.workflow;
   
  +import org.apache.lenya.cms.ac.Machine;
  +import org.apache.lenya.cms.ac.User;
  +import org.apache.lenya.cms.ac2.Identity;
   import org.apache.lenya.cms.publication.Document;
   import org.apache.lenya.cms.publication.DocumentIdToPathMapper;
   import org.apache.lenya.workflow.Event;
  @@ -89,6 +92,13 @@
       }
   
       private Document document;
  +    
  +    public static final String IDENTITY_ELEMENT = "identity";
  +    public static final String USER_ELEMENT = "user";
  +    public static final String MACHINE_ELEMENT = "machine";
  +    public static final String ID_ATTRIBUTE = "id";
  +    public static final String NAME_ATTRIBUTE = "name";
  +    public static final String IP_ATTRIBUTE = "ip-address";
   
       /** (non-Javadoc)
        * @see org.apache.lenya.cms.workflow.History#createVersionElement(org.apache.lenya.xml.NamespaceHelper,
org.apache.lenya.workflow.impl.StateImpl, org.apache.lenya.workflow.Situation, org.apache.lenya.workflow.Event)
  @@ -97,13 +107,50 @@
           Situation situation, Event event) {
           Element element = super.createVersionElement(helper, state, situation, event);
   
  -        // TODO: add identity
  +        CMSSituation cmsSituation = (CMSSituation) situation;
  +        Identity identity = cmsSituation.getIdentity();
  +        
  +        Element identityElement = helper.createElement(IDENTITY_ELEMENT);
  +        element.appendChild(identityElement);
  +        
  +        User user = identity.getUser();
  +        if (user != null) {
  +            identityElement.appendChild(generateUserElement(helper, user));
  +        }
  +
  +        Machine machine = identity.getMachine();
  +        if (machine != null) {
  +            identityElement.appendChild(generateMachineElement(helper, machine));
  +        }
   
  -        /*
  -        User user = ((CMSSituation) situation).getUser();
  -        element.setAttribute(USER_ATTRIBUTE, user.getId());
  -        */
           return element;
  +    }
  +    
  +    /**
  +     * Creates an XML element describing the user.
  +     * @param helper The namespace helper of the document.
  +     * @param user The user.
  +     * @return An XML element.
  +     */
  +    protected Element generateUserElement(NamespaceHelper helper, User user) {
  +        Element userElement = null;
  +        userElement = helper.createElement(USER_ELEMENT);
  +        userElement.setAttribute(ID_ATTRIBUTE, user.getId());
  +        userElement.setAttribute(NAME_ATTRIBUTE, user.getName());
  +        return userElement;
  +    }
  +    
  +    /**
  +     * Creates an XML element describing the machine.
  +     * @param helper The namespace helper of the document.
  +     * @param machine The machine.
  +     * @return An XML element.
  +     */
  +    protected Element generateMachineElement(NamespaceHelper helper, Machine machine) {
  +        Element machineElement = null;
  +        machineElement = helper.createElement(MACHINE_ELEMENT);
  +        machineElement.setAttribute(IP_ATTRIBUTE, machine.getIp());
  +        return machineElement;
       }
   	
   	/**
  
  
  

---------------------------------------------------------------------
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