Author: sdumitriu
Date: 2008-01-02 17:39:44 +0100 (Wed, 02 Jan 2008)
New Revision: 6597

Modified:
   
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/api/RWOperation.java
   
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/AbstractOperationImpl.java
   
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/ClassPropertySetOperation.java
   
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/ContentDeleteOperation.java
   
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/ContentInsertOperation.java
   
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/LogicalTimeImpl.java
   
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/OriginatorImpl.java
   
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/PatchIdImpl.java
   
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/PositionImpl.java
   
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/PropertySetOperation.java
   
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/web/PatchServiceAction.java
   
xwiki-platform/core/trunk/xwiki-patchservice/src/test/java/org/xwiki/platform/ClassPropertyOperationsTest.java
Log:
XWIKI-1977: Create a patchservice data model
Cleanup, add some javadoc.


Modified: 
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/api/RWOperation.java
===================================================================
--- 
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/api/RWOperation.java
     2008-01-02 16:27:50 UTC (rev 6596)
+++ 
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/api/RWOperation.java
     2008-01-02 16:39:44 UTC (rev 6597)
@@ -1,12 +1,13 @@
 package org.xwiki.platform.patchservice.api;
 
 import java.io.InputStream;
-import java.util.Date;
 import java.util.Map;
 
 /**
  * A read-write operation, or one that can be defined using method calls. The 
+ *  
  * @see Operation
+ * @version $Id: $
  */
 public interface RWOperation extends Operation
 {
@@ -48,7 +49,5 @@
     boolean deleteAttachment(String name);
 
     /* Operation metadata */
-    void setTime(Date time);
-
     void setType(String type);
 }

Modified: 
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/AbstractOperationImpl.java
===================================================================
--- 
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/AbstractOperationImpl.java
  2008-01-02 16:27:50 UTC (rev 6596)
+++ 
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/AbstractOperationImpl.java
  2008-01-02 16:39:44 UTC (rev 6597)
@@ -1,119 +1,145 @@
 package org.xwiki.platform.patchservice.impl;
 
 import java.io.InputStream;
-import java.util.Date;
 import java.util.Map;
 
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
 import org.xwiki.platform.patchservice.api.Position;
 import org.xwiki.platform.patchservice.api.RWOperation;
 
