Author: heiko.braun(a)jboss.com
Date: 2009-07-01 06:28:46 -0400 (Wed, 01 Jul 2009)
New Revision: 5172
Added:
projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/util/RsComment.java
projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/util/RsDocBuilder.java
Modified:
projects/gwt-console/trunk/gui/workspace-api/src/main/java/org/jboss/bpm/console/client/URLBuilder.java
projects/gwt-console/trunk/server/server-core/server-core.iml
projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/ConsoleServerApplication.java
projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/EngineFacade.java
projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/FormProcessingFacade.java
projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/InfoFacade.java
projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/ProcessMgmtFacade.java
projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/TaskListFacade.java
projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/TaskMgmtFacade.java
projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/UserMgmtFacade.java
projects/gwt-console/trunk/server/server-core/src/main/webapp/index.html
projects/gwt-console/trunk/server/server-integration/server-integration.iml
Log:
Added RsDocBuilder. Create JAX-RS docs on the fly.
Modified:
projects/gwt-console/trunk/gui/workspace-api/src/main/java/org/jboss/bpm/console/client/URLBuilder.java
===================================================================
---
projects/gwt-console/trunk/gui/workspace-api/src/main/java/org/jboss/bpm/console/client/URLBuilder.java 2009-07-01
10:19:31 UTC (rev 5171)
+++
projects/gwt-console/trunk/gui/workspace-api/src/main/java/org/jboss/bpm/console/client/URLBuilder.java 2009-07-01
10:28:46 UTC (rev 5172)
@@ -47,7 +47,7 @@
public String getProcessInstancesURL(String processId)
{
String encodedId = URL.encode(processId);
- return config.getConsoleServerUrl() + "/rs/process/definitions/" +
encodedId + "/instances";
+ return config.getConsoleServerUrl() + "/rs/process/definition/" + encodedId
+ "/instances";
}
public String getUserInRoleURL(String[] possibleRoles)
@@ -71,47 +71,42 @@
public String getRemoveDefinitionURL(String processId)
{
String encodedId = URL.encode(processId);
- return config.getConsoleServerUrl() + "/rs/process/definitions/" +
encodedId+ "/remove";
+ return config.getConsoleServerUrl() + "/rs/process/definition/" +
encodedId+ "/remove";
}
public String getProcessImageURL(String processId)
{
String encodedId = URL.encode(processId);
- return config.getConsoleServerUrl() + "/rs/process/definitions/"+
encodedId+ "/image";
+ return config.getConsoleServerUrl() + "/rs/process/definition/"+ encodedId+
"/image";
}
public String getActiveNodeInfoURL(String instanceId)
{
- return config.getConsoleServerUrl() + "/rs/process/instances/" + instanceId
+ "/activeNodeInfo";
+ return config.getConsoleServerUrl() + "/rs/process/instance/" + instanceId
+ "/activeNodeInfo";
}
public String getStateChangeURL(String instanceId, ProcessInstanceRef.STATE state)
{
- return config.getConsoleServerUrl() + "/rs/process/instances/" + instanceId
+ "/state/" + state;
+ return config.getConsoleServerUrl() + "/rs/process/instance/" + instanceId
+ "/state/" + state;
}
public String getInstanceEndURL(String instanceId, ProcessInstanceRef.RESULT result)
{
- return config.getConsoleServerUrl() + "/rs/process/instances/" + instanceId
+ "/end/" + result;
+ return config.getConsoleServerUrl() + "/rs/process/instance/" + instanceId
+ "/end/" + result;
}
public String getInstanceDeleteURL(String instanceId)
{
- return config.getConsoleServerUrl() + "/rs/process/instances/" + instanceId
+ "/delete";
+ return config.getConsoleServerUrl() + "/rs/process/instance/" + instanceId
+ "/delete";
}
public String getStartNewInstanceURL(String processId)
{
String encodedID = URL.encode(processId);
- return config.getConsoleServerUrl() + "/rs/process/definitions/" +
encodedID + "/instances/new";
+ return config.getConsoleServerUrl() + "/rs/process/definition/" + encodedID
+ "/new_instance";
}
- public String getUploadDefinitionURL()
- {
- return config.getConsoleServerUrl() + "/rs/process/definitions/new";
- }
-
public String getTaskListURL(String idRef)
{
return config.getConsoleServerUrl() + "/rs/tasks/" + URL.encode(idRef);
@@ -158,11 +153,6 @@
return config.getConsoleServerUrl() + "/rs/identity/user/" + actorId +
"/actors";
}
- public String getProcessDefinitionByNameURL(String name)
- {
- return config.getConsoleServerUrl() + "/rs/process/definitions/" + name;
- }
-
public String getDeployTestHarnessUrl()
{
return config.getConsoleServerUrl() + "/rs/test/deploy/harness";
Modified: projects/gwt-console/trunk/server/server-core/server-core.iml
===================================================================
--- projects/gwt-console/trunk/server/server-core/server-core.iml 2009-07-01 10:19:31 UTC
(rev 5171)
+++ projects/gwt-console/trunk/server/server-core/server-core.iml 2009-07-01 10:28:46 UTC
(rev 5172)
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4" relativePaths="true"
type="JAVA_MODULE">
<component name="ModuleRootManager" />
- <component name="NewModuleRootManager"
inherit-compiler-output="true">
+ <component name="NewModuleRootManager"
inherit-compiler-output="false">
+ <output url="file://$MODULE_DIR$/target/classes" />
<exclude-output />
+ <output-test
url="file://$MODULE_DIR$/../../../../../jbpm4/trunk/classes/test/server-core"
/>
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java"
isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources"
isTestSource="false" />
Modified:
projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/ConsoleServerApplication.java
===================================================================
---
projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/ConsoleServerApplication.java 2009-07-01
10:19:31 UTC (rev 5171)
+++
projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/ConsoleServerApplication.java 2009-07-01
10:28:46 UTC (rev 5172)
@@ -46,7 +46,7 @@
singletons.add(new TestFacade());
singletons.add(new EngineFacade());
singletons.add(new FormProcessingFacade());
- singletons.add( new ReportFacade() );
+ singletons.add(new ReportFacade() );
}
@Override
Modified:
projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/EngineFacade.java
===================================================================
---
projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/EngineFacade.java 2009-07-01
10:19:31 UTC (rev 5171)
+++
projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/EngineFacade.java 2009-07-01
10:28:46 UTC (rev 5172)
@@ -31,6 +31,7 @@
import org.jboss.bpm.console.server.gson.GsonFactory;
import org.jboss.bpm.console.server.plugin.ProcessEnginePlugin;
import org.jboss.bpm.console.server.plugin.PluginMgr;
+import org.jboss.bpm.console.server.util.RsComment;
import javax.ws.rs.*;
import javax.ws.rs.core.Response;
@@ -42,6 +43,10 @@
* @author Heiko.Braun <heiko.braun(a)jboss.com>
*/
@Path("engine")
+@RsComment(
+ title = "Process Engine",
+ description = "Process runtime state"
+)
public class EngineFacade
{
private static final Log log = LogFactory.getLog(EngineFacade.class);
Modified:
projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/FormProcessingFacade.java
===================================================================
---
projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/FormProcessingFacade.java 2009-07-01
10:19:31 UTC (rev 5171)
+++
projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/FormProcessingFacade.java 2009-07-01
10:28:46 UTC (rev 5172)
@@ -26,6 +26,7 @@
import org.jboss.bpm.console.server.plugin.FormAuthorityRef;
import org.jboss.bpm.console.server.plugin.FormDispatcherPlugin;
import org.jboss.bpm.console.server.plugin.PluginMgr;
+import org.jboss.bpm.console.server.util.RsComment;
import org.jboss.resteasy.plugins.providers.multipart.InputPart;
import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput;
@@ -48,6 +49,10 @@
* @author Heiko.Braun <heiko.braun(a)jboss.com>
*/
@Path("form")
+@RsComment(
+ title = "Form Processing",
+ description = "Web based form processing"
+)
public class FormProcessingFacade
{
private static final Log log = LogFactory.getLog(FormProcessingFacade.class);
Modified:
projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/InfoFacade.java
===================================================================
---
projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/InfoFacade.java 2009-07-01
10:19:31 UTC (rev 5171)
+++
projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/InfoFacade.java 2009-07-01
10:28:46 UTC (rev 5172)
@@ -26,13 +26,18 @@
import org.jboss.bpm.console.server.plugin.GraphViewerPlugin;
import org.jboss.bpm.console.server.plugin.ProcessEnginePlugin;
import org.jboss.bpm.console.server.gson.GsonFactory;
+import org.jboss.bpm.console.server.util.RsDocBuilder;
+import org.jboss.bpm.console.server.util.RsComment;
import org.jboss.bpm.console.client.model.ServerStatus;
import org.jboss.bpm.console.client.model.PluginInfo;
+import org.jboss.bpm.report.ReportFacade;
import javax.ws.rs.Path;
import javax.ws.rs.GET;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Context;
+import javax.servlet.http.HttpServletRequest;
import com.google.gson.Gson;
@@ -40,6 +45,10 @@
* @author Heiko.Braun <heiko.braun(a)jboss.com>
*/
@Path("server")
+@RsComment(
+ title = "Server Info",
+ description = "General REST server information"
+)
public class InfoFacade
{
@@ -54,6 +63,10 @@
@GET
@Path("status")
@Produces("application/json")
+ @RsComment(
+ title = "Plugins",
+ description = "Plugin availablity"
+ )
public Response getServerInfo()
{
ServerStatus status = getServerStatus();
@@ -76,6 +89,31 @@
return status;
}
+ @GET
+ @Path("resources")
+ @Produces("text/html")
+ public Response getPublishedUrls(
+ @Context
+ HttpServletRequest request
+ )
+ {
+ final Class[] rootResources = new Class[]
+ {
+ InfoFacade.class,
+ ProcessMgmtFacade.class,
+ TaskListFacade.class,
+ TaskMgmtFacade.class,
+ UserMgmtFacade.class,
+ EngineFacade.class,
+ FormProcessingFacade.class
+ //,ReportFacade.class
+ };
+
+ RsDocBuilder rsDocBuilder = new
RsDocBuilder(request.getContextPath(),rootResources);
+ StringBuffer sb = rsDocBuilder.build();
+ return Response.ok(sb.toString()).build();
+ }
+
private Response createJsonResponse(Object wrapper)
{
Gson gson = GsonFactory.createInstance();
Modified:
projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/ProcessMgmtFacade.java
===================================================================
---
projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/ProcessMgmtFacade.java 2009-07-01
10:19:31 UTC (rev 5171)
+++
projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/ProcessMgmtFacade.java 2009-07-01
10:28:46 UTC (rev 5172)
@@ -36,6 +36,7 @@
import org.jboss.bpm.console.server.plugin.FormDispatcherPlugin;
import org.jboss.bpm.console.server.plugin.GraphViewerPlugin;
import org.jboss.bpm.console.server.plugin.PluginMgr;
+import org.jboss.bpm.console.server.util.RsComment;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.*;
@@ -52,6 +53,9 @@
* @author Heiko.Braun <heiko.braun(a)jboss.com>
*/
@Path("process")
+@RsComment(
+ title = "Process Management",
+ description = "Process related data.")
public class ProcessMgmtFacade
{
private static final Log log = LogFactory.getLog(ProcessMgmtFacade.class);
@@ -132,7 +136,7 @@
}
@POST
- @Path("definitions/{id}/remove")
+ @Path("definition/{id}/remove")
@Produces("application/json")
public Response removeDefinitionsJSON(
@PathParam("id")
@@ -145,7 +149,7 @@
}
@GET
- @Path("definitions/{id}/instances")
+ @Path("definition/{id}/instances")
@Produces("application/json")
public Response getInstancesJSON(
@PathParam("id")
@@ -158,7 +162,7 @@
}
@POST
- @Path("definitions/{id}/instances/new")
+ @Path("definition/{id}/new_instance")
@Produces("application/json")
public Response newInstance(
@PathParam("id")
@@ -178,8 +182,16 @@
}
+ @GET
+ @Path("instance/{id}/dataset")
+ @Produces("application/json")
+ public Response getInstanceData()
+ {
+ return Response.ok().build();
+ }
+
@POST
- @Path("instances/{id}/state/{next}")
+ @Path("instance/{id}/state/{next}")
@Produces("application/json")
public Response changeState(
@PathParam("id")
@@ -194,7 +206,7 @@
}
@POST
- @Path("instances/{id}/end/{result}")
+ @Path("instance/{id}/end/{result}")
@Produces("application/json")
public Response endInstance(
@PathParam("id")
@@ -209,7 +221,7 @@
}
@POST
- @Path("instances/{id}/delete")
+ @Path("instance/{id}/delete")
@Produces("application/json")
public Response deleteInstance(
@PathParam("id")
@@ -252,61 +264,8 @@
return Response.ok().type("application/json").build();
}
- @POST
- @Path("definitions/new")
- @Produces("application/json")
- @Consumes("multipart/form-data")
- public Response postNewDefinition(
- @Context
- HttpServletRequest request
- )
- {
- try
- {
- FileItemFactory factory = new DiskFileItemFactory();
- ServletFileUpload upload = new ServletFileUpload(factory);
- List items = upload.parseRequest(request);
-
- Iterator iter = items.iterator();
- while (iter.hasNext())
- {
- FileItem item = (FileItem) iter.next();
-
- if (item.isFormField())
- {
- // ignore
- System.out.println("Caught form field on file upload: " +
item.getName());
- }
- else
- {
- String fieldName = item.getFieldName();
- String fileName = item.getName();
- String contentType = item.getContentType();
- boolean isInMemory = item.isInMemory();
- long sizeInBytes = item.getSize();
-
- // Process a file upload in memory
- //byte[] data = item.get();
-
- // Process stream
- InputStream uploadedStream = item.getInputStream();
- getProcessManagement().deploy(fileName, contentType, uploadedStream);
- uploadedStream.close();
-
-
- }
-
- }
- } catch (Exception e)
- {
- return Response.serverError().build();
- }
-
- return Response.ok().build();
- }
-
@GET
- @Path("definitions/{id}/image")
+ @Path("definition/{id}/image")
@Produces("image/*")
public Response getProcessImage(
@PathParam("id")
@@ -325,7 +284,7 @@
}
@GET
- @Path("instances/{id}/activeNodeInfo")
+ @Path("instance/{id}/activeNodeInfo")
@Produces("application/json")
public Response getActiveNodeInfo(
@PathParam("id")
Modified:
projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/TaskListFacade.java
===================================================================
---
projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/TaskListFacade.java 2009-07-01
10:19:31 UTC (rev 5171)
+++
projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/TaskListFacade.java 2009-07-01
10:28:46 UTC (rev 5172)
@@ -32,6 +32,7 @@
import org.jboss.bpm.console.server.plugin.PluginMgr;
import org.jboss.bpm.console.server.plugin.FormAuthorityRef;
import org.jboss.bpm.console.server.plugin.FormDispatcherPlugin;
+import org.jboss.bpm.console.server.util.RsComment;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
@@ -47,6 +48,10 @@
* @author Heiko.Braun <heiko.braun(a)jboss.com>
*/
@Path("tasks")
+@RsComment(
+ title = "Task Lists",
+ description = "Access task lists"
+)
public class TaskListFacade
{
private static final Log log = LogFactory.getLog(TaskMgmtFacade.class);
Modified:
projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/TaskMgmtFacade.java
===================================================================
---
projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/TaskMgmtFacade.java 2009-07-01
10:19:31 UTC (rev 5171)
+++
projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/TaskMgmtFacade.java 2009-07-01
10:28:46 UTC (rev 5172)
@@ -28,6 +28,7 @@
import org.jboss.bpm.console.server.plugin.PluginMgr;
import org.jboss.bpm.console.server.plugin.FormAuthorityRef;
import org.jboss.bpm.console.server.plugin.FormDispatcherPlugin;
+import org.jboss.bpm.console.server.util.RsComment;
import org.jboss.resteasy.plugins.providers.multipart.InputPart;
import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput;
@@ -52,6 +53,10 @@
* @author Heiko.Braun <heiko.braun(a)jboss.com>
*/
@Path("task")
+@RsComment(
+ title = "Task Management",
+ description = "Manage task instances"
+)
public class TaskMgmtFacade
{
private static final Log log = LogFactory.getLog(TaskMgmtFacade.class);
Modified:
projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/UserMgmtFacade.java
===================================================================
---
projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/UserMgmtFacade.java 2009-07-01
10:19:31 UTC (rev 5171)
+++
projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/UserMgmtFacade.java 2009-07-01
10:28:46 UTC (rev 5172)
@@ -29,6 +29,7 @@
import org.jboss.bpm.console.server.gson.GsonFactory;
import org.jboss.bpm.console.server.integration.ManagementFactory;
import org.jboss.bpm.console.server.integration.UserManagement;
+import org.jboss.bpm.console.server.util.RsComment;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.*;
@@ -42,6 +43,10 @@
* @author Heiko.Braun <heiko.braun(a)jboss.com>
*/
@Path("identity")
+@RsComment(
+ title = "User management",
+ description = "Manage user and groups"
+)
public class UserMgmtFacade
{
@@ -61,7 +66,7 @@
}
@GET
- @Path("/user/roles")
+ @Path("user/roles")
@Produces("application/json")
public Response getRolesForJAASPrincipal(
@Context
@@ -89,7 +94,7 @@
}
@GET
- @Path("/user/{actorId}/groups/")
+ @Path("user/{actorId}/groups/")
@Produces("application/json")
public Response getGroupsForActor(
@PathParam("actorId")
@@ -101,7 +106,7 @@
}
@GET
- @Path("/group/{groupName}/members")
+ @Path("group/{groupName}/members")
@Produces("application/json")
public Response getActorsForGroup(
@PathParam("groupName")
@@ -113,7 +118,7 @@
}
@GET
- @Path("/user/{actorId}/actors")
+ @Path("user/{actorId}/actors")
@Produces("application/json")
public Response getAvailableActors(
@PathParam("actorId")
Added:
projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/util/RsComment.java
===================================================================
---
projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/util/RsComment.java
(rev 0)
+++
projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/util/RsComment.java 2009-07-01
10:28:46 UTC (rev 5172)
@@ -0,0 +1,29 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.bpm.console.server.util;
+
+(a)java.lang.annotation.Target(value = {java.lang.annotation.ElementType.TYPE,
java.lang.annotation.ElementType.METHOD}) @java.lang.annotation.Retention(value =
java.lang.annotation.RetentionPolicy.RUNTIME)
+public @interface RsComment {
+
+ java.lang.String title();
+ java.lang.String description();
+}
\ No newline at end of file
Added:
projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/util/RsDocBuilder.java
===================================================================
---
projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/util/RsDocBuilder.java
(rev 0)
+++
projects/gwt-console/trunk/server/server-core/src/main/java/org/jboss/bpm/console/server/util/RsDocBuilder.java 2009-07-01
10:28:46 UTC (rev 5172)
@@ -0,0 +1,180 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.bpm.console.server.util;
+
+import org.jboss.bpm.console.server.ProcessMgmtFacade;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.Produces;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Date;
+
+/**
+ * Creates HTML documention for JAX-RS resource classes.
+ *
+ * @author Heiko.Braun <heiko.braun(a)jboss.com>
+ */
+public class RsDocBuilder
+{
+ private String webContext;
+ private Class[] rootResources;
+
+ public RsDocBuilder(String webContext, Class[] rootResources)
+ {
+ this.rootResources = rootResources;
+ this.webContext = webContext.startsWith("/") ? webContext :
"/"+webContext;
+ }
+
+ public static void main(String[] args)
+ {
+ RsDocBuilder rsDocBuilder = new RsDocBuilder(
+ "gwt-console-server",
+ new Class[] {ProcessMgmtFacade.class}
+ );
+
+ StringBuffer sb = rsDocBuilder.build(rsDocBuilder.getRootResources()[0]);
+ System.out.println(sb.toString());
+ }
+
+
+ public String getWebContext()
+ {
+ return webContext;
+ }
+
+ public Class[] getRootResources()
+ {
+ return rootResources;
+ }
+
+ private StringBuffer build(Class root)
+ {
+ Path rootPath = (Path)root.getAnnotation(Path.class);
+ RsComment rootComment = (RsComment)root.getAnnotation(RsComment.class);
+
+ List<Representation> representations = new ArrayList<Representation>();
+
+ for(Method m : root.getDeclaredMethods())
+ {
+ Path resPath = m.getAnnotation(Path.class);
+ if(resPath!=null)
+ {
+ Representation r = new Representation();
+
+ r.path = resPath.value();
+ r.httpMethod = m.getAnnotation(GET.class)!=null ? "GET" :
"POST"; // currently limited to those
+ r.consume = (m.getAnnotation(Consumes.class)!=null) ?
+ arrayToString(m.getAnnotation(Consumes.class).value()) : "*/*";
+ r.produce = (m.getAnnotation(Produces.class)!=null) ?
+ arrayToString(m.getAnnotation(Produces.class).value()) : "*/*";
+ representations.add(r);
+ }
+ }
+
+ StringBuffer sb = new StringBuffer();
+
+ if(rootComment!=null)
+ {
+ sb.append("<tr>");
+ sb.append("<td colspan=5 style='border-bottom:1px solid
black;'>");
+
sb.append("<b>").append(rootComment.title()).append("</b>").append("<br>");
+
sb.append("<i>").append(rootComment.description()).append("</i>");
+ sb.append("</td>");
+ sb.append("</tr>");
+ }
+
+ for(Representation r : representations)
+ {
+ sb.append("<tr>");
+
sb.append("<td>").append(r.httpMethod.toUpperCase()).append("</td>");
+
sb.append("<td>").append(buildPath(rootPath.value(),r.path)).append("</td>");
+
sb.append("<td>").append("").append("</td>"); //
description
+
sb.append("<td>").append(r.consume).append("</td>");
+
sb.append("<td>").append(r.produce).append("</td>");
+ sb.append("</tr>");
+ }
+
+ sb.append("<tr><td
colspan=5> </td></tr>");
+
+ return sb;
+ }
+
+ private String arrayToString(String[] arr)
+ {
+ StringBuffer sb = new StringBuffer();
+ for(int i=0; i<arr.length; i++)
+ {
+ sb.append(arr[i]);
+ if(i<arr.length-1)
+ sb.append(",");
+ }
+ return sb.toString();
+ }
+
+ private String buildPath(String root, String resourcePath)
+ {
+ StringBuffer sb = new StringBuffer();
+ sb.append(webContext);
+ sb.append("/").append(root).append("/");
+ sb.append(resourcePath);
+ return sb.toString();
+ }
+
+ public StringBuffer build()
+ {
+ StringBuffer sb = new StringBuffer();
+ sb.append("<html>").append("<body style='font-family:
sans-serif; font-size:10pt;'>");
+ sb.append("<!--").append(" generated by RsDoc at ").append(
new Date() ).append(" -->");
+ sb.append("<table style='margin-top:10px;'
width='100%'>");
+
+ sb.append("<tr>");
+
sb.append("<th>").append("Method").append("</th>");
+
sb.append("<th>").append("Path").append("</th>");
+
sb.append("<th>").append("Description").append("</th>");
// description
+
sb.append("<th>").append("Consumes").append("</th>");
+
sb.append("<th>").append("Produces").append("</th>");
+ sb.append("</tr>");
+
+ for(Class c : rootResources)
+ {
+ sb.append(
+ build(c).toString()
+ );
+ }
+ sb.append("</table>");
+ sb.append("</body>").append("<html>");
+ return sb;
+
+ }
+
+ private class Representation
+ {
+ String description,title = "";
+ String consume,produce = "";
+ String path;
+ String httpMethod;
+ }
+}
Modified: projects/gwt-console/trunk/server/server-core/src/main/webapp/index.html
===================================================================
--- projects/gwt-console/trunk/server/server-core/src/main/webapp/index.html 2009-07-01
10:19:31 UTC (rev 5171)
+++ projects/gwt-console/trunk/server/server-core/src/main/webapp/index.html 2009-07-01
10:28:46 UTC (rev 5172)
@@ -1,107 +1,20 @@
<html>
-<body>
+<body style='font-family: sans-serif; font-size:10pt;'>
<h1>GWT Console Server</h1>
-<h2>Published REST Url's </h2>
+<h2>Published URL's</h2>
+You can find a list of resources <a
href="/gwt-console-server/rs/server/resources">here</a>.
-<table border=1 cellpadding=5>
-<tr>
- <th>Method</th>
- <th>Context</th>
- <th>Description</th>
- <th>Mime Types</th>
-</tr>
-
-<tr>
- <td colspan=4><h3>Process Management</h3></td>
-</tr>
-
-<tr>
- <td>GET</td>
- <td><a
href="/gwt-console-server/rs/process/definitions">/rs/process/definitions</a></td>
- <td>A list of process definitions</td>
- <td>application/json</td>
-</tr>
-
-<tr>
- <td>POST</td>
- <td>/rs/process/definitions/{processId}/remove</td>
- <td>Removes a particular process definition</td>
- <td>application/json</td>
-</tr>
-
-<tr>
- <td>GET</td>
- <td><a
href="/gwt-console-server/rs/process/definitions/1/instances">/rs/process/definitions/{id}/instances</a></td>
- <td>A list of process instances for a given process definition</td>
- <td>application/json</td>
-</tr>
-
-<tr>
- <td>POST</td>
- <td>/rs/process/instances/{id}/state/{next}</td>
- <td>Change instance state (RUNNING, SUSPENDED, ENDED)</td>
- <td>*/*</td>
-</tr>
-
-<tr>
- <td>POST</td>
- <td>/rs/process/definitions/{processId}/instances/new</td>
- <td>Create a new process instance</td>
- <td>application/json</td>
-</tr>
-
-<tr>
- <td colspan=4><h3>User Management</h3></td>
-</tr>
-
-<tr>
- <td>GET</td>
- <td><a
href="/gwt-console-server/rs/identity/user/roles?roleCheck=admin,user">/rs/identity/user/roles?roleCheck=a,b,c</a></td>
- <td>A list of assigned roles matching the query parameter (Comma seperated
list)</td>
- <td>application/json</td>
-</tr>
-
-<tr>
- <td colspan=4><h3>Task Management</h3></td>
-</tr>
-
-<tr>
- <td>GET</td>
- <td>/rs/tasks/actor/{actorId}</td>
- <td>A list of available tasks (OPEN and IN_PROGRESS) for an actor</td>
- <td>application/json</td>
-</tr>
-
-<tr>
- <td>GET</td>
- <td>/rs/tasks/{taskId}/assignment/{actorId}</td>
- <td>Assign a task to an actor actor. If you leave out the actorId it will
release (IN_PROGRESS->OPEN) the task</td>
- <td>application/json</td>
-</tr>
-
-<tr>
- <td>POST</td>
- <td>/rs/tasks/{taskId}/close/transition?signal={signalName}</td>
- <td>Complete a task with signal</td>
- <td>application/json</td>
-</tr>
-
-<tr>
- <td>POST</td>
- <td>/rs/tasks/{taskId}/close/transition/default</td>
- <td>Complete a task with default transition</td>
- <td>application/json</td>
-</tr>
-
-</table>
-
<h2>Example usage</h2>
<pre>
curl -u "user:password" -H 'Accept: application/json'
http://localhost:8080/gwt-console-server/rs/process/definitions
- curl -H 'Accept: application/json'
http://localhost:8080/gwt-console-server/rs/process/definitions/1/instances
+ curl -H 'Accept: application/json'
http://localhost:8080/gwt-console-server/rs/process/definition/1/instances
</pre>
+
+<h2>Problems?</h2>
+Please post any questions to the <a
href="http://www.jboss.org/index.html?module=bb&op=viewforum&...
developer forum</a>.
+
</body>
</html>
\ No newline at end of file
Modified: projects/gwt-console/trunk/server/server-integration/server-integration.iml
===================================================================
--- projects/gwt-console/trunk/server/server-integration/server-integration.iml 2009-07-01
10:19:31 UTC (rev 5171)
+++ projects/gwt-console/trunk/server/server-integration/server-integration.iml 2009-07-01
10:28:46 UTC (rev 5172)
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4" relativePaths="true"
type="JAVA_MODULE">
<component name="ModuleRootManager" />
- <component name="NewModuleRootManager"
inherit-compiler-output="true">
+ <component name="NewModuleRootManager"
inherit-compiler-output="false">
+ <output url="file://$MODULE_DIR$/target/classes" />
<exclude-output />
+ <output-test
url="file://$MODULE_DIR$/../../../../../jbpm4/trunk/classes/test/server-integration"
/>
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java"
isTestSource="false" />
</content>