diff --git a/scm-core/src/main/java/sonia/scm/repository/Changeset.java b/scm-core/src/main/java/sonia/scm/repository/Changeset.java index c7adbec394..f0abf95c45 100644 --- a/scm-core/src/main/java/sonia/scm/repository/Changeset.java +++ b/scm-core/src/main/java/sonia/scm/repository/Changeset.java @@ -38,6 +38,7 @@ package sonia.scm.repository; import sonia.scm.Validateable; import sonia.scm.util.Util; import sonia.scm.util.ValidationUtil; +import sonia.scm.xml.XmlMapStringAdapter; //~--- JDK imports ------------------------------------------------------------ @@ -45,12 +46,15 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.Date; +import java.util.HashMap; import java.util.List; +import java.util.Map; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; /** * @@ -321,6 +325,22 @@ public class Changeset implements Validateable, Cloneable, Serializable return modifications; } + /** + * Method description + * + * + * @return + */ + public Map getProperties() + { + if (properties == null) + { + properties = new HashMap(); + } + + return properties; + } + /** * Method description * @@ -418,6 +438,17 @@ public class Changeset implements Validateable, Cloneable, Serializable this.modifications = modifications; } + /** + * Method description + * + * + * @param properties + */ + public void setProperties(Map properties) + { + this.properties = properties; + } + /** * Method description * @@ -450,6 +481,10 @@ public class Changeset implements Validateable, Cloneable, Serializable @XmlElement(name = "modifications") private Modifications modifications; + /** changeset properties */ + @XmlJavaTypeAdapter(XmlMapStringAdapter.class) + private Map properties; + /** The name of the branches on which the changeset was committed. */ private List tags; } diff --git a/scm-core/src/main/java/sonia/scm/xml/XmlMapStringAdapter.java b/scm-core/src/main/java/sonia/scm/xml/XmlMapStringAdapter.java new file mode 100644 index 0000000000..e8a4f32906 --- /dev/null +++ b/scm-core/src/main/java/sonia/scm/xml/XmlMapStringAdapter.java @@ -0,0 +1,100 @@ +/** + * Copyright (c) 2010, Sebastian Sdorra + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of SCM-Manager; nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * http://bitbucket.org/sdorra/scm-manager + * + */ + + + +package sonia.scm.xml; + +//~--- JDK imports ------------------------------------------------------------ + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import javax.xml.bind.annotation.adapters.XmlAdapter; + +/** + * + * @author Sebastian Sdorra + */ +public class XmlMapStringAdapter + extends XmlAdapter, Map> +{ + + /** + * Method description + * + * + * @param map + * + * @return + * + * @throws Exception + */ + @Override + public Set marshal(Map map) + throws Exception + { + Set set = new HashSet(); + + for (Map.Entry e : map.entrySet()) + { + set.add(new XmlMapStringElement(e.getKey(), e.getValue())); + } + + return set; + } + + /** + * Method description + * + * + * @param set + * + * @return + * + * @throws Exception + */ + @Override + public Map unmarshal(Set set) + throws Exception + { + Map map = new HashMap(); + + for (XmlMapStringElement e : set) + { + map.put(e.getKey(), e.getValue()); + } + + return map; + } +} diff --git a/scm-core/src/main/java/sonia/scm/xml/XmlMapStringElement.java b/scm-core/src/main/java/sonia/scm/xml/XmlMapStringElement.java new file mode 100644 index 0000000000..79a0e89c0f --- /dev/null +++ b/scm-core/src/main/java/sonia/scm/xml/XmlMapStringElement.java @@ -0,0 +1,125 @@ +/** + * Copyright (c) 2010, Sebastian Sdorra + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of SCM-Manager; nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * http://bitbucket.org/sdorra/scm-manager + * + */ + + + +package sonia.scm.xml; + +//~--- JDK imports ------------------------------------------------------------ + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * + * @author Sebastian Sdorra + */ +@XmlRootElement(name = "element") +@XmlAccessorType(XmlAccessType.FIELD) +public class XmlMapStringElement +{ + + /** + * Constructs ... + * + */ + public XmlMapStringElement() {} + + /** + * Constructs ... + * + * + * @param key + * @param value + */ + public XmlMapStringElement(String key, String value) + { + this.key = key; + this.value = value; + } + + //~--- get methods ---------------------------------------------------------- + + /** + * Method description + * + * + * @return + */ + public String getKey() + { + return key; + } + + /** + * Method description + * + * + * @return + */ + public String getValue() + { + return value; + } + + //~--- set methods ---------------------------------------------------------- + + /** + * Method description + * + * + * @param key + */ + public void setKey(String key) + { + this.key = key; + } + + /** + * Method description + * + * + * @param value + */ + public void setValue(String value) + { + this.value = value; + } + + //~--- fields --------------------------------------------------------------- + + /** Field description */ + private String key; + + /** Field description */ + private String value; +}