diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..4b8b074 --- /dev/null +++ b/pom.xml @@ -0,0 +1,77 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>pl.com.it-crowd.youtrack-rest-api</groupId> + <artifactId>youtrack-rest-api</artifactId> + <version>1.0.0-SNAPSHOT</version> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.8.2</version> + </dependency> + + <dependency> + <groupId>net.sourceforge.htmlunit</groupId> + <artifactId>htmlunit</artifactId> + <version>2.8</version> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-source-plugin</artifactId> + <version>2.1.2</version> + <executions> + <execution> + <id>attach-sources</id> + <phase>package</phase> + <goals> + <goal>jar-no-fork</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + + <profiles> + <profile> + <id>generate-jaxb-artifacts</id> + <build> + <plugins> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>jaxb2-maven-plugin</artifactId> + <version>1.3</version> + <executions> + <execution> + <goals> + <goal>xjc</goal> + </goals> + </execution> + </executions> + <configuration> + <packageName>pl.com.it_crowd.youtrack.api.rest</packageName> + <outputDirectory>${build.sourceDirectory}</outputDirectory> + <clearOutputDir>false</clearOutputDir> + </configuration> + </plugin> + </plugins> + </build> + </profile> + </profiles> + + <distributionManagement> + <snapshotRepository> + <id>it-crowd.com.pl</id> + <name>MyCo Internal Repository</name> + <url>http://artifactory.it-crowd.com.pl/libs-snapshot-local</url> + </snapshotRepository> + </distributionManagement> +</project> \ No newline at end of file diff --git a/src/main/java/pl/com/it_crowd/youtrack/api/IssuesUnmarshaller.java b/src/main/java/pl/com/it_crowd/youtrack/api/IssuesUnmarshaller.java new file mode 100644 index 0000000..7621f92 --- /dev/null +++ b/src/main/java/pl/com/it_crowd/youtrack/api/IssuesUnmarshaller.java @@ -0,0 +1,38 @@ +package pl.com.it_crowd.youtrack.api; + +import org.apache.commons.io.IOUtils; +import pl.com.it_crowd.youtrack.api.rest.Issues; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.io.StringReader; +import java.net.URL; + +public class IssuesUnmarshaller { + + public static Issues unmarshal(String url) throws JAXBException, IOException + { + return unmarshal(new URL(url).openStream()); + } + + public static Issues unmarshal(InputStream stream) throws JAXBException, IOException + { + return unmarshal(new InputStreamReader(stream)); + } + + public static Issues unmarshal(Reader reader) throws JAXBException, IOException + { + String content = IOUtils.toString(reader); + try { + JAXBContext jaxbContext = JAXBContext.newInstance(Issues.class.getPackage().getName()); + return (Issues) jaxbContext.createUnmarshaller().unmarshal(new StringReader(content)); + } catch (JAXBException e) { + System.err.println("Cannot unmarshal input stream.\n" + content + e); + throw e; + } + } +} diff --git a/src/main/java/pl/com/it_crowd/youtrack/api/rest/Issues.java b/src/main/java/pl/com/it_crowd/youtrack/api/rest/Issues.java new file mode 100644 index 0000000..c6b0128 --- /dev/null +++ b/src/main/java/pl/com/it_crowd/youtrack/api/rest/Issues.java @@ -0,0 +1,810 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2011.12.05 at 08:56:01 AM CET +// + +package pl.com.it_crowd.youtrack.api.rest; + +import javax.xml.bind.JAXBElement; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementRef; +import javax.xml.bind.annotation.XmlElements; +import javax.xml.bind.annotation.XmlMixed; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlValue; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +/** + * <p>Java class for anonymous complex type. + * <p/> + * <p>The following schema fragment specifies the expected content contained within this class. + * <p/> + * <pre> + * <complexType> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> + * <element name="issue" maxOccurs="unbounded" minOccurs="0"> + * <complexType> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <choice maxOccurs="unbounded" minOccurs="0"> + * <element name="field"> + * <complexType> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> + * <element name="value" maxOccurs="unbounded" minOccurs="0"> + * <complexType> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <attribute name="type" type="{http://www.w3.org/2001/XMLSchema}string" /> + * <attribute name="role" type="{http://www.w3.org/2001/XMLSchema}string" /> + * </restriction> + * </complexContent> + * </complexType> + * </element> + * </sequence> + * <attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" /> + * </restriction> + * </complexContent> + * </complexType> + * </element> + * <element name="comment"> + * <complexType> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> + * <element name="replies" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * <element name="value" minOccurs="0"> + * <complexType> + * <simpleContent> + * <extension base="<http://www.w3.org/2001/XMLSchema>string"> + * <attribute name="type" type="{http://www.w3.org/2001/XMLSchema}string" /> + * <attribute name="role" type="{http://www.w3.org/2001/XMLSchema}string" /> + * </extension> + * </simpleContent> + * </complexType> + * </element> + * </sequence> + * <attribute name="id" type="{http://www.w3.org/2001/XMLSchema}string" /> + * <attribute name="author" type="{http://www.w3.org/2001/XMLSchema}string" /> + * <attribute name="issueId" type="{http://www.w3.org/2001/XMLSchema}string" /> + * <attribute name="deleted" type="{http://www.w3.org/2001/XMLSchema}string" /> + * <attribute name="text" type="{http://www.w3.org/2001/XMLSchema}string" /> + * <attribute name="shownForIssueAuthor" type="{http://www.w3.org/2001/XMLSchema}string" /> + * <attribute name="created" type="{http://www.w3.org/2001/XMLSchema}string" /> + * <attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" /> + * </restriction> + * </complexContent> + * </complexType> + * </element> + * </choice> + * <attribute name="id" type="{http://www.w3.org/2001/XMLSchema}string" /> + * </restriction> + * </complexContent> + * </complexType> + * </element> + * </sequence> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = {"issue"}) +@XmlRootElement(name = "issues") +public class Issues { + + protected List<Issues.Issue> issue; + + /** + * Gets the value of the issue property. + * <p/> + * <p/> + * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a <CODE>set</CODE> method for the issue property. + * <p/> + * <p/> + * For example, to add a new item, do as follows: + * <pre> + * getIssue().add(newItem); + * </pre> + * <p/> + * <p/> + * <p/> + * Objects of the following type(s) are allowed in the list + * {@link Issues.Issue } + */ + public List<Issues.Issue> getIssue() + { + if (issue == null) { + issue = new ArrayList<Issues.Issue>(); + } + return this.issue; + } + + /** + * <p>Java class for anonymous complex type. + * <p/> + * <p>The following schema fragment specifies the expected content contained within this class. + * <p/> + * <pre> + * <complexType> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <choice maxOccurs="unbounded" minOccurs="0"> + * <element name="field"> + * <complexType> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> + * <element name="value" maxOccurs="unbounded" minOccurs="0"> + * <complexType> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <attribute name="type" type="{http://www.w3.org/2001/XMLSchema}string" /> + * <attribute name="role" type="{http://www.w3.org/2001/XMLSchema}string" /> + * </restriction> + * </complexContent> + * </complexType> + * </element> + * </sequence> + * <attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" /> + * </restriction> + * </complexContent> + * </complexType> + * </element> + * <element name="comment"> + * <complexType> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> + * <element name="replies" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * <element name="value" minOccurs="0"> + * <complexType> + * <simpleContent> + * <extension base="<http://www.w3.org/2001/XMLSchema>string"> + * <attribute name="type" type="{http://www.w3.org/2001/XMLSchema}string" /> + * <attribute name="role" type="{http://www.w3.org/2001/XMLSchema}string" /> + * </extension> + * </simpleContent> + * </complexType> + * </element> + * </sequence> + * <attribute name="id" type="{http://www.w3.org/2001/XMLSchema}string" /> + * <attribute name="author" type="{http://www.w3.org/2001/XMLSchema}string" /> + * <attribute name="issueId" type="{http://www.w3.org/2001/XMLSchema}string" /> + * <attribute name="deleted" type="{http://www.w3.org/2001/XMLSchema}string" /> + * <attribute name="text" type="{http://www.w3.org/2001/XMLSchema}string" /> + * <attribute name="shownForIssueAuthor" type="{http://www.w3.org/2001/XMLSchema}string" /> + * <attribute name="created" type="{http://www.w3.org/2001/XMLSchema}string" /> + * <attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" /> + * </restriction> + * </complexContent> + * </complexType> + * </element> + * </choice> + * <attribute name="id" type="{http://www.w3.org/2001/XMLSchema}string" /> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "", propOrder = {"fieldOrComment"}) + public static class Issue { + + @XmlElements({@XmlElement(name = "field", type = Issues.Issue.Field.class), @XmlElement(name = "comment", type = Issues.Issue.Comment.class)}) + protected List<Object> fieldOrComment; + + @XmlAttribute + protected String id; + + /** + * Gets the value of the fieldOrComment property. + * <p/> + * <p/> + * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a <CODE>set</CODE> method for the fieldOrComment property. + * <p/> + * <p/> + * For example, to add a new item, do as follows: + * <pre> + * getFieldOrComment().add(newItem); + * </pre> + * <p/> + * <p/> + * <p/> + * Objects of the following type(s) are allowed in the list + * {@link Issues.Issue.Field } + * {@link Issues.Issue.Comment } + */ + public List<Object> getFieldOrComment() + { + if (fieldOrComment == null) { + fieldOrComment = new ArrayList<Object>(); + } + return this.fieldOrComment; + } + + /** + * Gets the value of the id property. + * + * @return possible object is + * {@link String } + */ + public String getId() + { + return id; + } + + /** + * Sets the value of the id property. + * + * @param value allowed object is + * {@link String } + */ + public void setId(String value) + { + this.id = value; + } + + /** + * <p>Java class for anonymous complex type. + * <p/> + * <p>The following schema fragment specifies the expected content contained within this class. + * <p/> + * <pre> + * <complexType> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> + * <element name="replies" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> + * <element name="value" minOccurs="0"> + * <complexType> + * <simpleContent> + * <extension base="<http://www.w3.org/2001/XMLSchema>string"> + * <attribute name="type" type="{http://www.w3.org/2001/XMLSchema}string" /> + * <attribute name="role" type="{http://www.w3.org/2001/XMLSchema}string" /> + * </extension> + * </simpleContent> + * </complexType> + * </element> + * </sequence> + * <attribute name="id" type="{http://www.w3.org/2001/XMLSchema}string" /> + * <attribute name="author" type="{http://www.w3.org/2001/XMLSchema}string" /> + * <attribute name="issueId" type="{http://www.w3.org/2001/XMLSchema}string" /> + * <attribute name="deleted" type="{http://www.w3.org/2001/XMLSchema}string" /> + * <attribute name="text" type="{http://www.w3.org/2001/XMLSchema}string" /> + * <attribute name="shownForIssueAuthor" type="{http://www.w3.org/2001/XMLSchema}string" /> + * <attribute name="created" type="{http://www.w3.org/2001/XMLSchema}string" /> + * <attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" /> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "", propOrder = {"replies", "value"}) + public static class Comment { + + protected String replies; + + protected Issues.Issue.Comment.Value value; + + @XmlAttribute + protected String id; + + @XmlAttribute + protected String author; + + @XmlAttribute + protected String issueId; + + @XmlAttribute + protected String deleted; + + @XmlAttribute + protected String text; + + @XmlAttribute + protected String shownForIssueAuthor; + + @XmlAttribute + protected String created; + + @XmlAttribute + protected String name; + + /** + * Gets the value of the replies property. + * + * @return possible object is + * {@link String } + */ + public String getReplies() + { + return replies; + } + + /** + * Sets the value of the replies property. + * + * @param value allowed object is + * {@link String } + */ + public void setReplies(String value) + { + this.replies = value; + } + + /** + * Gets the value of the value property. + * + * @return possible object is + * {@link Issues.Issue.Comment.Value } + */ + public Issues.Issue.Comment.Value getValue() + { + return value; + } + + /** + * Sets the value of the value property. + * + * @param value allowed object is + * {@link Issues.Issue.Comment.Value } + */ + public void setValue(Issues.Issue.Comment.Value value) + { + this.value = value; + } + + /** + * Gets the value of the id property. + * + * @return possible object is + * {@link String } + */ + public String getId() + { + return id; + } + + /** + * Sets the value of the id property. + * + * @param value allowed object is + * {@link String } + */ + public void setId(String value) + { + this.id = value; + } + + /** + * Gets the value of the author property. + * + * @return possible object is + * {@link String } + */ + public String getAuthor() + { + return author; + } + + /** + * Sets the value of the author property. + * + * @param value allowed object is + * {@link String } + */ + public void setAuthor(String value) + { + this.author = value; + } + + /** + * Gets the value of the issueId property. + * + * @return possible object is + * {@link String } + */ + public String getIssueId() + { + return issueId; + } + + /** + * Sets the value of the issueId property. + * + * @param value allowed object is + * {@link String } + */ + public void setIssueId(String value) + { + this.issueId = value; + } + + /** + * Gets the value of the deleted property. + * + * @return possible object is + * {@link String } + */ + public String getDeleted() + { + return deleted; + } + + /** + * Sets the value of the deleted property. + * + * @param value allowed object is + * {@link String } + */ + public void setDeleted(String value) + { + this.deleted = value; + } + + /** + * Gets the value of the text property. + * + * @return possible object is + * {@link String } + */ + public String getText() + { + return text; + } + + /** + * Sets the value of the text property. + * + * @param value allowed object is + * {@link String } + */ + public void setText(String value) + { + this.text = value; + } + + /** + * Gets the value of the shownForIssueAuthor property. + * + * @return possible object is + * {@link String } + */ + public String getShownForIssueAuthor() + { + return shownForIssueAuthor; + } + + /** + * Sets the value of the shownForIssueAuthor property. + * + * @param value allowed object is + * {@link String } + */ + public void setShownForIssueAuthor(String value) + { + this.shownForIssueAuthor = value; + } + + /** + * Gets the value of the created property. + * + * @return possible object is + * {@link String } + */ + public String getCreated() + { + return created; + } + + /** + * Sets the value of the created property. + * + * @param value allowed object is + * {@link String } + */ + public void setCreated(String value) + { + this.created = value; + } + + /** + * Gets the value of the name property. + * + * @return possible object is + * {@link String } + */ + public String getName() + { + return name; + } + + /** + * Sets the value of the name property. + * + * @param value allowed object is + * {@link String } + */ + public void setName(String value) + { + this.name = value; + } + + /** + * <p>Java class for anonymous complex type. + * <p/> + * <p>The following schema fragment specifies the expected content contained within this class. + * <p/> + * <pre> + * <complexType> + * <simpleContent> + * <extension base="<http://www.w3.org/2001/XMLSchema>string"> + * <attribute name="type" type="{http://www.w3.org/2001/XMLSchema}string" /> + * <attribute name="role" type="{http://www.w3.org/2001/XMLSchema}string" /> + * </extension> + * </simpleContent> + * </complexType> + * </pre> + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "", propOrder = {"value"}) + public static class Value { + + @XmlValue + protected String value; + + @XmlAttribute + protected String type; + + @XmlAttribute + protected String role; + + /** + * Gets the value of the value property. + * + * @return possible object is + * {@link String } + */ + public String getValue() + { + return value; + } + + /** + * Sets the value of the value property. + * + * @param value allowed object is + * {@link String } + */ + public void setValue(String value) + { + this.value = value; + } + + /** + * Gets the value of the type property. + * + * @return possible object is + * {@link String } + */ + public String getType() + { + return type; + } + + /** + * Sets the value of the type property. + * + * @param value allowed object is + * {@link String } + */ + public void setType(String value) + { + this.type = value; + } + + /** + * Gets the value of the role property. + * + * @return possible object is + * {@link String } + */ + public String getRole() + { + return role; + } + + /** + * Sets the value of the role property. + * + * @param value allowed object is + * {@link String } + */ + public void setRole(String value) + { + this.role = value; + } + } + } + + /** + * <p>Java class for anonymous complex type. + * <p/> + * <p>The following schema fragment specifies the expected content contained within this class. + * <p/> + * <pre> + * <complexType> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <sequence> + * <element name="value" maxOccurs="unbounded" minOccurs="0"> + * <complexType> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <attribute name="type" type="{http://www.w3.org/2001/XMLSchema}string" /> + * <attribute name="role" type="{http://www.w3.org/2001/XMLSchema}string" /> + * </restriction> + * </complexContent> + * </complexType> + * </element> + * </sequence> + * <attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" /> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "", propOrder = {"content"}) + public static class Field { + + @XmlElementRef(name = "value", type = JAXBElement.class) + @XmlMixed + protected List<Serializable> content; + + @XmlAttribute + protected String name; + + /** + * Gets the value of the content property. + * <p/> + * <p/> + * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a <CODE>set</CODE> method for the content property. + * <p/> + * <p/> + * For example, to add a new item, do as follows: + * <pre> + * getContent().add(newItem); + * </pre> + * <p/> + * <p/> + * <p/> + * Objects of the following type(s) are allowed in the list + * {@link String } + * {@link JAXBElement }{@code <}{@link Issues.Issue.Field.Value }{@code >} + */ + public List<Serializable> getContent() + { + if (content == null) { + content = new ArrayList<Serializable>(); + } + return this.content; + } + + /** + * Gets the value of the name property. + * + * @return possible object is + * {@link String } + */ + public String getName() + { + return name; + } + + /** + * Sets the value of the name property. + * + * @param value allowed object is + * {@link String } + */ + public void setName(String value) + { + this.name = value; + } + + /** + * <p>Java class for anonymous complex type. + * <p/> + * <p>The following schema fragment specifies the expected content contained within this class. + * <p/> + * <pre> + * <complexType> + * <complexContent> + * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> + * <attribute name="type" type="{http://www.w3.org/2001/XMLSchema}string" /> + * <attribute name="role" type="{http://www.w3.org/2001/XMLSchema}string" /> + * </restriction> + * </complexContent> + * </complexType> + * </pre> + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "") + public static class Value { + + @XmlAttribute + protected String type; + + @XmlAttribute + protected String role; + + /** + * Gets the value of the type property. + * + * @return possible object is + * {@link String } + */ + public String getType() + { + return type; + } + + /** + * Sets the value of the type property. + * + * @param value allowed object is + * {@link String } + */ + public void setType(String value) + { + this.type = value; + } + + /** + * Gets the value of the role property. + * + * @return possible object is + * {@link String } + */ + public String getRole() + { + return role; + } + + /** + * Sets the value of the role property. + * + * @param value allowed object is + * {@link String } + */ + public void setRole(String value) + { + this.role = value; + } + } + } + } +} diff --git a/src/main/java/pl/com/it_crowd/youtrack/api/rest/ObjectFactory.java b/src/main/java/pl/com/it_crowd/youtrack/api/rest/ObjectFactory.java new file mode 100644 index 0000000..aaa5260 --- /dev/null +++ b/src/main/java/pl/com/it_crowd/youtrack/api/rest/ObjectFactory.java @@ -0,0 +1,96 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833 +// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2011.12.05 at 08:56:01 AM CET +// + +package pl.com.it_crowd.youtrack.api.rest; + +import javax.xml.bind.JAXBElement; +import javax.xml.bind.annotation.XmlElementDecl; +import javax.xml.bind.annotation.XmlRegistry; +import javax.xml.namespace.QName; + +/** + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the pl.com.it_crowd.youtrack.api.rest package. + * <p>An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are + * provided in this class. + */ +@XmlRegistry +public class ObjectFactory { + + private final static QName _IssuesIssueFieldValue_QNAME = new QName("", "value"); + + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: pl.com.it_crowd.youtrack.api.rest + */ + public ObjectFactory() + { + } + + /** + * Create an instance of {@link Issues.Issue.Comment.Value } + */ + public Issues.Issue.Comment.Value createIssuesIssueCommentValue() + { + return new Issues.Issue.Comment.Value(); + } + + /** + * Create an instance of {@link Issues.Issue.Comment } + */ + public Issues.Issue.Comment createIssuesIssueComment() + { + return new Issues.Issue.Comment(); + } + + /** + * Create an instance of {@link Issues.Issue.Field } + */ + public Issues.Issue.Field createIssuesIssueField() + { + return new Issues.Issue.Field(); + } + + /** + * Create an instance of {@link Issues } + */ + public Issues createIssues() + { + return new Issues(); + } + + /** + * Create an instance of {@link Issues.Issue } + */ + public Issues.Issue createIssuesIssue() + { + return new Issues.Issue(); + } + + /** + * Create an instance of {@link Issues.Issue.Field.Value } + */ + public Issues.Issue.Field.Value createIssuesIssueFieldValue() + { + return new Issues.Issue.Field.Value(); + } + + /** + * Create an instance of {@link JAXBElement }{@code <}{@link Issues.Issue.Field.Value }{@code >}} + */ + @XmlElementDecl(namespace = "", name = "value", scope = Issues.Issue.Field.class) + public JAXBElement<Issues.Issue.Field.Value> createIssuesIssueFieldValue(Issues.Issue.Field.Value value) + { + return new JAXBElement<Issues.Issue.Field.Value>(_IssuesIssueFieldValue_QNAME, Issues.Issue.Field.Value.class, Issues.Issue.Field.class, value); + } +} diff --git a/src/main/java/pl/com/it_crowd/youtrack/api/rest/YoutrackAPI.java b/src/main/java/pl/com/it_crowd/youtrack/api/rest/YoutrackAPI.java new file mode 100644 index 0000000..9b64c5f --- /dev/null +++ b/src/main/java/pl/com/it_crowd/youtrack/api/rest/YoutrackAPI.java @@ -0,0 +1,59 @@ +package pl.com.it_crowd.youtrack.api.rest; + +import com.gargoylesoftware.htmlunit.BrowserVersion; +import com.gargoylesoftware.htmlunit.HttpMethod; +import com.gargoylesoftware.htmlunit.Page; +import com.gargoylesoftware.htmlunit.WebClient; +import com.gargoylesoftware.htmlunit.WebRequest; +import com.gargoylesoftware.htmlunit.WebResponse; +import com.gargoylesoftware.htmlunit.util.NameValuePair; +import pl.com.it_crowd.youtrack.api.IssuesUnmarshaller; + +import javax.xml.bind.JAXBException; +import java.io.IOException; +import java.net.URL; +import java.util.ArrayList; + +public class YoutrackAPI { + + private String serviceLocation; + + private WebClient webClient; + + public String getServiceLocation() + { + return serviceLocation; + } + + public YoutrackAPI(String serviceLocation) + { + this.serviceLocation = serviceLocation; + this.webClient = new WebClient(BrowserVersion.FIREFOX_3_6); + this.webClient.setJavaScriptEnabled(false); + this.webClient.setCssEnabled(false); + } + + public YoutrackAPI(String serviceLocation, String username, String password) throws IOException + { + this(serviceLocation); + login(username, password); + } + + public void login(String username, String password) throws IOException + { + ArrayList<NameValuePair> requestParameters = new ArrayList<NameValuePair>(); + requestParameters.add(new NameValuePair("login", username)); + requestParameters.add(new NameValuePair("password", password)); + WebRequest request = new WebRequest(new URL(serviceLocation + "/rest/user/login"), HttpMethod.POST); + request.setRequestParameters(requestParameters); + WebResponse response = webClient.getPage(request).getWebResponse(); + System.out.println(response); + System.out.println(response.getContentAsString()); + } + + public Issues searchIssuesByProject(String project, String filter) throws JAXBException, IOException + { + String url = serviceLocation + "/rest/issue/byproject/" + project + "?filter=" + filter; + return IssuesUnmarshaller.unmarshal(webClient.<Page>getPage(url).getWebResponse().getContentAsStream()); + } +} diff --git a/src/main/xsd/issuesByProject.xml b/src/main/xsd/issuesByProject.xml new file mode 100644 index 0000000..321a578 --- /dev/null +++ b/src/main/xsd/issuesByProject.xml @@ -0,0 +1,587 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<issues> + <issue id="SM-1"> + <field name="voterName"/> + <field name="Priority"> + <value>Normal</value> + </field> + <field name="Type"> + <value>Task</value> + </field> + <field name="State"> + <value>Verified</value> + </field> + <field name="Subsystem"> + <value>No subsystem</value> + </field> + <field name="links"> + <value type="Depend" role="depends on">SM-2</value> + <value type="Depend" role="depends on">SM-3</value> + <value type="Depend" role="depends on">SM-4</value> + <value type="Depend" role="depends on">SM-5</value> + <value type="Depend" role="depends on">SM-6</value> + <value type="Depend" role="depends on">SM-7</value> + <value type="Depend" role="depends on">SM-8</value> + <value type="Depend" role="depends on">SM-9</value> + <value type="Depend" role="depends on">SM-10</value> + </field> + <field name="projectShortName"> + <value>SM</value> + </field> + <field name="numberInProject"> + <value>1</value> + </field> + <field name="summary"> + <value>Draw screens</value> + </field> + <field name="description"> + <value>Draw screens in Balsamiq, the online tool for drawing screen sketches. http://balsamiq.com/ + As a result the screen image in PNG format and Balsamiq source in XML format are expected. + Artefacts must be delivered in form of directory structure (not in Enterprise Architect file). + Partially documented packages will not be accepted. + Sample directory structure: + + Package name (directory) + + Screen name (directory) + - Screen name.png + - Screen name.xml + + In screens include only elements specific to documented screen. Do not include stuff that will land in template. + </value> + </field> + <field name="created"> + <value>1292829185847</value> + </field> + <field name="updated"> + <value>1321871424473</value> + </field> + <field name="updaterName"> + <value>root</value> + </field> + <field name="resolved"> + <value>1321607946298</value> + </field> + <field name="reporterName"> + <value>bernard</value> + </field> + <field name="commentsCount"> + <value>0</value> + </field> + <field name="votes"> + <value>0</value> + </field> + </issue> + <issue id="SM-2"> + <field name="voterName"/> + <comment id="39-74" author="bernard" issueId="SM-2" deleted="false" text="See parent task for details." shownForIssueAuthor="false" + created="1292829250455"> + <replies/> + </comment> + <field name="Priority"> + <value>Normal</value> + </field> + <field name="Type"> + <value>Task</value> + </field> + <field name="State"> + <value>Verified</value> + </field> + <field name="Assignee"> + <value>tomek</value> + </field> + <field name="Subsystem"> + <value>No subsystem</value> + </field> + <field name="links"> + <value type="Depend" role="is required for">SM-1</value> + </field> + <field name="projectShortName"> + <value>SM</value> + </field> + <field name="numberInProject"> + <value>2</value> + </field> + <field name="summary"> + <value>Draw screens for "Courses & classes" package</value> + </field> + <field name="created"> + <value>1292829263475</value> + </field> + <field name="updated"> + <value>1321871424473</value> + </field> + <field name="updaterName"> + <value>root</value> + </field> + <field name="resolved"> + <value>1321607946297</value> + </field> + <field name="reporterName"> + <value>bernard</value> + </field> + <field name="commentsCount"> + <value>1</value> + </field> + <field name="votes"> + <value>0</value> + </field> + </issue> + <issue id="SM-3"> + <field name="voterName"/> + <comment id="39-75" author="bernard" issueId="SM-3" deleted="false" text="See parent task for details." shownForIssueAuthor="false" + created="1292829295404"> + <replies/> + </comment> + <field name="Priority"> + <value>Normal</value> + </field> + <field name="Type"> + <value>Task</value> + </field> + <field name="State"> + <value>Verified</value> + </field> + <field name="Assignee"> + <value>tomek</value> + </field> + <field name="Subsystem"> + <value>No subsystem</value> + </field> + <field name="links"> + <value type="Depend" role="is required for">SM-1</value> + </field> + <field name="projectShortName"> + <value>SM</value> + </field> + <field name="numberInProject"> + <value>3</value> + </field> + <field name="summary"> + <value>Draw screens for "Discounts" package</value> + </field> + <field name="created"> + <value>1292829302297</value> + </field> + <field name="updated"> + <value>1321871424473</value> + </field> + <field name="updaterName"> + <value>root</value> + </field> + <field name="resolved"> + <value>1321607946296</value> + </field> + <field name="reporterName"> + <value>bernard</value> + </field> + <field name="commentsCount"> + <value>1</value> + </field> + <field name="votes"> + <value>0</value> + </field> + </issue> + <issue id="SM-4"> + <field name="voterName"/> + <comment id="39-76" author="bernard" issueId="SM-4" deleted="false" text="See parent task for details." shownForIssueAuthor="false" + created="1292829335014"> + <replies/> + </comment> + <comment id="39-86" author="tomek" issueId="SM-4" deleted="false" + text="Some use cases are related to "Students" and "Courses and Classes" packages. These weren't finished yet." + shownForIssueAuthor="false" created="1292932584457"> + <replies/> + </comment> + <field name="Priority"> + <value>Normal</value> + </field> + <field name="Type"> + <value>Task</value> + </field> + <field name="State"> + <value>Verified</value> + </field> + <field name="Assignee"> + <value>tomek</value> + </field> + <field name="Subsystem"> + <value>No subsystem</value> + </field> + <field name="links"> + <value type="Depend" role="is required for">SM-1</value> + </field> + <field name="projectShortName"> + <value>SM</value> + </field> + <field name="numberInProject"> + <value>4</value> + </field> + <field name="summary"> + <value>Draw screens for "Passes" package</value> + </field> + <field name="created"> + <value>1292829339100</value> + </field> + <field name="updated"> + <value>1321871424473</value> + </field> + <field name="updaterName"> + <value>root</value> + </field> + <field name="resolved"> + <value>1321607946296</value> + </field> + <field name="reporterName"> + <value>bernard</value> + </field> + <field name="commentsCount"> + <value>2</value> + </field> + <field name="votes"> + <value>0</value> + </field> + </issue> + <issue id="SM-5"> + <field name="voterName"/> + <comment id="39-77" author="bernard" issueId="SM-5" deleted="false" text="See parent task for details." shownForIssueAuthor="false" + created="1292829374840"> + <replies/> + </comment> + <comment id="39-83" author="jacek" issueId="SM-5" deleted="true" + text="Można by się zastanowić czy szkoła ustala listę sprzętu i przy tworzeniu sali wybiera sprzęt z listy, czy po prostu wpisuje w inputa całą listę" + shownForIssueAuthor="false" created="1292881859712"> + <replies/> + </comment> + <comment id="39-84" author="jacek" issueId="SM-5" deleted="false" + text="Zastanawiam się czy będziemy używać stron w modelu view/edit, czy na liście będziemy mieli przyciski edytuj oraz usuń po których wykonywać się będą odpowiednie akcje" + shownForIssueAuthor="false" created="1292882323313"> + <replies/> + </comment> + <comment id="39-85" author="jacek" issueId="SM-5" deleted="false" text="Będziemy używać komponentów typu input inplace " shownForIssueAuthor="false" + created="1292924308679"> + <replies/> + </comment> + <field name="Priority"> + <value>Normal</value> + </field> + <field name="Type"> + <value>Task</value> + </field> + <field name="State"> + <value>Verified</value> + </field> + <field name="Assignee"> + <value>jacek</value> + </field> + <field name="Subsystem"> + <value>No subsystem</value> + </field> + <field name="links"> + <value type="Depend" role="is required for">SM-1</value> + </field> + <field name="projectShortName"> + <value>SM</value> + </field> + <field name="numberInProject"> + <value>5</value> + </field> + <field name="summary"> + <value>Draw screens for "Rooms" package</value> + </field> + <field name="created"> + <value>1292829377329</value> + </field> + <field name="updated"> + <value>1321871424471</value> + </field> + <field name="updaterName"> + <value>root</value> + </field> + <field name="resolved"> + <value>1321607946295</value> + </field> + <field name="reporterName"> + <value>bernard</value> + </field> + <field name="commentsCount"> + <value>3</value> + </field> + <field name="votes"> + <value>0</value> + </field> + </issue> + <issue id="SM-6"> + <field name="voterName"/> + <comment id="39-78" author="bernard" issueId="SM-6" deleted="false" text="See parent task for details." shownForIssueAuthor="false" + created="1292829408224"> + <replies/> + </comment> + <field name="Priority"> + <value>Normal</value> + </field> + <field name="Type"> + <value>Task</value> + </field> + <field name="State"> + <value>Verified</value> + </field> + <field name="Assignee"> + <value>tomek</value> + </field> + <field name="Subsystem"> + <value>No subsystem</value> + </field> + <field name="links"> + <value type="Depend" role="is required for">SM-1</value> + </field> + <field name="projectShortName"> + <value>SM</value> + </field> + <field name="numberInProject"> + <value>6</value> + </field> + <field name="summary"> + <value>Draw screens for "Schools" package</value> + </field> + <field name="created"> + <value>1292829411325</value> + </field> + <field name="updated"> + <value>1321871424472</value> + </field> + <field name="updaterName"> + <value>root</value> + </field> + <field name="resolved"> + <value>1321607946294</value> + </field> + <field name="reporterName"> + <value>bernard</value> + </field> + <field name="commentsCount"> + <value>1</value> + </field> + <field name="votes"> + <value>0</value> + </field> + </issue> + <issue id="SM-7"> + <field name="voterName"/> + <comment id="39-79" author="bernard" issueId="SM-7" deleted="false" text="See parent task for details." shownForIssueAuthor="false" + created="1292829466655"> + <replies/> + </comment> + <field name="Priority"> + <value>Normal</value> + </field> + <field name="Type"> + <value>Task</value> + </field> + <field name="State"> + <value>Verified</value> + </field> + <field name="Assignee"> + <value>jacek</value> + </field> + <field name="Subsystem"> + <value>No subsystem</value> + </field> + <field name="links"> + <value type="Depend" role="is required for">SM-1</value> + </field> + <field name="projectShortName"> + <value>SM</value> + </field> + <field name="numberInProject"> + <value>7</value> + </field> + <field name="summary"> + <value>Draw screens for "Students" package</value> + </field> + <field name="created"> + <value>1292829469581</value> + </field> + <field name="updated"> + <value>1321871424472</value> + </field> + <field name="updaterName"> + <value>root</value> + </field> + <field name="resolved"> + <value>1321607946302</value> + </field> + <field name="reporterName"> + <value>bernard</value> + </field> + <field name="commentsCount"> + <value>1</value> + </field> + <field name="votes"> + <value>0</value> + </field> + </issue> + <issue id="SM-8"> + <field name="voterName"/> + <comment id="39-80" author="bernard" issueId="SM-8" deleted="false" text="See parent task for details." shownForIssueAuthor="false" + created="1292829510003"> + <replies/> + </comment> + <field name="Priority"> + <value>Normal</value> + </field> + <field name="Type"> + <value>Task</value> + </field> + <field name="State"> + <value>Verified</value> + </field> + <field name="Assignee"> + <value>tomek</value> + </field> + <field name="Subsystem"> + <value>No subsystem</value> + </field> + <field name="links"> + <value type="Depend" role="is required for">SM-1</value> + </field> + <field name="projectShortName"> + <value>SM</value> + </field> + <field name="numberInProject"> + <value>8</value> + </field> + <field name="summary"> + <value>Draw screens for "Subjects" package</value> + </field> + <field name="created"> + <value>1292829513591</value> + </field> + <field name="updated"> + <value>1321871424472</value> + </field> + <field name="updaterName"> + <value>root</value> + </field> + <field name="resolved"> + <value>1321607946301</value> + </field> + <field name="reporterName"> + <value>bernard</value> + </field> + <field name="commentsCount"> + <value>1</value> + </field> + <field name="votes"> + <value>0</value> + </field> + </issue> + <issue id="SM-9"> + <field name="voterName"/> + <comment id="39-81" author="bernard" issueId="SM-9" deleted="false" text="See parent task for details." shownForIssueAuthor="false" + created="1292829550576"> + <replies/> + </comment> + <field name="Priority"> + <value>Normal</value> + </field> + <field name="Type"> + <value>Task</value> + </field> + <field name="State"> + <value>Verified</value> + </field> + <field name="Assignee"> + <value>tomek</value> + </field> + <field name="Subsystem"> + <value>No subsystem</value> + </field> + <field name="links"> + <value type="Depend" role="is required for">SM-1</value> + </field> + <field name="projectShortName"> + <value>SM</value> + </field> + <field name="numberInProject"> + <value>9</value> + </field> + <field name="summary"> + <value>Draw screens for "Teachers" package</value> + </field> + <field name="created"> + <value>1292829553292</value> + </field> + <field name="updated"> + <value>1321871424470</value> + </field> + <field name="updaterName"> + <value>root</value> + </field> + <field name="resolved"> + <value>1321607946301</value> + </field> + <field name="reporterName"> + <value>bernard</value> + </field> + <field name="commentsCount"> + <value>1</value> + </field> + <field name="votes"> + <value>0</value> + </field> + </issue> + <issue id="SM-10"> + <field name="voterName"/> + <comment id="39-82" author="bernard" issueId="SM-10" deleted="false" text="See parent task for details." shownForIssueAuthor="false" + created="1292829586642"> + <replies/> + </comment> + <field name="Priority"> + <value>Normal</value> + </field> + <field name="Type"> + <value>Task</value> + </field> + <field name="State"> + <value>Verified</value> + </field> + <field name="Assignee"> + <value>tomek</value> + </field> + <field name="Subsystem"> + <value>No subsystem</value> + </field> + <field name="links"> + <value type="Depend" role="is required for">SM-1</value> + </field> + <field name="projectShortName"> + <value>SM</value> + </field> + <field name="numberInProject"> + <value>10</value> + </field> + <field name="summary"> + <value>Draw screens for "Users" package</value> + </field> + <field name="created"> + <value>1292829588016</value> + </field> + <field name="updated"> + <value>1321871424471</value> + </field> + <field name="updaterName"> + <value>root</value> + </field> + <field name="resolved"> + <value>1321607946300</value> + </field> + <field name="reporterName"> + <value>bernard</value> + </field> + <field name="commentsCount"> + <value>1</value> + </field> + <field name="votes"> + <value>0</value> + </field> + </issue> +</issues> \ No newline at end of file diff --git a/src/main/xsd/issuesByProject.xsd b/src/main/xsd/issuesByProject.xsd new file mode 100644 index 0000000..a8e4eb0 --- /dev/null +++ b/src/main/xsd/issuesByProject.xsd @@ -0,0 +1,54 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> + <xs:element name="issues"> + <xs:complexType> + <xs:sequence> + <xs:element name="issue" maxOccurs="unbounded" minOccurs="0"> + <xs:complexType> + <xs:choice maxOccurs="unbounded" minOccurs="0"> + <xs:element name="field"> + <xs:complexType mixed="true"> + <xs:sequence> + <xs:element name="value" maxOccurs="unbounded" minOccurs="0"> + <xs:complexType> + <xs:attribute type="xs:string" name="type" use="optional"/> + <xs:attribute type="xs:string" name="role" use="optional"/> + </xs:complexType> + </xs:element> + </xs:sequence> + <xs:attribute type="xs:string" name="name" use="optional"/> + </xs:complexType> + </xs:element> + <xs:element name="comment"> + <xs:complexType> + <xs:sequence> + <xs:element type="xs:string" name="replies" minOccurs="0"/> + <xs:element name="value" minOccurs="0"> + <xs:complexType> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attribute type="xs:string" name="type" use="optional"/> + <xs:attribute type="xs:string" name="role" use="optional"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + </xs:element> + </xs:sequence> + <xs:attribute type="xs:string" name="id" use="optional"/> + <xs:attribute type="xs:string" name="author" use="optional"/> + <xs:attribute type="xs:string" name="issueId" use="optional"/> + <xs:attribute type="xs:string" name="deleted" use="optional"/> + <xs:attribute type="xs:string" name="text" use="optional"/> + <xs:attribute type="xs:string" name="shownForIssueAuthor" use="optional"/> + <xs:attribute type="xs:string" name="created" use="optional"/> + <xs:attribute type="xs:string" name="name" use="optional"/> + </xs:complexType> + </xs:element> + </xs:choice> + <xs:attribute type="xs:string" name="id" use="optional"/> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + </xs:element> +</xs:schema> \ No newline at end of file