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 2012/01/22 09:05:57 UTC
svn commit: r1234460 [18/30] - in /incubator/isis/trunk/framework/viewer:
bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/
bdd/common/src/main/java/org/apache/isis/viewer/bdd/common/components/
bdd/common/src/main/java/org/apache/isis/viewer...
Modified: incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/service/serviceId/DomainServiceResourceTest_serviceId_representationAndHeaders.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/service/serviceId/DomainServiceResourceTest_serviceId_representationAndHeaders.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/service/serviceId/DomainServiceResourceTest_serviceId_representationAndHeaders.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/service/serviceId/DomainServiceResourceTest_serviceId_representationAndHeaders.java Sun Jan 22 08:05:17 2012
@@ -16,8 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.isis.viewer.json.tck.resources.service.serviceId;
-
+package org.apache.isis.viewer.json.tck.resources.service.serviceId;
+
import static org.apache.isis.core.commons.matchers.IsisMatchers.matches;
import static org.apache.isis.viewer.json.tck.RepresentationMatchers.assertThat;
import static org.apache.isis.viewer.json.tck.RepresentationMatchers.isArray;
@@ -45,91 +45,84 @@ import org.codehaus.jackson.map.JsonMapp
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
-
-
-public class DomainServiceResourceTest_serviceId_representationAndHeaders {
-
- @Rule
- public IsisWebServerRule webServerRule = new IsisWebServerRule();
-
- private RestfulClient client;
- private DomainServiceResource resource;
-
- @Before
- public void setUp() throws Exception {
- WebServer webServer = webServerRule.getWebServer();
- client = new RestfulClient(webServer.getBase());
-
- resource = client.getDomainServiceResource();
- }
-
-
- @Test
- public void representation() throws Exception {
-
- // given
- Response resp = resource.service("simples");
-
- // when
- RestfulResponse<DomainObjectRepresentation> jsonResp = RestfulResponse.ofT(resp);
-
- // then
- assertThat(jsonResp.getStatus(), is(HttpStatusCode.OK));
-
- DomainObjectRepresentation repr = jsonResp.getEntity();
-
- assertThat(repr, isMap());
-
- assertThat(repr.getSelf(), isLink().httpMethod(HttpMethod.GET));
- assertThat(repr.getOid(), matches("OID[:].+"));
- assertThat(repr.getTitle(), matches("Simples"));
-
- assertThat(repr.getMembers(), isArray());
-
- assertThat(repr.getLinks(), isArray());
- assertThat(repr.getExtensions(), isMap());
- }
-
-
- @Test
- public void headers() throws Exception {
- // given
- Response resp = resource.service("simples");
-
- // when
- RestfulResponse<DomainObjectRepresentation> jsonResp = RestfulResponse.ofT(resp);
-
- // then
- assertThat(jsonResp.getStatus(), is(HttpStatusCode.OK));
- assertThat(jsonResp.getHeader(RestfulResponse.Header.CONTENT_TYPE), is(RepresentationType.DOMAIN_OBJECT.getMediaType()));
- assertThat(jsonResp.getHeader(RestfulResponse.Header.CACHE_CONTROL).getMaxAge(), is(24*60*60));
- }
-
- @Test
- public void self_isFollowable() throws Exception {
- // given
- DomainObjectRepresentation repr = givenRepresentation("simples");
-
- // when, then
- assertThat(repr, isFollowableLinkToSelf(client));
- }
-
-
- @Test
- public void links() throws Exception {
- // given, when
- DomainObjectRepresentation repr = givenRepresentation("simples");
-
- // then
- assertThat(repr.getLinks().size(), is(3));
- }
-
-
- private DomainObjectRepresentation givenRepresentation(String serviceId) throws JsonParseException, JsonMappingException, IOException {
- RestfulResponse<DomainObjectRepresentation> jsonResp = RestfulResponse.ofT(resource.service(serviceId));
- return jsonResp.getEntity();
- }
-
-
-}
-
\ No newline at end of file
+
+public class DomainServiceResourceTest_serviceId_representationAndHeaders {
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+ private RestfulClient client;
+ private DomainServiceResource resource;
+
+ @Before
+ public void setUp() throws Exception {
+ final WebServer webServer = webServerRule.getWebServer();
+ client = new RestfulClient(webServer.getBase());
+
+ resource = client.getDomainServiceResource();
+ }
+
+ @Test
+ public void representation() throws Exception {
+
+ // given
+ final Response resp = resource.service("simples");
+
+ // when
+ final RestfulResponse<DomainObjectRepresentation> jsonResp = RestfulResponse.ofT(resp);
+
+ // then
+ assertThat(jsonResp.getStatus(), is(HttpStatusCode.OK));
+
+ final DomainObjectRepresentation repr = jsonResp.getEntity();
+
+ assertThat(repr, isMap());
+
+ assertThat(repr.getSelf(), isLink().httpMethod(HttpMethod.GET));
+ assertThat(repr.getOid(), matches("OID[:].+"));
+ assertThat(repr.getTitle(), matches("Simples"));
+
+ assertThat(repr.getMembers(), isArray());
+
+ assertThat(repr.getLinks(), isArray());
+ assertThat(repr.getExtensions(), isMap());
+ }
+
+ @Test
+ public void headers() throws Exception {
+ // given
+ final Response resp = resource.service("simples");
+
+ // when
+ final RestfulResponse<DomainObjectRepresentation> jsonResp = RestfulResponse.ofT(resp);
+
+ // then
+ assertThat(jsonResp.getStatus(), is(HttpStatusCode.OK));
+ assertThat(jsonResp.getHeader(RestfulResponse.Header.CONTENT_TYPE), is(RepresentationType.DOMAIN_OBJECT.getMediaType()));
+ assertThat(jsonResp.getHeader(RestfulResponse.Header.CACHE_CONTROL).getMaxAge(), is(24 * 60 * 60));
+ }
+
+ @Test
+ public void self_isFollowable() throws Exception {
+ // given
+ final DomainObjectRepresentation repr = givenRepresentation("simples");
+
+ // when, then
+ assertThat(repr, isFollowableLinkToSelf(client));
+ }
+
+ @Test
+ public void links() throws Exception {
+ // given, when
+ final DomainObjectRepresentation repr = givenRepresentation("simples");
+
+ // then
+ assertThat(repr.getLinks().size(), is(3));
+ }
+
+ private DomainObjectRepresentation givenRepresentation(final String serviceId) throws JsonParseException, JsonMappingException, IOException {
+ final RestfulResponse<DomainObjectRepresentation> jsonResp = RestfulResponse.ofT(resource.service(serviceId));
+ return jsonResp.getEntity();
+ }
+
+}
Modified: incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/service/serviceId/DomainServiceResourceTest_serviceId_xrofollowlinks.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/service/serviceId/DomainServiceResourceTest_serviceId_xrofollowlinks.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/service/serviceId/DomainServiceResourceTest_serviceId_xrofollowlinks.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/service/serviceId/DomainServiceResourceTest_serviceId_xrofollowlinks.java Sun Jan 22 08:05:17 2012
@@ -16,8 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.isis.viewer.json.tck.resources.service.serviceId;
-
+package org.apache.isis.viewer.json.tck.resources.service.serviceId;
+
import static org.apache.isis.viewer.json.tck.RepresentationMatchers.isArray;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
@@ -45,54 +45,52 @@ import org.codehaus.jackson.map.JsonMapp
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
-
-public class DomainServiceResourceTest_serviceId_xrofollowlinks {
-
- @Rule
- public IsisWebServerRule webServerRule = new IsisWebServerRule();
-
- private RestfulClient client;
-
- @Before
- public void setUp() throws Exception {
- WebServer webServer = webServerRule.getWebServer();
- client = new RestfulClient(webServer.getBase());
- }
-
- @Test
- public void withCriteria() throws Exception {
-
- final String href = givenHrefToService("simples");
-
- final RestfulRequest request =
- client.createRequest(HttpMethod.GET, href).withArg(RequestParameter.FOLLOW_LINKS, "members[id=%s].links[rel=details]", "list");
- final RestfulResponse<DomainObjectRepresentation> restfulResponse = request.executeT();
-
- assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
- final DomainObjectRepresentation repr = restfulResponse.getEntity();
-
- JsonRepresentation membersList = repr.getMembers();
- assertThat(membersList, isArray());
-
- JsonRepresentation actionRepr;
-
- actionRepr = membersList.getRepresentation("[id=%s]", "list");
- assertThat(actionRepr.getRepresentation("links[rel=details]"), is(not(nullValue())));
- assertThat(actionRepr.getRepresentation("links[rel=details].value"), is(not(nullValue()))); // followed
-
- actionRepr = membersList.getRepresentation("[id=%s]", "newTransientEntity");
- assertThat(actionRepr.getRepresentation("links[rel=details]"), is(not(nullValue())));
- assertThat(actionRepr.getRepresentation("links[rel=details].value"), is(nullValue())); // not followed
- }
-
-
- private String givenHrefToService(String serviceId) throws JsonParseException, JsonMappingException, IOException {
- final DomainServiceResource resource = client.getDomainServiceResource();
- final Response response = resource.services();
- final ListRepresentation services = RestfulResponse.<ListRepresentation>ofT(response).getEntity();
-
- return services.getRepresentation("values[id=%s]", serviceId).asLink().getHref();
- }
-
-
-}
+
+public class DomainServiceResourceTest_serviceId_xrofollowlinks {
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+ private RestfulClient client;
+
+ @Before
+ public void setUp() throws Exception {
+ final WebServer webServer = webServerRule.getWebServer();
+ client = new RestfulClient(webServer.getBase());
+ }
+
+ @Test
+ public void withCriteria() throws Exception {
+
+ final String href = givenHrefToService("simples");
+
+ final RestfulRequest request = client.createRequest(HttpMethod.GET, href).withArg(RequestParameter.FOLLOW_LINKS, "members[id=%s].links[rel=details]", "list");
+ final RestfulResponse<DomainObjectRepresentation> restfulResponse = request.executeT();
+
+ assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
+ final DomainObjectRepresentation repr = restfulResponse.getEntity();
+
+ final JsonRepresentation membersList = repr.getMembers();
+ assertThat(membersList, isArray());
+
+ JsonRepresentation actionRepr;
+
+ actionRepr = membersList.getRepresentation("[id=%s]", "list");
+ assertThat(actionRepr.getRepresentation("links[rel=details]"), is(not(nullValue())));
+ assertThat(actionRepr.getRepresentation("links[rel=details].value"), is(not(nullValue()))); // followed
+
+ actionRepr = membersList.getRepresentation("[id=%s]", "newTransientEntity");
+ assertThat(actionRepr.getRepresentation("links[rel=details]"), is(not(nullValue())));
+ assertThat(actionRepr.getRepresentation("links[rel=details].value"), is(nullValue())); // not
+ // followed
+ }
+
+ private String givenHrefToService(final String serviceId) throws JsonParseException, JsonMappingException, IOException {
+ final DomainServiceResource resource = client.getDomainServiceResource();
+ final Response response = resource.services();
+ final ListRepresentation services = RestfulResponse.<ListRepresentation> ofT(response).getEntity();
+
+ return services.getRepresentation("values[id=%s]", serviceId).asLink().getHref();
+ }
+
+}
Modified: incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/service/services/DomainServiceResourceTest_services_accept.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/service/services/DomainServiceResourceTest_services_accept.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/service/services/DomainServiceResourceTest_services_accept.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/service/services/DomainServiceResourceTest_services_accept.java Sun Jan 22 08:05:17 2012
@@ -16,8 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.isis.viewer.json.tck.resources.service.services;
-
+package org.apache.isis.viewer.json.tck.resources.service.services;
+
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
@@ -35,47 +35,45 @@ import org.apache.isis.viewer.json.tck.I
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
-
-public class DomainServiceResourceTest_services_accept {
-
- @Rule
- public IsisWebServerRule webServerRule = new IsisWebServerRule();
-
- private RestfulClient client;
-
- @Before
- public void setUp() throws Exception {
- WebServer webServer = webServerRule.getWebServer();
- client = new RestfulClient(webServer.getBase());
- }
-
- @Test
- public void applicationJson() throws Exception {
-
- final RestfulRequest request =
- client.createRequest(HttpMethod.GET, "services").withHeader(RestfulRequest.Header.ACCEPT, MediaType.APPLICATION_JSON_TYPE);
- final RestfulResponse<HomePageRepresentation> restfulResponse = request.executeT();
-
- assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
- }
-
- @Test
- public void applicationJson_profileList() throws Exception {
-
- final RestfulRequest request =
- client.createRequest(HttpMethod.GET, "services").withHeader(RestfulRequest.Header.ACCEPT, RepresentationType.LIST.getMediaType());
- final RestfulResponse<HomePageRepresentation> restfulResponse = request.executeT();
-
- assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
- }
-
- @Test
- public void applicationJson_invalid() throws Exception {
-
- final RestfulRequest request = client.createRequest(HttpMethod.GET, "services").withHeader(RestfulRequest.Header.ACCEPT, RepresentationType.USER.getMediaType());
- final RestfulResponse<HomePageRepresentation> restfulResponse = request.executeT();
-
- assertThat(restfulResponse.getStatus(), is(HttpStatusCode.NOT_ACCEPTABLE));
- }
-
-}
+
+public class DomainServiceResourceTest_services_accept {
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+ private RestfulClient client;
+
+ @Before
+ public void setUp() throws Exception {
+ final WebServer webServer = webServerRule.getWebServer();
+ client = new RestfulClient(webServer.getBase());
+ }
+
+ @Test
+ public void applicationJson() throws Exception {
+
+ final RestfulRequest request = client.createRequest(HttpMethod.GET, "services").withHeader(RestfulRequest.Header.ACCEPT, MediaType.APPLICATION_JSON_TYPE);
+ final RestfulResponse<HomePageRepresentation> restfulResponse = request.executeT();
+
+ assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
+ }
+
+ @Test
+ public void applicationJson_profileList() throws Exception {
+
+ final RestfulRequest request = client.createRequest(HttpMethod.GET, "services").withHeader(RestfulRequest.Header.ACCEPT, RepresentationType.LIST.getMediaType());
+ final RestfulResponse<HomePageRepresentation> restfulResponse = request.executeT();
+
+ assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
+ }
+
+ @Test
+ public void applicationJson_invalid() throws Exception {
+
+ final RestfulRequest request = client.createRequest(HttpMethod.GET, "services").withHeader(RestfulRequest.Header.ACCEPT, RepresentationType.USER.getMediaType());
+ final RestfulResponse<HomePageRepresentation> restfulResponse = request.executeT();
+
+ assertThat(restfulResponse.getStatus(), is(HttpStatusCode.NOT_ACCEPTABLE));
+ }
+
+}
Modified: incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/service/services/DomainServiceResourceTest_services_representationAndHeaders.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/service/services/DomainServiceResourceTest_services_representationAndHeaders.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/service/services/DomainServiceResourceTest_services_representationAndHeaders.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/service/services/DomainServiceResourceTest_services_representationAndHeaders.java Sun Jan 22 08:05:17 2012
@@ -16,8 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.isis.viewer.json.tck.resources.service.services;
-
+package org.apache.isis.viewer.json.tck.resources.service.services;
+
import static org.apache.isis.viewer.json.tck.RepresentationMatchers.assertThat;
import static org.apache.isis.viewer.json.tck.RepresentationMatchers.isArray;
import static org.apache.isis.viewer.json.tck.RepresentationMatchers.isFollowableLinkToSelf;
@@ -47,87 +47,80 @@ import org.codehaus.jackson.map.JsonMapp
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
-
-
-public class DomainServiceResourceTest_services_representationAndHeaders {
-
- @Rule
- public IsisWebServerRule webServerRule = new IsisWebServerRule();
-
- private RestfulClient client;
- private DomainServiceResource resource;
-
- @Before
- public void setUp() throws Exception {
- WebServer webServer = webServerRule.getWebServer();
- client = new RestfulClient(webServer.getBase());
-
- resource = client.getDomainServiceResource();
- }
-
-
- @Test
- public void representation() throws Exception {
-
- // when
- final Response response = resource.services();
- final RestfulResponse<ListRepresentation> restfulResponse = RestfulResponse.ofT(response);
-
- // then
- assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
- assertThat(restfulResponse.getHeader(RestfulResponse.Header.CONTENT_TYPE), is(RepresentationType.LIST.getMediaType()));
- assertThat(restfulResponse.getHeader(RestfulResponse.Header.CACHE_CONTROL).getMaxAge(), is(24*60*60));
-
- ListRepresentation repr = restfulResponse.getEntity();
-
- assertThat(repr, isMap());
-
- assertThat(repr.getSelf(), isLink().httpMethod(HttpMethod.GET));
-
- assertThat(repr.getValues(), isArray());
-
- assertThat(repr.getLinks(), isArray());
- assertThat(repr.getExtensions(), isMap());
- }
-
-
- @Test
- public void self_isFollowable() throws Exception {
- // given
- ListRepresentation repr = givenRepresentation();
-
- // when, then
- assertThat(repr, isFollowableLinkToSelf(client));
- }
-
-
- @Test
- public void linksToDomainServiceResources() throws Exception {
-
- // given
- ListRepresentation repr = givenRepresentation();
-
- // when
- JsonRepresentation values = repr.getValues();
-
- // then
- for (LinkRepresentation link : values.arrayIterable(LinkRepresentation.class)) {
- final RestfulResponse<JsonRepresentation> followJsonResp = client.follow(link);
- assertThat(followJsonResp.getStatus().getFamily(), is(Family.SUCCESSFUL));
-
- JsonRepresentation followRepr = followJsonResp.getEntity();
- LinkRepresentation self = followRepr.getLink("links[rel=self]");
-
- assertThat(self.getHref(), is(link.getHref()));
- }
- }
-
-
- private ListRepresentation givenRepresentation() throws JsonParseException, JsonMappingException, IOException {
- RestfulResponse<ListRepresentation> jsonResp = RestfulResponse.ofT(resource.services());
- return jsonResp.getEntity();
- }
-
-
-}
-
\ No newline at end of file
+
+public class DomainServiceResourceTest_services_representationAndHeaders {
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+ private RestfulClient client;
+ private DomainServiceResource resource;
+
+ @Before
+ public void setUp() throws Exception {
+ final WebServer webServer = webServerRule.getWebServer();
+ client = new RestfulClient(webServer.getBase());
+
+ resource = client.getDomainServiceResource();
+ }
+
+ @Test
+ public void representation() throws Exception {
+
+ // when
+ final Response response = resource.services();
+ final RestfulResponse<ListRepresentation> restfulResponse = RestfulResponse.ofT(response);
+
+ // then
+ assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
+ assertThat(restfulResponse.getHeader(RestfulResponse.Header.CONTENT_TYPE), is(RepresentationType.LIST.getMediaType()));
+ assertThat(restfulResponse.getHeader(RestfulResponse.Header.CACHE_CONTROL).getMaxAge(), is(24 * 60 * 60));
+
+ final ListRepresentation repr = restfulResponse.getEntity();
+
+ assertThat(repr, isMap());
+
+ assertThat(repr.getSelf(), isLink().httpMethod(HttpMethod.GET));
+
+ assertThat(repr.getValues(), isArray());
+
+ assertThat(repr.getLinks(), isArray());
+ assertThat(repr.getExtensions(), isMap());
+ }
+
+ @Test
+ public void self_isFollowable() throws Exception {
+ // given
+ final ListRepresentation repr = givenRepresentation();
+
+ // when, then
+ assertThat(repr, isFollowableLinkToSelf(client));
+ }
+
+ @Test
+ public void linksToDomainServiceResources() throws Exception {
+
+ // given
+ final ListRepresentation repr = givenRepresentation();
+
+ // when
+ final JsonRepresentation values = repr.getValues();
+
+ // then
+ for (final LinkRepresentation link : values.arrayIterable(LinkRepresentation.class)) {
+ final RestfulResponse<JsonRepresentation> followJsonResp = client.follow(link);
+ assertThat(followJsonResp.getStatus().getFamily(), is(Family.SUCCESSFUL));
+
+ final JsonRepresentation followRepr = followJsonResp.getEntity();
+ final LinkRepresentation self = followRepr.getLink("links[rel=self]");
+
+ assertThat(self.getHref(), is(link.getHref()));
+ }
+ }
+
+ private ListRepresentation givenRepresentation() throws JsonParseException, JsonMappingException, IOException {
+ final RestfulResponse<ListRepresentation> jsonResp = RestfulResponse.ofT(resource.services());
+ return jsonResp.getEntity();
+ }
+
+}
Modified: incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/service/services/DomainServiceResourceTest_services_xrofollowlinks.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/service/services/DomainServiceResourceTest_services_xrofollowlinks.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/service/services/DomainServiceResourceTest_services_xrofollowlinks.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/service/services/DomainServiceResourceTest_services_xrofollowlinks.java Sun Jan 22 08:05:17 2012
@@ -16,8 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.isis.viewer.json.tck.resources.service.services;
-
+package org.apache.isis.viewer.json.tck.resources.service.services;
+
import static org.apache.isis.viewer.json.tck.RepresentationMatchers.assertThat;
import static org.apache.isis.viewer.json.tck.RepresentationMatchers.isArray;
import static org.apache.isis.viewer.json.tck.RepresentationMatchers.isLink;
@@ -40,45 +40,40 @@ import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
-
-
-public class DomainServiceResourceTest_services_xrofollowlinks {
-
- @Rule
- public IsisWebServerRule webServerRule = new IsisWebServerRule();
- private RestfulClient client;
-
- @Before
- public void setUp() throws Exception {
- WebServer webServer = webServerRule.getWebServer();
- client = new RestfulClient(webServer.getBase());
- }
-
- @Test
- public void xrofollowLinks() throws Exception {
-
- RestfulRequest request;
- RestfulResponse<ListRepresentation> restfulResponse;
- ListRepresentation repr;
-
- request = client.createRequest(HttpMethod.GET, "services");
- restfulResponse = request.executeT();
- repr = restfulResponse.getEntity();
-
- assertThat(repr.getValues(), isArray());
- assertThat(repr.getValues().size(), is(greaterThan(0)));
- assertThat(repr.getValues().arrayGet(0), isLink().novalue());
-
- request = client.createRequest(HttpMethod.GET, "services").withArg(RequestParameter.FOLLOW_LINKS, "values");
- restfulResponse = request.executeT();
- repr = restfulResponse.getEntity();
-
- assertThat(repr.getValues().arrayGet(0), isLink().value(is(not(Matchers.<JsonRepresentation>nullValue()))));
- assertThat(repr.getValues().arrayGet(0).getRepresentation("value"), isMap());
- }
-
-
-}
-
-
-
\ No newline at end of file
+
+public class DomainServiceResourceTest_services_xrofollowlinks {
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+ private RestfulClient client;
+
+ @Before
+ public void setUp() throws Exception {
+ final WebServer webServer = webServerRule.getWebServer();
+ client = new RestfulClient(webServer.getBase());
+ }
+
+ @Test
+ public void xrofollowLinks() throws Exception {
+
+ RestfulRequest request;
+ RestfulResponse<ListRepresentation> restfulResponse;
+ ListRepresentation repr;
+
+ request = client.createRequest(HttpMethod.GET, "services");
+ restfulResponse = request.executeT();
+ repr = restfulResponse.getEntity();
+
+ assertThat(repr.getValues(), isArray());
+ assertThat(repr.getValues().size(), is(greaterThan(0)));
+ assertThat(repr.getValues().arrayGet(0), isLink().novalue());
+
+ request = client.createRequest(HttpMethod.GET, "services").withArg(RequestParameter.FOLLOW_LINKS, "values");
+ restfulResponse = request.executeT();
+ repr = restfulResponse.getEntity();
+
+ assertThat(repr.getValues().arrayGet(0), isLink().value(is(not(Matchers.<JsonRepresentation> nullValue()))));
+ assertThat(repr.getValues().arrayGet(0).getRepresentation("value"), isMap());
+ }
+
+}
Modified: incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/user/UserResourceTest_accept.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/user/UserResourceTest_accept.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/user/UserResourceTest_accept.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/user/UserResourceTest_accept.java Sun Jan 22 08:05:17 2012
@@ -16,8 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.isis.viewer.json.tck.resources.user;
-
+package org.apache.isis.viewer.json.tck.resources.user;
+
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
@@ -35,47 +35,45 @@ import org.apache.isis.viewer.json.tck.I
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
-
-public class UserResourceTest_accept {
-
- @Rule
- public IsisWebServerRule webServerRule = new IsisWebServerRule();
-
- private RestfulClient client;
-
- @Before
- public void setUp() throws Exception {
- WebServer webServer = webServerRule.getWebServer();
- client = new RestfulClient(webServer.getBase());
- }
-
- @Test
- public void applicationJson() throws Exception {
-
- final RestfulRequest request =
- client.createRequest(HttpMethod.GET, "user").withHeader(RestfulRequest.Header.ACCEPT, MediaType.APPLICATION_JSON_TYPE);
- final RestfulResponse<HomePageRepresentation> restfulResponse = request.executeT();
-
- assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
- }
-
- @Test
- public void applicationJson_profileUser() throws Exception {
-
- final RestfulRequest request =
- client.createRequest(HttpMethod.GET, "user").withHeader(RestfulRequest.Header.ACCEPT, RepresentationType.USER.getMediaType());
- final RestfulResponse<HomePageRepresentation> restfulResponse = request.executeT();
-
- assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
- }
-
- @Test
- public void applicationJson_invalid() throws Exception {
-
- final RestfulRequest request = client.createRequest(HttpMethod.GET, "user").withHeader(RestfulRequest.Header.ACCEPT, RepresentationType.HOME_PAGE.getMediaType());
- final RestfulResponse<HomePageRepresentation> restfulResponse = request.executeT();
-
- assertThat(restfulResponse.getStatus(), is(HttpStatusCode.NOT_ACCEPTABLE));
- }
-
-}
+
+public class UserResourceTest_accept {
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+ private RestfulClient client;
+
+ @Before
+ public void setUp() throws Exception {
+ final WebServer webServer = webServerRule.getWebServer();
+ client = new RestfulClient(webServer.getBase());
+ }
+
+ @Test
+ public void applicationJson() throws Exception {
+
+ final RestfulRequest request = client.createRequest(HttpMethod.GET, "user").withHeader(RestfulRequest.Header.ACCEPT, MediaType.APPLICATION_JSON_TYPE);
+ final RestfulResponse<HomePageRepresentation> restfulResponse = request.executeT();
+
+ assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
+ }
+
+ @Test
+ public void applicationJson_profileUser() throws Exception {
+
+ final RestfulRequest request = client.createRequest(HttpMethod.GET, "user").withHeader(RestfulRequest.Header.ACCEPT, RepresentationType.USER.getMediaType());
+ final RestfulResponse<HomePageRepresentation> restfulResponse = request.executeT();
+
+ assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
+ }
+
+ @Test
+ public void applicationJson_invalid() throws Exception {
+
+ final RestfulRequest request = client.createRequest(HttpMethod.GET, "user").withHeader(RestfulRequest.Header.ACCEPT, RepresentationType.HOME_PAGE.getMediaType());
+ final RestfulResponse<HomePageRepresentation> restfulResponse = request.executeT();
+
+ assertThat(restfulResponse.getStatus(), is(HttpStatusCode.NOT_ACCEPTABLE));
+ }
+
+}
Modified: incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/user/UserResourceTest_representationAndHeaders.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/user/UserResourceTest_representationAndHeaders.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/user/UserResourceTest_representationAndHeaders.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/resources/user/UserResourceTest_representationAndHeaders.java Sun Jan 22 08:05:17 2012
@@ -16,8 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.isis.viewer.json.tck.resources.user;
-
+package org.apache.isis.viewer.json.tck.resources.user;
+
import static org.apache.isis.viewer.json.tck.RepresentationMatchers.assertThat;
import static org.apache.isis.viewer.json.tck.RepresentationMatchers.hasMaxAge;
import static org.apache.isis.viewer.json.tck.RepresentationMatchers.hasParameter;
@@ -54,89 +54,89 @@ import org.codehaus.jackson.map.JsonMapp
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
-
-
-public class UserResourceTest_representationAndHeaders {
-
- @Rule
- public IsisWebServerRule webServerRule = new IsisWebServerRule();
-
- private RestfulClient client;
- private UserResource resource;
-
- @Before
- public void setUp() throws Exception {
- WebServer webServer = webServerRule.getWebServer();
- client = new RestfulClient(webServer.getBase());
-
- resource = client.getUserResource();
- }
-
- @Test
- public void representation() throws Exception {
-
- // given
- Response resp = resource.user();
-
- // when
- RestfulResponse<UserRepresentation> jsonResp = RestfulResponse.ofT(resp);
- assertThat(jsonResp.getStatus().getFamily(), is(Family.SUCCESSFUL));
-
- // then
- assertThat(jsonResp.getStatus(), is(HttpStatusCode.OK));
-
- UserRepresentation repr = jsonResp.getEntity();
- assertThat(repr, is(not(nullValue())));
- assertThat(repr.isMap(), is(true));
-
- assertThat(repr.getSelf(), isLink(client).httpMethod(HttpMethod.GET));
- assertThat(repr.getUserName(), is(not(nullValue())));
- assertThat(repr.getFriendlyName(), is(nullValue())); // TODO: change fixture so populated
- assertThat(repr.getEmail(), is(nullValue())); // TODO: change fixture so populated
- assertThat(repr.getRoles(), is(not(nullValue()))); // TODO: change fixture so have non-empty list
-
- assertThat(repr.getLinks(), isArray());
- assertThat(repr.getExtensions(), isMap());
- }
-
- @Test
- public void headers() throws Exception {
-
- // given
- Response resp = resource.user();
-
- // when
- RestfulResponse<UserRepresentation> restfulResponse = RestfulResponse.ofT(resp);
-
- // then
- final MediaType contentType = restfulResponse.getHeader(Header.CONTENT_TYPE);
- assertThat(contentType, hasType("application"));
- assertThat(contentType, hasSubType("json"));
- assertThat(contentType, hasParameter("profile", "urn:org.restfulobjects/user"));
- assertThat(contentType, is(RepresentationType.USER.getMediaType()));
-
- // then
- final CacheControl cacheControl = restfulResponse.getHeader(Header.CACHE_CONTROL);
- assertThat(cacheControl, hasMaxAge(60*60));
- assertThat(cacheControl.getMaxAge(), is(60*60));
- }
-
-
- @Test
- public void self_isFollowable() throws Exception {
- // given
- UserRepresentation repr = givenRepresentation();
-
- // when, then
- assertThat(repr, isFollowableLinkToSelf(client));
- }
-
- private UserRepresentation givenRepresentation() throws JsonParseException, JsonMappingException, IOException {
- RestfulResponse<UserRepresentation> jsonResp = RestfulResponse.ofT(resource.user());
- return jsonResp.getEntity();
- }
-
-}
-
-
-
\ No newline at end of file
+
+public class UserResourceTest_representationAndHeaders {
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+ private RestfulClient client;
+ private UserResource resource;
+
+ @Before
+ public void setUp() throws Exception {
+ final WebServer webServer = webServerRule.getWebServer();
+ client = new RestfulClient(webServer.getBase());
+
+ resource = client.getUserResource();
+ }
+
+ @Test
+ public void representation() throws Exception {
+
+ // given
+ final Response resp = resource.user();
+
+ // when
+ final RestfulResponse<UserRepresentation> jsonResp = RestfulResponse.ofT(resp);
+ assertThat(jsonResp.getStatus().getFamily(), is(Family.SUCCESSFUL));
+
+ // then
+ assertThat(jsonResp.getStatus(), is(HttpStatusCode.OK));
+
+ final UserRepresentation repr = jsonResp.getEntity();
+ assertThat(repr, is(not(nullValue())));
+ assertThat(repr.isMap(), is(true));
+
+ assertThat(repr.getSelf(), isLink(client).httpMethod(HttpMethod.GET));
+ assertThat(repr.getUserName(), is(not(nullValue())));
+ assertThat(repr.getFriendlyName(), is(nullValue())); // TODO: change
+ // fixture so
+ // populated
+ assertThat(repr.getEmail(), is(nullValue())); // TODO: change fixture so
+ // populated
+ assertThat(repr.getRoles(), is(not(nullValue()))); // TODO: change
+ // fixture so have
+ // non-empty list
+
+ assertThat(repr.getLinks(), isArray());
+ assertThat(repr.getExtensions(), isMap());
+ }
+
+ @Test
+ public void headers() throws Exception {
+
+ // given
+ final Response resp = resource.user();
+
+ // when
+ final RestfulResponse<UserRepresentation> restfulResponse = RestfulResponse.ofT(resp);
+
+ // then
+ final MediaType contentType = restfulResponse.getHeader(Header.CONTENT_TYPE);
+ assertThat(contentType, hasType("application"));
+ assertThat(contentType, hasSubType("json"));
+ assertThat(contentType, hasParameter("profile", "urn:org.restfulobjects/user"));
+ assertThat(contentType, is(RepresentationType.USER.getMediaType()));
+
+ // then
+ final CacheControl cacheControl = restfulResponse.getHeader(Header.CACHE_CONTROL);
+ assertThat(cacheControl, hasMaxAge(60 * 60));
+ assertThat(cacheControl.getMaxAge(), is(60 * 60));
+ }
+
+ @Test
+ public void self_isFollowable() throws Exception {
+ // given
+ final UserRepresentation repr = givenRepresentation();
+
+ // when, then
+ assertThat(repr, isFollowableLinkToSelf(client));
+ }
+
+ private UserRepresentation givenRepresentation() throws JsonParseException, JsonMappingException, IOException {
+ final RestfulResponse<UserRepresentation> jsonResp = RestfulResponse.ofT(resource.user());
+ return jsonResp.getEntity();
+ }
+
+}
Modified: incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/stories/UserStoryTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/stories/UserStoryTest.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/stories/UserStoryTest.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-tck/src/test/java/org/apache/isis/viewer/json/tck/stories/UserStoryTest.java Sun Jan 22 08:05:17 2012
@@ -16,8 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.isis.viewer.json.tck.stories;
-
+package org.apache.isis.viewer.json.tck.stories;
+
import static org.apache.isis.core.commons.matchers.IsisMatchers.matches;
import static org.junit.Assert.assertThat;
@@ -33,54 +33,53 @@ import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
-
-
-public class UserStoryTest {
-
- @Rule
- public IsisWebServerRule webServerRule = new IsisWebServerRule();
-
- protected RestfulClient client;
-
- @Before
- public void setUp() throws Exception {
- WebServer webServer = webServerRule.getWebServer();
- client = new RestfulClient(webServer.getBase());
- }
-
-
- @Ignore("to get working again")
- @Test
- public void walkResources() throws Exception {
-
- // given a response for an initial resource
- HomePageResource homePageResource = client.getHomePageResource();
- Response homePageResp = homePageResource.homePage();
-
- // and given a walker starting from this response
- RepresentationWalker walker = client.createWalker(homePageResp);
-
- // when walk the home pages' 'services' link
- walker.walk("services");
-
- // and when locate the ApplibValues repo and walk the its 'object' link
- walker.walk("values[title=ApplibValues].links[rel=object]");
-
- // and when locate the AppLibValues repo's "newEntity" action and walk to its details
- walker.walk("values[memberType=action].details");
-
- // and when find the invoke body for the "newEntity" action and then walk the action using the body
- JsonRepresentation newEntityActionDetails = walker.getEntity();
- JsonRepresentation newEntityActionInvokeBody = newEntityActionDetails.getArray("invoke.body");
- walker.walk("invoke", newEntityActionInvokeBody);
-
- // and when walk the link to the returned object
- walker.walk("link");
-
- // then the returned object is created with its OID
- JsonRepresentation newEntityDomainObject = walker.getEntity();
- assertThat(newEntityDomainObject.getString("_self.link.href"), matches(".+/objects/OID:[\\d]+$"));
- }
-
-}
-
\ No newline at end of file
+
+public class UserStoryTest {
+
+ @Rule
+ public IsisWebServerRule webServerRule = new IsisWebServerRule();
+
+ protected RestfulClient client;
+
+ @Before
+ public void setUp() throws Exception {
+ final WebServer webServer = webServerRule.getWebServer();
+ client = new RestfulClient(webServer.getBase());
+ }
+
+ @Ignore("to get working again")
+ @Test
+ public void walkResources() throws Exception {
+
+ // given a response for an initial resource
+ final HomePageResource homePageResource = client.getHomePageResource();
+ final Response homePageResp = homePageResource.homePage();
+
+ // and given a walker starting from this response
+ final RepresentationWalker walker = client.createWalker(homePageResp);
+
+ // when walk the home pages' 'services' link
+ walker.walk("services");
+
+ // and when locate the ApplibValues repo and walk the its 'object' link
+ walker.walk("values[title=ApplibValues].links[rel=object]");
+
+ // and when locate the AppLibValues repo's "newEntity" action and walk
+ // to its details
+ walker.walk("values[memberType=action].details");
+
+ // and when find the invoke body for the "newEntity" action and then
+ // walk the action using the body
+ final JsonRepresentation newEntityActionDetails = walker.getEntity();
+ final JsonRepresentation newEntityActionInvokeBody = newEntityActionDetails.getArray("invoke.body");
+ walker.walk("invoke", newEntityActionInvokeBody);
+
+ // and when walk the link to the returned object
+ walker.walk("link");
+
+ // then the returned object is created with its OID
+ final JsonRepresentation newEntityDomainObject = walker.getEntity();
+ assertThat(newEntityDomainObject.getString("_self.link.href"), matches(".+/objects/OID:[\\d]+$"));
+ }
+
+}
Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/Constants.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/Constants.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/Constants.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/Constants.java Sun Jan 22 08:05:17 2012
@@ -28,8 +28,7 @@ public final class Constants {
public static final String ISIS_REST_SUPPORT_JS = "isis-rest-support.js";
public static final String JQUERY_SRC_JS = "jquery-1.6.1.js";
public static final String JQUERY_MIN_JS = "jquery-1.6.1.min.js";
- public static final String URL_ENCODING_CHAR_SET =
- org.apache.isis.viewer.json.applib.Constants.URL_ENCODING_CHAR_SET;
+ public static final String URL_ENCODING_CHAR_SET = org.apache.isis.viewer.json.applib.Constants.URL_ENCODING_CHAR_SET;
private Constants() {
}
Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/HasHttpStatusCode.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/HasHttpStatusCode.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/HasHttpStatusCode.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/HasHttpStatusCode.java Sun Jan 22 08:05:17 2012
@@ -16,11 +16,11 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.isis.viewer.json.viewer;
-
+package org.apache.isis.viewer.json.viewer;
+
import org.apache.isis.viewer.json.applib.RestfulResponse.HttpStatusCode;
-
-public interface HasHttpStatusCode {
-
- HttpStatusCode getHttpStatusCode();
-}
+
+public interface HasHttpStatusCode {
+
+ HttpStatusCode getHttpStatusCode();
+}
Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/JsonApplication.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/JsonApplication.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/JsonApplication.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/JsonApplication.java Sun Jan 22 08:05:17 2012
@@ -36,16 +36,15 @@ public class JsonApplication extends Abs
addClass(DomainObjectResourceServerside.class);
addClass(DomainServiceResourceServerside.class);
addClass(VersionResourceServerside.class);
-
+
addSingleton(new JsonApplicationExceptionMapper());
addSingleton(new RuntimeExceptionMapper());
-
+
// TODO: doesn't get injected
// addSingleton(new TypedReprBuilderFactoryRegistry());
-
+
// TODO: idea being to remove the init()
// addSingleton(new PreProcessInterceptorForIsisSession());
}
-
}
Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/JsonApplicationException.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/JsonApplicationException.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/JsonApplicationException.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/JsonApplicationException.java Sun Jan 22 08:05:17 2012
@@ -16,54 +16,54 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.isis.viewer.json.viewer;
-
+package org.apache.isis.viewer.json.viewer;
+
import org.apache.isis.viewer.json.applib.JsonRepresentation;
import org.apache.isis.viewer.json.applib.RestfulResponse.HttpStatusCode;
-
-public class JsonApplicationException extends RuntimeException implements HasHttpStatusCode {
-
- public static final JsonApplicationException create(HttpStatusCode httpStatusCode) {
- return create(httpStatusCode, null);
- }
-
- public static JsonApplicationException create(HttpStatusCode httpStatusCode, String message, Object... args) {
- return create(httpStatusCode, (Exception)null, message, args);
- }
-
- public static JsonApplicationException create(HttpStatusCode httpStatusCode, Exception cause) {
- return create(httpStatusCode, cause, null);
- }
-
- public static JsonApplicationException create(HttpStatusCode httpStatusCode, Exception cause, String message, Object... args) {
- return new JsonApplicationException(httpStatusCode, formatString(message, args), cause, null);
- }
- public static JsonApplicationException create(HttpStatusCode httpStatusCode, JsonRepresentation repr, String message, Object... args) {
+public class JsonApplicationException extends RuntimeException implements HasHttpStatusCode {
+
+ public static final JsonApplicationException create(final HttpStatusCode httpStatusCode) {
+ return create(httpStatusCode, null);
+ }
+
+ public static JsonApplicationException create(final HttpStatusCode httpStatusCode, final String message, final Object... args) {
+ return create(httpStatusCode, (Exception) null, message, args);
+ }
+
+ public static JsonApplicationException create(final HttpStatusCode httpStatusCode, final Exception cause) {
+ return create(httpStatusCode, cause, null);
+ }
+
+ public static JsonApplicationException create(final HttpStatusCode httpStatusCode, final Exception cause, final String message, final Object... args) {
+ return new JsonApplicationException(httpStatusCode, formatString(message, args), cause, null);
+ }
+
+ public static JsonApplicationException create(final HttpStatusCode httpStatusCode, final JsonRepresentation repr, final String message, final Object... args) {
return new JsonApplicationException(httpStatusCode, formatString(message, args), null, repr);
}
-
- private static String formatString(String formatStr, Object... args) {
- return formatStr != null? String.format(formatStr, args): null;
- }
-
- private static final long serialVersionUID = 1L;
- private HttpStatusCode httpStatusCode;
- private final JsonRepresentation jsonRepresentation;
-
- private JsonApplicationException(HttpStatusCode httpStatusCode, String message, Throwable ex, JsonRepresentation jsonRepresentation) {
- super(message, ex);
+
+ private static String formatString(final String formatStr, final Object... args) {
+ return formatStr != null ? String.format(formatStr, args) : null;
+ }
+
+ private static final long serialVersionUID = 1L;
+ private final HttpStatusCode httpStatusCode;
+ private final JsonRepresentation jsonRepresentation;
+
+ private JsonApplicationException(final HttpStatusCode httpStatusCode, final String message, final Throwable ex, final JsonRepresentation jsonRepresentation) {
+ super(message, ex);
this.httpStatusCode = httpStatusCode;
- this.jsonRepresentation = jsonRepresentation;
- }
+ this.jsonRepresentation = jsonRepresentation;
+ }
- public HttpStatusCode getHttpStatusCode() {
- return httpStatusCode;
+ @Override
+ public HttpStatusCode getHttpStatusCode() {
+ return httpStatusCode;
}
public JsonRepresentation getJsonRepresentation() {
return jsonRepresentation;
}
-
-
-}
+
+}
Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/JsonApplicationExceptionMapper.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/JsonApplicationExceptionMapper.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/JsonApplicationExceptionMapper.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/JsonApplicationExceptionMapper.java Sun Jan 22 08:05:17 2012
@@ -16,8 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.isis.viewer.json.viewer;
-
+package org.apache.isis.viewer.json.viewer;
+
import java.util.List;
import javax.ws.rs.core.Response;
@@ -32,92 +32,88 @@ import org.apache.isis.viewer.json.appli
import org.apache.isis.viewer.json.applib.util.JsonMapper;
import com.google.common.collect.Lists;
-
-@Provider
-public class JsonApplicationExceptionMapper implements ExceptionMapper<JsonApplicationException> {
-
- @Override
- public Response toResponse(JsonApplicationException ex) {
- ResponseBuilder builder =
- Response.status(ex.getHttpStatusCode().getJaxrsStatusType())
- .type(RestfulMediaType.APPLICATION_JSON_ERROR)
- .entity(jsonFor(ex));
- String message = ex.getMessage();
- if(message != null) {
- builder.header(RestfulResponse.Header.WARNING.getName(), message);
- }
- return builder.build();
- }
-
-
- private static class ExceptionPojo {
-
- public static ExceptionPojo create(Exception ex) {
- return new ExceptionPojo(ex);
- }
-
- private static String format(StackTraceElement stackTraceElement) {
- return stackTraceElement.toString();
- }
-
- private final int httpStatusCode;
- private final String message;
- private final List<String> stackTrace = Lists.newArrayList();
- private ExceptionPojo causedBy;
-
- public ExceptionPojo(Throwable ex) {
- httpStatusCode = getHttpStatusCodeIfAny(ex);
- this.message = ex.getMessage();
- StackTraceElement[] stackTraceElements = ex.getStackTrace();
- for (StackTraceElement stackTraceElement : stackTraceElements) {
- this.stackTrace.add(format(stackTraceElement));
- }
- Throwable cause = ex.getCause();
- if(cause != null && cause != ex) {
- this.causedBy = new ExceptionPojo(cause);
- }
- }
-
- private int getHttpStatusCodeIfAny(Throwable ex) {
- if(!(ex instanceof HasHttpStatusCode)) {
- return 0;
- }
- HasHttpStatusCode hasHttpStatusCode = (HasHttpStatusCode) ex;
- return hasHttpStatusCode.getHttpStatusCode().getStatusCode();
- }
-
- @SuppressWarnings("unused")
- public int getHttpStatusCode() {
- return httpStatusCode;
- }
-
- @SuppressWarnings("unused")
- public String getMessage() {
- return message;
- }
-
- @SuppressWarnings("unused")
- public List<String> getStackTrace() {
- return stackTrace;
- }
-
- @SuppressWarnings("unused")
- public ExceptionPojo getCausedBy() {
- return causedBy;
- }
-
- }
-
- static String jsonFor(JsonApplicationException ex) {
+
+@Provider
+public class JsonApplicationExceptionMapper implements ExceptionMapper<JsonApplicationException> {
+
+ @Override
+ public Response toResponse(final JsonApplicationException ex) {
+ final ResponseBuilder builder = Response.status(ex.getHttpStatusCode().getJaxrsStatusType()).type(RestfulMediaType.APPLICATION_JSON_ERROR).entity(jsonFor(ex));
+ final String message = ex.getMessage();
+ if (message != null) {
+ builder.header(RestfulResponse.Header.WARNING.getName(), message);
+ }
+ return builder.build();
+ }
+
+ private static class ExceptionPojo {
+
+ public static ExceptionPojo create(final Exception ex) {
+ return new ExceptionPojo(ex);
+ }
+
+ private static String format(final StackTraceElement stackTraceElement) {
+ return stackTraceElement.toString();
+ }
+
+ private final int httpStatusCode;
+ private final String message;
+ private final List<String> stackTrace = Lists.newArrayList();
+ private ExceptionPojo causedBy;
+
+ public ExceptionPojo(final Throwable ex) {
+ httpStatusCode = getHttpStatusCodeIfAny(ex);
+ this.message = ex.getMessage();
+ final StackTraceElement[] stackTraceElements = ex.getStackTrace();
+ for (final StackTraceElement stackTraceElement : stackTraceElements) {
+ this.stackTrace.add(format(stackTraceElement));
+ }
+ final Throwable cause = ex.getCause();
+ if (cause != null && cause != ex) {
+ this.causedBy = new ExceptionPojo(cause);
+ }
+ }
+
+ private int getHttpStatusCodeIfAny(final Throwable ex) {
+ if (!(ex instanceof HasHttpStatusCode)) {
+ return 0;
+ }
+ final HasHttpStatusCode hasHttpStatusCode = (HasHttpStatusCode) ex;
+ return hasHttpStatusCode.getHttpStatusCode().getStatusCode();
+ }
+
+ @SuppressWarnings("unused")
+ public int getHttpStatusCode() {
+ return httpStatusCode;
+ }
+
+ @SuppressWarnings("unused")
+ public String getMessage() {
+ return message;
+ }
+
+ @SuppressWarnings("unused")
+ public List<String> getStackTrace() {
+ return stackTrace;
+ }
+
+ @SuppressWarnings("unused")
+ public ExceptionPojo getCausedBy() {
+ return causedBy;
+ }
+
+ }
+
+ static String jsonFor(final JsonApplicationException ex) {
final JsonRepresentation jsonRepresentation = ex.getJsonRepresentation();
- if(jsonRepresentation != null) {
+ if (jsonRepresentation != null) {
return jsonRepresentation.toString();
}
- try {
- return JsonMapper.instance().write(ExceptionPojo.create(ex));
- } catch (Exception e) {
- // fallback
- return "{ \"exception\": \"" + ExceptionUtils.getFullStackTrace(ex) + "\" }";
- }
- }
-}
+ try {
+ return JsonMapper.instance().write(ExceptionPojo.create(ex));
+ } catch (final Exception e) {
+ // fallback
+ return "{ \"exception\": \"" + ExceptionUtils.getFullStackTrace(ex) + "\" }";
+ }
+ }
+}
Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/ResourceContext.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/ResourceContext.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/ResourceContext.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/ResourceContext.java Sun Jan 22 08:05:17 2012
@@ -31,7 +31,6 @@ import javax.ws.rs.core.UriInfo;
import org.apache.isis.applib.profiles.Localization;
import org.apache.isis.core.commons.authentication.AuthenticationSession;
-import org.apache.isis.core.commons.exceptions.NotYetImplementedException;
import org.apache.isis.core.metamodel.adapter.ObjectAdapterLookup;
import org.apache.isis.core.metamodel.adapter.oid.stringable.OidStringifier;
import org.apache.isis.core.metamodel.spec.SpecificationLookup;
@@ -61,34 +60,25 @@ public class ResourceContext {
private final PersistenceSession persistenceSession;
private final ObjectAdapterLookup objectAdapterLookup;
private final SpecificationLookup specificationLookup;
-
+
private List<List<String>> followLinks;
-
+
private final static Predicate<MediaType> MEDIA_TYPE_NOT_GENERIC_APPLICATION_JSON = new Predicate<MediaType>() {
@Override
- public boolean apply(MediaType mediaType) {
+ public boolean apply(final MediaType mediaType) {
return !mediaType.equals(MediaType.APPLICATION_JSON_TYPE);
}
};
private final static Predicate<MediaType> MEDIA_TYPE_CONTAINS_PROFILE = new Predicate<MediaType>() {
@Override
- public boolean apply(MediaType mediaType) {
+ public boolean apply(final MediaType mediaType) {
return mediaType.getParameters().containsKey("profile");
}
};
private JsonRepresentation readQueryStringAsMap;
- public ResourceContext(
- RepresentationType representationType, final HttpHeaders httpHeaders, final UriInfo uriInfo,
- final Request request, final HttpServletRequest httpServletRequest,
- final HttpServletResponse httpServletResponse,
- final SecurityContext securityContext,
- final OidStringifier oidStringifier,
- final Localization localization,
- final AuthenticationSession authenticationSession,
- final PersistenceSession persistenceSession,
- final ObjectAdapterLookup objectAdapterLookup,
- final SpecificationLookup specificationLookup) {
+ public ResourceContext(final RepresentationType representationType, final HttpHeaders httpHeaders, final UriInfo uriInfo, final Request request, final HttpServletRequest httpServletRequest, final HttpServletResponse httpServletResponse, final SecurityContext securityContext,
+ final OidStringifier oidStringifier, final Localization localization, final AuthenticationSession authenticationSession, final PersistenceSession persistenceSession, final ObjectAdapterLookup objectAdapterLookup, final SpecificationLookup specificationLookup) {
this.httpHeaders = httpHeaders;
this.uriInfo = uriInfo;
@@ -102,11 +92,11 @@ public class ResourceContext {
this.persistenceSession = persistenceSession;
this.objectAdapterLookup = objectAdapterLookup;
this.specificationLookup = specificationLookup;
-
+
init(representationType);
}
- void init(RepresentationType representationType) {
+ void init(final RepresentationType representationType) {
ensureCompatibleAcceptHeader(representationType);
this.followLinks = Collections.unmodifiableList(getArg(RequestParameter.FOLLOW_LINKS));
}
@@ -120,13 +110,13 @@ public class ResourceContext {
}
public JsonRepresentation getQueryStringAsJsonRepr() {
- if(readQueryStringAsMap == null) {
+ if (readQueryStringAsMap == null) {
readQueryStringAsMap = DomainResourceHelper.readQueryStringAsMap(getQueryString());
}
return readQueryStringAsMap;
}
- public <Q> Q getArg(RequestParameter<Q> requestParameter) {
+ public <Q> Q getArg(final RequestParameter<Q> requestParameter) {
final JsonRepresentation queryStringJsonRepr = getQueryStringAsJsonRepr();
return requestParameter.valueOf(queryStringJsonRepr);
}
@@ -151,42 +141,41 @@ public class ResourceContext {
return securityContext;
}
-
- private void ensureCompatibleAcceptHeader(RepresentationType representationType) {
- if(representationType == null) {
+ private void ensureCompatibleAcceptHeader(final RepresentationType representationType) {
+ if (representationType == null) {
return;
}
final MediaType producedType = representationType.getMediaType();
- List<MediaType> acceptableMediaTypes = acceptableMediaTypes();
- for (MediaType mediaType : acceptableMediaTypes) {
- if(compatible(mediaType, representationType)) {
+ final List<MediaType> acceptableMediaTypes = acceptableMediaTypes();
+ for (final MediaType mediaType : acceptableMediaTypes) {
+ if (compatible(mediaType, representationType)) {
return;
}
}
- if(!acceptableMediaTypes.contains(producedType)) {
+ if (!acceptableMediaTypes.contains(producedType)) {
throw JsonApplicationException.create(HttpStatusCode.NOT_ACCEPTABLE, "Resource produces %s media type", representationType.getMediaTypeWithProfile());
}
}
/**
- * If no media type has a profile parameter, then simply return all the media types.
+ * If no media type has a profile parameter, then simply return all the
+ * media types.
*
* <p>
- * Otherwise, though, filter out the {@link MediaType#APPLICATION_JSON_TYPE generic application/json}
- * media type if it is present.
+ * Otherwise, though, filter out the {@link MediaType#APPLICATION_JSON_TYPE
+ * generic application/json} media type if it is present.
*/
private List<MediaType> acceptableMediaTypes() {
final List<MediaType> acceptableMediaTypes = getHttpHeaders().getAcceptableMediaTypes();
- if(Collections2.filter(acceptableMediaTypes, MEDIA_TYPE_CONTAINS_PROFILE).isEmpty()) {
+ if (Collections2.filter(acceptableMediaTypes, MEDIA_TYPE_CONTAINS_PROFILE).isEmpty()) {
return acceptableMediaTypes;
}
- return Lists.newArrayList(
- Iterables.filter(acceptableMediaTypes, MEDIA_TYPE_NOT_GENERIC_APPLICATION_JSON));
+ return Lists.newArrayList(Iterables.filter(acceptableMediaTypes, MEDIA_TYPE_NOT_GENERIC_APPLICATION_JSON));
}
- private boolean compatible(MediaType acceptedMediaType, RepresentationType representationType) {
- MediaType producedMediaType = representationType.getMediaType();
- String profile = acceptedMediaType.getParameters().get("profile");
+ private boolean compatible(final MediaType acceptedMediaType, final RepresentationType representationType) {
+ final MediaType producedMediaType = representationType.getMediaType();
+ final String profile = acceptedMediaType.getParameters().get("profile");
return profile == null ? acceptedMediaType.isCompatible(producedMediaType) : acceptedMediaType.equals(producedMediaType);
}
@@ -194,11 +183,10 @@ public class ResourceContext {
return followLinks;
}
- public String urlFor(String url) {
+ public String urlFor(final String url) {
return getUriInfo().getBaseUri().toString() + url;
}
-
public OidStringifier getOidStringifier() {
return oidStringifier;
}
@@ -223,10 +211,4 @@ public class ResourceContext {
return specificationLookup;
}
-
-
-
-
-
-
}
Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/RuntimeExceptionMapper.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/RuntimeExceptionMapper.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/RuntimeExceptionMapper.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/RuntimeExceptionMapper.java Sun Jan 22 08:05:17 2012
@@ -16,8 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.isis.viewer.json.viewer;
-
+package org.apache.isis.viewer.json.viewer;
+
import java.util.List;
import javax.ws.rs.core.Response;
@@ -31,73 +31,69 @@ import org.apache.isis.viewer.json.appli
import org.apache.isis.viewer.json.applib.util.JsonMapper;
import com.google.common.collect.Lists;
-
-@Provider
-public class RuntimeExceptionMapper implements ExceptionMapper<RuntimeException> {
-
- @Override
- public Response toResponse(RuntimeException ex) {
- ResponseBuilder builder =
- Response.status(HttpStatusCode.INTERNAL_SERVER_ERROR.getJaxrsStatusType())
- .type(RestfulMediaType.APPLICATION_JSON_ERROR)
- .entity(jsonFor(ex));
- return builder.build();
- }
-
-
- private static class ExceptionPojo {
-
- public static ExceptionPojo create(Exception ex) {
- return new ExceptionPojo(ex);
- }
-
- private static String format(StackTraceElement stackTraceElement) {
- return stackTraceElement.toString();
- }
-
- private final String message;
- private final List<String> stackTrace = Lists.newArrayList();
- private ExceptionPojo causedBy;
-
- public ExceptionPojo(Throwable ex) {
- this.message = messageFor(ex);
- StackTraceElement[] stackTraceElements = ex.getStackTrace();
- for (StackTraceElement stackTraceElement : stackTraceElements) {
- this.stackTrace.add(format(stackTraceElement));
- }
- Throwable cause = ex.getCause();
- if(cause != null && cause != ex) {
- this.causedBy = new ExceptionPojo(cause);
- }
- }
-
- private static String messageFor(Throwable ex) {
- final String message = ex.getMessage();
- return message!=null?message:ex.getClass().getName();
- }
-
- @SuppressWarnings("unused")
- public String getMessage() {
- return message;
- }
-
- @SuppressWarnings("unused")
- public List<String> getStackTrace() {
- return stackTrace;
- }
-
- @SuppressWarnings("unused")
- public ExceptionPojo getCausedBy() {
- return causedBy;
- }
- }
-
- static String jsonFor(Exception ex) {
- try {
- return JsonMapper.instance().write(ExceptionPojo.create(ex));
- } catch (Exception e) {
- // fallback
- return "{ \"exception\": \"" + ExceptionUtils.getFullStackTrace(ex) + "\" }";
- }
- }
-}
+
+@Provider
+public class RuntimeExceptionMapper implements ExceptionMapper<RuntimeException> {
+
+ @Override
+ public Response toResponse(final RuntimeException ex) {
+ final ResponseBuilder builder = Response.status(HttpStatusCode.INTERNAL_SERVER_ERROR.getJaxrsStatusType()).type(RestfulMediaType.APPLICATION_JSON_ERROR).entity(jsonFor(ex));
+ return builder.build();
+ }
+
+ private static class ExceptionPojo {
+
+ public static ExceptionPojo create(final Exception ex) {
+ return new ExceptionPojo(ex);
+ }
+
+ private static String format(final StackTraceElement stackTraceElement) {
+ return stackTraceElement.toString();
+ }
+
+ private final String message;
+ private final List<String> stackTrace = Lists.newArrayList();
+ private ExceptionPojo causedBy;
+
+ public ExceptionPojo(final Throwable ex) {
+ this.message = messageFor(ex);
+ final StackTraceElement[] stackTraceElements = ex.getStackTrace();
+ for (final StackTraceElement stackTraceElement : stackTraceElements) {
+ this.stackTrace.add(format(stackTraceElement));
+ }
+ final Throwable cause = ex.getCause();
+ if (cause != null && cause != ex) {
+ this.causedBy = new ExceptionPojo(cause);
+ }
+ }
+
+ private static String messageFor(final Throwable ex) {
+ final String message = ex.getMessage();
+ return message != null ? message : ex.getClass().getName();
+ }
+
+ @SuppressWarnings("unused")
+ public String getMessage() {
+ return message;
+ }
+
+ @SuppressWarnings("unused")
+ public List<String> getStackTrace() {
+ return stackTrace;
+ }
+
+ @SuppressWarnings("unused")
+ public ExceptionPojo getCausedBy() {
+ return causedBy;
+ }
+ }
+
+ static String jsonFor(final Exception ex) {
+ try {
+ return JsonMapper.instance().write(ExceptionPojo.create(ex));
+ } catch (final Exception e) {
+ // fallback
+ return "{ \"exception\": \"" + ExceptionUtils.getFullStackTrace(ex) + "\" }";
+ }
+ }
+}
Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/authentication/AuthenticationSessionStrategyBasicAuth.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/authentication/AuthenticationSessionStrategyBasicAuth.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/authentication/AuthenticationSessionStrategyBasicAuth.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/authentication/AuthenticationSessionStrategyBasicAuth.java Sun Jan 22 08:05:17 2012
@@ -34,7 +34,8 @@ import org.apache.isis.runtimes.dflt.run
import org.apache.isis.runtimes.dflt.webapp.auth.AuthenticationSessionStrategyAbstract;
/**
- * Implements the HTTP Basic Auth protocol; does not bind the {@link AuthenticationSession} onto the {@link HttpSession}.
+ * Implements the HTTP Basic Auth protocol; does not bind the
+ * {@link AuthenticationSession} onto the {@link HttpSession}.
*/
public class AuthenticationSessionStrategyBasicAuth extends AuthenticationSessionStrategyAbstract {
@@ -45,23 +46,23 @@ public class AuthenticationSessionStrate
final HttpServletRequest httpServletRequest = (HttpServletRequest) servletRequest;
final String authStr = httpServletRequest.getHeader("Authorization");
-
+
// value should be in the form:
// Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
- if(authStr == null || !authStr.startsWith("Basic ")) {
+ if (authStr == null || !authStr.startsWith("Basic ")) {
return null;
}
final String digest = authStr.substring(6);
-
+
final String userAndPassword = new String(new Base64().decode(digest.getBytes()));
final Matcher matcher = USER_AND_PASSWORD_REGEX.matcher(userAndPassword);
- if(!matcher.matches()) {
+ if (!matcher.matches()) {
return null;
}
-
+
final String user = matcher.group(1);
final String password = matcher.group(2);
-
+
final AuthenticationSession authSession = getAuthenticationManager().authenticate(new AuthenticationRequestPassword(user, password));
return authSession;
}
Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/authentication/AuthenticationSessionStrategyHeader.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/authentication/AuthenticationSessionStrategyHeader.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/authentication/AuthenticationSessionStrategyHeader.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/authentication/AuthenticationSessionStrategyHeader.java Sun Jan 22 08:05:17 2012
@@ -35,7 +35,8 @@ import com.google.common.base.Strings;
import com.google.common.collect.Lists;
/**
- * Implements a home-grown protocol, whereby the user id and roles are passed using custom headers.
+ * Implements a home-grown protocol, whereby the user id and roles are passed
+ * using custom headers.
*
* <p>
* Does not bind the {@link AuthenticationSession} onto the {@link HttpSession}.
@@ -57,7 +58,7 @@ public class AuthenticationSessionStrate
protected List<String> rolesFrom(final HttpServletRequest httpServletRequest) {
final String rolesStr = httpServletRequest.getHeader("isis.roles");
- if(rolesStr == null) {
+ if (rolesStr == null) {
return Collections.emptyList();
}
return Lists.newArrayList(Splitter.on(",").split(rolesStr));
Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/embedded/EmbeddedWebViewerJson.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/embedded/EmbeddedWebViewerJson.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/embedded/EmbeddedWebViewerJson.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/embedded/EmbeddedWebViewerJson.java Sun Jan 22 08:05:17 2012
@@ -40,9 +40,7 @@ final class EmbeddedWebViewerJson extend
webAppSpec.addServletContextListener(ResteasyBootstrap.class);
- webAppSpec.addFilterSpecification(IsisSessionFilter.class, MapUtils.asMap(
- IsisSessionFilter.AUTHENTICATION_SESSION_STRATEGY_KEY,
- AuthenticationSessionStrategyTrusted.class.getName()), JsonViewerInstaller.EVERYTHING);
+ webAppSpec.addFilterSpecification(IsisSessionFilter.class, MapUtils.asMap(IsisSessionFilter.AUTHENTICATION_SESSION_STRATEGY_KEY, AuthenticationSessionStrategyTrusted.class.getName()), JsonViewerInstaller.EVERYTHING);
webAppSpec.addServletSpecification(HttpServletDispatcher.class, JsonViewerInstaller.ROOT);
webAppSpec.addFilterSpecification(ResourceCachingFilter.class, JsonViewerInstaller.STATIC_CONTENT);
Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/embedded/JsonViewerInstaller.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/embedded/JsonViewerInstaller.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/embedded/JsonViewerInstaller.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/embedded/JsonViewerInstaller.java Sun Jan 22 08:05:17 2012
@@ -24,12 +24,13 @@ import org.apache.isis.runtimes.dflt.run
import org.apache.isis.runtimes.dflt.runtime.viewer.web.WebAppSpecification;
/**
- * Convenience implementation of a {@link IsisViewer} providing the ability to configured for the JSON viewer from
- * the {@link Isis command line} using <tt>--viewer restful</tt> command line option.
+ * Convenience implementation of a {@link IsisViewer} providing the ability to
+ * configured for the JSON viewer from the {@link Isis command line} using
+ * <tt>--viewer restful</tt> command line option.
*
* <p>
- * In a production deployment the configuration represented by the {@link WebAppSpecification} would be specified in the
- * <tt>web.xml<tt> file.
+ * In a production deployment the configuration represented by the
+ * {@link WebAppSpecification} would be specified in the <tt>web.xml<tt> file.
*/
public class JsonViewerInstaller extends IsisViewerInstallerAbstract {
Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/GraphUtil.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/GraphUtil.java?rev=1234460&r1=1234459&r2=1234460&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/GraphUtil.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/GraphUtil.java Sun Jan 22 08:05:17 2012
@@ -16,8 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.isis.viewer.json.viewer.representations;
-
+package org.apache.isis.viewer.json.viewer.representations;
+
import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -25,35 +25,36 @@ import java.util.Map;
import org.apache.isis.viewer.json.applib.util.PathNode;
import com.google.common.collect.Maps;
-
-@SuppressWarnings({"rawtypes","unchecked"})
-public final class GraphUtil {
-
- private GraphUtil(){}
-
- public final static Map<PathNode,Map> asGraph(List<List<String>> links) {
- if(links == null) {
- return Collections.emptyMap();
- }
- final Map<PathNode, Map> map = Maps.newHashMap();
- for (List<String> link : links) {
- GraphUtil.mergeInto(link, map);
- }
- return map;
- }
-
- private static void mergeInto(List<String> list, Map<PathNode, Map> map) {
- if(list.size() == 0) {
- return;
- }
- final String str = list.get(0);
- final PathNode node = PathNode.parse(str);
- Map<PathNode,Map> submap = map.get(node);
- if(submap == null) {
- submap = Maps.newHashMap();
- map.put(node, submap);
- }
- mergeInto(list.subList(1, list.size()), submap);
- }
-
-}
+
+@SuppressWarnings({ "rawtypes", "unchecked" })
+public final class GraphUtil {
+
+ private GraphUtil() {
+ }
+
+ public final static Map<PathNode, Map> asGraph(final List<List<String>> links) {
+ if (links == null) {
+ return Collections.emptyMap();
+ }
+ final Map<PathNode, Map> map = Maps.newHashMap();
+ for (final List<String> link : links) {
+ GraphUtil.mergeInto(link, map);
+ }
+ return map;
+ }
+
+ private static void mergeInto(final List<String> list, final Map<PathNode, Map> map) {
+ if (list.size() == 0) {
+ return;
+ }
+ final String str = list.get(0);
+ final PathNode node = PathNode.parse(str);
+ Map<PathNode, Map> submap = map.get(node);
+ if (submap == null) {
+ submap = Maps.newHashMap();
+ map.put(node, submap);
+ }
+ mergeInto(list.subList(1, list.size()), submap);
+ }
+
+}