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 2011/06/26 13:51:10 UTC
svn commit: r1139763 [7/10] - in /incubator/isis/trunk/viewer: json/
json/applib2/ json/applib2/src/ json/applib2/src/main/
json/applib2/src/main/java/ json/applib2/src/main/java/META-INF/
json/applib2/src/main/java/org/ json/applib2/src/main/java/org/...
Added: incubator/isis/trunk/viewer/xhtml/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/xhtml/src/site/apt/index.apt?rev=1139763&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/xhtml/src/site/apt/index.apt (added)
+++ incubator/isis/trunk/viewer/xhtml/src/site/apt/index.apt Sun Jun 26 11:51:01 2011
@@ -0,0 +1,53 @@
+~~ 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.
+
+
+Restful Viewer
+
+ The <restful> viewer provides a RESTful interface to the domain object model,
+ running over the HTTP protocol, and implemented as a webapp (servlet).
+
+ Each domain object (or part of object) is exposed as a RESTful resource, as
+ defined by the following table:
+
+*-----------------+------------------+------------------+------------------+------------------+
+|Method \ Resource|Object |Property |Collection |Action |
+*-----------------+------------------+------------------+------------------+------------------+
+|GET |List all property |n/a |List all objects |n/a |
+| |values for object | |in collection | |
+*-----------------+------------------+------------------+------------------+------------------+
+|PUT |Add new object |Set value |Add object into |n/a |
+| | | |collection | |
+*-----------------+------------------+------------------+------------------+------------------+
+|DELETE |Delete |Clear value |Remove object |n/a |
+| |existing object | |collection | |
+*-----------------+------------------+------------------+------------------+------------------+
+|POST | | | |Invoke |
+*-----------------+------------------+------------------+------------------+------------------+
+
+
+Representation
+
+ The viewer currently represents all domain object as XHTML, meaning that it can be rendered by
+ browers. This XHTML also serves up a small amount of JavaScript which enables the HTTP PUT
+ and HTTP DELETE methods. This allows the developer to interact with the system through
+ the browser.
+
+Further Info
+
+ See this module's {{{./apidocs/index.html}Javadoc}} and the {{{./docbkx/html/guide/isis-restful-viewer.html}user guide}} for more information.
+
Added: incubator/isis/trunk/viewer/xhtml/src/site/apt/jottings.apt
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/xhtml/src/site/apt/jottings.apt?rev=1139763&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/xhtml/src/site/apt/jottings.apt (added)
+++ incubator/isis/trunk/viewer/xhtml/src/site/apt/jottings.apt Sun Jun 26 11:51:01 2011
@@ -0,0 +1,24 @@
+~~ 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.
+
+
+
+Jottings
+
+ This page is to capture any random jottings relating to this module prior
+ to being moved into formal documentation.
+
Added: incubator/isis/trunk/viewer/xhtml/src/site/site.xml
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/xhtml/src/site/site.xml?rev=1139763&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/xhtml/src/site/site.xml (added)
+++ incubator/isis/trunk/viewer/xhtml/src/site/site.xml Sun Jun 26 11:51:01 2011
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<project name="${project.name}">
+ <version position="right"/>
+
+ <body>
+ <breadcrumbs>
+ <item name="XHTML" href="index.html"/>
+ </breadcrumbs>
+
+ <menu name="XHTML Viewer">
+ <item name="About" href="index.html" />
+ <item name="Jottings" href="jottings.html" />
+ </menu>
+
+ <menu name="Viewer Modules">
+ <item name="DnD" href="../dnd/index.html" />
+ <item name="HTML" href="../html/index.html" />
+ <item name="Scimpi" href="../scimpi/index.html" />
+ <item name="Wicket" href="../wicket/index.html" />
+ <item name="XHTML" href="../xhtml/index.html" />
+ <item name="JSON" href="../json/index.html" />
+ <item name="JUnit Support" href="../junit/index.html" />
+ <item name="BDD Integration" href="../bdd/index.html" />
+ </menu>
+
+ <menu name="Restful Modules">
+ <item name="Applib" href="./applib/index.html" />
+ <item name="Viewer" href="./viewer/index.html" />
+ </menu>
+
+ <menu name="Documentation">
+ <item name="${docbkxGuideTitle} (PDF)" href="docbkx/pdf/${docbkxGuideName}.pdf" />
+ <item name="${docbkxGuideTitle} (HTML)" href="docbkx/html/guide/${docbkxGuideName}.html" />
+ </menu>
+
+ <menu name="Maven Reports" ref="reports" />
+ </body>
+
+</project>
Added: incubator/isis/trunk/viewer/xhtml/viewer/NOTICE
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/xhtml/viewer/NOTICE?rev=1139763&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/xhtml/viewer/NOTICE (added)
+++ incubator/isis/trunk/viewer/xhtml/viewer/NOTICE Sun Jun 26 11:51:01 2011
@@ -0,0 +1,7 @@
+Apache Isis
+Copyright 2010-2011 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+
Added: incubator/isis/trunk/viewer/xhtml/viewer/pom.xml
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/xhtml/viewer/pom.xml?rev=1139763&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/xhtml/viewer/pom.xml (added)
+++ incubator/isis/trunk/viewer/xhtml/viewer/pom.xml Sun Jun 26 11:51:01 2011
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.isis.viewer</groupId>
+ <artifactId>restful</artifactId>
+ <version>0.1.2-incubating-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>restful-viewer</artifactId>
+ <name>Restful Viewer Implementation</name>
+
+ <properties>
+ <siteBaseDir>../../..</siteBaseDir>
+ <relativeUrl>viewer/restful/viewer/</relativeUrl>
+ </properties>
+
+ <!-- used in Site generation for relative references. -->
+ <url>http://incubator.apache.org/isis/${relativeUrl}</url>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.isis.viewer</groupId>
+ <artifactId>restful-applib</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.isis</groupId>
+ <artifactId>applib</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.isis.core</groupId>
+ <artifactId>webapp</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.isis.runtimes.dflt</groupId>
+ <artifactId>webapp</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-jaxrs</artifactId>
+ </dependency>
+
+ <!-- the javax:* equivalents of these are excluded in
+ dependencyManagement of resteasy-jaxrs, so
+ are required here -->
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-servlet_2.5_spec</artifactId>
+ <version>1.2</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-annotation_1.0_spec</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-activation_1.1_spec</artifactId>
+ <version>1.1</version>
+ </dependency>
+
+ </dependencies>
+</project>
Added: incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/AbstractJaxRsApplication.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/AbstractJaxRsApplication.java?rev=1139763&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/AbstractJaxRsApplication.java (added)
+++ incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/AbstractJaxRsApplication.java Sun Jun 26 11:51:01 2011
@@ -0,0 +1,53 @@
+/*
+ * 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.restful.viewer;
+
+import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import javax.ws.rs.core.Application;
+
+public abstract class AbstractJaxRsApplication extends Application {
+
+ private final Set<Object> singletons = new LinkedHashSet<Object>();
+ private final Set<Class<?>> classes = new LinkedHashSet<Class<?>>();
+
+ public AbstractJaxRsApplication() {
+ }
+
+ @Override
+ public Set<Class<?>> getClasses() {
+ return Collections.unmodifiableSet(classes);
+ }
+
+ @Override
+ public Set<Object> getSingletons() {
+ return Collections.unmodifiableSet(singletons);
+ }
+
+ protected boolean addClass(final Class<?> cls) {
+ return classes.add(cls);
+ }
+
+ protected boolean addSingleton(final Object resource) {
+ return singletons.add(resource);
+ }
+
+}
\ No newline at end of file
Added: incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/Constants.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/Constants.java?rev=1139763&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/Constants.java (added)
+++ incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/Constants.java Sun Jun 26 11:51:01 2011
@@ -0,0 +1,37 @@
+/*
+ * 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.restful.viewer;
+
+import org.apache.isis.runtimes.dflt.runtime.system.SystemConstants;
+
+public final class Constants {
+
+ public static final String VIEWER_PREFIX_KEY = SystemConstants.VIEWER_KEY + ".restful";
+ public static final String JAVASCRIPT_DEBUG_KEY = VIEWER_PREFIX_KEY + ".javascript-debug";
+
+ 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.restful.applib.Constants.URL_ENCODING_CHAR_SET;
+
+ private Constants() {
+ }
+
+}
Added: incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/RestfulApplication.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/RestfulApplication.java?rev=1139763&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/RestfulApplication.java (added)
+++ incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/RestfulApplication.java Sun Jun 26 11:51:01 2011
@@ -0,0 +1,40 @@
+/*
+ * 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.restful.viewer;
+
+import org.apache.isis.viewer.restful.applib.providers.StringApplicationXhtmlXmlProvider;
+import org.apache.isis.viewer.restful.viewer.resources.HomePageResourceImpl;
+import org.apache.isis.viewer.restful.viewer.resources.objects.ObjectResourceImpl;
+import org.apache.isis.viewer.restful.viewer.resources.services.ServicesResourceImpl;
+import org.apache.isis.viewer.restful.viewer.resources.specs.SpecsResourceImpl;
+import org.apache.isis.viewer.restful.viewer.resources.user.UserResourceImpl;
+
+public class RestfulApplication extends AbstractJaxRsApplication {
+
+ public RestfulApplication() {
+ addSingleton(new HomePageResourceImpl());
+ addSingleton(new ObjectResourceImpl());
+ addSingleton(new ServicesResourceImpl());
+ addSingleton(new SpecsResourceImpl());
+ addSingleton(new UserResourceImpl());
+
+ addClass(StringApplicationXhtmlXmlProvider.class);
+ }
+
+}
Added: incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/authentication/AuthenticationSessionLookupStrategyParams.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/authentication/AuthenticationSessionLookupStrategyParams.java?rev=1139763&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/authentication/AuthenticationSessionLookupStrategyParams.java (added)
+++ incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/authentication/AuthenticationSessionLookupStrategyParams.java Sun Jun 26 11:51:01 2011
@@ -0,0 +1,51 @@
+/*
+ * 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.restful.viewer.authentication;
+
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.runtime.authentication.AuthenticationRequestPassword;
+import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
+import org.apache.isis.runtimes.dflt.webapp.auth.AuthenticationSessionLookupStrategyDefault;
+
+import com.google.common.base.Strings;
+
+public class AuthenticationSessionLookupStrategyParams extends AuthenticationSessionLookupStrategyDefault {
+
+ @Override
+ public AuthenticationSession lookup(final ServletRequest servletRequest, final ServletResponse servletResponse) {
+ final AuthenticationSession session = super.lookup(servletRequest, servletResponse);
+ if (session != null) {
+ return session;
+ }
+
+ final HttpServletRequest httpServletRequest = (HttpServletRequest) servletRequest;
+ final String user = httpServletRequest.getParameter("user");
+ final String password = httpServletRequest.getParameter("password");
+
+ if (Strings.isNullOrEmpty(user) || Strings.isNullOrEmpty(password)) {
+ return null;
+ }
+ final AuthenticationRequestPassword request = new AuthenticationRequestPassword(user, password);
+ return IsisContext.getAuthenticationManager().authenticate(request);
+ }
+}
Added: incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/authentication/AuthenticationSessionLookupStrategyTrusted.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/authentication/AuthenticationSessionLookupStrategyTrusted.java?rev=1139763&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/authentication/AuthenticationSessionLookupStrategyTrusted.java (added)
+++ incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/authentication/AuthenticationSessionLookupStrategyTrusted.java Sun Jun 26 11:51:01 2011
@@ -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.restful.viewer.authentication;
+
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.runtimes.dflt.runtime.authentication.exploration.AuthenticationRequestExploration;
+import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
+import org.apache.isis.runtimes.dflt.webapp.auth.AuthenticationSessionLookupStrategyDefault;
+
+public class AuthenticationSessionLookupStrategyTrusted extends AuthenticationSessionLookupStrategyDefault {
+
+ @Override
+ public AuthenticationSession lookup(final ServletRequest servletRequest, final ServletResponse servletResponse) {
+ final AuthenticationSession session = super.lookup(servletRequest, servletResponse);
+ if (session != null) {
+ return session;
+ }
+
+ // will always succeed.
+ final AuthenticationRequestExploration request = new AuthenticationRequestExploration();
+ return IsisContext.getAuthenticationManager().authenticate(request);
+ }
+}
Added: incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/embedded/EmbeddedWebViewerRestful.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/embedded/EmbeddedWebViewerRestful.java?rev=1139763&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/embedded/EmbeddedWebViewerRestful.java (added)
+++ incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/embedded/EmbeddedWebViewerRestful.java Sun Jun 26 11:51:01 2011
@@ -0,0 +1,53 @@
+/*
+ * 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.restful.viewer.embedded;
+
+import org.apache.isis.core.commons.lang.MapUtils;
+import org.apache.isis.core.webapp.content.ResourceServlet;
+import org.apache.isis.core.webapp.content.ResourceCachingFilter;
+import org.apache.isis.runtimes.dflt.runtime.viewer.web.WebAppSpecification;
+import org.apache.isis.runtimes.dflt.runtime.web.EmbeddedWebViewer;
+import org.apache.isis.runtimes.dflt.webapp.IsisSessionFilter;
+import org.apache.isis.viewer.restful.viewer.RestfulApplication;
+import org.apache.isis.viewer.restful.viewer.authentication.AuthenticationSessionLookupStrategyTrusted;
+import org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher;
+import org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap;
+
+final class EmbeddedWebViewerRestful extends EmbeddedWebViewer {
+ @Override
+ public WebAppSpecification getWebAppSpecification() {
+ final WebAppSpecification webAppSpec = new WebAppSpecification();
+
+ webAppSpec.addContextParams("isis.viewers", "restful");
+
+ webAppSpec.addContextParams(RestfulViewerInstaller.JAVAX_WS_RS_APPLICATION, RestfulApplication.class.getName());
+
+ webAppSpec.addServletContextListener(ResteasyBootstrap.class);
+
+ webAppSpec.addFilterSpecification(IsisSessionFilter.class, MapUtils.asMap(
+ IsisSessionFilter.AUTHENTICATION_SESSION_LOOKUP_STRATEGY_KEY,
+ AuthenticationSessionLookupStrategyTrusted.class.getName()), RestfulViewerInstaller.EVERYTHING);
+ webAppSpec.addServletSpecification(HttpServletDispatcher.class, RestfulViewerInstaller.ROOT);
+
+ webAppSpec.addFilterSpecification(ResourceCachingFilter.class, RestfulViewerInstaller.STATIC_CONTENT);
+ webAppSpec.addServletSpecification(ResourceServlet.class, RestfulViewerInstaller.STATIC_CONTENT);
+
+ return webAppSpec;
+ }
+}
\ No newline at end of file
Added: incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/embedded/RestfulViewerInstaller.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/embedded/RestfulViewerInstaller.java?rev=1139763&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/embedded/RestfulViewerInstaller.java (added)
+++ incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/embedded/RestfulViewerInstaller.java Sun Jun 26 11:51:01 2011
@@ -0,0 +1,51 @@
+/*
+ * 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.restful.viewer.embedded;
+
+import org.apache.isis.Isis;
+import org.apache.isis.runtimes.dflt.runtime.installerregistry.installerapi.IsisViewerInstallerAbstract;
+import org.apache.isis.runtimes.dflt.runtime.viewer.IsisViewer;
+import org.apache.isis.runtimes.dflt.runtime.viewer.web.WebAppSpecification;
+
+/**
+ * Convenience implementation of a {@link IsisViewer} providing the ability to configured for the Restful 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.
+ */
+public class RestfulViewerInstaller extends IsisViewerInstallerAbstract {
+
+ static final String JAVAX_WS_RS_APPLICATION = "javax.ws.rs.Application";
+
+ protected static final String EVERYTHING = "*";
+ protected static final String ROOT = "/";
+ protected static final String[] STATIC_CONTENT = new String[] { "*.js", "*.gif", "*.png" };
+
+ public RestfulViewerInstaller() {
+ super("restful");
+ }
+
+ @Override
+ protected IsisViewer doCreateViewer() {
+ return new EmbeddedWebViewerRestful();
+ }
+
+}
Added: incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/facets/TableColumnFacet.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/facets/TableColumnFacet.java?rev=1139763&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/facets/TableColumnFacet.java (added)
+++ incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/facets/TableColumnFacet.java Sun Jun 26 11:51:01 2011
@@ -0,0 +1,34 @@
+/*
+ * 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.restful.viewer.facets;
+
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.viewer.restful.viewer.xom.ResourceContext;
+import org.apache.isis.viewer.restful.viewer.xom.TableColumnAbstract;
+
+public abstract class TableColumnFacet extends TableColumnAbstract<Facet> {
+
+ TableColumnFacet(final String headerText, final ResourceContext resourceContext) {
+ super(headerText, resourceContext);
+ }
+
+}
Added: incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/facets/TableColumnFacetDisabling.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/facets/TableColumnFacetDisabling.java?rev=1139763&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/facets/TableColumnFacetDisabling.java (added)
+++ incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/facets/TableColumnFacetDisabling.java Sun Jun 26 11:51:01 2011
@@ -0,0 +1,35 @@
+/*
+ * 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.restful.viewer.facets;
+
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.interactions.DisablingInteractionAdvisor;
+import org.apache.isis.viewer.restful.viewer.tree.Element;
+import org.apache.isis.viewer.restful.viewer.xom.ResourceContext;
+
+public final class TableColumnFacetDisabling extends TableColumnFacet {
+ public TableColumnFacetDisabling(final ResourceContext resourceContext) {
+ super("Disabling", resourceContext);
+ }
+
+ @Override
+ public Element doTd(final Facet facet) {
+ return xhtmlRenderer.p(facet instanceof DisablingInteractionAdvisor, null);
+ }
+}
Added: incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/facets/TableColumnFacetFacetType.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/facets/TableColumnFacetFacetType.java?rev=1139763&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/facets/TableColumnFacetFacetType.java (added)
+++ incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/facets/TableColumnFacetFacetType.java Sun Jun 26 11:51:01 2011
@@ -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.restful.viewer.facets;
+
+import java.text.MessageFormat;
+
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.viewer.restful.viewer.html.HtmlClass;
+import org.apache.isis.viewer.restful.viewer.tree.Element;
+import org.apache.isis.viewer.restful.viewer.xom.ResourceContext;
+
+public final class TableColumnFacetFacetType extends TableColumnFacet {
+ private final String pathPrefix;
+
+ public TableColumnFacetFacetType(final String pathPrefix, final ResourceContext resourceContext) {
+ super("FacetType", resourceContext);
+ this.pathPrefix = pathPrefix;
+ }
+
+ @Override
+ public Element doTd(final Facet facet) {
+ final String facetTypeCanonicalName = facet.facetType().getCanonicalName();
+ final String uri = MessageFormat.format("{0}/facet/{1}", pathPrefix, facetTypeCanonicalName);
+ return new Element(xhtmlRenderer.aHref(uri, facetTypeCanonicalName, "facet", "spec", HtmlClass.FACET));
+ }
+}
Added: incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/facets/TableColumnFacetHiding.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/facets/TableColumnFacetHiding.java?rev=1139763&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/facets/TableColumnFacetHiding.java (added)
+++ incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/facets/TableColumnFacetHiding.java Sun Jun 26 11:51:01 2011
@@ -0,0 +1,35 @@
+/*
+ * 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.restful.viewer.facets;
+
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.interactions.HidingInteractionAdvisor;
+import org.apache.isis.viewer.restful.viewer.tree.Element;
+import org.apache.isis.viewer.restful.viewer.xom.ResourceContext;
+
+public final class TableColumnFacetHiding extends TableColumnFacet {
+ public TableColumnFacetHiding(final ResourceContext resourceContext) {
+ super("Hiding", resourceContext);
+ }
+
+ @Override
+ public Element doTd(final Facet facet) {
+ return xhtmlRenderer.p(facet instanceof HidingInteractionAdvisor, null);
+ }
+}
Added: incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/facets/TableColumnFacetImplementation.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/facets/TableColumnFacetImplementation.java?rev=1139763&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/facets/TableColumnFacetImplementation.java (added)
+++ incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/facets/TableColumnFacetImplementation.java Sun Jun 26 11:51:01 2011
@@ -0,0 +1,35 @@
+/*
+ * 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.restful.viewer.facets;
+
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.viewer.restful.viewer.tree.Element;
+import org.apache.isis.viewer.restful.viewer.xom.ResourceContext;
+
+public final class TableColumnFacetImplementation extends TableColumnFacet {
+
+ public TableColumnFacetImplementation(final ResourceContext resourceContext) {
+ super("Implementation", resourceContext);
+ }
+
+ @Override
+ public Element doTd(final Facet facet) {
+ return xhtmlRenderer.p(facet.getClass().getCanonicalName(), null);
+ }
+}
Added: incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/facets/TableColumnFacetIsImperative.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/facets/TableColumnFacetIsImperative.java?rev=1139763&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/facets/TableColumnFacetIsImperative.java (added)
+++ incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/facets/TableColumnFacetIsImperative.java Sun Jun 26 11:51:01 2011
@@ -0,0 +1,35 @@
+/*
+ * 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.restful.viewer.facets;
+
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facets.ImperativeFacetUtils;
+import org.apache.isis.viewer.restful.viewer.tree.Element;
+import org.apache.isis.viewer.restful.viewer.xom.ResourceContext;
+
+public final class TableColumnFacetIsImperative extends TableColumnFacet {
+ public TableColumnFacetIsImperative(final String headerText, final ResourceContext resourceContext) {
+ super(headerText, resourceContext);
+ }
+
+ @Override
+ public Element doTd(final Facet facet) {
+ return xhtmlRenderer.p(ImperativeFacetUtils.isImperativeFacet(facet), null);
+ }
+}
Added: incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/facets/TableColumnFacetValidating.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/facets/TableColumnFacetValidating.java?rev=1139763&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/facets/TableColumnFacetValidating.java (added)
+++ incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/facets/TableColumnFacetValidating.java Sun Jun 26 11:51:01 2011
@@ -0,0 +1,35 @@
+/*
+ * 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.restful.viewer.facets;
+
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.interactions.ValidatingInteractionAdvisor;
+import org.apache.isis.viewer.restful.viewer.tree.Element;
+import org.apache.isis.viewer.restful.viewer.xom.ResourceContext;
+
+public final class TableColumnFacetValidating extends TableColumnFacet {
+ public TableColumnFacetValidating(final ResourceContext resourceContext) {
+ super("Validating", resourceContext);
+ }
+
+ @Override
+ public Element doTd(final Facet facet) {
+ return xhtmlRenderer.p(facet instanceof ValidatingInteractionAdvisor, null);
+ }
+}
Added: incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/html/HtmlClass.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/html/HtmlClass.java?rev=1139763&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/html/HtmlClass.java (added)
+++ incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/html/HtmlClass.java Sun Jun 26 11:51:01 2011
@@ -0,0 +1,62 @@
+/*
+ * 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.restful.viewer.html;
+
+public final class HtmlClass {
+
+ public static final String SECTION = "isis-section";
+
+ public static final String FACETS = "isis-facets";
+ public static final String FACET = "isis-facet";
+ public static final String FACET_ELEMENTS = "isis-facet-elements";
+ public static final String FACET_ELEMENT = "isis-facet-element";
+
+ public static final String SPECIFICATIONS = "isis-specifications";
+ public static final String SPECIFICATION = "isis-specification";
+ public static final String PROPERTIES = "isis-properties";
+ public static final String PROPERTY = "isis-property";
+ public static final String COLLECTIONS = "isis-collections";
+ public static final String COLLECTION = "isis-collection";
+ public static final String ACTIONS = "isis-actions";
+ public static final String ACTION = "isis-action";
+ public static final String SERVICES = "isis-services";
+ public static final String SERVICE = "isis-service";
+ public static final String RESOURCES = "isis-resources";
+ public static final String RESOURCE = "isis-resource";
+
+ public static final String SESSION = "isis-session";
+ public static final String USER = "isis-user";
+ public static final String ROLES = "isis-roles";
+ public static final String ROLE = "isis-role";
+
+ public static final String TITLE = "isis-title";
+ public static final String OBJECT = "isis-object";
+ public static final String OID = "isis-oid";
+ public static final String ACTION_RESULT = "isis-action-result";
+
+ public static final String VISIBLE = "isis-visible";
+ public static final String USABLE = "isis-usable";
+ public static final String VALID = "isis-valid";
+
+ public static final String OBJECT_SPECS = "isis-object-specs";
+
+ private HtmlClass() {
+ }
+
+}
Added: incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/html/Xhtml.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/html/Xhtml.java?rev=1139763&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/html/Xhtml.java (added)
+++ incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/html/Xhtml.java Sun Jun 26 11:51:01 2011
@@ -0,0 +1,28 @@
+/*
+ * 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.restful.viewer.html;
+
+public final class Xhtml {
+
+ public static final String NAMESPACE = "http://www.w3.org/1999/xhtml";
+
+ private Xhtml() {
+ }
+
+}
Added: incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/html/XhtmlTemplate.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/html/XhtmlTemplate.java?rev=1139763&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/html/XhtmlTemplate.java (added)
+++ incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/html/XhtmlTemplate.java Sun Jun 26 11:51:01 2011
@@ -0,0 +1,109 @@
+/*
+ * 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.restful.viewer.html;
+
+import java.io.IOException;
+import java.io.StringWriter;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.isis.viewer.restful.viewer.tree.Attribute;
+import org.apache.isis.viewer.restful.viewer.tree.Element;
+import org.jdom.output.XMLOutputter;
+
+
+/**
+ * TODO: add in support for base URI in generated XML docs?
+ */
+public class XhtmlTemplate {
+
+ private final Element html;
+ private Element head;
+ private Element body;
+
+ public XhtmlTemplate(final String titleStr, final HttpServletRequest servletRequest,
+ final String... javaScriptFiles) {
+ this(titleStr, servletRequest.getSession().getServletContext(), javaScriptFiles);
+ }
+
+ private XhtmlTemplate(final String titleStr, final ServletContext servletContext, final String... javaScriptFiles) {
+ this.html = new Element("html");
+ addHeadAndTitle(titleStr);
+ for (final String javaScriptFile : javaScriptFiles) {
+ final Element script = new Element("script");
+ script.addAttribute(new Attribute("type", "text/javascript"));
+ script.addAttribute(new Attribute("src", "/" + javaScriptFile));
+ script.appendChild(""); // force the </script> to be separate.
+ head.appendChild(script);
+ }
+ addBody();
+ }
+
+ private void addHeadAndTitle(final String titleStr) {
+ head = new Element("head");
+ html.appendChild(head);
+ final Element title = new Element("title");
+ title.appendChild(titleStr);
+ head.appendChild(title);
+ }
+
+ /**
+ * Adds a <body id="body"> element.
+ *
+ * <p>
+ * The <tt>id</tt> attribute is so that Javascript can use <tt>document.getElementById("body");</tt>
+ *
+ */
+ private void addBody() {
+ body = new Element("body");
+ body.addAttribute(new Attribute("id", "body"));
+ html.appendChild(body);
+ }
+
+ public XhtmlTemplate appendToBody(final Element... elements) {
+ for (final Element element : elements) {
+ body.appendChild(element);
+ }
+ return this;
+ }
+
+ public void appendToDiv(final Element div, final Element... elements) {
+ for (final Element element : elements) {
+ div.appendChild(element);
+ }
+ }
+
+ public String toXML() {
+ return xmlUsingToXmlMethod();
+ }
+
+ private String xmlUsingToXmlMethod() {
+ org.jdom.Document document = new org.jdom.Document(html.xmlElement);
+ StringWriter sw = new StringWriter();
+ XMLOutputter xmlOutputter = new XMLOutputter();
+ try {
+ xmlOutputter.output(document, sw);
+ return sw.toString();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+}
Added: incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/HomePageResourceImpl.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/HomePageResourceImpl.java?rev=1139763&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/HomePageResourceImpl.java (added)
+++ incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/HomePageResourceImpl.java Sun Jun 26 11:51:01 2011
@@ -0,0 +1,47 @@
+/*
+ * 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.restful.viewer.resources;
+
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.apache.isis.viewer.restful.applib.resources.HomePageResource;
+import org.apache.isis.viewer.restful.viewer.html.XhtmlTemplate;
+
+/**
+ * Implementation note: it seems to be necessary to annotate the implementation with {@link Path} rather than the
+ * interface (at least under RestEasy 1.0.2 and 1.1-RC2).
+ */
+@Path("/")
+public class HomePageResourceImpl extends ResourceAbstract implements HomePageResource {
+
+ @Override
+ @Produces(MediaType.APPLICATION_XHTML_XML)
+ public String resources() {
+ init();
+ final XhtmlTemplate xhtml = new XhtmlTemplate("Home Page", getServletRequest());
+
+ xhtml.appendToBody(asDivIsisSession());
+ xhtml.appendToBody(resourcesDiv());
+
+ return xhtml.toXML();
+ }
+
+}
\ No newline at end of file
Added: incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/ResourceAbstract.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/ResourceAbstract.java?rev=1139763&view=auto
==============================================================================
--- incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/ResourceAbstract.java (added)
+++ incubator/isis/trunk/viewer/xhtml/viewer/src/main/java/org/apache/isis/viewer/restful/viewer/resources/ResourceAbstract.java Sun Jun 26 11:51:01 2011
@@ -0,0 +1,322 @@
+/*
+ * 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.restful.viewer.resources;
+
+import java.beans.BeanInfo;
+import java.beans.IntrospectionException;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.Request;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+import javax.ws.rs.core.SecurityContext;
+import javax.ws.rs.core.UriInfo;
+
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.commons.lang.CastUtils;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.oid.stringable.OidStringifier;
+import org.apache.isis.core.metamodel.consent.Consent;
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FacetFilters;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.spec.ActionType;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.SpecificationLoader;
+import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
+import org.apache.isis.runtimes.dflt.runtime.system.persistence.AdapterManager;
+import org.apache.isis.runtimes.dflt.runtime.system.persistence.OidGenerator;
+import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceSession;
+import org.apache.isis.viewer.restful.viewer.facets.TableColumnFacetDisabling;
+import org.apache.isis.viewer.restful.viewer.facets.TableColumnFacetFacetType;
+import org.apache.isis.viewer.restful.viewer.facets.TableColumnFacetHiding;
+import org.apache.isis.viewer.restful.viewer.facets.TableColumnFacetImplementation;
+import org.apache.isis.viewer.restful.viewer.facets.TableColumnFacetValidating;
+import org.apache.isis.viewer.restful.viewer.html.HtmlClass;
+import org.apache.isis.viewer.restful.viewer.tree.Attribute;
+import org.apache.isis.viewer.restful.viewer.tree.Element;
+import org.apache.isis.viewer.restful.viewer.util.OidUtils;
+import org.apache.isis.viewer.restful.viewer.xom.DtDd;
+import org.apache.isis.viewer.restful.viewer.xom.ElementBuilder;
+import org.apache.isis.viewer.restful.viewer.xom.ResourceContext;
+import org.apache.isis.viewer.restful.viewer.xom.TableColumn;
+import org.apache.isis.viewer.restful.viewer.xom.XhtmlRenderer;
+
+public abstract class ResourceAbstract {
+
+ public final static ActionType[] ACTION_TYPES = { ActionType.USER, ActionType.DEBUG, ActionType.EXPLORATION,
+ // SET is excluded; we simply flatten contributed actions.
+ };
+
+ protected final XhtmlRenderer xhtmlRenderer;
+ protected final ElementBuilder elementBuilder;
+
+ @Context
+ HttpHeaders httpHeaders;
+
+ @Context
+ UriInfo uriInfo;
+
+ @Context
+ Request request;
+
+ @Context
+ HttpServletRequest httpServletRequest;
+
+ @Context
+ HttpServletResponse httpServletResponse;
+
+ @Context
+ SecurityContext securityContext;
+
+ private ResourceContext resourceContext;
+
+ protected ResourceAbstract() {
+ this.xhtmlRenderer = new XhtmlRenderer();
+ this.elementBuilder = new ElementBuilder();
+ }
+
+ protected void init() {
+ this.resourceContext =
+ new ResourceContext(httpHeaders, uriInfo, request, httpServletRequest, httpServletResponse, securityContext);
+ }
+
+ protected ResourceContext getResourceContext() {
+ return resourceContext;
+ }
+
+ // //////////////////////////////////////////////////////////////
+ // Isis integration
+ // //////////////////////////////////////////////////////////////
+
+ protected static ObjectSpecification getSpecification(final String specFullName) {
+ return getSpecificationLoader().loadSpecification(specFullName);
+ }
+
+ protected ObjectAdapter getObjectAdapter(final String oidEncodedStr) {
+ return OidUtils.getNakedObject(oidEncodedStr, getOidStringifier());
+ }
+
+ protected String getOidStr(final ObjectAdapter nakedObject) {
+ return OidUtils.getOidStr(nakedObject, getOidStringifier());
+ }
+
+ // //////////////////////////////////////////////////////////////
+ // Rendering
+ // //////////////////////////////////////////////////////////////
+
+ protected Element asDivIsisSession() {
+ final Element div = xhtmlRenderer.div_p("Logged in as", null);
+
+ final Element ul = xhtmlRenderer.ul(HtmlClass.SESSION);
+ ul.appendChild(xhtmlRenderer.li_a("user", getSession().getUserName(), "user", "resource", HtmlClass.USER));
+ div.appendChild(ul);
+
+ return div;
+ }
+
+ protected Element resourcesDiv() {
+ final Element div = xhtmlRenderer.div_p("Resources", HtmlClass.SECTION);
+
+ final Element ul = xhtmlRenderer.ul(HtmlClass.RESOURCES);
+
+ ul.appendChild(xhtmlRenderer.li_a("services", "Services", "services", "resources", HtmlClass.RESOURCE));
+ ul.appendChild(xhtmlRenderer.li_a("specs", "Specifications (MetaModel)", "specs", "resources",
+ HtmlClass.RESOURCE));
+ ul.appendChild(xhtmlRenderer.li_a("user", "User (Security)", "user", "resources", HtmlClass.RESOURCE));
+
+ div.appendChild(ul);
+ return div;
+ }
+
+ protected Element div(final String htmlClassAttribute) {
+ return xhtmlRenderer.div(htmlClassAttribute);
+ }
+
+ protected Element asDivTableFacets(final FacetHolder facetHolder, final String pathPrefix) {
+ final Element div = xhtmlRenderer.div_p("Facets", HtmlClass.FACETS);
+ final List<Facet> rows = facetHolder.getFacets(FacetFilters.ANY);
+
+ final List<TableColumn<Facet>> columns = new ArrayList<TableColumn<Facet>>();
+ columns.add(new TableColumnFacetFacetType(pathPrefix, getResourceContext()));
+ columns.add(new TableColumnFacetImplementation(getResourceContext()));
+ columns.add(new TableColumnFacetHiding(getResourceContext()));
+ columns.add(new TableColumnFacetDisabling(getResourceContext()));
+ columns.add(new TableColumnFacetValidating(getResourceContext()));
+
+ final Element table = xhtmlRenderer.table(columns, rows, HtmlClass.FACETS);
+ div.appendChild(table);
+ return div;
+ }
+
+ public Element divFacetElements(final String facetTypeName, final FacetHolder facetHolder)
+ throws ClassNotFoundException, IntrospectionException, IllegalArgumentException, IllegalAccessException,
+ InvocationTargetException {
+ final Element div = xhtmlRenderer.div_p("Facet Elements", HtmlClass.FACET_ELEMENTS);
+ final Class<? extends Facet> facetType = CastUtils.cast(Class.forName(facetTypeName));
+ final Facet facet = facetHolder.getFacet(facetType);
+ final Class<? extends Facet> facetImplClass = facet.getClass();
+ final BeanInfo beanInfo = java.beans.Introspector.getBeanInfo(facetImplClass);
+ final PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
+ final Element dl = xhtmlRenderer.dl(HtmlClass.FACET_ELEMENTS);
+ for (final PropertyDescriptor descriptor : propertyDescriptors) {
+ final String name = descriptor.getName();
+ final Method readMethod = descriptor.getReadMethod();
+ if (readMethod != null) {
+ final Object value = readMethod.invoke(facet);
+ final String ddText = value != null ? value.toString() : "(null)";
+ final DtDd dt_dd = xhtmlRenderer.dt_dd(name, ddText, HtmlClass.FACET_ELEMENT);
+ dt_dd.appendTo(dl);
+ }
+ }
+ div.appendChild(dl);
+ return div;
+ }
+
+ protected Element asDivTableObjectDetails(final ObjectAdapter nakedObject) {
+
+ final ObjectSpecification noSpec = nakedObject.getSpecification();
+ final String oidStr = getOidStr(nakedObject);
+
+ final Element div = new Element("div");
+ div.addAttribute(new Attribute("class", HtmlClass.OBJECT_SPECS));
+ final Element table = new Element("table");
+ table.addAttribute(new Attribute("border", "1"));
+ div.appendChild(table);
+
+ Element value;
+
+ value = xhtmlRenderer.p(nakedObject.titleString(), null);
+ createRow(table, "Object title", value, HtmlClass.TITLE);
+
+ value =
+ xhtmlRenderer.aHref(MessageFormat.format("{0}/object/{1}", getServletRequest().getContextPath(), oidStr),
+ oidStr, "object", "object", HtmlClass.OID);
+ createRow(table, "OID", value, HtmlClass.OID);
+ final String noSpecFullName = noSpec.getFullIdentifier();
+
+ final String uri = MessageFormat.format("{0}/specs/{1}", getServletRequest().getContextPath(), noSpecFullName);
+ value = xhtmlRenderer.aHref(uri, noSpecFullName, "spec", "object", HtmlClass.SPECIFICATION);
+ createRow(table, "Specification", value, HtmlClass.SPECIFICATION);
+
+ return div;
+ }
+
+ private void createRow(final Element table, final String key, final Element value, final String htmlClassAttribute) {
+ Element tr;
+ Element td;
+ tr = new Element("tr");
+ table.appendChild(tr);
+
+ td = new Element("td");
+ td.appendChild(key);
+ tr.appendChild(td);
+
+ td = new Element("td");
+ td.appendChild(value);
+ td.addAttribute(new Attribute("class", htmlClassAttribute));
+ tr.appendChild(td);
+ }
+
+ // //////////////////////////////////////////////////////////////
+ // Responses
+ // //////////////////////////////////////////////////////////////
+
+ protected Response responseOfOk() {
+ return Response.ok().build();
+ }
+
+ protected Response responseOfGone(final String reason) {
+ return Response.status(Status.GONE).header("isis-reason", reason).build();
+ }
+
+ protected Response responseOfBadRequest(final Consent consent) {
+ return responseOfBadRequest(consent.getReason());
+ }
+
+ protected Response responseOfNoContent(final String reason) {
+ return Response.status(Status.NO_CONTENT).header("isis-reason", reason).build();
+ }
+
+ protected Response responseOfBadRequest(final String reason) {
+ return Response.status(Status.BAD_REQUEST).header("isis-reason", reason).build();
+ }
+
+ protected Response responseOfNotFound(final IllegalArgumentException e) {
+ return responseOfNotFound(e.getMessage());
+ }
+
+ protected Response responseOfNotFound(final String reason) {
+ return Response.status(Status.NOT_FOUND).header("isis-reason", reason).build();
+ }
+
+ protected Response responseOfInternalServerError(final Exception ex) {
+ return responseOfInternalServerError(ex.getMessage());
+ }
+
+ protected Response responseOfInternalServerError(final String reason) {
+ return Response.status(Status.INTERNAL_SERVER_ERROR).header("isis-reason", reason).build();
+ }
+
+ // //////////////////////////////////////////////////////////////
+ // Dependencies (from singletons)
+ // //////////////////////////////////////////////////////////////
+
+ protected static AuthenticationSession getSession() {
+ return IsisContext.getAuthenticationSession();
+ }
+
+ private static SpecificationLoader getSpecificationLoader() {
+ return IsisContext.getSpecificationLoader();
+ }
+
+ public static AdapterManager getAdapterManager() {
+ return getPersistenceSession().getAdapterManager();
+ }
+
+ protected static PersistenceSession getPersistenceSession() {
+ return IsisContext.getPersistenceSession();
+ }
+
+ private static OidGenerator getOidGenerator() {
+ return getPersistenceSession().getOidGenerator();
+ }
+
+ private static OidStringifier getOidStringifier() {
+ return getOidGenerator().getOidStringifier();
+ }
+
+ // //////////////////////////////////////////////////////////////
+ // Dependencies (injected via @Context)
+ // //////////////////////////////////////////////////////////////
+
+ protected HttpServletRequest getServletRequest() {
+ return getResourceContext().getHttpServletRequest();
+ }
+
+}