You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2013/02/08 14:16:19 UTC
[17/24] git commit: ISIS-323: lots more refactoring of RO
ISIS-323: lots more refactoring of RO
* bumped to 2.0.0-SNAPSHOT
* renamed impl -> server
* moved the representations from 'server' to 'rendering' module
* representations depend only on guava's MediaType (might reverse this decision)
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/75f41b75
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/75f41b75
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/75f41b75
Branch: refs/heads/dan/ISIS-323
Commit: 75f41b7537be239677c599b42f91dbedeaecee1b
Parents: c7d129a
Author: Dan Haywood <da...@apache.org>
Authored: Thu Feb 7 16:34:09 2013 +0000
Committer: Dan Haywood <da...@apache.org>
Committed: Thu Feb 7 16:34:09 2013 +0000
----------------------------------------------------------------------
component/viewer/restfulobjects/applib/pom.xml | 38 +-
.../applib/ClientRequestConfigurer.java | 21 +-
.../viewer/restfulobjects/applib/Constants.java | 28 -
.../viewer/restfulobjects/applib/HttpMethod.java | 89 ---
.../restfulobjects/applib/JsonRepresentation.java | 21 +-
.../viewer/restfulobjects/applib/MediaTypes.java | 39 +
.../restfulobjects/applib/RepresentationType.java | 65 ++-
.../applib/RepresentationWalker.java | 5 +-
.../restfulobjects/applib/RestfulClient.java | 13 +-
.../restfulobjects/applib/RestfulMediaType.java | 11 +-
.../restfulobjects/applib/RestfulRequest.java | 7 +-
.../restfulobjects/applib/RestfulResponse.java | 13 +-
.../viewer/restfulobjects/applib/RoHttpMethod.java | 92 +++
.../applib/boot/BootstrapResource.java | 33 +
.../AbstractDomainObjectRepresentation.java | 54 ++
.../AbstractObjectMemberRepresentation.java | 46 ++
.../domainobjects/ActionResultRepresentation.java | 65 ++
.../domainobjects/DomainObjectRepresentation.java | 42 +
.../applib/domainobjects/DomainObjectResource.java | 150 ++++
.../applib/domainobjects/DomainRepresentation.java | 58 ++
.../domainobjects/DomainServiceResource.java | 97 +++
.../applib/domainobjects/ListRepresentation.java | 34 +
.../domainobjects/ObjectActionRepresentation.java | 34 +
.../ObjectCollectionRepresentation.java | 29 +
.../ObjectPropertyRepresentation.java | 29 +
.../domainobjects/ScalarValueRepresentation.java | 34 +
.../TransientDomainObjectRepresentation.java | 34 +
.../AbstractTypeMemberRepresentation.java | 3 +-
.../domaintypes/DomainTypeRepresentation.java | 3 +-
.../applib/domaintypes/DomainTypeResource.java | 3 +-
.../TypeActionResultRepresentation.java | 3 +-
.../applib/domaintypes/TypeListRepresentation.java | 3 +-
.../applib/errors/ErrorRepresentation.java | 3 +-
.../applib/homepage/HomePageRepresentation.java | 5 +-
.../applib/homepage/HomePageResource.java | 3 +-
.../applib/links/LinkRepresentation.java | 19 +-
.../viewer/restfulobjects/applib/links/Rel.java | 47 +-
.../applib/user/UserRepresentation.java | 5 +-
.../restfulobjects/applib/user/UserResource.java | 3 +-
.../restfulobjects/applib/util/JsonMapper.java | 3 +-
.../restfulobjects/applib/util/JsonNodeUtils.java | 4 +-
.../viewer/restfulobjects/applib/util/Parser.java | 57 ++-
.../restfulobjects/applib/util/PathNode.java | 4 +-
.../applib/util/UrlEncodingUtils.java | 4 +-
.../applib/version/VersionRepresentation.java | 5 +-
.../applib/version/VersionResource.java | 3 +-
.../restfulobjects/boot/BootstrapResource.java | 33 -
.../AbstractDomainObjectRepresentation.java | 55 --
.../AbstractObjectMemberRepresentation.java | 47 --
.../domainobjects/ActionResultRepresentation.java | 66 --
.../domainobjects/DomainObjectRepresentation.java | 43 -
.../domainobjects/DomainObjectResource.java | 151 ----
.../domainobjects/DomainRepresentation.java | 59 --
.../domainobjects/DomainServiceResource.java | 98 ---
.../domainobjects/ListRepresentation.java | 35 -
.../domainobjects/ObjectActionRepresentation.java | 35 -
.../ObjectCollectionRepresentation.java | 29 -
.../ObjectPropertyRepresentation.java | 29 -
.../domainobjects/ScalarValueRepresentation.java | 35 -
.../TransientDomainObjectRepresentation.java | 35 -
.../applib/DomainObjectRepresentationTest.java | 4 +-
.../applib/HttpMethodTest_setUp.java | 97 ---
.../viewer/restfulobjects/applib/JsonFixture.java | 7 +-
...resentationTest_arrayGet_arraySetElementAt.java | 2 -
.../JsonRepresentationTest_arrayIterator.java | 2 -
.../JsonRepresentationTest_asInputStream.java | 4 +-
.../applib/JsonRepresentationTest_getArray.java | 2 -
.../JsonRepresentationTest_getBigInteger.java | 2 -
.../applib/JsonRepresentationTest_getBoolean.java | 2 -
.../applib/JsonRepresentationTest_getDouble.java | 2 -
.../applib/JsonRepresentationTest_getInt.java | 2 -
.../JsonRepresentationTest_getLink_isLink.java | 7 +-
.../applib/JsonRepresentationTest_getLong.java | 2 -
.../JsonRepresentationTest_getNull_isNull.java | 2 -
.../JsonRepresentationTest_getRepresentation.java | 2 -
.../JsonRepresentationTest_getString_isString.java | 2 -
...onRepresentationTest_isArray_isMap_isValue.java | 2 -
.../applib/JsonRepresentationTest_mapHas.java | 2 -
.../applib/JsonRepresentationTest_mapIterable.java | 2 -
.../applib/JsonRepresentationTest_newArray.java | 2 -
.../applib/JsonRepresentationTest_newObject.java | 2 -
.../applib/JsonRepresentationTest_putXxx.java | 2 -
.../applib/JsonRepresentationTest_size.java | 2 -
.../applib/JsonRepresentationTest_urlEncoding.java | 8 +-
...RepresentationTypeTest_getMediaType_lookup.java | 11 +-
.../RepresentationTypeTest_getName_lookup.java | 2 -
.../applib/RepresentationTypeTest_parser.java | 4 +-
.../applib/RestfulClientTest_follow.java | 12 +-
.../RestfulRequestDomainModelTest_parser.java | 4 +-
...RestfulRequestRequestParameterTest_valueOf.java | 5 +-
.../applib/RestfulResponse_HttpStatusCodeTest.java | 3 +-
.../applib/RoHttpMethodTest_setUp.java | 93 +++
.../links/LinkRepresentationTest_equals.java | 16 +-
.../restfulobjects/applib/util/ParserTest.java | 23 +-
.../applib/util/PathNodeTest_equalsHashcode.java | 2 -
.../applib/util/PathNodeTest_parse.java | 2 -
component/viewer/restfulobjects/impl/pom.xml | 85 --
.../viewer/AbstractJaxRsApplication.java | 53 --
.../viewer/restfulobjects/viewer/Constants.java | 36 -
.../restfulobjects/viewer/HasHttpStatusCode.java | 26 -
.../restfulobjects/viewer/RendererContext.java | 23 -
.../restfulobjects/viewer/ResourceContext.java | 231 ------
.../viewer/RestfulObjectsApplication.java | 50 --
.../viewer/RestfulObjectsApplicationException.java | 69 --
.../RestfulObjectsApplicationExceptionMapper.java | 120 ---
.../viewer/RuntimeExceptionMapper.java | 100 ---
.../AuthenticationSessionStrategyBasicAuth.java | 79 --
.../AuthenticationSessionStrategyHeader.java | 66 --
.../AuthenticationSessionStrategyTrusted.java | 42 -
.../embedded/EmbeddedWebViewerRestfulObjects.java | 61 --
.../embedded/RestfulObjectsViewerInstaller.java | 52 --
.../viewer/representations/GraphUtil.java | 60 --
.../viewer/representations/LinkBuilder.java | 94 ---
.../viewer/representations/LinkFollower.java | 124 ---
.../viewer/representations/RendererFactory.java | 32 -
.../representations/RendererFactoryRegistry.java | 90 ---
.../viewer/representations/ReprRenderer.java | 32 -
.../representations/ReprRendererAbstract.java | 185 -----
.../ReprRendererFactoryAbstract.java | 36 -
.../viewer/representations/WellKnownType.java | 66 --
.../viewer/resources/ResourceAbstract.java | 254 ------
.../AbstractObjectMemberReprRenderer.java | 259 ------
.../domainobjects/ActionResultReprRenderer.java | 183 -----
.../viewer/resources/domainobjects/BodyArgs.java | 41 -
.../domainobjects/CollectionSemantics.java | 45 --
.../domainobjects/DomainObjectLinkTo.java | 113 ---
.../domainobjects/DomainObjectReprRenderer.java | 314 --------
.../DomainObjectResourceServerside.java | 410 ----------
.../domainobjects/DomainResourceHelper.java | 592 --------------
.../domainobjects/DomainServiceLinkTo.java | 50 --
.../DomainServiceResourceServerside.java | 168 ----
.../viewer/resources/domainobjects/InvokeKeys.java | 40 -
.../resources/domainobjects/JsonValueEncoder.java | 224 ------
.../resources/domainobjects/ListReprRenderer.java | 116 ---
.../viewer/resources/domainobjects/MemberType.java | 152 ----
.../resources/domainobjects/MutatorSpec.java | 49 --
.../domainobjects/ObjectActionReprRenderer.java | 231 ------
.../domainobjects/ObjectAdapterLinkTo.java | 42 -
.../resources/domainobjects/ObjectAndAction.java | 30 -
.../domainobjects/ObjectAndActionInvocation.java | 55 --
.../domainobjects/ObjectAndCollection.java | 30 -
.../resources/domainobjects/ObjectAndMember.java | 41 -
.../resources/domainobjects/ObjectAndProperty.java | 30 -
.../ObjectCollectionReprRenderer.java | 158 ----
.../domainobjects/ObjectPropertyReprRenderer.java | 167 ----
.../domainobjects/ScalarValueReprRenderer.java | 84 --
.../AbstractTypeFeatureReprRenderer.java | 108 ---
.../AbstractTypeMemberReprRenderer.java | 75 --
.../domaintypes/ActionDescriptionReprRenderer.java | 103 ---
.../ActionParameterDescriptionReprRenderer.java | 116 ---
.../CollectionDescriptionReprRenderer.java | 76 --
.../domaintypes/DomainTypeReprRenderer.java | 192 -----
.../domaintypes/DomainTypeResourceServerside.java | 331 --------
.../domaintypes/ObjectSpecAndSuperSpec.java | 41 -
.../resources/domaintypes/ParentSpecAndAction.java | 30 -
.../domaintypes/ParentSpecAndActionParam.java | 30 -
.../domaintypes/ParentSpecAndCollection.java | 30 -
.../domaintypes/ParentSpecAndFeature.java | 42 -
.../domaintypes/ParentSpecAndProperty.java | 30 -
.../PropertyDescriptionReprRenderer.java | 85 --
.../domaintypes/TypeActionResultReprRenderer.java | 79 --
.../domaintypes/TypeListReprRenderer.java | 81 --
.../resources/home/HomePageReprRenderer.java | 167 ----
.../resources/home/HomePageResourceServerside.java | 66 --
.../viewer/resources/user/UserReprRenderer.java | 66 --
.../resources/user/UserResourceServerside.java | 48 --
.../resources/version/VersionReprRenderer.java | 104 ---
.../version/VersionResourceServerside.java | 69 --
.../restfulobjects/viewer/util/ActionUtils.java | 50 --
.../viewer/util/InputStreamUtil.java | 64 --
.../restfulobjects/viewer/util/ListUtils.java | 38 -
.../restfulobjects/viewer/util/MapUtils.java | 48 --
.../restfulobjects/viewer/util/OidUtils.java | 52 --
.../restfulobjects/viewer/util/PathUtils.java | 39 -
.../restfulobjects/viewer/util/StringUtil.java | 38 -
.../viewer/util/UrlDecoderUtils.java | 41 -
.../restfulobjects/viewer/util/UrlParserUtils.java | 52 --
.../PreProcessInterceptorForIsisSession.java | 42 -
.../restfulobjects/impl/src/site/apt/index.apt | 27 -
.../restfulobjects/impl/src/site/apt/jottings.apt | 24 -
.../viewer/restfulobjects/impl/src/site/site.xml | 39 -
...ceContextTest_ensureCompatibleAcceptHeader.java | 135 ----
.../viewer/ResourceContextTest_getArg.java | 91 ---
.../viewer/representations/GraphTest_asGraph.java | 78 --
.../representations/LinkFollowerTest_follow.java | 124 ---
.../JsonApplicationExceptionMapperTest.java | 113 ---
.../DomainResourceHelperTest_readBodyAsMap.java | 79 --
.../JsonValueEncoderTest_asAdapter.java | 370 ---------
.../JsonValueEncoderTest_asObject.java | 248 ------
.../restfulobjects/viewer/util/MapUtilsTest.java | 51 --
.../viewer/util/UrlParserUtilsTest.java | 62 --
component/viewer/restfulobjects/jaxrs/pom.xml | 85 ++
component/viewer/restfulobjects/pom.xml | 30 +-
component/viewer/restfulobjects/rendering/pom.xml | 62 ++
.../restfulobjects/rendering/LinkBuilder.java | 94 +++
.../restfulobjects/rendering/LinkFollower.java | 125 +++
.../rendering/NOTUSED_WellKnownType.java | 80 ++
.../restfulobjects/rendering/RendererContext.java | 23 +
.../restfulobjects/rendering/RendererFactory.java | 30 +
.../rendering/RendererFactoryRegistry.java | 83 ++
.../restfulobjects/rendering/ReprRenderer.java | 32 +
.../rendering/ReprRendererAbstract.java | 173 ++++
.../rendering/ReprRendererException.java | 57 ++
.../rendering/ReprRendererFactoryAbstract.java | 36 +
.../AbstractObjectMemberReprRenderer.java | 257 ++++++
.../domainobjects/ActionResultReprRenderer.java | 183 +++++
.../rendering/domainobjects/BodyArgs.java | 41 +
.../domainobjects/CollectionSemantics.java | 46 ++
.../domainobjects/DomainObjectLinkTo.java | 113 +++
.../domainobjects/DomainObjectReprRenderer.java | 313 ++++++++
.../domainobjects/DomainServiceLinkTo.java | 50 ++
.../rendering/domainobjects/InvokeKeys.java | 40 +
.../rendering/domainobjects/JsonValueEncoder.java | 224 ++++++
.../rendering/domainobjects/ListReprRenderer.java | 115 +++
.../rendering/domainobjects/MemberType.java | 152 ++++
.../rendering/domainobjects/MutatorSpec.java | 49 ++
.../domainobjects/ObjectActionReprRenderer.java | 228 ++++++
.../domainobjects/ObjectAdapterLinkTo.java | 42 +
.../rendering/domainobjects/ObjectAndAction.java | 30 +
.../domainobjects/ObjectAndActionInvocation.java | 55 ++
.../domainobjects/ObjectAndCollection.java | 30 +
.../rendering/domainobjects/ObjectAndMember.java | 41 +
.../rendering/domainobjects/ObjectAndProperty.java | 30 +
.../ObjectCollectionReprRenderer.java | 157 ++++
.../domainobjects/ObjectPropertyReprRenderer.java | 167 ++++
.../domainobjects/ScalarValueReprRenderer.java | 83 ++
.../AbstractTypeFeatureReprRenderer.java | 107 +++
.../AbstractTypeMemberReprRenderer.java | 75 ++
.../domaintypes/ActionDescriptionReprRenderer.java | 102 +++
.../ActionParameterDescriptionReprRenderer.java | 116 +++
.../CollectionDescriptionReprRenderer.java | 75 ++
.../domaintypes/DomainTypeReprRenderer.java | 190 +++++
.../domaintypes/ObjectSpecAndSuperSpec.java | 41 +
.../rendering/domaintypes/ParentSpecAndAction.java | 30 +
.../domaintypes/ParentSpecAndActionParam.java | 30 +
.../domaintypes/ParentSpecAndCollection.java | 30 +
.../domaintypes/ParentSpecAndFeature.java | 42 +
.../domaintypes/ParentSpecAndProperty.java | 30 +
.../PropertyDescriptionReprRenderer.java | 85 ++
.../domaintypes/TypeActionResultReprRenderer.java | 79 ++
.../domaintypes/TypeListReprRenderer.java | 80 ++
.../restfulobjects/rendering/util/GraphUtil.java | 60 ++
.../rendering/util/InputStreamUtil.java | 64 ++
.../restfulobjects/rendering/util/ListUtils.java | 38 +
.../restfulobjects/rendering/util/MapUtils.java | 48 ++
.../rendering/util/NOTUSED_ActionUtils.java | 53 ++
.../restfulobjects/rendering/util/OidUtils.java | 52 ++
.../restfulobjects/rendering/util/StringUtil.java | 38 +
.../rendering/util/UrlDecoderUtils.java | 41 +
.../rendering/util/UrlParserUtils.java | 52 ++
.../rendering/GraphTest_asGraph.java | 77 ++
.../rendering/LinkFollowerTest_follow.java | 122 +++
.../JsonValueEncoderTest_asAdapter.java | 368 +++++++++
.../JsonValueEncoderTest_asObject.java | 246 ++++++
.../rendering/util/MapUtilsTest.java | 49 ++
.../rendering/util/UrlParserUtilsTest.java | 60 ++
component/viewer/restfulobjects/server/pom.xml | 72 ++
.../server/AbstractJaxRsApplication.java | 53 ++
.../restfulobjects/server/HasHttpStatusCode.java | 26 +
.../restfulobjects/server/ResourceContext.java | 255 ++++++
.../server/RestfulObjectsApplication.java | 58 ++
.../server/RestfulObjectsApplicationException.java | 69 ++
.../RestfulObjectsApplicationExceptionMapper.java | 120 +++
.../server/RuntimeExceptionMapper.java | 100 +++
.../AuthenticationSessionStrategyBasicAuth.java | 79 ++
.../AuthenticationSessionStrategyHeader.java | 66 ++
.../AuthenticationSessionStrategyTrusted.java | 42 +
.../embedded/EmbeddedWebViewerRestfulObjects.java | 61 ++
.../embedded/RestfulObjectsViewerInstaller.java | 52 ++
.../resources/DomainObjectResourceServerside.java | 409 ++++++++++
.../server/resources/DomainResourceHelper.java | 605 +++++++++++++++
.../resources/DomainServiceResourceServerside.java | 170 ++++
.../resources/DomainTypeResourceServerside.java | 339 ++++++++
.../server/resources/HomePageReprRenderer.java | 165 ++++
.../resources/HomePageResourceServerside.java | 65 ++
.../server/resources/ResourceAbstract.java | 254 ++++++
.../server/resources/UserReprRenderer.java | 66 ++
.../server/resources/UserResourceServerside.java | 47 ++
.../server/resources/VersionReprRenderer.java | 103 +++
.../resources/VersionResourceServerside.java | 68 ++
.../restfulobjects/server/util/PathUtils.java | 40 +
.../PreProcessInterceptorForIsisSession.java | 42 +
.../restfulobjects/server/src/site/apt/index.apt | 27 +
.../server/src/site/apt/jottings.apt | 24 +
.../viewer/restfulobjects/server/src/site/site.xml | 39 +
...ceContextTest_ensureCompatibleAcceptHeader.java | 133 ++++
.../server/ResourceContextTest_getArg.java | 90 +++
...stfulObjectsApplicationExceptionMapperTest.java | 110 +++
.../DomainResourceHelperTest_readBodyAsMap.java | 77 ++
component/viewer/restfulobjects/tck/pom.xml | 6 +-
.../restfulobjects/tck/RepresentationMatchers.java | 8 +-
...eTest_clientAcceptHeader_exceptionHandling.java | 11 +-
...Test_serverSideException_exceptionHandling.java | 4 +-
.../home/HomePageResourceTest_accept.java | 9 +-
...ePageResourceTest_representationAndHeaders.java | 13 +-
.../home/HomePageResourceTest_xrofollowlinks.java | 6 +-
.../resources/object/DomainObjectResourceTest.java | 50 +-
.../DomainServiceResourceTest_invokeAction.java | 14 +-
...DomainServiceResourceTest_serviceId_accept.java | 15 +-
...mainServiceResourceTest_serviceId_notFound.java | 2 +-
...rceTest_serviceId_representationAndHeaders.java | 11 +-
...rviceResourceTest_serviceId_xrofollowlinks.java | 10 +-
.../DomainServiceResourceTest_services_accept.java | 9 +-
...urceTest_services_representationAndHeaders.java | 11 +-
...erviceResourceTest_services_xrofollowlinks.java | 8 +-
.../resources/user/UserResourceTest_accept.java | 9 +-
.../UserResourceTest_representationAndHeaders.java | 7 +-
.../version/VersionResourceTest_accept.java | 9 +-
...rsionResourceTest_representationAndHeaders.java | 7 +-
.../quickstart_wicket_restful_jdo/dom/pom.xml | 2 +-
.../quickstart_wicket_restful_jdo/fixture/pom.xml | 2 +-
.../objstore-jdo/pom.xml | 2 +-
.../quickstart_wicket_restful_jdo/pom.xml | 2 +-
.../viewer-webapp/pom.xml | 4 +-
314 files changed, 11112 insertions(+), 10896 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/75f41b75/component/viewer/restfulobjects/applib/pom.xml
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/applib/pom.xml b/component/viewer/restfulobjects/applib/pom.xml
index d2eb178..f383669 100644
--- a/component/viewer/restfulobjects/applib/pom.xml
+++ b/component/viewer/restfulobjects/applib/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.isis.viewer</groupId>
<artifactId>isis-viewer-restfulobjects</artifactId>
- <version>1.0.1-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
</parent>
<artifactId>isis-viewer-restfulobjects-applib</artifactId>
@@ -39,20 +39,6 @@
<dependencies>
<dependency>
- <groupId>org.jboss.resteasy</groupId>
- <artifactId>resteasy-jaxrs</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.codehaus.jackson</groupId>
- <artifactId>jackson-core-asl</artifactId>
- </dependency>
- <dependency>
- <groupId>org.codehaus.jackson</groupId>
- <artifactId>jackson-mapper-asl</artifactId>
- </dependency>
-
- <dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</dependency>
@@ -63,11 +49,6 @@
</dependency>
<dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- </dependency>
-
- <dependency>
<groupId>org.apache.isis.core</groupId>
<artifactId>isis-core-applib</artifactId>
</dependency>
@@ -84,6 +65,23 @@
<scope>test</scope>
</dependency>
+
+
+ <!-- TO REMOVE!!! -->
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-jaxrs</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-core-asl</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-mapper-asl</artifactId>
+ </dependency>
+
+
</dependencies>
http://git-wip-us.apache.org/repos/asf/isis/blob/75f41b75/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/ClientRequestConfigurer.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/ClientRequestConfigurer.java b/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/ClientRequestConfigurer.java
index 2232c07..179ea48 100644
--- a/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/ClientRequestConfigurer.java
+++ b/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/ClientRequestConfigurer.java
@@ -24,13 +24,12 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.UriBuilder;
-import org.jboss.resteasy.client.ClientExecutor;
-import org.jboss.resteasy.client.ClientRequest;
-import org.jboss.resteasy.specimpl.UriBuilderImpl;
-
import org.apache.isis.viewer.restfulobjects.applib.RestfulRequest.RequestParameter;
import org.apache.isis.viewer.restfulobjects.applib.links.LinkRepresentation;
import org.apache.isis.viewer.restfulobjects.applib.util.UrlEncodingUtils;
+import org.jboss.resteasy.client.ClientExecutor;
+import org.jboss.resteasy.client.ClientRequest;
+import org.jboss.resteasy.specimpl.UriBuilderImpl;
/**
* Configures the body, query string etc of a {@link ClientRequest}.
@@ -72,7 +71,7 @@ public class ClientRequestConfigurer {
* Prerequisite to {@link #configureArgs(JsonRepresentation)} or
* {@link #configureArgs(Map)}.
*/
- public ClientRequestConfigurer setHttpMethod(final HttpMethod httpMethod) {
+ public ClientRequestConfigurer setHttpMethod(final RoHttpMethod httpMethod) {
clientRequest.setHttpMethod(httpMethod.getJavaxRsMethod());
return this;
}
@@ -83,7 +82,7 @@ public class ClientRequestConfigurer {
* <p>
* Typical flow is:
* <ul>
- * <li> {@link RestfulClient#createRequest(HttpMethod, String)}
+ * <li> {@link RestfulClient#createRequest(RoHttpMethod, String)}
* <li> {@link RestfulRequest#withArg(RequestParameter, Object)} for each arg
* <li> {@link RestfulRequest#execute()} - which calls this method.
* </ul>
@@ -123,7 +122,7 @@ public class ClientRequestConfigurer {
/**
* Called back from
- * {@link HttpMethod#setUpArgs(ClientRequestConfigurer, JsonRepresentation)}
+ * {@link RoHttpMethod#setUpArgs(ClientRequestConfigurer, JsonRepresentation)}
*/
ClientRequestConfigurer body(final JsonRepresentation requestArgs) {
clientRequest.body(MediaType.APPLICATION_JSON_TYPE, requestArgs.toString());
@@ -132,7 +131,7 @@ public class ClientRequestConfigurer {
/**
* Called back from
- * {@link HttpMethod#setUpArgs(ClientRequestConfigurer, JsonRepresentation)}
+ * {@link RoHttpMethod#setUpArgs(ClientRequestConfigurer, JsonRepresentation)}
*/
ClientRequestConfigurer queryString(final JsonRepresentation requestArgs) {
if (requestArgs.size() == 0) {
@@ -145,7 +144,7 @@ public class ClientRequestConfigurer {
/**
* Called back from
- * {@link HttpMethod#setUpArgs(ClientRequestConfigurer, JsonRepresentation)}
+ * {@link RoHttpMethod#setUpArgs(ClientRequestConfigurer, JsonRepresentation)}
*/
ClientRequestConfigurer queryArgs(final JsonRepresentation requestArgs) {
final MultivaluedMap<String, String> queryParameters = clientRequest.getQueryParameters();
@@ -165,9 +164,9 @@ public class ClientRequestConfigurer {
return clientRequest;
}
- HttpMethod getHttpMethod() {
+ RoHttpMethod getHttpMethod() {
final String httpMethod = clientRequest.getHttpMethod();
- return HttpMethod.valueOf(httpMethod);
+ return RoHttpMethod.valueOf(httpMethod);
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/75f41b75/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/Constants.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/Constants.java b/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/Constants.java
deleted file mode 100644
index 32ddb75..0000000
--- a/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/Constants.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.isis.viewer.restfulobjects.applib;
-
-public final class Constants {
-
- public static final String URL_ENCODING_CHAR_SET = "UTF-8";
-
- private Constants() {
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/75f41b75/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/HttpMethod.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/HttpMethod.java b/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/HttpMethod.java
deleted file mode 100644
index 3b927f3..0000000
--- a/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/HttpMethod.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.isis.viewer.restfulobjects.applib;
-
-import org.jboss.resteasy.client.ClientRequest;
-import org.jboss.resteasy.specimpl.UriBuilderImpl;
-
-public enum HttpMethod {
- GET(javax.ws.rs.HttpMethod.GET, ArgStrategy.QUERY_STRING), PUT(javax.ws.rs.HttpMethod.PUT, ArgStrategy.BODY), DELETE(javax.ws.rs.HttpMethod.DELETE, ArgStrategy.QUERY_STRING), POST(javax.ws.rs.HttpMethod.POST, ArgStrategy.BODY);
-
- private enum ArgStrategy {
- /**
- * Individually encodes each query arg.
- */
- QUERY_ARGS {
- @Override
- void setUpArgs(final ClientRequestConfigurer clientRequestConfigurer, final JsonRepresentation requestArgs) {
- clientRequestConfigurer.queryArgs(requestArgs);
- }
- },
- /**
- * Sends entire request args as a URL encoded map
- */
- QUERY_STRING {
- @Override
- void setUpArgs(final ClientRequestConfigurer clientRequestConfigurer, final JsonRepresentation requestArgs) {
- clientRequestConfigurer.queryString(requestArgs);
- }
- },
- BODY {
- @Override
- void setUpArgs(final ClientRequestConfigurer clientRequestConfigurer, final JsonRepresentation requestArgs) {
- clientRequestConfigurer.body(requestArgs);
- }
- };
- abstract void setUpArgs(ClientRequestConfigurer clientRequestConfigurer, JsonRepresentation requestArgs);
- }
-
- private final String javaxRsMethod;
- private final ArgStrategy argStrategy;
-
- private HttpMethod(final String javaxRsMethod, final ArgStrategy argStrategy) {
- this.javaxRsMethod = javaxRsMethod;
- this.argStrategy = argStrategy;
- }
-
- public String getJavaxRsMethod() {
- return javaxRsMethod;
- }
-
- /**
- * It's a bit nasty that we need to ask for the {@link UriBuilderImpl} as
- * well as the {@link ClientRequest}, but that's because the
- * {@link ClientRequest} does not allow us to setup raw query strings (only
- * query name/arg pairs)
- *
- * @param restEasyRequest
- * @param uriBuilder
- * - that sits underneath the restEasyRequest
- * @param requestArgs
- */
- public void setUpArgs(final ClientRequestConfigurer clientRequestConfigurer, final JsonRepresentation requestArgs) {
- clientRequestConfigurer.setHttpMethod(this);
- if (requestArgs == null) {
- return;
- }
- if (!requestArgs.isMap()) {
- throw new IllegalArgumentException("requestArgs must be a map; instead got: " + requestArgs);
- }
- argStrategy.setUpArgs(clientRequestConfigurer, requestArgs);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/75f41b75/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/JsonRepresentation.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/JsonRepresentation.java b/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/JsonRepresentation.java
index 6a76a0a..d09b45f 100644
--- a/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/JsonRepresentation.java
+++ b/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/JsonRepresentation.java
@@ -29,13 +29,10 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-import com.google.common.base.Function;
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Iterators;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-
+import org.apache.isis.viewer.restfulobjects.applib.links.LinkRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.util.JsonNodeUtils;
+import org.apache.isis.viewer.restfulobjects.applib.util.PathNode;
+import org.apache.isis.viewer.restfulobjects.applib.util.UrlEncodingUtils;
import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.node.ArrayNode;
import org.codehaus.jackson.node.JsonNodeFactory;
@@ -43,10 +40,12 @@ import org.codehaus.jackson.node.NullNode;
import org.codehaus.jackson.node.ObjectNode;
import org.codehaus.jackson.node.POJONode;
-import org.apache.isis.viewer.restfulobjects.applib.links.LinkRepresentation;
-import org.apache.isis.viewer.restfulobjects.applib.util.JsonNodeUtils;
-import org.apache.isis.viewer.restfulobjects.applib.util.PathNode;
-import org.apache.isis.viewer.restfulobjects.applib.util.UrlEncodingUtils;
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Iterators;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
/**
* A wrapper around {@link JsonNode} that provides some additional helper
http://git-wip-us.apache.org/repos/asf/isis/blob/75f41b75/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/MediaTypes.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/MediaTypes.java b/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/MediaTypes.java
new file mode 100644
index 0000000..a90e187
--- /dev/null
+++ b/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/MediaTypes.java
@@ -0,0 +1,39 @@
+package org.apache.isis.viewer.restfulobjects.applib;
+
+import javax.ws.rs.core.MediaType;
+
+import com.google.common.base.Function;
+
+/**
+ * Convert between {@link com.google.common.net.MediaType guava MediaType} and {@link javax.ws.rs.core.MediaType jax-rs MediaType}.
+ */
+public final class MediaTypes {
+
+ private MediaTypes(){}
+
+ public static final Function<javax.ws.rs.core.MediaType, ? extends com.google.common.net.MediaType> JAXRS_TO_GUAVA = new Function<javax.ws.rs.core.MediaType, com.google.common.net.MediaType>() {
+
+ @Override
+ public com.google.common.net.MediaType apply(javax.ws.rs.core.MediaType input) {
+ return MediaTypes.jaxRsToGuava(input);
+ }
+ };
+
+ public static final Function<com.google.common.net.MediaType, MediaType> GUAVA_TO_JAXRS = new Function<com.google.common.net.MediaType, MediaType>() {
+
+ @Override
+ public MediaType apply(com.google.common.net.MediaType input) {
+ return MediaTypes.guavaToJaxRs(input);
+ }
+ };
+
+
+ public static com.google.common.net.MediaType jaxRsToGuava(javax.ws.rs.core.MediaType jaxRsMediaType) {
+ return com.google.common.net.MediaType.parse(jaxRsMediaType.toString());
+ }
+
+ public static javax.ws.rs.core.MediaType guavaToJaxRs(com.google.common.net.MediaType guavaMediaType) {
+ return javax.ws.rs.core.MediaType.valueOf(guavaMediaType.toString());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/75f41b75/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/RepresentationType.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/RepresentationType.java b/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/RepresentationType.java
index 039d6f4..c5c1262 100644
--- a/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/RepresentationType.java
+++ b/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/RepresentationType.java
@@ -18,9 +18,16 @@
*/
package org.apache.isis.viewer.restfulobjects.applib;
-import javax.ws.rs.core.MediaType;
import org.apache.isis.applib.util.Enums;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ActionResultRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainObjectRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ListRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ObjectActionRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ObjectCollectionRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ObjectPropertyRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.ScalarValueRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.TransientDomainObjectRepresentation;
import org.apache.isis.viewer.restfulobjects.applib.domaintypes.ActionDescriptionRepresentation;
import org.apache.isis.viewer.restfulobjects.applib.domaintypes.ActionParameterDescriptionRepresentation;
import org.apache.isis.viewer.restfulobjects.applib.domaintypes.CollectionDescriptionRepresentation;
@@ -33,34 +40,45 @@ import org.apache.isis.viewer.restfulobjects.applib.homepage.HomePageRepresentat
import org.apache.isis.viewer.restfulobjects.applib.user.UserRepresentation;
import org.apache.isis.viewer.restfulobjects.applib.util.Parser;
import org.apache.isis.viewer.restfulobjects.applib.version.VersionRepresentation;
-import org.apache.isis.viewer.restfulobjects.domainobjects.ActionResultRepresentation;
-import org.apache.isis.viewer.restfulobjects.domainobjects.DomainObjectRepresentation;
-import org.apache.isis.viewer.restfulobjects.domainobjects.ListRepresentation;
-import org.apache.isis.viewer.restfulobjects.domainobjects.ObjectActionRepresentation;
-import org.apache.isis.viewer.restfulobjects.domainobjects.ObjectCollectionRepresentation;
-import org.apache.isis.viewer.restfulobjects.domainobjects.ObjectPropertyRepresentation;
-import org.apache.isis.viewer.restfulobjects.domainobjects.ScalarValueRepresentation;
-import org.apache.isis.viewer.restfulobjects.domainobjects.TransientDomainObjectRepresentation;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.net.MediaType;
public enum RepresentationType {
- HOME_PAGE(RestfulMediaType.APPLICATION_JSON_HOME_PAGE, HomePageRepresentation.class), USER(RestfulMediaType.APPLICATION_JSON_USER, UserRepresentation.class), VERSION(RestfulMediaType.APPLICATION_JSON_VERSION, VersionRepresentation.class), LIST(RestfulMediaType.APPLICATION_JSON_LIST,
- ListRepresentation.class), SCALAR_VALUE(RestfulMediaType.APPLICATION_JSON_SCALAR_VALUE, ScalarValueRepresentation.class), DOMAIN_OBJECT(RestfulMediaType.APPLICATION_JSON_DOMAIN_OBJECT, DomainObjectRepresentation.class), TRANSIENT_DOMAIN_OBJECT(
- RestfulMediaType.APPLICATION_JSON_TRANSIENT_DOMAIN_OBJECT, TransientDomainObjectRepresentation.class), OBJECT_PROPERTY(RestfulMediaType.APPLICATION_JSON_OBJECT_PROPERTY, ObjectPropertyRepresentation.class), OBJECT_COLLECTION(RestfulMediaType.APPLICATION_JSON_OBJECT_COLLECTION,
- ObjectCollectionRepresentation.class), OBJECT_ACTION(RestfulMediaType.APPLICATION_JSON_OBJECT_ACTION, ObjectActionRepresentation.class), ACTION_RESULT(RestfulMediaType.APPLICATION_JSON_ACTION_RESULT, ActionResultRepresentation.class), TYPE_LIST(
- RestfulMediaType.APPLICATION_JSON_TYPE_LIST, TypeListRepresentation.class), DOMAIN_TYPE(RestfulMediaType.APPLICATION_JSON_DOMAIN_TYPE, DomainTypeRepresentation.class), PROPERTY_DESCRIPTION(RestfulMediaType.APPLICATION_JSON_PROPERTY_DESCRIPTION, PropertyDescriptionRepresentation.class), COLLECTION_DESCRIPTION(
- RestfulMediaType.APPLICATION_JSON_COLLECTION_DESCRIPTION, CollectionDescriptionRepresentation.class), ACTION_DESCRIPTION(RestfulMediaType.APPLICATION_JSON_ACTION_DESCRIPTION, ActionDescriptionRepresentation.class), ACTION_PARAMETER_DESCRIPTION(
- RestfulMediaType.APPLICATION_JSON_ACTION_PARAMETER_DESCRIPTION, ActionParameterDescriptionRepresentation.class), TYPE_ACTION_RESULT(RestfulMediaType.APPLICATION_JSON_TYPE_ACTION_RESULT, TypeActionResultRepresentation.class), ERROR(RestfulMediaType.APPLICATION_JSON_ERROR,
- ErrorRepresentation.class), GENERIC(MediaType.APPLICATION_JSON, JsonRepresentation.class);
+ HOME_PAGE(RestfulMediaType.APPLICATION_JSON_HOME_PAGE, HomePageRepresentation.class),
+ USER(RestfulMediaType.APPLICATION_JSON_USER, UserRepresentation.class),
+ VERSION(RestfulMediaType.APPLICATION_JSON_VERSION, VersionRepresentation.class),
+ LIST(RestfulMediaType.APPLICATION_JSON_LIST, ListRepresentation.class),
+ SCALAR_VALUE(RestfulMediaType.APPLICATION_JSON_SCALAR_VALUE, ScalarValueRepresentation.class),
+ DOMAIN_OBJECT(RestfulMediaType.APPLICATION_JSON_DOMAIN_OBJECT, DomainObjectRepresentation.class),
+ TRANSIENT_DOMAIN_OBJECT(RestfulMediaType.APPLICATION_JSON_TRANSIENT_DOMAIN_OBJECT, TransientDomainObjectRepresentation.class),
+ OBJECT_PROPERTY(RestfulMediaType.APPLICATION_JSON_OBJECT_PROPERTY, ObjectPropertyRepresentation.class),
+ OBJECT_COLLECTION(RestfulMediaType.APPLICATION_JSON_OBJECT_COLLECTION, ObjectCollectionRepresentation.class),
+ OBJECT_ACTION(RestfulMediaType.APPLICATION_JSON_OBJECT_ACTION, ObjectActionRepresentation.class),
+ ACTION_RESULT(RestfulMediaType.APPLICATION_JSON_ACTION_RESULT, ActionResultRepresentation.class),
+ TYPE_LIST(RestfulMediaType.APPLICATION_JSON_TYPE_LIST, TypeListRepresentation.class),
+ DOMAIN_TYPE(RestfulMediaType.APPLICATION_JSON_DOMAIN_TYPE, DomainTypeRepresentation.class),
+ PROPERTY_DESCRIPTION(RestfulMediaType.APPLICATION_JSON_PROPERTY_DESCRIPTION, PropertyDescriptionRepresentation.class),
+ COLLECTION_DESCRIPTION(RestfulMediaType.APPLICATION_JSON_COLLECTION_DESCRIPTION, CollectionDescriptionRepresentation.class),
+ ACTION_DESCRIPTION(RestfulMediaType.APPLICATION_JSON_ACTION_DESCRIPTION, ActionDescriptionRepresentation.class),
+ ACTION_PARAMETER_DESCRIPTION(RestfulMediaType.APPLICATION_JSON_ACTION_PARAMETER_DESCRIPTION, ActionParameterDescriptionRepresentation.class),
+ TYPE_ACTION_RESULT(RestfulMediaType.APPLICATION_JSON_TYPE_ACTION_RESULT, TypeActionResultRepresentation.class),
+ ERROR(RestfulMediaType.APPLICATION_JSON_ERROR, ErrorRepresentation.class),
+ GENERIC(MediaType.JSON_UTF_8, JsonRepresentation.class);
private final String name;
private final MediaType mediaType;
private final Class<? extends JsonRepresentation> representationClass;
private RepresentationType(final String mediaTypeStr, final Class<? extends JsonRepresentation> representationClass) {
+ this(MediaType.parse(mediaTypeStr), representationClass);
+ }
+
+ private RepresentationType(final MediaType mediaType, final Class<? extends JsonRepresentation> representationClass) {
this.representationClass = representationClass;
this.name = Enums.enumToCamelCase(this);
- this.mediaType = MediaType.valueOf(mediaTypeStr);
+ this.mediaType = mediaType;
}
public String getName() {
@@ -71,8 +89,15 @@ public enum RepresentationType {
return mediaType;
}
- public String getMediaTypeWithProfile() {
- return getMediaType().getParameters().get("profile");
+ public String getMediaTypeProfile() {
+ ImmutableList<String> immutableList = getMediaType().parameters().get("profile");
+ if (immutableList == null || immutableList.isEmpty()) return null;
+ for (String profileValue : immutableList) {
+ if(profileValue.startsWith(RestfulMediaType.PROFILE_PARAM_PREFIX)) {
+ return profileValue;
+ }
+ }
+ return null;
}
public Class<? extends JsonRepresentation> getRepresentationClass() {
http://git-wip-us.apache.org/repos/asf/isis/blob/75f41b75/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/RepresentationWalker.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/RepresentationWalker.java b/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/RepresentationWalker.java
index dd03968..6ccfbb6 100644
--- a/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/RepresentationWalker.java
+++ b/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/RepresentationWalker.java
@@ -24,12 +24,11 @@ import java.util.List;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status.Family;
-import com.google.common.collect.Lists;
-
+import org.apache.isis.viewer.restfulobjects.applib.links.LinkRepresentation;
import org.codehaus.jackson.JsonParseException;
import org.codehaus.jackson.map.JsonMappingException;
-import org.apache.isis.viewer.restfulobjects.applib.links.LinkRepresentation;
+import com.google.common.collect.Lists;
public class RepresentationWalker {
http://git-wip-us.apache.org/repos/asf/isis/blob/75f41b75/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/RestfulClient.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/RestfulClient.java b/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/RestfulClient.java
index 8270202..19589a2 100644
--- a/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/RestfulClient.java
+++ b/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/RestfulClient.java
@@ -24,17 +24,16 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.apache.commons.httpclient.HttpClient;
-import org.jboss.resteasy.client.ClientExecutor;
-import org.jboss.resteasy.client.ClientRequestFactory;
-import org.jboss.resteasy.client.core.executors.ApacheHttpClientExecutor;
-
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainObjectResource;
+import org.apache.isis.viewer.restfulobjects.applib.domainobjects.DomainServiceResource;
import org.apache.isis.viewer.restfulobjects.applib.domaintypes.DomainTypeResource;
import org.apache.isis.viewer.restfulobjects.applib.homepage.HomePageResource;
import org.apache.isis.viewer.restfulobjects.applib.links.LinkRepresentation;
import org.apache.isis.viewer.restfulobjects.applib.user.UserResource;
import org.apache.isis.viewer.restfulobjects.applib.version.VersionResource;
-import org.apache.isis.viewer.restfulobjects.domainobjects.DomainObjectResource;
-import org.apache.isis.viewer.restfulobjects.domainobjects.DomainServiceResource;
+import org.jboss.resteasy.client.ClientExecutor;
+import org.jboss.resteasy.client.ClientRequestFactory;
+import org.jboss.resteasy.client.core.executors.ApacheHttpClientExecutor;
public class RestfulClient {
@@ -116,7 +115,7 @@ public class RestfulClient {
return link.<T> follow(executor, requestArgs);
}
- public RestfulRequest createRequest(final HttpMethod httpMethod, final String uriTemplate) {
+ public RestfulRequest createRequest(final RoHttpMethod httpMethod, final String uriTemplate) {
final boolean includesScheme = uriTemplate.startsWith("http:") || uriTemplate.startsWith("https:");
final String base = clientRequestFactory.getBase().toString();
http://git-wip-us.apache.org/repos/asf/isis/blob/75f41b75/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/RestfulMediaType.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/RestfulMediaType.java b/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/RestfulMediaType.java
index ac95f14..81b68b6 100644
--- a/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/RestfulMediaType.java
+++ b/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/RestfulMediaType.java
@@ -18,10 +18,13 @@
*/
package org.apache.isis.viewer.restfulobjects.applib;
-import javax.ws.rs.core.MediaType;
/**
- * Values per the profile parameter
+ * Media types including the <tt>profile</tt> parameter.
+ *
+ * <p>
+ * Because these values are used in the <tt>@Produces</tt> annotation on the jax-rs
+ * resources, they must be constants and must be strings.
*
* @see http://buzzword.org.uk/2009/draft-inkster-profile-parameter-00.html
*/
@@ -29,8 +32,10 @@ public final class RestfulMediaType {
private RestfulMediaType() {
}
+
+ static final String PROFILE_PARAM_PREFIX = "urn:org.restfulobjects:repr-types/";
- private static final String BASE = MediaType.APPLICATION_JSON + ";profile=urn:org.restfulobjects/";
+ private static final String BASE = "application/json" + ";profile=" + PROFILE_PARAM_PREFIX;
public final static String APPLICATION_JSON_HOME_PAGE = BASE + "homepage";
public final static String APPLICATION_JSON_USER = BASE + "user";
http://git-wip-us.apache.org/repos/asf/isis/blob/75f41b75/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/RestfulRequest.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/RestfulRequest.java b/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/RestfulRequest.java
index a584e29..d67eb50 100644
--- a/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/RestfulRequest.java
+++ b/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/RestfulRequest.java
@@ -26,11 +26,10 @@ import java.util.Map;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import com.google.common.collect.Maps;
-
+import org.apache.isis.viewer.restfulobjects.applib.util.Parser;
import org.jboss.resteasy.client.core.BaseClientResponse;
-import org.apache.isis.viewer.restfulobjects.applib.util.Parser;
+import com.google.common.collect.Maps;
public final class RestfulRequest {
@@ -108,7 +107,7 @@ public final class RestfulRequest {
public static class Header<X> {
public static Header<String> IF_MATCH = new Header<String>("If-Match", Parser.forString());
- public static Header<List<MediaType>> ACCEPT = new Header<List<MediaType>>("Accept", Parser.forListOfMediaTypes());
+ public static Header<List<MediaType>> ACCEPT = new Header<List<MediaType>>("Accept", Parser.forListOfJaxRsMediaTypes());
private final String name;
private final Parser<X> parser;
http://git-wip-us.apache.org/repos/asf/isis/blob/75f41b75/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/RestfulResponse.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/RestfulResponse.java b/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/RestfulResponse.java
index 4a41f85..78af846 100644
--- a/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/RestfulResponse.java
+++ b/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/RestfulResponse.java
@@ -30,13 +30,12 @@ import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.Response.Status.Family;
import javax.ws.rs.core.Response.StatusType;
-import com.google.common.collect.Maps;
-
+import org.apache.isis.viewer.restfulobjects.applib.util.JsonMapper;
+import org.apache.isis.viewer.restfulobjects.applib.util.Parser;
import org.codehaus.jackson.JsonParseException;
import org.codehaus.jackson.map.JsonMappingException;
-import org.apache.isis.viewer.restfulobjects.applib.util.JsonMapper;
-import org.apache.isis.viewer.restfulobjects.applib.util.Parser;
+import com.google.common.collect.Maps;
public class RestfulResponse<T> {
@@ -241,7 +240,7 @@ public class RestfulResponse<T> {
public final static Header<String> WARNING = new Header<String>("Warning", Parser.forString());
public final static Header<Date> LAST_MODIFIED = new Header<Date>("Last-Modified", Parser.forDate());
public final static Header<CacheControl> CACHE_CONTROL = new Header<CacheControl>("Cache-Control", Parser.forCacheControl());
- public final static Header<MediaType> CONTENT_TYPE = new Header<MediaType>("Content-Type", Parser.forMediaType());
+ public final static Header<MediaType> CONTENT_TYPE = new Header<MediaType>("Content-Type", Parser.forJaxRsMediaType());
private final String name;
private final Parser<X> parser;
@@ -267,8 +266,8 @@ public class RestfulResponse<T> {
@SuppressWarnings({ "rawtypes", "unchecked" })
public static RestfulResponse<JsonRepresentation> of(final Response response) {
- final MediaType mediaType = getHeader(response, Header.CONTENT_TYPE);
- final RepresentationType representationType = RepresentationType.lookup(mediaType);
+ final MediaType jaxRsMediaType = getHeader(response, Header.CONTENT_TYPE);
+ final RepresentationType representationType = RepresentationType.lookup(MediaTypes.jaxRsToGuava(jaxRsMediaType));
final Class<? extends JsonRepresentation> returnType = representationType.getRepresentationClass();
return new RestfulResponse(response, returnType);
}
http://git-wip-us.apache.org/repos/asf/isis/blob/75f41b75/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/RoHttpMethod.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/RoHttpMethod.java b/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/RoHttpMethod.java
new file mode 100644
index 0000000..eb2679d
--- /dev/null
+++ b/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/RoHttpMethod.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.isis.viewer.restfulobjects.applib;
+
+import org.jboss.resteasy.client.ClientRequest;
+import org.jboss.resteasy.specimpl.UriBuilderImpl;
+
+public enum RoHttpMethod {
+ GET(javax.ws.rs.HttpMethod.GET, ArgStrategy.QUERY_STRING),
+ PUT(javax.ws.rs.HttpMethod.PUT, ArgStrategy.BODY),
+ DELETE(javax.ws.rs.HttpMethod.DELETE, ArgStrategy.QUERY_STRING),
+ POST(javax.ws.rs.HttpMethod.POST, ArgStrategy.BODY);
+
+ private enum ArgStrategy {
+ /**
+ * Individually encodes each query arg.
+ */
+ QUERY_ARGS {
+ @Override
+ void setUpArgs(final ClientRequestConfigurer clientRequestConfigurer, final JsonRepresentation requestArgs) {
+ clientRequestConfigurer.queryArgs(requestArgs);
+ }
+ },
+ /**
+ * Sends entire request args as a URL encoded map
+ */
+ QUERY_STRING {
+ @Override
+ void setUpArgs(final ClientRequestConfigurer clientRequestConfigurer, final JsonRepresentation requestArgs) {
+ clientRequestConfigurer.queryString(requestArgs);
+ }
+ },
+ BODY {
+ @Override
+ void setUpArgs(final ClientRequestConfigurer clientRequestConfigurer, final JsonRepresentation requestArgs) {
+ clientRequestConfigurer.body(requestArgs);
+ }
+ };
+ abstract void setUpArgs(ClientRequestConfigurer clientRequestConfigurer, JsonRepresentation requestArgs);
+ }
+
+ private final String javaxRsMethod;
+ private final ArgStrategy argStrategy;
+
+ private RoHttpMethod(final String javaxRsMethod, final ArgStrategy argStrategy) {
+ this.javaxRsMethod = javaxRsMethod;
+ this.argStrategy = argStrategy;
+ }
+
+ public String getJavaxRsMethod() {
+ return javaxRsMethod;
+ }
+
+ /**
+ * It's a bit nasty that we need to ask for the {@link UriBuilderImpl} as
+ * well as the {@link ClientRequest}, but that's because the
+ * {@link ClientRequest} does not allow us to setup raw query strings (only
+ * query name/arg pairs)
+ *
+ * @param restEasyRequest
+ * @param uriBuilder
+ * - that sits underneath the restEasyRequest
+ * @param requestArgs
+ */
+ public void setUpArgs(final ClientRequestConfigurer clientRequestConfigurer, final JsonRepresentation requestArgs) {
+ clientRequestConfigurer.setHttpMethod(this);
+ if (requestArgs == null) {
+ return;
+ }
+ if (!requestArgs.isMap()) {
+ throw new IllegalArgumentException("requestArgs must be a map; instead got: " + requestArgs);
+ }
+ argStrategy.setUpArgs(clientRequestConfigurer, requestArgs);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/75f41b75/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/boot/BootstrapResource.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/boot/BootstrapResource.java b/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/boot/BootstrapResource.java
new file mode 100644
index 0000000..0cae166
--- /dev/null
+++ b/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/boot/BootstrapResource.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.isis.viewer.restfulobjects.applib.boot;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+@Path("/boot")
+public interface BootstrapResource {
+
+ @GET
+ @Produces({ MediaType.TEXT_HTML })
+ public String bootstrap();
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/75f41b75/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/domainobjects/AbstractDomainObjectRepresentation.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/domainobjects/AbstractDomainObjectRepresentation.java b/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/domainobjects/AbstractDomainObjectRepresentation.java
new file mode 100644
index 0000000..24de931
--- /dev/null
+++ b/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/domainobjects/AbstractDomainObjectRepresentation.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.isis.viewer.restfulobjects.applib.domainobjects;
+
+import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation;
+import org.codehaus.jackson.JsonNode;
+
+public abstract class AbstractDomainObjectRepresentation extends DomainRepresentation {
+
+ public AbstractDomainObjectRepresentation(final JsonNode jsonNode) {
+ super(jsonNode);
+ }
+
+ public String getTitle() {
+ return getString("title");
+ }
+
+ public JsonRepresentation getMembers() {
+ return getRepresentation("members").ensureArray();
+ }
+
+ public JsonRepresentation getProperty(final String id) {
+ return getRepresentation("members[memberType=property id=%s]", id);
+ }
+
+ public JsonRepresentation getProperties() {
+ return getRepresentation("members[memberType=property]").ensureArray();
+ }
+
+ public JsonRepresentation getCollection(final String id) {
+ return getRepresentation("members[memberType=collection id=%s]", id);
+ }
+
+ public JsonRepresentation getCollections() {
+ return getRepresentation("members[memberType=collection]").ensureArray();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/75f41b75/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/domainobjects/AbstractObjectMemberRepresentation.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/domainobjects/AbstractObjectMemberRepresentation.java b/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/domainobjects/AbstractObjectMemberRepresentation.java
new file mode 100644
index 0000000..a41ade1
--- /dev/null
+++ b/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/domainobjects/AbstractObjectMemberRepresentation.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.isis.viewer.restfulobjects.applib.domainobjects;
+
+import org.apache.isis.viewer.restfulobjects.applib.links.LinkRepresentation;
+import org.codehaus.jackson.JsonNode;
+
+public abstract class AbstractObjectMemberRepresentation extends DomainRepresentation {
+
+ public AbstractObjectMemberRepresentation(final JsonNode jsonNode) {
+ super(jsonNode);
+ }
+
+ public String getId() {
+ return getString("id");
+ }
+
+ public String getMemberType() {
+ return getString("memberType");
+ }
+
+ public String getDisabledReason() {
+ return getString("disabledReason");
+ }
+
+ public LinkRepresentation getDetails() {
+ return getLinkWithRel("details");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/75f41b75/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/domainobjects/ActionResultRepresentation.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/domainobjects/ActionResultRepresentation.java b/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/domainobjects/ActionResultRepresentation.java
new file mode 100644
index 0000000..cf9d66a
--- /dev/null
+++ b/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/domainobjects/ActionResultRepresentation.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.isis.viewer.restfulobjects.applib.domainobjects;
+
+import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation;
+import org.codehaus.jackson.JsonNode;
+
+public class ActionResultRepresentation extends AbstractObjectMemberRepresentation {
+
+ public enum ResultType {
+ DOMAIN_OBJECT("domainobject"), LIST("list"), SCALAR_VALUE("scalarvalue"), VOID("void");
+
+ private final String value;
+
+ private ResultType(final String value) {
+ this.value = value;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public static ResultType lookup(final String value) {
+ for (final ResultType resultType : values()) {
+ if (resultType.value.equals(value)) {
+ return resultType;
+ }
+ }
+ throw new IllegalArgumentException("Value '" + value + "' is not a valid result type");
+ }
+
+ public boolean isVoid() {
+ return this == VOID;
+ }
+ }
+
+ public ActionResultRepresentation(final JsonNode jsonNode) {
+ super(jsonNode);
+ }
+
+ public JsonRepresentation getResult() {
+ return getRepresentation("result");
+ }
+
+ public ResultType getResultType() {
+ final String resultType = getString("resulttype");
+ return ResultType.lookup(resultType);
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/75f41b75/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/domainobjects/DomainObjectRepresentation.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/domainobjects/DomainObjectRepresentation.java b/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/domainobjects/DomainObjectRepresentation.java
new file mode 100644
index 0000000..f32b0e3
--- /dev/null
+++ b/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/domainobjects/DomainObjectRepresentation.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.isis.viewer.restfulobjects.applib.domainobjects;
+
+import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation;
+import org.codehaus.jackson.JsonNode;
+
+public class DomainObjectRepresentation extends AbstractDomainObjectRepresentation {
+
+ public DomainObjectRepresentation(final JsonNode jsonNode) {
+ super(jsonNode);
+ }
+
+ public String getOid() {
+ return getString("oid");
+ }
+
+ public JsonRepresentation getActions() {
+ return getRepresentation("members[memberType=action]");
+ }
+
+ public JsonRepresentation getAction(final String id) {
+ return getRepresentation("members[memberType=action id=%s]", id);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/75f41b75/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/domainobjects/DomainObjectResource.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/domainobjects/DomainObjectResource.java b/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/domainobjects/DomainObjectResource.java
new file mode 100644
index 0000000..9c28a32
--- /dev/null
+++ b/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/domainobjects/DomainObjectResource.java
@@ -0,0 +1,150 @@
+/*s
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.isis.viewer.restfulobjects.applib.domainobjects;
+
+import java.io.InputStream;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.apache.isis.viewer.restfulobjects.applib.RestfulMediaType;
+import org.jboss.resteasy.annotations.ClientResponseType;
+
+@Path("/objects")
+public interface DomainObjectResource {
+
+ @POST
+ @Path("/")
+ @Consumes({ MediaType.WILDCARD })
+ @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_DOMAIN_OBJECT, RestfulMediaType.APPLICATION_JSON_ERROR })
+ @ClientResponseType(entityType = String.class)
+ public Response persist(final InputStream object);
+
+ // //////////////////////////////////////////////////////////
+ // domain object
+ // //////////////////////////////////////////////////////////
+
+ @GET
+ @Path("/{oid}")
+ @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_DOMAIN_OBJECT, RestfulMediaType.APPLICATION_JSON_ERROR })
+ @ClientResponseType(entityType = String.class)
+ public Response object(@PathParam("oid") final String oidStr);
+
+ @PUT
+ @Path("/{oid}")
+ @Consumes({ MediaType.WILDCARD })
+ @Produces({ RestfulMediaType.APPLICATION_JSON_DOMAIN_OBJECT, RestfulMediaType.APPLICATION_JSON_ERROR })
+ @ClientResponseType(entityType = String.class)
+ public Response object(@PathParam("oid") final String oidStr, final InputStream arguments);
+
+ // //////////////////////////////////////////////////////////
+ // domain object property
+ // //////////////////////////////////////////////////////////
+
+ @GET
+ @Path("/{oid}/properties/{propertyId}")
+ @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_OBJECT_PROPERTY, RestfulMediaType.APPLICATION_JSON_ERROR })
+ @ClientResponseType(entityType = String.class)
+ public Response propertyDetails(@PathParam("oid") final String oidStr, @PathParam("propertyId") final String propertyId);
+
+ @PUT
+ @Path("/{oid}/properties/{propertyId}")
+ @Consumes({ MediaType.WILDCARD })
+ @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ERROR })
+ @ClientResponseType(entityType = String.class)
+ public Response modifyProperty(@PathParam("oid") final String oidStr, @PathParam("propertyId") final String propertyId, final InputStream arguments);
+
+ @DELETE
+ @Path("/{oid}/properties/{propertyId}")
+ @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ERROR })
+ @ClientResponseType(entityType = String.class)
+ public Response clearProperty(@PathParam("oid") final String oidStr, @PathParam("propertyId") final String propertyId);
+
+ // //////////////////////////////////////////////////////////
+ // domain object collection
+ // //////////////////////////////////////////////////////////
+
+ @GET
+ @Path("/{oid}/collections/{collectionId}")
+ @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_OBJECT_COLLECTION, RestfulMediaType.APPLICATION_JSON_ERROR })
+ @ClientResponseType(entityType = String.class)
+ public Response accessCollection(@PathParam("oid") final String oidStr, @PathParam("collectionId") final String collectionId);
+
+ @PUT
+ @Path("/{oid}/collections/{collectionId}")
+ @Consumes({ MediaType.WILDCARD })
+ @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ERROR })
+ public Response addToSet(@PathParam("oid") final String oidStr, @PathParam("collectionId") final String collectionId, final InputStream arguments);
+
+ @POST
+ @Path("/{oid}/collections/{collectionId}")
+ @Consumes({ MediaType.WILDCARD })
+ @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ERROR })
+ @ClientResponseType(entityType = String.class)
+ public Response addToList(@PathParam("oid") final String oidStr, @PathParam("collectionId") final String collectionId, final InputStream arguments);
+
+ @DELETE
+ @Path("/{oid}/collections/{collectionId}")
+ @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ERROR })
+ @ClientResponseType(entityType = String.class)
+ public Response removeFromCollection(@PathParam("oid") final String oidStr, @PathParam("collectionId") final String collectionId);
+
+ // //////////////////////////////////////////////////////////
+ // domain object action
+ // //////////////////////////////////////////////////////////
+
+ @GET
+ @Path("/{oid}/actions/{actionId}")
+ @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_OBJECT_ACTION, RestfulMediaType.APPLICATION_JSON_ERROR })
+ @ClientResponseType(entityType = String.class)
+ public Response actionPrompt(@PathParam("oid") final String oidStr, @PathParam("actionId") final String actionId);
+
+ // //////////////////////////////////////////////////////////
+ // domain object action invoke
+ // //////////////////////////////////////////////////////////
+
+ @GET
+ @Path("/{oid}/actions/{actionId}/invoke")
+ @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ACTION_RESULT, RestfulMediaType.APPLICATION_JSON_ERROR })
+ @ClientResponseType(entityType = String.class)
+ public Response invokeActionQueryOnly(@PathParam("oid") final String oidStr, @PathParam("actionId") final String actionId);
+
+ @PUT
+ @Path("/{oid}/actions/{actionId}/invoke")
+ @Consumes({ MediaType.WILDCARD })
+ @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ACTION_RESULT, RestfulMediaType.APPLICATION_JSON_SCALAR_VALUE, RestfulMediaType.APPLICATION_JSON_ERROR })
+ @ClientResponseType(entityType = String.class)
+ public Response invokeActionIdempotent(@PathParam("oid") final String oidStr, @PathParam("actionId") final String actionId, final InputStream arguments);
+
+ @POST
+ @Path("/{oid}/actions/{actionId}/invoke")
+ @Consumes({ MediaType.WILDCARD })
+ @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ACTION_RESULT, RestfulMediaType.APPLICATION_JSON_ERROR })
+ @ClientResponseType(entityType = String.class)
+ public Response invokeAction(@PathParam("oid") final String oidStr, @PathParam("actionId") final String actionId, final InputStream arguments);
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/75f41b75/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/domainobjects/DomainRepresentation.java
----------------------------------------------------------------------
diff --git a/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/domainobjects/DomainRepresentation.java b/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/domainobjects/DomainRepresentation.java
new file mode 100644
index 0000000..55fdc97
--- /dev/null
+++ b/component/viewer/restfulobjects/applib/src/main/java/org/apache/isis/viewer/restfulobjects/applib/domainobjects/DomainRepresentation.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.isis.viewer.restfulobjects.applib.domainobjects;
+
+import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation.HasExtensions;
+import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation.HasLinks;
+import org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation.LinksToSelf;
+import org.apache.isis.viewer.restfulobjects.applib.links.LinkRepresentation;
+import org.apache.isis.viewer.restfulobjects.applib.links.Rel;
+import org.codehaus.jackson.JsonNode;
+
+public abstract class DomainRepresentation extends JsonRepresentation implements LinksToSelf, HasLinks, HasExtensions {
+
+ public DomainRepresentation(final JsonNode jsonNode) {
+ super(jsonNode);
+ }
+
+ @Override
+ public LinkRepresentation getSelf() {
+ return getLinkWithRel(Rel.SELF);
+ }
+
+ @Override
+ public JsonRepresentation getLinks() {
+ return getArray("links").ensureArray();
+ }
+
+ public LinkRepresentation getLinkWithRel(final Rel rel) {
+ return getLinkWithRel(rel.getName());
+ }
+
+ public LinkRepresentation getLinkWithRel(final String rel) {
+ return getLink(String.format("links[rel=%s]", rel));
+ }
+
+ @Override
+ public JsonRepresentation getExtensions() {
+ return getMap("extensions");
+ }
+
+}