-import com.xpn.xwiki.XWikiException;
-import com.xpn.xwiki.doc.XWikiDocument;
-
 public abstract class AbstractOperationImpl implements RWOperation
 {
     public static final String NODE_NAME = "operation";
+
     public static final String TYPE_ATTRIBUTE_NAME = "type";
+
     public static final String TEXT_NODE_NAME = "text";
+
     public static final String OBJECT_NODE_NAME = "object";
+
     public static final String ATTACHMENT_NODE_NAME = "attachment";
+
     public static final String PROPERTY_NODE_NAME = "property";
 
-    private Date time;
-
     private String type;
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public boolean addObject(String objectClass)
     {
         return false;
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public boolean createType(String propertyType, Map properties)
     {
         return false;
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public boolean delete(String text, Position position)
     {
         return false;
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public boolean deleteAttachment(String name)
     {
         return false;
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public boolean deleteFromProperty(String property, String text, Position 
position)
     {
         return false;
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public boolean deleteObject(String objectClass, int index)
     {
         return false;
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public boolean deleteType(String propertyName)
     {
         return false;
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public boolean insert(String text, Position position)
     {
         return false;
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public boolean insertInProperty(String property, String text, Position 
position)
     {
         return false;
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public boolean modifyType(String propertyName, Map properties)
     {
         return false;
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public boolean setAttachment(InputStream is)
     {
         return false;
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public boolean setObjectProperty(String objectClass, String index, String 
propertyName,
         String value)
     {
         return false;
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public boolean setProperty(String property, String value)
     {
         return false;
     }
 
-    public void setTime(Date date)
-    {
-        this.time = date;
-    }
-
+    /**
+     * [EMAIL PROTECTED]
+     */
     public void setType(String type)
     {
         this.type = type;
     }
 
-    public Date getTime()
-    {
-        return this.time;
-    }
-
+    /**
+     * [EMAIL PROTECTED]
+     */
     public String getType()
     {
         return this.type;
     }
-
-    public abstract void apply(XWikiDocument doc) throws XWikiException;
-
-    public abstract void fromXml(Element e) throws XWikiException;
-
-    public abstract Element toXml(Document doc) throws XWikiException;
 }

Modified: 
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/ClassPropertySetOperation.java
===================================================================
--- 
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/ClassPropertySetOperation.java
      2008-01-02 16:27:50 UTC (rev 6596)
+++ 
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/ClassPropertySetOperation.java
      2008-01-02 16:39:44 UTC (rev 6597)
@@ -63,6 +63,9 @@
         }
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public boolean createType(String propertyType, Map properties)
     {
         this.propertyType = propertyType;
@@ -75,6 +78,9 @@
         return true;
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public boolean modifyType(String propertyType, Map properties)
     {
         this.propertyType = propertyType;
@@ -83,6 +89,9 @@
         return true;
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public void fromXml(Element e) throws XWikiException
     {
         this.setType(e.getAttribute(TYPE_ATTRIBUTE_NAME));
@@ -97,6 +106,9 @@
         }
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public Element toXml(Document doc) throws XWikiException
     {
         Element xmlNode = doc.createElement(AbstractOperationImpl.NODE_NAME);
@@ -115,6 +127,9 @@
         return xmlNode;
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public boolean equals(Object other)
     {
         try {
@@ -134,6 +149,9 @@
         }
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public int hashCode()
     {
         // return new HashCodeBuilder(11, 
13).append(this.propertyType).append(this.propertyConfig)
@@ -144,6 +162,9 @@
         return i;
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public String toString()
     {
         return this.getType() + ": [" + this.propertyType + "] = " + 
this.propertyConfig;

Modified: 
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/ContentDeleteOperation.java
===================================================================
--- 
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/ContentDeleteOperation.java
 2008-01-02 16:27:50 UTC (rev 6596)
+++ 
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/ContentDeleteOperation.java
 2008-01-02 16:39:44 UTC (rev 6597)
@@ -14,7 +14,7 @@
 
 public class ContentDeleteOperation extends AbstractOperationImpl implements 
RWOperation
 {
-    private Position position = null;
+    private Position position;
 
     private String removedContent;
 
@@ -57,6 +57,9 @@
         }
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public boolean delete(String text, Position position)
     {
         this.removedContent = text;
@@ -64,6 +67,9 @@
         return true;
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public void fromXml(Element e) throws XWikiException
     {
         Element textNode = (Element) 
e.getElementsByTagName(TEXT_NODE_NAME).item(0);
@@ -72,6 +78,9 @@
         position.fromXml((Element) 
e.getElementsByTagName(PositionImpl.NODE_NAME).item(0));
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public Element toXml(Document doc) throws XWikiException
     {
         Element xmlNode = doc.createElement(AbstractOperationImpl.NODE_NAME);
@@ -85,6 +94,9 @@
         return xmlNode;
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public boolean equals(Object other)
     {
         try {
@@ -96,12 +108,18 @@
         }
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public int hashCode()
     {
         return new HashCodeBuilder(5, 
7).append(this.position).append(this.removedContent)
             .toHashCode();
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public String toString()
     {
         return this.getType() + ": [" + this.removedContent + "] at " + 
this.position;

Modified: 
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/ContentInsertOperation.java
===================================================================
--- 
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/ContentInsertOperation.java
 2008-01-02 16:27:50 UTC (rev 6596)
+++ 
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/ContentInsertOperation.java
 2008-01-02 16:39:44 UTC (rev 6597)
@@ -13,7 +13,7 @@
 
 public class ContentInsertOperation extends AbstractOperationImpl implements 
RWOperation
 {
-    private Position position = null;
+    private Position position;
 
     private String addedContent;
 
@@ -27,6 +27,9 @@
         this.setType(Operation.TYPE_CONTENT_INSERT);
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public void apply(XWikiDocument doc) throws XWikiException
     {
         String content = doc.getContent();
@@ -41,6 +44,9 @@
         doc.setContent(content);
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public boolean insert(String text, Position position)
     {
         this.addedContent = text;
@@ -48,6 +54,9 @@
         return true;
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public void fromXml(Element e) throws XWikiException
     {
         Element textNode = (Element) 
e.getElementsByTagName(TEXT_NODE_NAME).item(0);
@@ -56,6 +65,9 @@
         position.fromXml((Element) 
e.getElementsByTagName(PositionImpl.NODE_NAME).item(0));
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public Element toXml(Document doc) throws XWikiException
     {
         Element xmlNode = doc.createElement(AbstractOperationImpl.NODE_NAME);
@@ -67,6 +79,9 @@
         return xmlNode;
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public boolean equals(Object other)
     {
         try {
@@ -78,12 +93,18 @@
         }
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public int hashCode()
     {
         return new HashCodeBuilder(3, 
5).append(this.position).append(this.addedContent)
             .toHashCode();
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public String toString()
     {
         return this.getType() + ": [" + this.addedContent + "] at " + 
this.position;

Modified: 
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/LogicalTimeImpl.java
===================================================================
--- 
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/LogicalTimeImpl.java
        2008-01-02 16:27:50 UTC (rev 6596)
+++ 
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/LogicalTimeImpl.java
        2008-01-02 16:39:44 UTC (rev 6597)
@@ -19,17 +19,26 @@
         fromXml(e);
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public void fromXml(Element e) throws XWikiException
     {
         // TODO Auto-generated method stub
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public Element toXml(Document doc) throws XWikiException
     {
         Element xmlNode = doc.createElement(NODE_NAME);
         return xmlNode;
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public int compareTo(Object other)
     {
         if (!(other instanceof LogicalTimeImpl))

Modified: 
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/OriginatorImpl.java
===================================================================
--- 
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/OriginatorImpl.java
 2008-01-02 16:27:50 UTC (rev 6596)
+++ 
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/OriginatorImpl.java
 2008-01-02 16:39:44 UTC (rev 6597)
@@ -9,49 +9,80 @@
 public class OriginatorImpl implements RWOriginator
 {
     public static final String NODE_NAME = "originator";
+
     public static final String AUTHOR_ATTRIBUTE_NAME = "author";
+
     public static final String HOST_ATTRIBUTE_NAME = "host";
+
     public static final String WIKI_ATTRIBUTE_NAME = "wiki";
+
     private String author;
+
     private String hostId;
+
     private String wikiId;
+
+    /**
+     * [EMAIL PROTECTED]
+     */
+    public String getAuthor()
+    {
+        return this.author;
+    }
+
+    /**
+     * [EMAIL PROTECTED]
+     */
     public void setAuthor(String author)
     {
         this.author = author;
     }
 
-    public void setHostId(String hostId)
+    /**
+     * [EMAIL PROTECTED]
+     */
+    public String getWikiId()
     {
-        this.hostId = hostId;
+        return this.wikiId;
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public void setWikiId(String wikiId)
     {
         this.wikiId = wikiId;
     }
 
-    public void fromXml(Element e) throws XWikiException
+    /**
+     * [EMAIL PROTECTED]
+     */
+    public String getHostId()
     {
-        this.author = e.getAttribute(AUTHOR_ATTRIBUTE_NAME);
-        this.hostId = e.getAttribute(HOST_ATTRIBUTE_NAME);
-        this.wikiId = e.getAttribute(WIKI_ATTRIBUTE_NAME);
+        return this.hostId;
     }
 
-    public String getAuthor()
+    /**
+     * [EMAIL PROTECTED]
+     */
+    public void setHostId(String hostId)
     {
-        return this.author;
+        this.hostId = hostId;
     }
 
-    public String getHostId()
+    /**
+     * [EMAIL PROTECTED]
+     */
+    public void fromXml(Element e) throws XWikiException
     {
-        return this.hostId;
+        this.author = e.getAttribute(AUTHOR_ATTRIBUTE_NAME);
+        this.hostId = e.getAttribute(HOST_ATTRIBUTE_NAME);
+        this.wikiId = e.getAttribute(WIKI_ATTRIBUTE_NAME);
     }
 
-    public String getWikiId()
-    {
-        return this.wikiId;
-    }
-
+    /**
+     * [EMAIL PROTECTED]
+     */
     public Element toXml(Document doc) throws XWikiException
     {
         Element xmlNode = doc.createElement(NODE_NAME);

Modified: 
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/PatchIdImpl.java
===================================================================
--- 
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/PatchIdImpl.java
    2008-01-02 16:27:50 UTC (rev 6596)
+++ 
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/PatchIdImpl.java
    2008-01-02 16:39:44 UTC (rev 6597)
@@ -32,26 +32,41 @@
 
     private LogicalTime logicalTime;
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public void setDocumentId(String documentId)
     {
         this.documentId = documentId;
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public void setHostId(String hostId)
     {
         this.hostId = hostId;
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public void setLogicalTime(LogicalTime logicalTime)
     {
         this.logicalTime = logicalTime;
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public void setTime(Date time)
     {
         this.time = time;
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public void fromXml(Element e) throws XWikiException
     {
         try {
@@ -70,26 +85,41 @@
         }
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public String getDocumentId()
     {
         return this.documentId;
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public String getHostId()
     {
         return this.hostId;
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public LogicalTime getLogicalTime()
     {
         return this.logicalTime;
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public Date getTime()
     {
         return this.time;
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public Element toXml(Document doc) throws XWikiException
     {
         Element xmlNode = doc.createElement(NODE_NAME);

Modified: 
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/PositionImpl.java
===================================================================
--- 
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/PositionImpl.java
   2008-01-02 16:27:50 UTC (rev 6596)
+++ 
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/PositionImpl.java
   2008-01-02 16:39:44 UTC (rev 6597)
@@ -24,9 +24,9 @@
 
     public static final String AFTER_ATTRIBUTE_NAME = "after";
 
-    private String before = null;
+    private String before;
 
-    private String after = null;
+    private String after;
 
     private int row = -1;
 
@@ -62,6 +62,9 @@
         this.after = after;
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public boolean checkPosition(String text)
     {
         String[] rows = StringUtils.splitPreserveAllTokens(text, '\n');
@@ -74,6 +77,9 @@
         return false;
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public String getTextBeforePosition(String text)
     {
         String[] rows = StringUtils.splitPreserveAllTokens(text, '\n');
@@ -81,6 +87,9 @@
             + StringUtils.substring(rows[row], 0, column);
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public String getTextAfterPosition(String text)
     {
         String[] rows = StringUtils.splitPreserveAllTokens(text, '\n');
@@ -90,6 +99,9 @@
         return (span <= 0) ? textAfter : textAfter.substring(span);
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public void fromXml(Element e) throws XWikiException
     {
         this.row = Integer.parseInt(e.getAttribute(ROW_ATTRIBUTE_NAME));
@@ -102,6 +114,9 @@
         }
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public Element toXml(Document doc) throws XWikiException
     {
         Element xmlNode = doc.createElement(NODE_NAME);
@@ -116,6 +131,9 @@
         return xmlNode;
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public boolean equals(Object other)
     {
         try {
@@ -131,6 +149,9 @@
         }
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public int hashCode()
     {
         return new HashCodeBuilder(5, 
47).append(this.row).append(this.column).append(
@@ -138,6 +159,9 @@
             .toHashCode();
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public String toString()
     {
         return "@" + this.row + "," + this.column + ": << [" + this.before + 
"] >> ["

Modified: 
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/PropertySetOperation.java
===================================================================
--- 
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/PropertySetOperation.java
   2008-01-02 16:27:50 UTC (rev 6596)
+++ 
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/impl/PropertySetOperation.java
   2008-01-02 16:39:44 UTC (rev 6597)
@@ -47,6 +47,9 @@
         }
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public boolean setProperty(String property, String value)
     {
         this.propertyName = property;
@@ -54,6 +57,9 @@
         return true;
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public void fromXml(Element e) throws XWikiException
     {
         Element textNode = (Element) e.getFirstChild();
@@ -63,6 +69,9 @@
             
StringEscapeUtils.unescapeXml(textNode.getAttribute(VALUE_ATTRIBUTE_NAME));
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public Element toXml(Document doc) throws XWikiException
     {
         Element xmlNode = doc.createElement(AbstractOperationImpl.NODE_NAME);
@@ -77,6 +86,9 @@
         return xmlNode;
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public boolean equals(Object other)
     {
         try {
@@ -88,12 +100,18 @@
         }
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public int hashCode()
     {
         return new HashCodeBuilder(7, 
11).append(this.propertyName).append(this.propertyValue)
             .toHashCode();
     }
 
+    /**
+     * [EMAIL PROTECTED]
+     */
     public String toString()
     {
         return this.getType() + ": [" + this.propertyName + "] to [" + 
this.propertyValue + "]";

Modified: 
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/web/PatchServiceAction.java
===================================================================
--- 
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/web/PatchServiceAction.java
      2008-01-02 16:27:50 UTC (rev 6596)
+++ 
xwiki-platform/core/trunk/xwiki-patchservice/src/main/java/org/xwiki/platform/patchservice/web/PatchServiceAction.java
      2008-01-02 16:39:44 UTC (rev 6597)
@@ -7,6 +7,7 @@
 public class PatchServiceAction extends XWikiAction
 {
     /**
+     * [EMAIL PROTECTED]
      * @todo Write me!
      */
     public boolean action(XWikiContext context) throws XWikiException

Modified: 
xwiki-platform/core/trunk/xwiki-patchservice/src/test/java/org/xwiki/platform/ClassPropertyOperationsTest.java
===================================================================
--- 
xwiki-platform/core/trunk/xwiki-patchservice/src/test/java/org/xwiki/platform/ClassPropertyOperationsTest.java
      2008-01-02 16:27:50 UTC (rev 6596)
+++ 
xwiki-platform/core/trunk/xwiki-patchservice/src/test/java/org/xwiki/platform/ClassPropertyOperationsTest.java
      2008-01-02 16:39:44 UTC (rev 6597)
@@ -47,7 +47,7 @@
         bclass.addTextField("prop1", "Property 1", 30);
         bclass.addBooleanField("prop2", "Property 2", "yesno");
         for (Iterator it = bclass.getFieldList().iterator(); it.hasNext();) {
-            RWOperation operation = getOperation((PropertyClass) it.next());
+            RWOperation operation = getOperation((PropertyClass) it.next(), 
true);
             operation.apply(doc);
         }
         assertEquals(2, doc.getxWikiClass().getProperties().length);
@@ -60,7 +60,7 @@
     public void testApplyTwicePropertyAddOperation() throws XWikiException
     {
         bclass.addTextField("prop1", "Property 1", 30);
-        RWOperation operation = getOperation((PropertyClass) 
bclass.getProperties()[0]);
+        RWOperation operation = getOperation((PropertyClass) 
bclass.getProperties()[0], true);
         operation.apply(doc);
         operation.apply(doc);
         assertEquals(1, doc.getxWikiClass().getProperties().length);
@@ -84,14 +84,32 @@
     public void testXmlRoundtripPropertyAddOperation() throws XWikiException
     {
         bclass.addTextField("prop1", "Property 1", 30);
-        RWOperation operation = getOperation((PropertyClass) 
bclass.getProperties()[0]);
+        RWOperation operation = getOperation((PropertyClass) 
bclass.getProperties()[0], true);
         Element e = operation.toXml(domDoc);
         Operation loadedOperation = 
OperationFactoryImpl.getInstance().loadOperation(e);
         assertEquals(loadedOperation, operation);
     }
 
-    private RWOperation getOperation(PropertyClass property) throws 
XWikiException
+    public void testApplyPropertySetOperation() throws XWikiException
     {
+        testApplyPropertyAddOperation();
+        ((PropertyClass) bclass.get("prop1")).setPrettyName("new Property 1");
+        RWOperation operation = getOperation((PropertyClass) 
bclass.get("prop1"), false);
+        operation.apply(doc);
+        assertEquals("new Property 1", ((PropertyClass) 
doc.getxWikiClass().get("prop1")).getPrettyName());
+    }
+
+    public void testXmlRoundtripPropertySetOperation() throws XWikiException
+    {
+        bclass.addTextField("prop1", "Property 1", 30);
+        RWOperation operation = getOperation((PropertyClass) 
bclass.getProperties()[0], true);
+        Element e = operation.toXml(domDoc);
+        Operation loadedOperation = 
OperationFactoryImpl.getInstance().loadOperation(e);
+        assertEquals(loadedOperation, operation);
+    }
+
+    private RWOperation getOperation(PropertyClass property, boolean create) 
throws XWikiException
+    {
         String type = property.getClass().getCanonicalName();
         Map config = new HashMap();
         for (Iterator it2 = property.getFieldList().iterator(); 
it2.hasNext();) {
@@ -99,8 +117,12 @@
             config.put(pr.getName(), pr.getValue());
         }
         RWOperation operation =
-            
OperationFactoryImpl.getInstance().newOperation(RWOperation.TYPE_CLASS_PROPERTY_ADD);
-        operation.createType(type, config);
+            OperationFactoryImpl.getInstance().newOperation(create ? 
RWOperation.TYPE_CLASS_PROPERTY_ADD : RWOperation.TYPE_CLASS_PROPERTY_CHANGE);
+        if (create) {
+            operation.createType(type, config);
+        } else {
+            operation.modifyType(type, config);
+        }
         return operation;
     }
 }

_______________________________________________
notifications mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/notifications

Reply via email to