Début ajout rest asset
This commit is contained in:
parent
0a9149d9ae
commit
c434544431
49 changed files with 3717 additions and 41 deletions
1
drools-framework-kie-wb-parent/drools-framework-kie-wb-rest-pojo/.gitignore
vendored
Normal file
1
drools-framework-kie-wb-parent/drools-framework-kie-wb-rest-pojo/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
/target
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jboss.errai:errai-common:4.3.3.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.jsinterop:jsinterop-annotations:1.0.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jboss.errai.reflections:reflections:4.3.3.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.guava:guava:13.0.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.javassist:javassist:3.20.0-GA" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: de.benediktmeurer.gwt-slf4j:gwt-slf4j:0.0.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.elemental2:elemental2-dom:1.0.0-beta-1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.jsinterop:base:1.0.0-beta-1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.elemental2:elemental2-core:1.0.0-beta-1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.elemental2:elemental2-promise:1.0.0-beta-1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.jboss.resteasy:resteasy-multipart-provider:3.0.24.Final" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.jboss.resteasy:resteasy-client:3.0.24.Final" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sun.mail:javax.mail:1.5.6" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.james:apache-mime4j:0.6" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-logging:commons-logging:1.1.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.jboss.resteasy:resteasy-jaxrs:3.0.24.Final" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.jboss.spec.javax.ws.rs:jboss-jaxrs-api_2.0_spec:1.0.1.Beta1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.jboss.spec.javax.annotation:jboss-annotations-api_1.2_spec:1.0.0.Final" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.activation:activation:1.1.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.httpcomponents:httpclient:4.3.6" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.httpcomponents:httpcore:4.3.3" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-codec:commons-codec:1.6" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-io:commons-io:2.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.jcip:jcip-annotations:1.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.jboss.logging:jboss-logging:3.3.0.Final" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.jboss.resteasy:resteasy-jaxb-provider:3.0.24.Final" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sun.xml.bind:jaxb-impl:2.2.7" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sun.xml.bind:jaxb-core:2.2.7" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.xml.bind:jaxb-api:2.2.7" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sun.istack:istack-commons-runtime:2.16" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sun.xml.fastinfoset:FastInfoset:1.2.12" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.xml.bind:jsr173_api:1.0" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>drools-framework-kie-wb-parent</artifactId>
|
||||
<groupId>com.pymmasoftware.jbpm</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>drools-framework-kie-wb-rest-pojo</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>kie drools Framework - REST pojo</name>
|
||||
<description>kie drools Framework - REST Client classes</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.jboss.errai</groupId>
|
||||
<artifactId>errai-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.jboss.resteasy</groupId>
|
||||
<artifactId>resteasy-multipart-provider</artifactId>
|
||||
<version>3.0.24.Final</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>mail</artifactId>
|
||||
<groupId>javax.mail</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.jboss.logging</groupId>
|
||||
<artifactId>jboss-logging</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.resteasy</groupId>
|
||||
<artifactId>resteasy-jaxrs</artifactId>
|
||||
<version>3.0.24.Final</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.resteasy</groupId>
|
||||
<artifactId>resteasy-jaxb-provider</artifactId>
|
||||
<version>3.0.24.Final</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
<!--build>
|
||||
<plugins>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-bundle-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>wrap-dependency</id>
|
||||
<goals>
|
||||
<goal>bundle</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<instructions>
|
||||
<Embed-Dependency>*</Embed-Dependency>
|
||||
<Export-Package>org.drools.guvnor.server.jaxrs.*</Export-Package>
|
||||
</instructions>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
|
||||
</build-->
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.10.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright 2012 JBoss Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.drools.guvnor.server.jaxrs.jaxb;
|
||||
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement(name = "archived")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class Archived {
|
||||
|
||||
@XmlElement
|
||||
private boolean value;
|
||||
|
||||
public boolean getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(boolean archived) {
|
||||
value = archived;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,145 @@
|
|||
/*
|
||||
* Copyright 2011 JBoss Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.drools.guvnor.server.jaxrs.jaxb;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.net.URI;
|
||||
import java.util.Date;
|
||||
|
||||
@XmlRootElement()
|
||||
public class Asset {
|
||||
|
||||
private String title;
|
||||
private String binaryContentAttachmentFileName;
|
||||
private String description;
|
||||
private String author;
|
||||
private Date published;
|
||||
private URI binaryLink, sourceLink, refLink;
|
||||
private String content;
|
||||
private AssetMetadata metadata;
|
||||
private String directory;
|
||||
private String comment;
|
||||
|
||||
@XmlElement
|
||||
public URI getBinaryLink() {
|
||||
return binaryLink;
|
||||
}
|
||||
|
||||
public void setBinaryLink(URI binaryLink) {
|
||||
this.binaryLink = binaryLink;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public URI getSourceLink() {
|
||||
return sourceLink;
|
||||
}
|
||||
|
||||
public void setSourceLink(URI sourceLink) {
|
||||
this.sourceLink = sourceLink;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String getBinaryContentAttachmentFileName() {
|
||||
return binaryContentAttachmentFileName;
|
||||
}
|
||||
|
||||
public void setBinaryContentAttachmentFileName(String binaryContentAttachmentFileName) {
|
||||
this.binaryContentAttachmentFileName = binaryContentAttachmentFileName;
|
||||
}
|
||||
|
||||
@XmlElement()
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public void setAuthor(String author) {
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public Date getPublished() {
|
||||
return published;
|
||||
}
|
||||
|
||||
public void setPublished(Date published) {
|
||||
this.published = published;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public URI getRefLink() {
|
||||
return refLink;
|
||||
}
|
||||
|
||||
public void setRefLink(URI refLink) {
|
||||
this.refLink = refLink;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public AssetMetadata getMetadata() {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
public void setMetadata(AssetMetadata metadata) {
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String getDirectory() {
|
||||
return directory;
|
||||
}
|
||||
|
||||
public void setDirectory(String directory) {
|
||||
this.directory = directory;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String getComment() {
|
||||
return comment;
|
||||
}
|
||||
|
||||
public void setComment(String comment) {
|
||||
this.comment = comment;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,117 @@
|
|||
/*
|
||||
* Copyright 2012 JBoss Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.drools.guvnor.server.jaxrs.jaxb;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.Date;
|
||||
|
||||
@XmlRootElement(name = "metadata")
|
||||
public class AssetMetadata {
|
||||
|
||||
private String uuid;
|
||||
private String[] categories;
|
||||
private String note;
|
||||
private Date created;
|
||||
private String format;
|
||||
private boolean disabled;
|
||||
private String state;
|
||||
private long versionNumber;
|
||||
private String checkInComment;
|
||||
|
||||
@XmlElement
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String[] getCategories() {
|
||||
return categories;
|
||||
}
|
||||
|
||||
public void setCategories(String[] categories) {
|
||||
this.categories = categories;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String getNote() {
|
||||
return note;
|
||||
}
|
||||
|
||||
public void setNote(String note) {
|
||||
this.note = note;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
public void setCreated(Date created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String getFormat() {
|
||||
return format;
|
||||
}
|
||||
|
||||
public void setFormat(String format) {
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public boolean isDisabled() {
|
||||
return disabled;
|
||||
}
|
||||
|
||||
public void setDisabled(boolean disabled) {
|
||||
this.disabled = disabled;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public long getVersionNumber() {
|
||||
return versionNumber;
|
||||
}
|
||||
|
||||
public void setVersionNumber(long versionNumber) {
|
||||
this.versionNumber = versionNumber;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String getCheckInComment() {
|
||||
return checkInComment;
|
||||
}
|
||||
|
||||
public void setCheckInComment(String checkInComment) {
|
||||
this.checkInComment = checkInComment;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Copyright 2012 JBoss Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.drools.guvnor.server.jaxrs.jaxb;
|
||||
|
||||
import org.jboss.resteasy.annotations.providers.multipart.PartType;
|
||||
|
||||
import javax.ws.rs.FormParam;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class AssetMultipartForm {
|
||||
|
||||
@FormParam("asset")
|
||||
@PartType(MediaType.APPLICATION_JSON)
|
||||
private Asset asset;
|
||||
|
||||
@FormParam("binary")
|
||||
@PartType(MediaType.APPLICATION_OCTET_STREAM)
|
||||
private InputStream binary;
|
||||
|
||||
public Asset getAsset() {
|
||||
return asset;
|
||||
}
|
||||
|
||||
public void setAsset(Asset asset) {
|
||||
this.asset = asset;
|
||||
}
|
||||
|
||||
public InputStream getBinary() {
|
||||
return binary;
|
||||
}
|
||||
|
||||
public void setBinary(InputStream binary) {
|
||||
this.binary = binary;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,175 @@
|
|||
/*
|
||||
* Copyright 2012 JBoss Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.drools.guvnor.server.jaxrs.jaxb;
|
||||
|
||||
import javax.xml.bind.annotation.*;
|
||||
import java.util.Date;
|
||||
|
||||
@XmlRootElement(name = "metadata")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlSeeAlso({Categories.class})
|
||||
public class AtomAssetMetadata {
|
||||
|
||||
@XmlElement
|
||||
private Uuid uuid;
|
||||
@XmlElement
|
||||
private Categories categories;
|
||||
@XmlElement
|
||||
private Note note;
|
||||
@XmlElement
|
||||
private Created created;
|
||||
@XmlElement
|
||||
private Format format;
|
||||
@XmlElement
|
||||
private Disabled disabled;
|
||||
@XmlElement
|
||||
private State state;
|
||||
@XmlElement
|
||||
private VersionNumber versionNumber;
|
||||
@XmlElement
|
||||
private CheckinComment checkinComment;
|
||||
@XmlElement
|
||||
private Archived archived;
|
||||
|
||||
public String getUuid() {
|
||||
return uuid != null ? uuid.getValue() : null;
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
if (this.uuid == null) {
|
||||
this.uuid = new Uuid();
|
||||
}
|
||||
this.uuid.setValue(uuid);
|
||||
}
|
||||
|
||||
public String[] getCategories() {
|
||||
return categories != null ? categories.getValues() : null;
|
||||
}
|
||||
|
||||
public void setCategories(String[] categories) {
|
||||
if (this.categories == null) {
|
||||
this.categories = new Categories();
|
||||
}
|
||||
this.categories.setValue(categories);
|
||||
}
|
||||
|
||||
public String getNote() {
|
||||
return note != null ? note.getValue() : null;
|
||||
}
|
||||
|
||||
public void setNote(String note) {
|
||||
if (this.note == null) {
|
||||
this.note = new Note();
|
||||
}
|
||||
this.note.setValue(note);
|
||||
}
|
||||
|
||||
public Date getCreated() {
|
||||
return created != null ? created.getValue() : null;
|
||||
}
|
||||
|
||||
public void setCreated(Date created) {
|
||||
if (this.created == null) {
|
||||
this.created = new Created();
|
||||
}
|
||||
this.created.setValue(created);
|
||||
}
|
||||
|
||||
public String getFormat() {
|
||||
return format != null ? format.getValue() : null;
|
||||
}
|
||||
|
||||
public void setFormat(String format) {
|
||||
if (this.format == null) {
|
||||
this.format = new Format();
|
||||
}
|
||||
this.format.setValue(format);
|
||||
}
|
||||
|
||||
public boolean getDisabled() {
|
||||
return disabled != null ? disabled.getValue() : false;
|
||||
}
|
||||
|
||||
public void setDisabled(boolean disabled) {
|
||||
if (this.disabled == null) {
|
||||
this.disabled = new Disabled();
|
||||
}
|
||||
this.disabled.setValue(disabled);
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return state != null ? state.getValue() : null;
|
||||
}
|
||||
|
||||
public void setState(String state) {
|
||||
if (this.state == null) {
|
||||
this.state = new State();
|
||||
}
|
||||
this.state.setValue(state);
|
||||
}
|
||||
|
||||
public long getVersionNumber() {
|
||||
return versionNumber != null ? versionNumber.getValue() : -1L;
|
||||
}
|
||||
|
||||
public void setVersionNumber(long versionNumber) {
|
||||
if (this.versionNumber == null) {
|
||||
this.versionNumber = new VersionNumber();
|
||||
}
|
||||
this.versionNumber.setValue(versionNumber);
|
||||
}
|
||||
|
||||
public String getCheckinComment() {
|
||||
return checkinComment != null ? checkinComment.getValue() : null;
|
||||
}
|
||||
|
||||
public void setCheckinComment(String checkinComment) {
|
||||
if (this.checkinComment == null) {
|
||||
this.checkinComment = new CheckinComment();
|
||||
}
|
||||
this.checkinComment.setValue(checkinComment);
|
||||
}
|
||||
|
||||
public boolean isArchived() {
|
||||
return archived != null ? archived.getValue() : false;
|
||||
}
|
||||
|
||||
public void setArchived(boolean archived) {
|
||||
if (this.archived == null) {
|
||||
this.archived = new Archived();
|
||||
}
|
||||
this.archived.setValue(archived);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AtomAssetMetadata{" +
|
||||
"uuid=" + uuid +
|
||||
", categories=" + categories +
|
||||
", note=" + note +
|
||||
", created=" + created +
|
||||
", format=" + format +
|
||||
", disabled=" + disabled +
|
||||
", state=" + state +
|
||||
", versionNumber=" + versionNumber +
|
||||
", checkinComment=" + checkinComment +
|
||||
", archived=" + archived +
|
||||
'}';
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,123 @@
|
|||
/*
|
||||
* Copyright 2012 JBoss Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.drools.guvnor.server.jaxrs.jaxb;
|
||||
|
||||
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 java.util.Date;
|
||||
|
||||
@XmlRootElement(name = "metadata")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class AtomPackageMetadata {
|
||||
|
||||
@XmlElement
|
||||
private Uuid uuid;
|
||||
@XmlElement
|
||||
private Created created;
|
||||
@XmlElement
|
||||
private Format format;
|
||||
@XmlElement
|
||||
private State state;
|
||||
@XmlElement
|
||||
private Archived archived;
|
||||
@XmlElement
|
||||
private VersionNumber versionNumber;
|
||||
@XmlElement
|
||||
private CheckinComment checkinComment;
|
||||
|
||||
|
||||
public String getUuid() {
|
||||
return uuid != null ? uuid.getValue() : "";
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
if (this.uuid == null) {
|
||||
this.uuid = new Uuid();
|
||||
}
|
||||
this.uuid.setValue(uuid);
|
||||
}
|
||||
|
||||
public Date getCreated() {
|
||||
return created != null ? created.getValue() : null;
|
||||
}
|
||||
|
||||
public void setCreated(Date created) {
|
||||
if (this.created == null) {
|
||||
this.created = new Created();
|
||||
}
|
||||
this.created.setValue(created);
|
||||
}
|
||||
|
||||
public String getFormat() {
|
||||
return format != null ? format.getValue() : "";
|
||||
}
|
||||
|
||||
public void setFormat(String format) {
|
||||
if (this.format == null) {
|
||||
this.format = new Format();
|
||||
}
|
||||
this.format.setValue(format);
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return state != null ? state.getValue() : "";
|
||||
}
|
||||
|
||||
public void setState(String state) {
|
||||
if (this.state == null) {
|
||||
this.state = new State();
|
||||
}
|
||||
this.state.setValue(state);
|
||||
}
|
||||
|
||||
public boolean isArchived() {
|
||||
return archived != null ? archived.getValue() : false;
|
||||
}
|
||||
|
||||
public void setArchived(boolean archived) {
|
||||
if (this.archived == null) {
|
||||
this.archived = new Archived();
|
||||
}
|
||||
this.archived.setValue(archived);
|
||||
}
|
||||
|
||||
public long getVersionNumber() {
|
||||
return versionNumber != null ? versionNumber.getValue() : -1L;
|
||||
}
|
||||
|
||||
public void setVersionNumber(long versionNumber) {
|
||||
if (this.versionNumber == null) {
|
||||
this.versionNumber = new VersionNumber();
|
||||
}
|
||||
this.versionNumber.setValue(versionNumber);
|
||||
}
|
||||
|
||||
public String getCheckinComment() {
|
||||
return checkinComment != null ? checkinComment.getValue() : "";
|
||||
}
|
||||
|
||||
public void setCheckinComment(String checkinComment) {
|
||||
if (this.checkinComment == null) {
|
||||
this.checkinComment = new CheckinComment();
|
||||
}
|
||||
this.checkinComment.setValue(checkinComment);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright 2012 JBoss Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.drools.guvnor.server.jaxrs.jaxb;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement(name = "categories")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class Categories {
|
||||
|
||||
@XmlElement(name = "value")
|
||||
private String[] values;
|
||||
|
||||
public String[] getValues() {
|
||||
return values;
|
||||
}
|
||||
|
||||
public void setValue(String[] categories) {
|
||||
values = categories;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright 2011 JBoss Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.drools.guvnor.server.jaxrs.jaxb;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.net.URI;
|
||||
|
||||
@XmlRootElement()
|
||||
public class Category {
|
||||
|
||||
private String path;
|
||||
|
||||
private URI refLink;
|
||||
|
||||
@XmlElement()
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public URI getRefLink() {
|
||||
return refLink;
|
||||
}
|
||||
|
||||
public void setRefLink(URI refLink) {
|
||||
this.refLink = refLink;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright 2012 JBoss Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.drools.guvnor.server.jaxrs.jaxb;
|
||||
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement(name = "checkinComment")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class CheckinComment {
|
||||
|
||||
@XmlElement
|
||||
private String value;
|
||||
|
||||
public String getValue() {
|
||||
return value; //To change body of created methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
public void setValue(String checkin) {
|
||||
value = checkin;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright 2012 JBoss Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.drools.guvnor.server.jaxrs.jaxb;
|
||||
|
||||
|
||||
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 java.util.Date;
|
||||
|
||||
@XmlRootElement(name = "created")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class Created {
|
||||
|
||||
@XmlElement
|
||||
private Date value;
|
||||
|
||||
public Date getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(Date created) {
|
||||
value = created;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright 2012 JBoss Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.drools.guvnor.server.jaxrs.jaxb;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement(name = "disabled")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class Disabled {
|
||||
|
||||
@XmlElement
|
||||
private boolean value;
|
||||
|
||||
public boolean getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(boolean disabled) {
|
||||
value = disabled;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright 2012 JBoss Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.drools.guvnor.server.jaxrs.jaxb;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement(name = "format")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class Format {
|
||||
|
||||
@XmlElement
|
||||
private String value;
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String format) {
|
||||
value = format;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
package org.drools.guvnor.server.jaxrs.jaxb;
|
||||
|
||||
import org.drools.guvnor.server.jaxrs.providers.atom.Entry;
|
||||
import org.jboss.resteasy.spi.interception.DecoratorProcessor;
|
||||
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.Marshaller;
|
||||
import java.lang.annotation.Annotation;
|
||||
|
||||
/**
|
||||
* 10 19 2012
|
||||
*
|
||||
* @author <a href="mailto:l.weinan@gmail.com">Weinan Li</a>
|
||||
*/
|
||||
public class GuvnorAtomProcessor implements DecoratorProcessor<Marshaller, GuvnorDecorators> {
|
||||
|
||||
@Override
|
||||
public Marshaller decorate(Marshaller target, GuvnorDecorators annotation, Class type, Annotation[] annotations, MediaType mediaType) {
|
||||
Class[] classes = new Class[]{AtomAssetMetadata.class, AtomPackageMetadata.class, Entry.class};
|
||||
try {
|
||||
JAXBContext jaxbContext = JAXBContext.newInstance(classes);
|
||||
return jaxbContext.createMarshaller();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package org.drools.guvnor.server.jaxrs.jaxb;
|
||||
|
||||
import org.jboss.resteasy.annotations.Decorator;
|
||||
|
||||
import javax.xml.bind.Marshaller;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 10 19 2012
|
||||
*
|
||||
* @author <a href="mailto:l.weinan@gmail.com">Weinan Li</a>
|
||||
*/
|
||||
@Target({ElementType.TYPE, ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Decorator(processor = GuvnorAtomProcessor.class, target = Marshaller.class)
|
||||
public @interface GuvnorDecorators {
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright 2012 JBoss Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.drools.guvnor.server.jaxrs.jaxb;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement(name = "note")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class Note {
|
||||
|
||||
@XmlElement
|
||||
private String value;
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String note) {
|
||||
value = note;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,122 @@
|
|||
/*
|
||||
* Copyright 2011 JBoss Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.drools.guvnor.server.jaxrs.jaxb;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
|
||||
@XmlRootElement()
|
||||
public class Package {
|
||||
|
||||
private String title;
|
||||
private String description;
|
||||
private String author;
|
||||
private Date published;
|
||||
|
||||
private Collection<String> modules = new LinkedList<>();
|
||||
|
||||
private PackageMetadata metadata;
|
||||
|
||||
private String groupID;
|
||||
private String artifactID;
|
||||
private String version;
|
||||
|
||||
@XmlElement
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public void setAuthor(String author) {
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public Date getPublished() {
|
||||
return published;
|
||||
}
|
||||
|
||||
public void setPublished(Date published) {
|
||||
this.published = published;
|
||||
}
|
||||
|
||||
|
||||
@XmlElement
|
||||
public PackageMetadata getMetadata() {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
public void setMetadata(PackageMetadata metadata) {
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String getGroupID() {
|
||||
return groupID;
|
||||
}
|
||||
|
||||
public void setGroupID(String groupID) {
|
||||
this.groupID = groupID;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String getArtifactID() {
|
||||
return artifactID;
|
||||
}
|
||||
|
||||
public void setArtifactID(String artifactID) {
|
||||
this.artifactID = artifactID;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public Collection<String> getModules() {
|
||||
return modules;
|
||||
}
|
||||
|
||||
public void setModules(Collection<String> modules) {
|
||||
this.modules = modules;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,111 @@
|
|||
/*
|
||||
* Copyright 2011 JBoss Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.drools.guvnor.server.jaxrs.jaxb;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.Date;
|
||||
|
||||
@XmlRootElement(name = "metadata")
|
||||
public class PackageMetadata {
|
||||
|
||||
private String uuid;
|
||||
private Date created;
|
||||
private String format;
|
||||
private String state;
|
||||
private boolean archived;
|
||||
private long versionNumber;
|
||||
private String checkinComment;
|
||||
|
||||
@XmlElement
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
public void setCreated(Date created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String getFormat() {
|
||||
return format;
|
||||
}
|
||||
|
||||
public void setFormat(String format) {
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public boolean isArchived() {
|
||||
return archived;
|
||||
}
|
||||
|
||||
public void setArchived(boolean archived) {
|
||||
this.archived = archived;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public long getVersionNumber() {
|
||||
return versionNumber;
|
||||
}
|
||||
|
||||
public void setVersionNumber(long versionNumber) {
|
||||
this.versionNumber = versionNumber;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String getCheckinComment() {
|
||||
return checkinComment;
|
||||
}
|
||||
|
||||
public void setCheckinComment(String checkinComment) {
|
||||
this.checkinComment = checkinComment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PackageMetadata{" +
|
||||
"uuid='" + uuid + '\'' +
|
||||
", created=" + created +
|
||||
", format='" + format + '\'' +
|
||||
", state='" + state + '\'' +
|
||||
", archived=" + archived +
|
||||
", versionNumber=" + versionNumber +
|
||||
", checkinComment='" + checkinComment + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
* Copyright 2013 JBoss by Red Hat.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.drools.guvnor.server.jaxrs.jaxb;
|
||||
|
||||
import javax.xml.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* @author nheron
|
||||
*/
|
||||
@XmlRootElement(namespace = "http://www.w3.org/2005/Atom", name = "SnapshotCreationData")
|
||||
@XmlAccessorType(XmlAccessType.PROPERTY)
|
||||
@XmlType(propOrder = {"buildMode", "statusOperator", "statusDescriptionValue", "enableStatusSelector", "categoryOperator",
|
||||
"categoryValue", "enableCategorySelector", "customSelectorConfigName"})
|
||||
public class SnapshotCreationData {
|
||||
|
||||
private String buildMode;
|
||||
private String statusOperator;
|
||||
private String statusDescriptionValue;
|
||||
private boolean enableStatusSelector = false;
|
||||
private String categoryOperator;
|
||||
private String categoryValue;
|
||||
private boolean enableCategorySelector = false;
|
||||
private String customSelectorConfigName;
|
||||
|
||||
@XmlElement(namespace = "http://www.w3.org/2005/Atom")
|
||||
public String getBuildMode() {
|
||||
return buildMode;
|
||||
}
|
||||
|
||||
public void setBuildMode(String buildMode) {
|
||||
this.buildMode = buildMode;
|
||||
}
|
||||
|
||||
@XmlElement(namespace = "http://www.w3.org/2005/Atom")
|
||||
public String getStatusOperator() {
|
||||
return statusOperator;
|
||||
}
|
||||
|
||||
public void setStatusOperator(String statusOperator) {
|
||||
this.statusOperator = statusOperator;
|
||||
}
|
||||
|
||||
@XmlElement(namespace = "http://www.w3.org/2005/Atom")
|
||||
public String getStatusDescriptionValue() {
|
||||
return statusDescriptionValue;
|
||||
}
|
||||
|
||||
public void setStatusDescriptionValue(String statusDescriptionValue) {
|
||||
this.statusDescriptionValue = statusDescriptionValue;
|
||||
}
|
||||
|
||||
@XmlElement(namespace = "http://www.w3.org/2005/Atom")
|
||||
public boolean getEnableStatusSelector() {
|
||||
return enableStatusSelector;
|
||||
}
|
||||
|
||||
public void setEnableStatusSelector(boolean enableStatusSelector) {
|
||||
this.enableStatusSelector = enableStatusSelector;
|
||||
}
|
||||
|
||||
@XmlElement(namespace = "http://www.w3.org/2005/Atom")
|
||||
public String getCategoryOperator() {
|
||||
return categoryOperator;
|
||||
}
|
||||
|
||||
public void setCategoryOperator(String categoryOperator) {
|
||||
this.categoryOperator = categoryOperator;
|
||||
}
|
||||
|
||||
@XmlElement(namespace = "http://www.w3.org/2005/Atom")
|
||||
public String getCategoryValue() {
|
||||
return categoryValue;
|
||||
}
|
||||
|
||||
public void setCategoryValue(String categoryValue) {
|
||||
this.categoryValue = categoryValue;
|
||||
}
|
||||
|
||||
@XmlElement(namespace = "http://www.w3.org/2005/Atom")
|
||||
public boolean getEnableCategorySelector() {
|
||||
return enableCategorySelector;
|
||||
}
|
||||
|
||||
public void setEnableCategorySelector(boolean enableCategorySelector) {
|
||||
this.enableCategorySelector = enableCategorySelector;
|
||||
}
|
||||
|
||||
@XmlElement(namespace = "http://www.w3.org/2005/Atom")
|
||||
public String getCustomSelectorConfigName() {
|
||||
return customSelectorConfigName;
|
||||
}
|
||||
|
||||
public void setCustomSelectorConfigName(String customSelectorConfigName) {
|
||||
this.customSelectorConfigName = customSelectorConfigName;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright 2012 JBoss Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.drools.guvnor.server.jaxrs.jaxb;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement(name = "snapshots")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class Snapshots {
|
||||
|
||||
@XmlElement(name = "packageName")
|
||||
private String packageName;
|
||||
|
||||
@XmlElement(name = "name")
|
||||
private String[] listNames;
|
||||
|
||||
public String getPackageName() {
|
||||
return packageName;
|
||||
}
|
||||
|
||||
public void setPackageName(String packageName) {
|
||||
this.packageName = packageName;
|
||||
}
|
||||
|
||||
public String[] getListNames() {
|
||||
return listNames;
|
||||
}
|
||||
|
||||
public void setListNames(String[] names) {
|
||||
listNames = names;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright 2012 JBoss Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.drools.guvnor.server.jaxrs.jaxb;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement(name = "state")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class State {
|
||||
|
||||
@XmlElement
|
||||
private String value;
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String state) {
|
||||
value = state;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright 2012 JBoss Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.drools.guvnor.server.jaxrs.jaxb;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement(name = "uuid")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class Uuid {
|
||||
|
||||
@XmlElement
|
||||
private String value;
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String uuid) {
|
||||
value = uuid;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright 2012 JBoss Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.drools.guvnor.server.jaxrs.jaxb;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement(name = "versionNumber")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class VersionNumber {
|
||||
|
||||
@XmlElement
|
||||
private long value;
|
||||
|
||||
public long getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(long uuid) {
|
||||
value = uuid;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,119 @@
|
|||
/*
|
||||
* Copyright 2012 JBoss Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.drools.guvnor.server.jaxrs.providers.atom;
|
||||
|
||||
|
||||
import org.jboss.resteasy.plugins.providers.jaxb.JAXBContextFinder;
|
||||
import org.jboss.resteasy.plugins.providers.jaxb.JAXBMarshalException;
|
||||
import org.jboss.resteasy.plugins.providers.jaxb.JAXBUnmarshalException;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.WebApplicationException;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
import javax.ws.rs.ext.*;
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Marshaller;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* TODO remove this file when JBoss AS includes RESTEasy 2.3.4.Final or higher
|
||||
*/
|
||||
@Provider
|
||||
@Produces("application/atom+*")
|
||||
@Consumes("application/atom+*")
|
||||
public class AtomEntryProvider implements MessageBodyReader<Entry>, MessageBodyWriter<Entry> {
|
||||
@Context
|
||||
protected Providers providers;
|
||||
|
||||
protected JAXBContextFinder getFinder(MediaType type) {
|
||||
ContextResolver<JAXBContextFinder> resolver = providers.getContextResolver(JAXBContextFinder.class, type);
|
||||
if (resolver == null) return null;
|
||||
return resolver.getContext(null);
|
||||
}
|
||||
|
||||
public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
|
||||
return Entry.class.isAssignableFrom(type);
|
||||
}
|
||||
|
||||
public Entry readFrom(Class<Entry> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException {
|
||||
JAXBContextFinder finder = getFinder(mediaType);
|
||||
if (finder == null) {
|
||||
throw new JAXBUnmarshalException("Unable to find JAXBContext for media type: " + mediaType);
|
||||
}
|
||||
|
||||
try {
|
||||
JAXBContext ctx = finder.findCachedContext(Entry.class, mediaType, annotations);
|
||||
Entry entry = (Entry) ctx.createUnmarshaller().unmarshal(entityStream);
|
||||
if (entry.getContent() != null) entry.getContent().setFinder(finder);
|
||||
entry.setFinder(finder);
|
||||
return entry;
|
||||
} catch (JAXBException e) {
|
||||
throw new JAXBUnmarshalException("Unable to unmarshal: " + mediaType, e);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
|
||||
return Entry.class.isAssignableFrom(type);
|
||||
}
|
||||
|
||||
public long getSize(Entry entry, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void writeTo(Entry entry, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException {
|
||||
JAXBContextFinder finder = getFinder(mediaType);
|
||||
if (finder == null) {
|
||||
throw new JAXBMarshalException("Unable to find JAXBContext for media type: " + mediaType);
|
||||
}
|
||||
HashSet<Class> set = new HashSet<Class>();
|
||||
set.add(Entry.class);
|
||||
|
||||
if (entry.getAnyOtherJAXBObject() != null) {
|
||||
set.add(entry.getAnyOtherJAXBObject().getClass());
|
||||
}
|
||||
if (entry.getContent() != null && entry.getContent().getJAXBObject() != null) {
|
||||
set.add(entry.getContent().getJAXBObject().getClass());
|
||||
}
|
||||
try {
|
||||
JAXBContext ctx = finder.findCacheContext(mediaType, annotations, set.toArray(new Class[set.size()]));
|
||||
Marshaller marshaller = ctx.createMarshaller();
|
||||
/* NamespacePrefixMapper mapper = new NamespacePrefixMapper()
|
||||
{
|
||||
public String getPreferredPrefix(String namespace, String s1, boolean b)
|
||||
{
|
||||
if (namespace.equals("http://www.w3.org/2005/Atom")) return "atom";
|
||||
else return s1;
|
||||
}
|
||||
};
|
||||
|
||||
marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper", mapper);
|
||||
*/
|
||||
marshaller.marshal(entry, entityStream);
|
||||
} catch (JAXBException e) {
|
||||
throw new JAXBMarshalException("Unable to marshal: " + mediaType, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,118 @@
|
|||
/*
|
||||
* Copyright 2012 JBoss Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.drools.guvnor.server.jaxrs.providers.atom;
|
||||
|
||||
|
||||
import org.jboss.resteasy.plugins.providers.jaxb.JAXBContextFinder;
|
||||
import org.jboss.resteasy.plugins.providers.jaxb.JAXBMarshalException;
|
||||
import org.jboss.resteasy.plugins.providers.jaxb.JAXBUnmarshalException;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.WebApplicationException;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
import javax.ws.rs.ext.*;
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Marshaller;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* TODO remove this file when JBoss AS includes RESTEasy 2.3.4.Final or higher
|
||||
*/
|
||||
@Provider
|
||||
@Produces("application/atom+*")
|
||||
@Consumes("application/atom+*")
|
||||
public class AtomFeedProvider implements MessageBodyReader<Feed>, MessageBodyWriter<Feed> {
|
||||
@Context
|
||||
protected Providers providers;
|
||||
|
||||
protected JAXBContextFinder getFinder(MediaType type) {
|
||||
ContextResolver<JAXBContextFinder> resolver = providers.getContextResolver(JAXBContextFinder.class, type);
|
||||
if (resolver == null) return null;
|
||||
return resolver.getContext(null);
|
||||
}
|
||||
|
||||
public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
|
||||
return Feed.class.isAssignableFrom(type);
|
||||
}
|
||||
|
||||
public Feed readFrom(Class<Feed> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException {
|
||||
JAXBContextFinder finder = getFinder(mediaType);
|
||||
if (finder == null) {
|
||||
throw new JAXBUnmarshalException("Unable to find JAXBContext for media type: " + mediaType);
|
||||
}
|
||||
|
||||
try {
|
||||
JAXBContext ctx = finder.findCachedContext(Feed.class, mediaType, annotations);
|
||||
Feed feed = (Feed) ctx.createUnmarshaller().unmarshal(entityStream);
|
||||
for (Entry entry : feed.getEntries()) {
|
||||
if (entry.getContent() != null) entry.getContent().setFinder(finder);
|
||||
}
|
||||
return feed;
|
||||
} catch (JAXBException e) {
|
||||
throw new JAXBUnmarshalException("Unable to unmarshal: " + mediaType, e);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
|
||||
return Feed.class.isAssignableFrom(type);
|
||||
}
|
||||
|
||||
public long getSize(Feed feed, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void writeTo(Feed feed, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException {
|
||||
JAXBContextFinder finder = getFinder(mediaType);
|
||||
if (finder == null) {
|
||||
throw new JAXBMarshalException("Unable to find JAXBContext for media type: " + mediaType);
|
||||
}
|
||||
HashSet<Class> set = new HashSet<Class>();
|
||||
set.add(Feed.class);
|
||||
for (Entry entry : feed.getEntries()) {
|
||||
if (entry.getContent() != null && entry.getContent().getJAXBObject() != null) {
|
||||
set.add(entry.getContent().getJAXBObject().getClass());
|
||||
}
|
||||
}
|
||||
try {
|
||||
JAXBContext ctx = finder.findCacheContext(mediaType, annotations, set.toArray(new Class[set.size()]));
|
||||
Marshaller marshaller = ctx.createMarshaller();
|
||||
/* NamespacePrefixMapper mapper = new NamespacePrefixMapper()
|
||||
{
|
||||
public String getPreferredPrefix(String namespace, String s1, boolean b)
|
||||
{
|
||||
if (namespace.equals("http://www.w3.org/2005/Atom")) return "atom";
|
||||
else return s1;
|
||||
}
|
||||
};
|
||||
|
||||
marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper", mapper);
|
||||
*/
|
||||
marshaller.marshal(feed, entityStream);
|
||||
} catch (JAXBException e) {
|
||||
throw new JAXBMarshalException("Unable to marshal: " + mediaType, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright 2012 JBoss Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.drools.guvnor.server.jaxrs.providers.atom;
|
||||
|
||||
import org.jboss.resteasy.spi.ResteasyProviderFactory;
|
||||
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.net.URI;
|
||||
|
||||
/**
|
||||
* If invoked within the context of a JAX-RS call, it will automatically build a
|
||||
* URI based the base URI of the JAX-RS application. Same URI as UriInfo.getBaseUri().
|
||||
* <p/>
|
||||
* TODO remove this file when JBoss AS includes RESTEasy 2.3.4.Final or higher
|
||||
*/
|
||||
@XmlRootElement(name = "link")
|
||||
@XmlAccessorType(XmlAccessType.PROPERTY)
|
||||
public class BaseLink extends Link {
|
||||
public BaseLink() {
|
||||
}
|
||||
|
||||
public BaseLink(String rel, String relativeLink) {
|
||||
UriInfo uriInfo = ResteasyProviderFactory.getContextData(UriInfo.class);
|
||||
if (uriInfo == null)
|
||||
throw new IllegalStateException("This constructor must be called in the context of a JAX-RS request");
|
||||
URI uri = uriInfo.getBaseUriBuilder().path(relativeLink).build();
|
||||
setHref(uri);
|
||||
setRel(rel);
|
||||
}
|
||||
|
||||
public BaseLink(String rel, String relativeLink, MediaType mediaType) {
|
||||
this(rel, relativeLink);
|
||||
this.setType(mediaType);
|
||||
}
|
||||
|
||||
public BaseLink(String rel, String relativeLink, String mediaType) {
|
||||
this(rel, relativeLink);
|
||||
this.setType(MediaType.valueOf(mediaType));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* Copyright 2012 JBoss Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.drools.guvnor.server.jaxrs.providers.atom;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.net.URI;
|
||||
|
||||
/**
|
||||
* <p>Per RFC4287:</p>
|
||||
* <p/>
|
||||
* <pre>
|
||||
* The "atom:category" element conveys information about a category
|
||||
* associated with an entry or feed. This specification assigns no
|
||||
* meaning to the content (if any) of this element.
|
||||
*
|
||||
* atomCategory =
|
||||
* element atom:category {
|
||||
* atomCommonAttributes,
|
||||
* attribute term { text },
|
||||
* attribute scheme { atomUri }?,
|
||||
* attribute label { text }?,
|
||||
* undefinedContent
|
||||
* }
|
||||
* </pre>
|
||||
* <p/>
|
||||
* TODO remove this file when JBoss AS includes RESTEasy 2.3.4.Final or higher
|
||||
*/
|
||||
@XmlRootElement(name = "category")
|
||||
@XmlAccessorType(XmlAccessType.PROPERTY)
|
||||
public class Category extends CommonAttributes {
|
||||
private String term;
|
||||
|
||||
private URI scheme;
|
||||
|
||||
private String label;
|
||||
|
||||
@XmlAttribute
|
||||
public String getTerm() {
|
||||
return term;
|
||||
}
|
||||
|
||||
public void setTerm(String term) {
|
||||
this.term = term;
|
||||
}
|
||||
|
||||
@XmlAttribute
|
||||
public URI getScheme() {
|
||||
return scheme;
|
||||
}
|
||||
|
||||
public void setScheme(URI scheme) {
|
||||
this.scheme = scheme;
|
||||
}
|
||||
|
||||
@XmlAttribute
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* Copyright 2012 JBoss Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.drools.guvnor.server.jaxrs.providers.atom;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlAnyAttribute;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import java.net.URI;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Attributes common across all atom types
|
||||
* <p/>
|
||||
* TODO remove this file when JBoss AS includes RESTEasy 2.3.4.Final or higher
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.PROPERTY)
|
||||
public class CommonAttributes {
|
||||
private String language;
|
||||
private URI base;
|
||||
|
||||
|
||||
private Map extensionAttributes = new HashMap();
|
||||
|
||||
@XmlAttribute(name = "lang", namespace = "http://www.w3.org/XML/1998/namespace")
|
||||
public String getLanguage() {
|
||||
return language;
|
||||
}
|
||||
|
||||
public void setLanguage(String language) {
|
||||
this.language = language;
|
||||
}
|
||||
|
||||
@XmlAttribute(namespace = "http://www.w3.org/XML/1998/namespace")
|
||||
public URI getBase() {
|
||||
return base;
|
||||
}
|
||||
|
||||
public void setBase(URI base) {
|
||||
this.base = base;
|
||||
}
|
||||
|
||||
@XmlAnyAttribute
|
||||
public Map getExtensionAttributes() {
|
||||
return extensionAttributes;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,268 @@
|
|||
/*
|
||||
* Copyright 2012 JBoss Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.drools.guvnor.server.jaxrs.providers.atom;
|
||||
|
||||
import org.jboss.resteasy.plugins.providers.jaxb.JAXBContextFinder;
|
||||
import org.jboss.resteasy.plugins.providers.jaxb.JAXBXmlTypeProvider;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBElement;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.annotation.*;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>Represents an atom:content element.</p>
|
||||
* <p/>
|
||||
* <p>Per RFC4287:</p>
|
||||
* <p/>
|
||||
* <pre>
|
||||
* The "atom:content" element either contains or links to the content of
|
||||
* the entry. The content of atom:content is Language-Sensitive.
|
||||
*
|
||||
* atomInlineTextContent =
|
||||
* element atom:content {
|
||||
* atomCommonAttributes,
|
||||
* attribute type { "text" | "html" }?,
|
||||
* (text)*
|
||||
* }
|
||||
*
|
||||
* atomInlineXHTMLContent =
|
||||
* element atom:content {
|
||||
* atomCommonAttributes,
|
||||
* attribute type { "xhtml" },
|
||||
* xhtmlDiv
|
||||
* }
|
||||
* atomInlineOtherContent =
|
||||
* element atom:content {
|
||||
* atomCommonAttributes,
|
||||
* attribute type { atomMediaType }?,
|
||||
* (text|anyElement)*
|
||||
* }
|
||||
*
|
||||
* atomOutOfLineContent =
|
||||
* element atom:content {
|
||||
* atomCommonAttributes,
|
||||
* attribute type { atomMediaType }?,
|
||||
* attribute src { atomUri },
|
||||
* empty
|
||||
* }
|
||||
*
|
||||
* atomContent = atomInlineTextContent
|
||||
* | atomInlineXHTMLContent
|
||||
* | atomInlineOtherContent
|
||||
* | atomOutOfLineContent
|
||||
*
|
||||
* </pre>
|
||||
* <p/>
|
||||
* TODO remove this file when JBoss AS includes RESTEasy 2.3.4.Final or higher
|
||||
*/
|
||||
@XmlRootElement(name = "content")
|
||||
@XmlAccessorType(XmlAccessType.PROPERTY)
|
||||
public class Content extends CommonAttributes {
|
||||
|
||||
protected JAXBContextFinder finder;
|
||||
private String type;
|
||||
private MediaType mediaType;
|
||||
private String text;
|
||||
private Element element;
|
||||
private URI src;
|
||||
private List<Object> value;
|
||||
private Object jaxbObject;
|
||||
|
||||
protected void setFinder(JAXBContextFinder finder) {
|
||||
this.finder = finder;
|
||||
}
|
||||
|
||||
@XmlAnyElement
|
||||
@XmlMixed
|
||||
public List<Object> getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(List<Object> value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@XmlAttribute
|
||||
public URI getSrc() {
|
||||
return src;
|
||||
}
|
||||
|
||||
public void setSrc(URI src) {
|
||||
this.src = src;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mime type of the content
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@XmlTransient
|
||||
public MediaType getType() {
|
||||
if (mediaType == null) {
|
||||
if (type.equals("html")) mediaType = MediaType.TEXT_HTML_TYPE;
|
||||
else if (type.equals("text")) mediaType = MediaType.TEXT_PLAIN_TYPE;
|
||||
else if (type.equals("xhtml")) mediaType = MediaType.APPLICATION_XHTML_XML_TYPE;
|
||||
else mediaType = MediaType.valueOf(type);
|
||||
}
|
||||
return mediaType;
|
||||
}
|
||||
|
||||
public void setType(MediaType type) {
|
||||
mediaType = type;
|
||||
if (type.equals(MediaType.TEXT_PLAIN_TYPE)) this.type = "text";
|
||||
else if (type.equals(MediaType.TEXT_HTML_TYPE)) this.type = "html";
|
||||
else if (type.equals(MediaType.APPLICATION_XHTML_XML_TYPE)) this.type = "xhtml";
|
||||
else this.type = type.toString();
|
||||
}
|
||||
|
||||
@XmlAttribute(name = "type")
|
||||
public String getRawType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
public void setRawType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* If content is text, return it as a String. Otherwise, if content is not text this will return null.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@XmlTransient
|
||||
public String getText() {
|
||||
if (value == null) return null;
|
||||
if (value.size() == 0) return null;
|
||||
if (text != null) return text;
|
||||
StringBuffer buf = new StringBuffer();
|
||||
for (Object obj : value) {
|
||||
if (obj instanceof String) buf.append(obj.toString());
|
||||
}
|
||||
text = buf.toString();
|
||||
return text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set content as text
|
||||
*
|
||||
* @param text
|
||||
*/
|
||||
public void setText(String text) {
|
||||
if (value == null) value = new ArrayList<>();
|
||||
if (this.text != null && value != null) value.clear();
|
||||
this.text = text;
|
||||
value.add(text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content as an XML Element if the content is XML. Otherwise, this will just return null.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@XmlTransient
|
||||
public Element getElement() {
|
||||
if (value == null) return null;
|
||||
if (element != null) return element;
|
||||
for (Object obj : value) {
|
||||
if (obj instanceof Element) {
|
||||
element = (Element) obj;
|
||||
return element;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the content to an XML Element
|
||||
*
|
||||
* @param element
|
||||
*/
|
||||
public void setElement(Element element) {
|
||||
if (value == null) value = new ArrayList();
|
||||
if (this.element != null && value != null) value.clear();
|
||||
this.element = element;
|
||||
value.add(element);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the content as the provided JAXB annotated type.
|
||||
* <p/>
|
||||
* This method will use a cached JAXBContext used by the Resteasy JAXB providers
|
||||
* or, if those are not existent, it will create a new JAXBContext from scratch
|
||||
* using the class.
|
||||
*
|
||||
* @param clazz class type you are expecting
|
||||
* @param otherPossibleClasses Other classe you want to create the JAXBContext with
|
||||
* @return null if there is no XML content
|
||||
* @throws JAXBException
|
||||
*/
|
||||
public <T> T getJAXBObject(Class<T> clazz, Class... otherPossibleClasses) throws JAXBException {
|
||||
JAXBContext ctx = null;
|
||||
Class[] classes = {clazz};
|
||||
if (otherPossibleClasses != null && otherPossibleClasses.length > 0) {
|
||||
classes = new Class[1 + otherPossibleClasses.length];
|
||||
classes[0] = clazz;
|
||||
for (int i = 0; i < otherPossibleClasses.length; i++) classes[i + 1] = otherPossibleClasses[i];
|
||||
}
|
||||
if (finder != null) {
|
||||
ctx = finder.findCacheContext(MediaType.APPLICATION_XML_TYPE, null, classes);
|
||||
} else {
|
||||
ctx = JAXBContext.newInstance(classes);
|
||||
}
|
||||
if (getElement() == null) return null;
|
||||
Object obj = ctx.createUnmarshaller().unmarshal(getElement());
|
||||
if (obj instanceof JAXBElement) {
|
||||
jaxbObject = ((JAXBElement) obj).getValue();
|
||||
return (T) jaxbObject;
|
||||
} else {
|
||||
jaxbObject = obj;
|
||||
return (T) obj;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns previous extracted jaxbobject from a call to getJAXBObject(Class<T> clazz)
|
||||
* or value passed in through a previous setJAXBObject().
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@XmlTransient
|
||||
public Object getJAXBObject() {
|
||||
return jaxbObject;
|
||||
}
|
||||
|
||||
public void setJAXBObject(Object obj) {
|
||||
if (value == null) value = new ArrayList();
|
||||
if (jaxbObject != null && value != null) value.clear();
|
||||
if (!obj.getClass().isAnnotationPresent(XmlRootElement.class) && obj.getClass().isAnnotationPresent(XmlType.class)) {
|
||||
value.add(JAXBXmlTypeProvider.wrapInJAXBElement(obj, obj.getClass()));
|
||||
} else {
|
||||
value.add(obj);
|
||||
}
|
||||
jaxbObject = obj;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,353 @@
|
|||
/*
|
||||
* Copyright 2012 JBoss Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.drools.guvnor.server.jaxrs.providers.atom;
|
||||
|
||||
import org.jboss.resteasy.plugins.providers.jaxb.JAXBContextFinder;
|
||||
import org.jboss.resteasy.plugins.providers.jaxb.JAXBXmlTypeProvider;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBElement;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.annotation.*;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>Per RFC4287:</p>
|
||||
* <pre>
|
||||
* The "atom:entry" element represents an individual entry, acting as a
|
||||
* container for metadata and data associated with the entry. This
|
||||
* element can appear as a child of the atom:feed element, or it can
|
||||
* appear as the document (i.e., top-level) element of a stand-alone
|
||||
* Atom Entry Document.
|
||||
*
|
||||
* atomEntry =
|
||||
* element atom:entry {
|
||||
* atomCommonAttributes,
|
||||
* (atomAuthor*
|
||||
* & atomCategory*
|
||||
* & atomContent?
|
||||
* & atomContributor*
|
||||
* & atomId
|
||||
* & atomLink*
|
||||
* & atomPublished?
|
||||
* & atomRights?
|
||||
* & atomSource?
|
||||
* & atomSummary?
|
||||
* & atomTitle
|
||||
* & atomUpdated
|
||||
* & extensionElement*)
|
||||
* }
|
||||
*
|
||||
* This specification assigns no significance to the order of appearance
|
||||
* of the child elements of atom:entry.
|
||||
*
|
||||
* The following child elements are defined by this specification (note
|
||||
* that it requires the presence of some of these elements):
|
||||
*
|
||||
* o atom:entry elements MUST contain one or more atom:author elements,
|
||||
* unless the atom:entry contains an atom:source element that
|
||||
* contains an atom:author element or, in an Atom Feed Document, the
|
||||
* atom:feed element contains an atom:author element itself.
|
||||
* o atom:entry elements MAY contain any number of atom:category
|
||||
* elements.
|
||||
* o atom:entry elements MUST NOT contain more than one atom:content
|
||||
* element.
|
||||
* o atom:entry elements MAY contain any number of atom:contributor
|
||||
* elements.
|
||||
* o atom:entry elements MUST contain exactly one atom:id element.
|
||||
* o atom:entry elements that contain no child atom:content element
|
||||
* MUST contain at least one atom:link element with a rel attribute
|
||||
* value of "alternate".
|
||||
* o atom:entry elements MUST NOT contain more than one atom:link
|
||||
* element with a rel attribute value of "alternate" that has the
|
||||
* same combination of type and hreflang attribute values.
|
||||
* o atom:entry elements MAY contain additional atom:link elements
|
||||
* beyond those described above.
|
||||
* o atom:entry elements MUST NOT contain more than one atom:published
|
||||
* element.
|
||||
* o atom:entry elements MUST NOT contain more than one atom:rights
|
||||
* element.
|
||||
* o atom:entry elements MUST NOT contain more than one atom:source
|
||||
* element.
|
||||
* o atom:entry elements MUST contain an atom:summary element in either
|
||||
* of the following cases:
|
||||
* * the atom:entry contains an atom:content that has a "src"
|
||||
* attribute (and is thus empty).
|
||||
* * the atom:entry contains content that is encoded in Base64;
|
||||
* i.e., the "type" attribute of atom:content is a MIME media type
|
||||
* [MIMEREG], but is not an XML media type [RFC3023], does not
|
||||
* begin with "text/", and does not end with "/xml" or "+xml".
|
||||
* o atom:entry elements MUST NOT contain more than one atom:summary
|
||||
* element.
|
||||
* o atom:entry elements MUST contain exactly one atom:title element.
|
||||
* o atom:entry elements MUST contain exactly one atom:updated element.
|
||||
* </pre>
|
||||
* <p/>
|
||||
* TODO remove this file when JBoss AS includes RESTEasy 2.3.4.Final or higher
|
||||
*/
|
||||
@XmlRootElement(namespace = "http://www.w3.org/2005/Atom", name = "entry")
|
||||
@XmlAccessorType(XmlAccessType.PROPERTY)
|
||||
@XmlType(propOrder = {"title", "links", "categories", "updated", "id", "published", "authors", "contributors", "source",
|
||||
"rights", "content", "summary", "anyOther"})
|
||||
public class Entry extends CommonAttributes {
|
||||
protected JAXBContextFinder finder;
|
||||
private List<Person> authors = new ArrayList<Person>();
|
||||
private List<Category> categories = new ArrayList<Category>();
|
||||
private Content content;
|
||||
private List<Person> contributors = new ArrayList<Person>();
|
||||
private URI id;
|
||||
private List<Link> links = new ArrayList<Link>();
|
||||
private Date published;
|
||||
private String title;
|
||||
private Date updated;
|
||||
private String rights;
|
||||
private Source source;
|
||||
private String summary;
|
||||
private Element anyOtherElement;
|
||||
private List<Object> anyOther;
|
||||
private Object anyOtherJaxbObject;
|
||||
|
||||
protected void setFinder(JAXBContextFinder finder) {
|
||||
this.finder = finder;
|
||||
}
|
||||
|
||||
@XmlElement(namespace = "http://www.w3.org/2005/Atom")
|
||||
public URI getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(URI id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@XmlElement(namespace = "http://www.w3.org/2005/Atom")
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
@XmlElement(namespace = "http://www.w3.org/2005/Atom")
|
||||
public Date getUpdated() {
|
||||
return updated;
|
||||
}
|
||||
|
||||
public void setUpdated(Date updated) {
|
||||
this.updated = updated;
|
||||
}
|
||||
|
||||
public Link getLinkByRel(String name) {
|
||||
for (Link link : links) if (link.getRel().equals(name)) return link;
|
||||
return null;
|
||||
}
|
||||
|
||||
@XmlElementRef(namespace = "http://www.w3.org/2005/Atom")
|
||||
public List<Link> getLinks() {
|
||||
return links;
|
||||
}
|
||||
|
||||
@XmlElementRef(namespace = "http://www.w3.org/2005/Atom")
|
||||
public Content getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(Content content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
@XmlElement(namespace = "http://www.w3.org/2005/Atom", name = "author")
|
||||
public List<Person> getAuthors() {
|
||||
return authors;
|
||||
}
|
||||
|
||||
@XmlElementRef(namespace = "http://www.w3.org/2005/Atom")
|
||||
public List<Category> getCategories() {
|
||||
return categories;
|
||||
}
|
||||
|
||||
@XmlElement(namespace = "http://www.w3.org/2005/Atom", name = "contributor")
|
||||
public List<Person> getContributors() {
|
||||
return contributors;
|
||||
}
|
||||
|
||||
@XmlElement(namespace = "http://www.w3.org/2005/Atom")
|
||||
public Date getPublished() {
|
||||
return published;
|
||||
}
|
||||
|
||||
public void setPublished(Date published) {
|
||||
this.published = published;
|
||||
}
|
||||
|
||||
@XmlElement(namespace = "http://www.w3.org/2005/Atom")
|
||||
public String getRights() {
|
||||
return rights;
|
||||
}
|
||||
|
||||
public void setRights(String rights) {
|
||||
this.rights = rights;
|
||||
}
|
||||
|
||||
@XmlElement(namespace = "http://www.w3.org/2005/Atom")
|
||||
public Source getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
public void setSource(Source source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
@XmlElement(namespace = "http://www.w3.org/2005/Atom")
|
||||
public String getSummary() {
|
||||
return summary;
|
||||
}
|
||||
|
||||
public void setSummary(String summary) {
|
||||
this.summary = summary;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Entry{" +
|
||||
"authors=" + authors +
|
||||
", categories=" + categories +
|
||||
", content=" + content +
|
||||
", contributors=" + contributors +
|
||||
", id=" + id +
|
||||
", links=" + links +
|
||||
", published=" + published +
|
||||
", title='" + title + '\'' +
|
||||
", updated=" + updated +
|
||||
", rights='" + rights + '\'' +
|
||||
", source=" + source +
|
||||
", summary='" + summary + '\'' +
|
||||
", anyOtherElement=" + anyOtherElement +
|
||||
", anyOther=" + anyOther +
|
||||
", anyOtherJaxbObject=" + anyOtherJaxbObject +
|
||||
'}';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content as an XML Element if the content is XML. Otherwise, this will just return null.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@XmlTransient
|
||||
public Element getAnyOtherElement() {
|
||||
if (anyOther == null) return null;
|
||||
if (anyOtherElement != null) return anyOtherElement;
|
||||
for (Object obj : anyOther) {
|
||||
if (obj instanceof Element) {
|
||||
anyOtherElement = (Element) obj;
|
||||
return anyOtherElement;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@XmlMixed
|
||||
@XmlAnyElement(lax = true)
|
||||
public List<Object> getAnyOther() {
|
||||
if (anyOther == null) {
|
||||
anyOther = new ArrayList<Object>();
|
||||
}
|
||||
return this.anyOther;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the content as the provided JAXB annotated type.
|
||||
* <p/>
|
||||
* This method will use a cached JAXBContext used by the Resteasy JAXB providers
|
||||
* or, if those are not existent, it will create a new JAXBContext from scratch
|
||||
* using the class.
|
||||
*
|
||||
* @param clazz class type you are expecting
|
||||
* @param otherPossibleClasses Other classe you want to create the JAXBContext with
|
||||
* @return null if there is no XML content
|
||||
* @throws JAXBException
|
||||
*/
|
||||
public <T> T getAnyOtherJAXBObject(Class<T> clazz, Class... otherPossibleClasses) throws JAXBException {
|
||||
JAXBContext ctx = null;
|
||||
Class[] classes = {clazz};
|
||||
if (otherPossibleClasses != null && otherPossibleClasses.length > 0) {
|
||||
classes = new Class[1 + otherPossibleClasses.length];
|
||||
classes[0] = clazz;
|
||||
for (int i = 0; i < otherPossibleClasses.length; i++) classes[i + 1] = otherPossibleClasses[i];
|
||||
}
|
||||
if (finder != null) {
|
||||
ctx = finder.findCacheContext(MediaType.APPLICATION_XML_TYPE, null, classes);
|
||||
} else {
|
||||
ctx = JAXBContext.newInstance(classes);
|
||||
}
|
||||
|
||||
Object obj = null;
|
||||
|
||||
if (getAnyOtherElement() != null) {
|
||||
obj = ctx.createUnmarshaller().unmarshal(getAnyOtherElement());
|
||||
} else {
|
||||
if (getAnyOther().size() == 0) return null;
|
||||
for (Object _obj : getAnyOther()) {
|
||||
for (Class _clazz : classes) {
|
||||
if (_obj.getClass().equals(_clazz)) {
|
||||
obj = _obj;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (obj == null)
|
||||
return null;
|
||||
}
|
||||
|
||||
if (obj instanceof JAXBElement) {
|
||||
anyOtherJaxbObject = ((JAXBElement) obj).getValue();
|
||||
return (T) anyOtherJaxbObject;
|
||||
} else {
|
||||
anyOtherJaxbObject = obj;
|
||||
return (T) obj;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns previous extracted jaxbobject from a call to getJAXBObject(Class<T> clazz)
|
||||
* or value passed in through a previous setJAXBObject().
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@XmlTransient
|
||||
public Object getAnyOtherJAXBObject() {
|
||||
return anyOtherJaxbObject;
|
||||
}
|
||||
|
||||
public void setAnyOtherJAXBObject(Object obj) {
|
||||
if (anyOther == null) anyOther = new ArrayList();
|
||||
if (anyOtherJaxbObject != null && anyOther != null) anyOther.clear();
|
||||
if (!obj.getClass().isAnnotationPresent(XmlRootElement.class) && obj.getClass().isAnnotationPresent(XmlType.class)) {
|
||||
anyOther.add(JAXBXmlTypeProvider.wrapInJAXBElement(obj, obj.getClass()));
|
||||
} else {
|
||||
anyOther.add(obj);
|
||||
}
|
||||
anyOtherJaxbObject = obj;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,111 @@
|
|||
/*
|
||||
* Copyright 2012 JBoss Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.drools.guvnor.server.jaxrs.providers.atom;
|
||||
|
||||
import org.drools.guvnor.server.jaxrs.jaxb.AtomAssetMetadata;
|
||||
|
||||
import javax.xml.bind.annotation.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>Per RFC4287:</p>
|
||||
* <p/>
|
||||
* <pre>
|
||||
* The "atom:feed" element is the document (i.e., top-level) element of
|
||||
* an Atom Feed Document, acting as a container for metadata and data
|
||||
* associated with the feed. Its element children consist of metadata
|
||||
* elements followed by zero or more atom:entry child elements.
|
||||
*
|
||||
* atomFeed =
|
||||
* element atom:feed {
|
||||
* atomCommonAttributes,
|
||||
* (atomAuthor*
|
||||
* & atomCategory*
|
||||
* & atomContributor*
|
||||
* & atomGenerator?
|
||||
* & atomIcon?
|
||||
* & atomId
|
||||
* & atomLink*
|
||||
* & atomLogo?
|
||||
* & atomRights?
|
||||
* & atomSubtitle?
|
||||
* & atomTitle
|
||||
* & atomUpdated
|
||||
* & extensionElement*),
|
||||
* atomEntry*
|
||||
* }
|
||||
*
|
||||
* This specification assigns no significance to the order of atom:entry
|
||||
* elements within the feed.
|
||||
*
|
||||
* The following child elements are defined by this specification (note
|
||||
* that the presence of some of these elements is required):
|
||||
*
|
||||
* o atom:feed elements MUST contain one or more atom:author elements,
|
||||
* unless all of the atom:feed element's child atom:entry elements
|
||||
* contain at least one atom:author element.
|
||||
* o atom:feed elements MAY contain any number of atom:category
|
||||
* elements.
|
||||
* o atom:feed elements MAY contain any number of atom:contributor
|
||||
* elements.
|
||||
* o atom:feed elements MUST NOT contain more than one atom:generator
|
||||
* element.
|
||||
* o atom:feed elements MUST NOT contain more than one atom:icon
|
||||
* element.
|
||||
* o atom:feed elements MUST NOT contain more than one atom:logo
|
||||
* element.
|
||||
* o atom:feed elements MUST contain exactly one atom:id element.
|
||||
* o atom:feed elements SHOULD contain one atom:link element with a rel
|
||||
* attribute value of "self". This is the preferred URI for
|
||||
* retrieving Atom Feed Documents representing this Atom feed.
|
||||
* o atom:feed elements MUST NOT contain more than one atom:link
|
||||
* element with a rel attribute value of "alternate" that has the
|
||||
* same combination of type and hreflang attribute values.
|
||||
* o atom:feed elements MAY contain additional atom:link elements
|
||||
* beyond those described above.
|
||||
* o atom:feed elements MUST NOT contain more than one atom:rights
|
||||
* element.
|
||||
* o atom:feed elements MUST NOT contain more than one atom:subtitle
|
||||
* element.
|
||||
* o atom:feed elements MUST contain exactly one atom:title element.
|
||||
* o atom:feed elements MUST contain exactly one atom:updated element.
|
||||
*
|
||||
* If multiple atom:entry elements with the same atom:id value appear in
|
||||
* an Atom Feed Document, they represent the same entry. Their
|
||||
* atom:updated timestamps SHOULD be different. If an Atom Feed
|
||||
* Document contains multiple entries with the same atom:id, Atom
|
||||
* Processors MAY choose to display all of them or some subset of them.
|
||||
* One typical behavior would be to display only the entry with the
|
||||
* latest atom:updated timestamp.
|
||||
* </pre>
|
||||
* <p/>
|
||||
* TODO remove this file when JBoss AS includes RESTEasy 2.3.4.Final or higher
|
||||
*/
|
||||
@XmlRootElement(namespace = "http://www.w3.org/2005/Atom", name = "feed")
|
||||
@XmlAccessorType(XmlAccessType.PROPERTY)
|
||||
@XmlSeeAlso({AtomAssetMetadata.class})
|
||||
public class Feed extends Source {
|
||||
|
||||
private List<Entry> entries = new ArrayList<Entry>();
|
||||
|
||||
@XmlElementRef(namespace = "http://www.w3.org/2005/Atom")
|
||||
public List<Entry> getEntries() {
|
||||
return entries;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
* Copyright 2012 JBoss Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.drools.guvnor.server.jaxrs.providers.atom;
|
||||
|
||||
import javax.xml.bind.annotation.*;
|
||||
import java.net.URI;
|
||||
|
||||
/**
|
||||
* <p>Per RFC4287</p>
|
||||
* <p/>
|
||||
* <pre>
|
||||
* atomGenerator = element atom:generator {
|
||||
* atomCommonAttributes,
|
||||
* attribute uri { atomUri }?,
|
||||
* attribute version { text }?,
|
||||
* text
|
||||
* }
|
||||
* </pre>
|
||||
* <p/>
|
||||
* TODO remove this file when JBoss AS includes RESTEasy 2.3.4.Final or higher
|
||||
*/
|
||||
@XmlRootElement(name = "generator")
|
||||
@XmlAccessorType(XmlAccessType.PROPERTY)
|
||||
public class Generator {
|
||||
private URI uri;
|
||||
|
||||
private String version;
|
||||
|
||||
private String text;
|
||||
|
||||
private String language;
|
||||
|
||||
private URI base;
|
||||
|
||||
@XmlAttribute(name = "lang")
|
||||
public String getLanguage() {
|
||||
return language;
|
||||
}
|
||||
|
||||
public void setLanguage(String language) {
|
||||
this.language = language;
|
||||
}
|
||||
|
||||
@XmlAttribute
|
||||
public URI getBase() {
|
||||
return base;
|
||||
}
|
||||
|
||||
public void setBase(URI base) {
|
||||
this.base = base;
|
||||
}
|
||||
|
||||
@XmlAttribute
|
||||
public URI getUri() {
|
||||
return uri;
|
||||
}
|
||||
|
||||
public void setUri(URI uri) {
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
@XmlAttribute
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
@XmlValue
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,147 @@
|
|||
/*
|
||||
* Copyright 2012 JBoss Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.drools.guvnor.server.jaxrs.providers.atom;
|
||||
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.net.URI;
|
||||
|
||||
/**
|
||||
* <p>Per RFC4287:</p>
|
||||
* <p/>
|
||||
* <pre>
|
||||
* The "atom:link" element defines a reference from an entry or feed to
|
||||
* a Web resource. This specification assigns no meaning to the content
|
||||
* (if any) of this element.
|
||||
*
|
||||
* atomLink =
|
||||
* element atom:link {
|
||||
* atomCommonAttributes,
|
||||
* attribute href { atomUri },
|
||||
* attribute rel { atomNCName | atomUri }?,
|
||||
* attribute type { atomMediaType }?,
|
||||
* attribute hreflang { atomLanguageTag }?,
|
||||
* attribute title { text }?,
|
||||
* attribute length { text }?,
|
||||
* undefinedContent
|
||||
* }
|
||||
* </pre>
|
||||
* <p/>
|
||||
* TODO remove this file when JBoss AS includes RESTEasy 2.3.4.Final or higher
|
||||
*/
|
||||
@XmlRootElement(name = "link")
|
||||
@XmlAccessorType(XmlAccessType.PROPERTY)
|
||||
public class Link extends CommonAttributes {
|
||||
protected URI href;
|
||||
|
||||
protected String rel;
|
||||
|
||||
protected MediaType type;
|
||||
|
||||
protected String hreflang;
|
||||
|
||||
protected String title;
|
||||
|
||||
protected String length;
|
||||
|
||||
public Link() {
|
||||
}
|
||||
|
||||
public Link(String rel, URI href) {
|
||||
this.rel = rel;
|
||||
this.href = href;
|
||||
}
|
||||
|
||||
public Link(String rel, URI href, MediaType type) {
|
||||
this.rel = rel;
|
||||
this.href = href;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Link(String rel, String href) {
|
||||
this.rel = rel;
|
||||
this.href = URI.create(href);
|
||||
}
|
||||
|
||||
public Link(String rel, String href, MediaType type) {
|
||||
this.rel = rel;
|
||||
this.href = URI.create(href);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Link(String rel, String href, String type) {
|
||||
this.rel = rel;
|
||||
this.href = URI.create(href);
|
||||
this.type = MediaType.valueOf(type);
|
||||
}
|
||||
|
||||
@XmlAttribute(required = true)
|
||||
public URI getHref() {
|
||||
return href;
|
||||
}
|
||||
|
||||
public void setHref(URI href) {
|
||||
this.href = href;
|
||||
}
|
||||
|
||||
@XmlAttribute
|
||||
public String getRel() {
|
||||
return rel;
|
||||
}
|
||||
|
||||
public void setRel(String rel) {
|
||||
this.rel = rel;
|
||||
}
|
||||
|
||||
public MediaType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(MediaType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@XmlAttribute
|
||||
public String getHreflang() {
|
||||
return hreflang;
|
||||
}
|
||||
|
||||
public void setHreflang(String hreflang) {
|
||||
this.hreflang = hreflang;
|
||||
}
|
||||
|
||||
@XmlAttribute
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
@XmlAttribute
|
||||
public String getLength() {
|
||||
return length;
|
||||
}
|
||||
|
||||
public void setLength(String length) {
|
||||
this.length = length;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Copyright 2012 JBoss Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.drools.guvnor.server.jaxrs.providers.atom;
|
||||
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.xml.bind.annotation.adapters.XmlAdapter;
|
||||
|
||||
/**
|
||||
* TODO remove this file when JBoss AS includes RESTEasy 2.3.4.Final or higher
|
||||
*/
|
||||
public class MediaTypeAdapter extends XmlAdapter<String, MediaType> {
|
||||
public MediaType unmarshal(String s) throws Exception {
|
||||
if (s == null) return null;
|
||||
return MediaType.valueOf(s);
|
||||
}
|
||||
|
||||
public String marshal(MediaType mediaType) throws Exception {
|
||||
if (mediaType == null) return null;
|
||||
return mediaType.toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* Copyright 2012 JBoss Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.drools.guvnor.server.jaxrs.providers.atom;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import java.net.URI;
|
||||
|
||||
/**
|
||||
* <p>Per RFC4287:</p>
|
||||
* <p/>
|
||||
* <pre>
|
||||
* A Person construct is an element that describes a person,
|
||||
* corporation, or similar entity (hereafter, 'person').
|
||||
*
|
||||
* atomPersonConstruct =
|
||||
* atomCommonAttributes,
|
||||
* (element atom:name { text }
|
||||
* & element atom:uri { atomUri }?
|
||||
* & element atom:email { atomEmailAddress }?
|
||||
* & extensionElement*)
|
||||
*
|
||||
* </pre>
|
||||
* <p/>
|
||||
* TODO remove this file when JBoss AS includes RESTEasy 2.3.4.Final or higher
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.PROPERTY)
|
||||
public class Person extends CommonAttributes {
|
||||
private String name;
|
||||
|
||||
private URI uri;
|
||||
|
||||
private String email;
|
||||
|
||||
public Person() {
|
||||
}
|
||||
|
||||
public Person(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public URI getUri() {
|
||||
return uri;
|
||||
}
|
||||
|
||||
public void setUri(URI uri) {
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright 2012 JBoss Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.drools.guvnor.server.jaxrs.providers.atom;
|
||||
|
||||
import org.jboss.resteasy.spi.ResteasyProviderFactory;
|
||||
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.net.URI;
|
||||
|
||||
/**
|
||||
* If invoked within the context of a JAX-RS call, it will automatically build a
|
||||
* URI based the base URI of the JAX-RS application. Same URI as UriInfo.getRequestUri().
|
||||
* <p/>
|
||||
* TODO remove this file when JBoss AS includes RESTEasy 2.3.4.Final or higher
|
||||
*/
|
||||
@XmlRootElement(name = "link")
|
||||
@XmlAccessorType(XmlAccessType.PROPERTY)
|
||||
public class RelativeLink extends Link {
|
||||
public RelativeLink() {
|
||||
}
|
||||
|
||||
public RelativeLink(String rel, String relativeLink) {
|
||||
UriInfo uriInfo = ResteasyProviderFactory.getContextData(UriInfo.class);
|
||||
if (uriInfo == null)
|
||||
throw new IllegalStateException("This constructor must be called in the context of a JAX-RS request");
|
||||
URI uri = uriInfo.getAbsolutePathBuilder().path(relativeLink).build();
|
||||
setHref(uri);
|
||||
setRel(rel);
|
||||
}
|
||||
|
||||
public RelativeLink(String rel, String relativeLink, MediaType mediaType) {
|
||||
this(rel, relativeLink);
|
||||
this.setType(mediaType);
|
||||
}
|
||||
|
||||
public RelativeLink(String rel, String relativeLink, String mediaType) {
|
||||
this(rel, relativeLink);
|
||||
this.setType(MediaType.valueOf(mediaType));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,181 @@
|
|||
/*
|
||||
* Copyright 2012 JBoss Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.drools.guvnor.server.jaxrs.providers.atom;
|
||||
|
||||
import javax.xml.bind.annotation.*;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>Per RFC4287:</p>
|
||||
* <p/>
|
||||
* <pre>
|
||||
* If an atom:entry is copied from one feed into another feed, then the
|
||||
* source atom:feed's metadata (all child elements of atom:feed other
|
||||
* than the atom:entry elements) MAY be preserved within the copied
|
||||
* entry by adding an atom:source child element, if it is not already
|
||||
* present in the entry, and including some or all of the source feed's
|
||||
* Metadata elements as the atom:source element's children. Such
|
||||
* metadata SHOULD be preserved if the source atom:feed contains any of
|
||||
* the child elements atom:author, atom:contributor, atom:rights, or
|
||||
* atom:category and those child elements are not present in the source
|
||||
* atom:entry.
|
||||
*
|
||||
* atomSource =
|
||||
* element atom:source {
|
||||
* atomCommonAttributes,
|
||||
* (atomAuthor*
|
||||
* & atomCategory*
|
||||
* & atomContributor*
|
||||
* & atomGenerator?
|
||||
* & atomIcon?
|
||||
* & atomId?
|
||||
* & atomLink*
|
||||
* & atomLogo?
|
||||
* & atomRights?
|
||||
* & atomSubtitle?
|
||||
* & atomTitle?
|
||||
* & atomUpdated?
|
||||
* & extensionElement*)
|
||||
* }
|
||||
*
|
||||
* The atom:source element is designed to allow the aggregation of
|
||||
* entries from different feeds while retaining information about an
|
||||
* entry's source feed. For this reason, Atom Processors that are
|
||||
* performing such aggregation SHOULD include at least the required
|
||||
* feed-level Metadata elements (atom:id, atom:title, and atom:updated)
|
||||
* in the atom:source element.
|
||||
* </pre>
|
||||
* <p/>
|
||||
* TODO remove this file when JBoss AS includes RESTEasy 2.3.4.Final or higher
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.PROPERTY)
|
||||
@XmlType(propOrder = {"title", "subtitle", "categories", "updated", "id", "links", "authors", "contributors", "rights",
|
||||
"icon", "logo", "generator"})
|
||||
public class Source extends CommonAttributes {
|
||||
private List<Person> authors = new ArrayList<Person>();
|
||||
private List<Category> categories = new ArrayList<Category>();
|
||||
private List<Person> contributors = new ArrayList<Person>();
|
||||
private Generator generator;
|
||||
private URI id;
|
||||
private String title;
|
||||
private Date updated;
|
||||
private List<Link> links = new ArrayList<Link>();
|
||||
private URI icon;
|
||||
private URI logo;
|
||||
private String rights;
|
||||
private String subtitle;
|
||||
|
||||
@XmlElement(name = "author")
|
||||
public List<Person> getAuthors() {
|
||||
return authors;
|
||||
}
|
||||
|
||||
@XmlElement(name = "contributor")
|
||||
public List<Person> getContributors() {
|
||||
return contributors;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public URI getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(URI id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public Date getUpdated() {
|
||||
return updated;
|
||||
}
|
||||
|
||||
public void setUpdated(Date updated) {
|
||||
this.updated = updated;
|
||||
}
|
||||
|
||||
public Link getLinkByRel(String name) {
|
||||
for (Link link : links) if (link.getRel().equals(name)) return link;
|
||||
return null;
|
||||
}
|
||||
|
||||
@XmlElementRef
|
||||
public List<Link> getLinks() {
|
||||
return links;
|
||||
}
|
||||
|
||||
@XmlElementRef
|
||||
public List<Category> getCategories() {
|
||||
return categories;
|
||||
}
|
||||
|
||||
@XmlElementRef
|
||||
public Generator getGenerator() {
|
||||
return generator;
|
||||
}
|
||||
|
||||
public void setGenerator(Generator generator) {
|
||||
this.generator = generator;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public URI getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public void setIcon(URI icon) {
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public URI getLogo() {
|
||||
return logo;
|
||||
}
|
||||
|
||||
public void setLogo(URI logo) {
|
||||
this.logo = logo;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String getRights() {
|
||||
return rights;
|
||||
}
|
||||
|
||||
public void setRights(String rights) {
|
||||
this.rights = rights;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String getSubtitle() {
|
||||
return subtitle;
|
||||
}
|
||||
|
||||
public void setSubtitle(String subtitle) {
|
||||
this.subtitle = subtitle;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Copyright 2012 JBoss Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.drools.guvnor.server.jaxrs.providers.atom;
|
||||
|
||||
import javax.xml.bind.annotation.adapters.XmlAdapter;
|
||||
import java.net.URI;
|
||||
|
||||
/**
|
||||
* TODO remove this file when JBoss AS includes RESTEasy 2.3.4.Final or higher
|
||||
*/
|
||||
public class UriAdapter extends XmlAdapter<String, URI> {
|
||||
public URI unmarshal(String s) throws Exception {
|
||||
if (s == null) return null;
|
||||
return new URI(s);
|
||||
}
|
||||
|
||||
public String marshal(URI uri) throws Exception {
|
||||
if (uri == null) return null;
|
||||
return uri.toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Copyright 2012 JBoss Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@XmlSchema(namespace = "http://www.w3.org/2005/Atom",
|
||||
// attributeFormDefault = XmlNsForm.QUALIFIED,
|
||||
xmlns = {@javax.xml.bind.annotation.XmlNs(prefix = "atom", namespaceURI = "http://www.w3.org/2005/Atom")},
|
||||
elementFormDefault = XmlNsForm.QUALIFIED
|
||||
)
|
||||
@XmlJavaTypeAdapters(
|
||||
{
|
||||
@XmlJavaTypeAdapter(type = URI.class, value = UriAdapter.class),
|
||||
@XmlJavaTypeAdapter(type = MediaType.class, value = MediaTypeAdapter.class)
|
||||
})
|
||||
package org.drools.guvnor.server.jaxrs.providers.atom;
|
||||
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.xml.bind.annotation.XmlNsForm;
|
||||
import javax.xml.bind.annotation.XmlSchema;
|
||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters;
|
||||
import java.net.URI;
|
||||
|
|
@ -15,12 +15,27 @@
|
|||
<description>kie drools Framework - REST Backend</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.pymmasoftware.jbpm</groupId>
|
||||
<artifactId>drools-framework-kie-wb-rest-pojo</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.spec.javax.ejb</groupId>
|
||||
<artifactId>jboss-ejb-api_3.2_spec</artifactId>
|
||||
<version>1.0.0.Final</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.kie</groupId>
|
||||
<artifactId>kie-api</artifactId>
|
||||
<version>${jbpm.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.kie</groupId>
|
||||
<artifactId>kie-internal</artifactId>
|
||||
<version>${jbpm.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
|
|
|
|||
|
|
@ -1,17 +1,21 @@
|
|||
package org.chtijbug.kie.rest.backend;
|
||||
|
||||
|
||||
import org.drools.guvnor.server.jaxrs.jaxb.Asset;
|
||||
import org.guvnor.common.services.project.model.WorkspaceProject;
|
||||
import org.guvnor.common.services.project.service.WorkspaceProjectService;
|
||||
import org.guvnor.rest.client.ProjectResponse;
|
||||
import org.guvnor.structure.organizationalunit.OrganizationalUnit;
|
||||
import org.guvnor.structure.organizationalunit.OrganizationalUnitService;
|
||||
import org.guvnor.structure.repositories.Branch;
|
||||
import org.guvnor.structure.repositories.PublicURI;
|
||||
import org.guvnor.structure.repositories.Repository;
|
||||
import org.guvnor.structure.repositories.RepositoryService;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.uberfire.io.IOService;
|
||||
import org.uberfire.java.nio.base.options.CommentedOption;
|
||||
import org.uberfire.java.nio.file.DirectoryStream;
|
||||
import org.uberfire.java.nio.file.Paths;
|
||||
import org.uberfire.spaces.Space;
|
||||
|
||||
import javax.enterprise.context.ApplicationScoped;
|
||||
|
|
@ -21,10 +25,12 @@ import javax.ws.rs.*;
|
|||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.FileAlreadyExistsException;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
@Path("/chtijbug")
|
||||
|
|
@ -46,7 +52,10 @@ public class PackageResource {
|
|||
|
||||
@Inject
|
||||
private RepositoryService repositoryService;
|
||||
@Inject
|
||||
private WorkspaceProjectService projectService;
|
||||
|
||||
private RestTypeDefinition dotFileFilter = new RestTypeDefinition();
|
||||
|
||||
@Inject
|
||||
private WorkspaceProjectService workspaceProjectService;
|
||||
|
|
@ -108,15 +117,24 @@ public class PackageResource {
|
|||
@GET
|
||||
@Path("{organizationalUnitName}/{repositoryName}")
|
||||
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
||||
public Collection<Package> getPackagesAsJAXB(@PathParam("organizationalUnitName") String organizationalUnitName, @PathParam("repositoryName") String repositoryName) {
|
||||
public Collection<org.drools.guvnor.server.jaxrs.jaxb.Package> getPackagesAsJAXB(@PathParam("organizationalUnitName") String organizationalUnitName, @PathParam("repositoryName") String repositoryName) {
|
||||
OrganizationalUnit organizationalUnit = organizationalUnitService.getOrganizationalUnit(organizationalUnitName);
|
||||
Collection<Repository> repositories = organizationalUnit.getRepositories();
|
||||
for (Repository repository : repositories) {
|
||||
if (repository.getAlias().equals(repositoryName)) {
|
||||
|
||||
Optional<Branch> branch = repository.getDefaultBranch();
|
||||
Collection<WorkspaceProject> projects = projectService.getAllWorkspaceProjects(organizationalUnit);
|
||||
Collection<org.drools.guvnor.server.jaxrs.jaxb.Package> packages = new ArrayList<>();
|
||||
for (WorkspaceProject project : projects) {
|
||||
org.drools.guvnor.server.jaxrs.jaxb.Package aPackage = new org.drools.guvnor.server.jaxrs.jaxb.Package();
|
||||
aPackage.setTitle(project.getName());
|
||||
aPackage.setGroupID(project.getMainModule().getPom().getGav().getGroupId());
|
||||
aPackage.setArtifactID(project.getMainModule().getPom().getGav().getArtifactId());
|
||||
aPackage.setVersion(project.getMainModule().getPom().getGav().getVersion());
|
||||
|
||||
Collection<Package> packages = new ArrayList<>();
|
||||
|
||||
packages.add(aPackage);
|
||||
}
|
||||
return packages;
|
||||
}
|
||||
}
|
||||
|
|
@ -126,12 +144,19 @@ public class PackageResource {
|
|||
@GET
|
||||
@Path("{organizationalUnitName}/{repositoryName}/{packageName}/assets")
|
||||
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
||||
public Collection<String> getAssetsAsJAXB(
|
||||
public Collection<Asset> getAssetsAsJAXB(
|
||||
@PathParam("organizationalUnitName") String organizationalUnitName, @PathParam("repositoryName") String repositoryName,
|
||||
@PathParam("packageName") String packageName,
|
||||
@QueryParam("format") List<String> formats) {
|
||||
try {
|
||||
List<String> contentList = new LinkedList<>();
|
||||
List<Asset> contentList = new LinkedList<>();
|
||||
WorkspaceProject project = getProject(organizationalUnitName, repositoryName, packageName);
|
||||
if (project != null && project.getName().equals(packageName)) {
|
||||
org.uberfire.backend.vfs.Path rootPath = project.getRootPath();
|
||||
org.uberfire.java.nio.file.Path nioPath = Paths.get(rootPath.toURI());
|
||||
DirectoryStream<org.uberfire.java.nio.file.Path> directoryStream = ioService.newDirectoryStream(nioPath);
|
||||
getContent(directoryStream, contentList);
|
||||
}
|
||||
|
||||
|
||||
return contentList;
|
||||
|
|
@ -140,32 +165,55 @@ public class PackageResource {
|
|||
}
|
||||
}
|
||||
|
||||
private String getProject(String organizationalUnitName, String repositoryName, String packageName) {
|
||||
private WorkspaceProject getProject(String organizationalUnitName, String repositoryName, String packageName) {
|
||||
OrganizationalUnit organizationalUnit = organizationalUnitService.getOrganizationalUnit(organizationalUnitName);
|
||||
Collection<Repository> repositories = organizationalUnit.getRepositories();
|
||||
for (Repository repository : repositories) {
|
||||
if (repository.getAlias().equals(repositoryName)) {
|
||||
Optional<Branch> branch = repository.getDefaultBranch();
|
||||
Collection<WorkspaceProject> workspaceProjects = projectService.getAllWorkspaceProjects(organizationalUnit);
|
||||
|
||||
return "tto";
|
||||
for (WorkspaceProject project : workspaceProjects) {
|
||||
if (project.getName().equals(packageName)) {
|
||||
return project;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private void getContentSource(DirectoryStream<org.uberfire.java.nio.file.Path> directoryStream, String asset, List<org.uberfire.java.nio.file.Path> pathLinkedList) {
|
||||
private void getContentSource(DirectoryStream<org.uberfire.java.nio.file.Path> directoryStream, Asset asset, List<org.uberfire.java.nio.file.Path> pathLinkedList) {
|
||||
for (org.uberfire.java.nio.file.Path elementPath : directoryStream) {
|
||||
if (org.uberfire.java.nio.file.Files.isDirectory(elementPath)) {
|
||||
DirectoryStream<org.uberfire.java.nio.file.Path> adirectoryStream = ioService.newDirectoryStream(elementPath);
|
||||
getContentSource(adirectoryStream, asset, pathLinkedList);
|
||||
} else {
|
||||
|
||||
if (dotFileFilter.accept(elementPath.getFileName().toString())) {
|
||||
Map<String, Object> listAttributes = ioService.readAttributes(elementPath);
|
||||
if (asset.getTitle().equals(elementPath.getFileName().toString())) {
|
||||
pathLinkedList.add(elementPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void getContent(DirectoryStream<org.uberfire.java.nio.file.Path> directoryStream, Collection<String> contentList) {
|
||||
private void getContent(DirectoryStream<org.uberfire.java.nio.file.Path> directoryStream, Collection<Asset> contentList) {
|
||||
for (org.uberfire.java.nio.file.Path elementPath : directoryStream) {
|
||||
if (org.uberfire.java.nio.file.Files.isDirectory(elementPath)) {
|
||||
DirectoryStream<org.uberfire.java.nio.file.Path> adirectoryStream = ioService.newDirectoryStream(elementPath);
|
||||
getContent(adirectoryStream, contentList);
|
||||
} else {
|
||||
|
||||
if (dotFileFilter.accept(elementPath.getFileName().toString())) {
|
||||
Map<String, Object> listAttributes = ioService.readAttributes(elementPath);
|
||||
Asset asset = new Asset();
|
||||
asset.setTitle(elementPath.getFileName().toString());
|
||||
asset.setDirectory(elementPath.getParent().toString());
|
||||
asset.setRefLink(elementPath.getFileName().toUri());
|
||||
contentList.add(asset);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -179,7 +227,9 @@ public class PackageResource {
|
|||
return foundElementPath;
|
||||
}
|
||||
} else {
|
||||
|
||||
if (dotFileFilter.accept(elementPath.getFileName().toString())) {
|
||||
return elementPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
@ -204,12 +254,24 @@ public class PackageResource {
|
|||
@GET
|
||||
@Path("{organizationalUnitName}/{repositoryName}/{packageName}/assets/{assetName}")
|
||||
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
||||
public Collection<String> getAssetAsJaxB(
|
||||
public Collection<Asset> getAssetAsJaxB(
|
||||
@PathParam("organizationalUnitName") String organizationalUnitName, @PathParam("repositoryName") String repositoryName,
|
||||
@PathParam("packageName") String packageName, @PathParam("assetName") String assetName) {
|
||||
List<String> resultList = new LinkedList<>();
|
||||
List<Asset> resultList = new LinkedList<>();
|
||||
try {
|
||||
|
||||
WorkspaceProject project = getProject(organizationalUnitName, repositoryName, packageName);
|
||||
if (project != null && project.getName().equals(packageName)) {
|
||||
List<Asset> contentList = new LinkedList<>();
|
||||
org.uberfire.backend.vfs.Path rootPath = project.getRootPath();
|
||||
org.uberfire.java.nio.file.Path nioPath = Paths.get(rootPath.toURI());
|
||||
DirectoryStream<org.uberfire.java.nio.file.Path> directoryStream = ioService.newDirectoryStream(nioPath);
|
||||
getContent(directoryStream, contentList);
|
||||
for (Asset asset : contentList) {
|
||||
if (asset.getTitle().equals(assetName)) {
|
||||
resultList.add(asset);
|
||||
}
|
||||
}
|
||||
}
|
||||
return resultList;
|
||||
} catch (RuntimeException e) {
|
||||
throw new WebApplicationException(e);
|
||||
|
|
@ -223,15 +285,32 @@ public class PackageResource {
|
|||
public String getAssetSource(
|
||||
@PathParam("organizationalUnitName") String organizationalUnitName, @PathParam("repositoryName") String repositoryName,
|
||||
@PathParam("packageName") String packageName, @PathParam("assetName") String assetName) {
|
||||
List<String> resultList = new LinkedList<>();
|
||||
List<Asset> resultList = new LinkedList<>();
|
||||
String result = "";
|
||||
try {
|
||||
|
||||
WorkspaceProject project = getProject(organizationalUnitName, repositoryName, packageName);
|
||||
if (project != null && project.getName().equals(packageName)) {
|
||||
List<Asset> contentList = new LinkedList<>();
|
||||
List<org.uberfire.java.nio.file.Path> pathLinkedList = new LinkedList<>();
|
||||
org.uberfire.backend.vfs.Path rootPath = project.getRootPath();
|
||||
org.uberfire.java.nio.file.Path nioPath = Paths.get(rootPath.toURI());
|
||||
DirectoryStream<org.uberfire.java.nio.file.Path> directoryStream = ioService.newDirectoryStream(nioPath);
|
||||
getContent(directoryStream, contentList);
|
||||
for (Asset asset : contentList) {
|
||||
if (asset.getTitle().equals(assetName)) {
|
||||
resultList.add(asset);
|
||||
DirectoryStream<org.uberfire.java.nio.file.Path> directoryStream2 = ioService.newDirectoryStream(nioPath);
|
||||
getContentSource(directoryStream2, asset, pathLinkedList);
|
||||
if (pathLinkedList.size() == 1) {
|
||||
result = ioService.readAllString(pathLinkedList.get(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
} catch (RuntimeException e) {
|
||||
throw new WebApplicationException(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@PUT
|
||||
|
|
@ -241,22 +320,29 @@ public class PackageResource {
|
|||
@PathParam("organizationalUnitName") String organizationalUnitName, @PathParam("repositoryName") String repositoryName,
|
||||
@PathParam("packageName") String packageName,
|
||||
@PathParam("assetName") String assetName, String asset) {
|
||||
try {
|
||||
|
||||
} catch (RuntimeException e) {
|
||||
throw new WebApplicationException(e);
|
||||
}
|
||||
updateAssetContent(organizationalUnitName, repositoryName, packageName, assetName, asset);
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("{organizationalUnitName}/{repositoryName}/{packageName}/newAsset")
|
||||
@Consumes(MediaType.MULTIPART_FORM_DATA)
|
||||
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
||||
public String createAssetFromSourceAndJAXB(
|
||||
public Asset createAssetFromSourceAndJAXB(
|
||||
@PathParam("organizationalUnitName") String organizationalUnitName, @PathParam("repositoryName") String repositoryName,
|
||||
@PathParam("packageName") String packageName, String asset) {
|
||||
@PathParam("packageName") String packageName, Asset asset) {
|
||||
try {
|
||||
WorkspaceProject project = getProject(organizationalUnitName, repositoryName, packageName);
|
||||
org.uberfire.backend.vfs.Path rootPath = project.getRootPath();
|
||||
org.uberfire.java.nio.file.Path nioPathDirectory = Paths.get(rootPath.toURI());
|
||||
DirectoryStream<org.uberfire.java.nio.file.Path> directoryStream = ioService.newDirectoryStream(nioPathDirectory);
|
||||
|
||||
org.uberfire.java.nio.file.Path directoryWhereCreateAsset = getDirectoryElementPath(directoryStream, asset.getTitle());
|
||||
final org.uberfire.java.nio.file.Path nioPath = Paths.get(directoryWhereCreateAsset.toUri());
|
||||
if (ioService.exists(nioPath)) {
|
||||
throw new FileAlreadyExistsException(nioPath.toString());
|
||||
}
|
||||
CommentedOption commentedOption = new CommentedOption(asset.getComment());
|
||||
ioService.write(nioPath, asset.getContent().getBytes(), commentedOption);
|
||||
} catch (Exception e) {
|
||||
throw new WebApplicationException(e);
|
||||
}
|
||||
|
|
@ -270,13 +356,34 @@ public class PackageResource {
|
|||
public void updateAssetSource(
|
||||
@PathParam("organizationalUnitName") String organizationalUnitName, @PathParam("repositoryName") String repositoryName,
|
||||
@PathParam("packageName") String packageName, @PathParam("assetName") String assetName, String content) {
|
||||
try {
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new WebApplicationException(e);
|
||||
}
|
||||
updateAssetContent(organizationalUnitName, repositoryName, packageName, assetName, content);
|
||||
|
||||
}
|
||||
|
||||
private void updateAssetContent(String organizationalUnitName, String repositoryName, String packageName, String assetName, String content) {
|
||||
try {
|
||||
WorkspaceProject project = getProject(organizationalUnitName, repositoryName, packageName);
|
||||
|
||||
if (project != null && project.getName().equals(packageName)) {
|
||||
org.uberfire.backend.vfs.Path rootPath = project.getRootPath();
|
||||
org.uberfire.java.nio.file.Path nioPath = Paths.get(rootPath.toURI());
|
||||
DirectoryStream<org.uberfire.java.nio.file.Path> directoryStream = ioService.newDirectoryStream(nioPath);
|
||||
org.uberfire.java.nio.file.Path elementToUpdate = getFileElementPath(directoryStream, assetName);
|
||||
File fileToUpdate = elementToUpdate.toFile();
|
||||
if (fileToUpdate.isFile()) {
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(fileToUpdate);
|
||||
fileOutputStream.write(content.getBytes());
|
||||
fileOutputStream.close();
|
||||
}
|
||||
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
throw new WebApplicationException(e);
|
||||
} catch (FileNotFoundException e) {
|
||||
throw new WebApplicationException(e);
|
||||
} catch (IOException e) {
|
||||
throw new WebApplicationException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,54 @@
|
|||
package org.chtijbug.kie.rest.backend;
|
||||
|
||||
import org.kie.api.io.Resource;
|
||||
import org.kie.api.io.ResourceType;
|
||||
import org.kie.internal.io.ResourceFactory;
|
||||
|
||||
|
||||
/**
|
||||
* Created by nheron on 23/01/15.
|
||||
*/
|
||||
public class RestTypeDefinition {
|
||||
|
||||
|
||||
public boolean accept(String fileName) {
|
||||
boolean result = false;
|
||||
Resource zz = ResourceFactory.newFileResource("rr");
|
||||
|
||||
if (fileName.endsWith("." + ResourceType.DRL.getDefaultExtension())
|
||||
|| fileName.endsWith("." + ResourceType.GDRL.getDefaultExtension())
|
||||
|| fileName.endsWith("." + ResourceType.RDRL.getDefaultExtension())
|
||||
|| fileName.endsWith("." + ResourceType.XDRL.getDefaultExtension())
|
||||
|| fileName.endsWith("." + ResourceType.DSL.getDefaultExtension())
|
||||
|| fileName.endsWith("." + ResourceType.DSLR.getDefaultExtension())
|
||||
|| fileName.endsWith("." + ResourceType.RDSLR.getDefaultExtension())
|
||||
|| fileName.endsWith("." + ResourceType.DRF.getDefaultExtension())
|
||||
|| fileName.endsWith("." + ResourceType.BPMN2.getDefaultExtension())
|
||||
|| fileName.endsWith("." + ResourceType.CMMN.getDefaultExtension())
|
||||
|| fileName.endsWith("." + ResourceType.DTABLE.getDefaultExtension())
|
||||
|| fileName.endsWith("." + ResourceType.BRL.getDefaultExtension())
|
||||
|| fileName.endsWith("." + ResourceType.XSD.getDefaultExtension())
|
||||
|| fileName.endsWith("." + ResourceType.PMML.getDefaultExtension())
|
||||
|| fileName.endsWith("." + ResourceType.DESCR.getDefaultExtension())
|
||||
|| fileName.endsWith("." + ResourceType.JAVA.getDefaultExtension())
|
||||
|| fileName.endsWith("." + ResourceType.PROPERTIES.getDefaultExtension())
|
||||
|| fileName.endsWith("." + ResourceType.SCARD.getDefaultExtension())
|
||||
|| fileName.endsWith("." + ResourceType.TDRL.getDefaultExtension())
|
||||
|| fileName.endsWith("." + ResourceType.BAYES.getDefaultExtension())
|
||||
// ||fileName.endsWith("." + ResourceType.JAVA.getDefaultExtension())
|
||||
|| fileName.endsWith("." + ResourceType.TEMPLATE.getDefaultExtension())
|
||||
|| fileName.endsWith("." + ResourceType.DRT.getDefaultExtension())
|
||||
|| fileName.endsWith("." + ResourceType.GDST.getDefaultExtension())
|
||||
|| fileName.endsWith("." + ResourceType.SCGD.getDefaultExtension())
|
||||
|| fileName.endsWith("." + ResourceType.SOLVER.getDefaultExtension())
|
||||
|| fileName.endsWith("." + ResourceType.DMN.getDefaultExtension())
|
||||
|| fileName.endsWith("." + ResourceType.FEEL.getDefaultExtension())
|
||||
|
||||
|
||||
) {
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -23,7 +23,24 @@
|
|||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="kie-drools-framework-rest-backend" />
|
||||
<orderEntry type="module" module-name="drools-framework-kie-wb-rest-pojo" />
|
||||
<orderEntry type="library" name="Maven: org.jboss.errai:errai-common:4.3.3.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.jsinterop:jsinterop-annotations:1.0.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jboss.errai.reflections:reflections:4.3.3.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.guava:guava:13.0.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.javassist:javassist:3.20.0-GA" level="project" />
|
||||
<orderEntry type="library" name="Maven: junit:junit:4.12" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: de.benediktmeurer.gwt-slf4j:gwt-slf4j:0.0.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.elemental2:elemental2-dom:1.0.0-beta-1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.jsinterop:base:1.0.0-beta-1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.elemental2:elemental2-core:1.0.0-beta-1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.elemental2:elemental2-promise:1.0.0-beta-1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.kie:kie-api:7.15.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.kie.soup:kie-soup-maven-support:7.15.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.kie:kie-internal:7.15.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.kie:kie-wb:war:wildfly14:7.14.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.kie:business-central:war:wildfly14:7.15.0.Final" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
<dependency>
|
||||
<groupId>org.kie</groupId>
|
||||
<artifactId>kie-wb</artifactId>
|
||||
<artifactId>business-central</artifactId>
|
||||
<classifier>wildfly14</classifier>
|
||||
<version>${jbpm.version}</version>
|
||||
<type>war</type>
|
||||
|
|
@ -57,7 +57,7 @@
|
|||
<artifactItems>
|
||||
<artifactItem>
|
||||
<groupId>org.kie</groupId>
|
||||
<artifactId>kie-wb</artifactId>
|
||||
<artifactId>business-central</artifactId>
|
||||
<classifier>wildfly14</classifier>
|
||||
<version>${jbpm.version}</version>
|
||||
<type>war</type>
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
<modules>
|
||||
<module>kie-wb</module>
|
||||
<module>kie-drools-framework-rest-backend</module>
|
||||
<module>drools-framework-kie-wb-rest-pojo</module>
|
||||
</modules>
|
||||
|
||||
<dependencyManagement>
|
||||
|
|
|
|||
|
|
@ -25,9 +25,9 @@
|
|||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.8.9" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.8.9" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.8.9" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.kie:kie-internal:7.14.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.kie:kie-api:7.14.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.kie.soup:kie-soup-maven-support:7.14.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.kie:kie-internal:7.15.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.kie:kie-api:7.15.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.kie.soup:kie-soup-maven-support:7.15.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.2" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
2
pom.xml
2
pom.xml
|
|
@ -24,7 +24,7 @@
|
|||
<packaging>pom</packaging>
|
||||
|
||||
<properties>
|
||||
<jbpm.version>7.14.0.Final</jbpm.version>
|
||||
<jbpm.version>7.15.0.Final</jbpm.version>
|
||||
<spring.boot.version>1.5.12.RELEASE</spring.boot.version>
|
||||
<spring.version>4.3.16.RELEASE</spring.version>
|
||||
<version.thorntail>2.2.1.Final</version.thorntail>
|
||||
|
|
|
|||
Loading…
Add table
editor.link_modal.header
Reference in a new issue