Author: chathura
Date: Mon Dec 3 22:20:10 2007
New Revision: 10462
Log:
More integrating work.
Modified:
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/ControllerServlet.java
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/UIConstants.java
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/AbstractRegistryAction.java
trunk/registry/modules/webapps/src/main/webapp/admin/header.jsp
trunk/registry/modules/webapps/src/main/webapp/admin/registry-resources.jsp
Modified:
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/ControllerServlet.java
==============================================================================
---
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/ControllerServlet.java
(original)
+++
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/ControllerServlet.java
Mon Dec 3 22:20:10 2007
@@ -18,10 +18,8 @@
import org.wso2.registry.servlet.Utils;
import org.wso2.registry.servlet.FileUploadUtil;
-import org.wso2.registry.Registry;
-import org.wso2.registry.Resource;
-import org.wso2.registry.RegistryConstants;
-import org.wso2.registry.ActionConstants;
+import org.wso2.registry.*;
+import org.wso2.registry.secure.SecureRegistry;
import org.wso2.registry.web.UIConstants;
import org.wso2.registry.web.actions.*;
import org.wso2.registry.web.ActionInvoker;
@@ -40,13 +38,27 @@
//To store the conetxt path
private String contextRoot = null;
- private ActionInvoker actionInvoker = new ActionInvoker();
-
protected void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
initContextRoot(request);
+ // if a path is not set in the session, set the path to the root
+ String path = (String)
request.getSession().getAttribute(UIConstants.PATH_ATTR);
+ if (path == null || path.length() == 0) {
+ path = RegistryConstants.ROOT_PATH;
+ request.getSession().setAttribute(UIConstants.PATH_ATTR,
RegistryConstants.ROOT_PATH);
+ }
+
+ // set the user name for the session
+ SecureRegistry userRegistry =
+ (SecureRegistry)
request.getSession().getAttribute(ConsoleConstants.USER_REGISTRY);
+ if (userRegistry != null) {
+ request.getSession().setAttribute(UIConstants.USER_ATTR,
userRegistry.getUserID());
+ } else {
+ request.getSession().setAttribute(UIConstants.USER_ATTR,
RegistryConstants.ANONYMOUS_USER);
+ }
+
String uri = request.getRequestURI();
String controlPart = uri.substring(contextRoot.length(), uri.length());
@@ -69,12 +81,7 @@
e.printStackTrace();
}
- String currentPath = (String)
request.getSession().getAttribute(UIConstants.PATH_ATTR);
- if (currentPath == null) {
- currentPath = RegistryConstants.ROOT_PATH;
- }
-
- forwardToResources(request, response, currentPath);
+ forwardToResources(request, response, path);
} else if (command.equals("/signout")) {
@@ -88,12 +95,7 @@
e.printStackTrace();
}
- String currentPath = (String)
request.getSession().getAttribute(UIConstants.PATH_ATTR);
- if (currentPath == null) {
- currentPath = RegistryConstants.ROOT_PATH;
- }
-
- forwardToResources(request, response, currentPath);
+ forwardToResources(request, response, path);
} else if (command.equals("/addUser")) {
@@ -125,11 +127,6 @@
} else if (command.equals("/tag")) {
- String path = (String)
request.getSession().getAttribute(UIConstants.PATH_ATTR);
- if (path == null) {
- path = RegistryConstants.ROOT_PATH;
- }
-
AddTagAction addTagAction = new AddTagAction();
addTagAction.setPath(path);
addTagAction.setTag(request.getParameter("tag"));
@@ -139,16 +136,11 @@
} catch (Exception e) {
e.printStackTrace();
}
-
+
forwardToResources(request, response, path);
} else if (command.equals("/authorize")) {
- String path = (String)
request.getSession().getAttribute(UIConstants.PATH_ATTR);
- if (path == null) {
- path = RegistryConstants.ROOT_PATH;
- }
-
AuthorizationAction authorizationAction = new
AuthorizationAction();
authorizationAction.setPathToAuthorize(path);
authorizationAction.setUserToAuthorize(request.getParameter("userToAuthorize"));
@@ -162,11 +154,27 @@
}
forwardToResources(request, response, path);
- }
- }
- if (controlPart.equals("/web/addResource")) {
- handleFileUpload(request, response);
+ } else if (command.equals("/addCollection")) {
+
+ AddCollectionAction addCollectionAction = new
AddCollectionAction();
+
addCollectionAction.setParentPath(request.getParameter("parentPath"));
+
addCollectionAction.setCollectionName(request.getParameter("collectionName"));
+
addCollectionAction.setMediaType(request.getParameter("mediaType"));
+
addCollectionAction.setDescription(request.getParameter("description"));
+
+ try {
+ addCollectionAction.execute(request);
+ } catch (RegistryException e) {
+ e.printStackTrace();
+ }
+
+ forwardToResources(request, response, path);
+
+ } else if (command.equals("/addResource")) {
+
+ handleFileUpload(request, response);
+ }
}
}
@@ -214,6 +222,22 @@
HttpServletResponse response)
throws ServletException, IOException {
+ // if a path is not set in the session, set the path to the root
+ String path = (String)
request.getSession().getAttribute(UIConstants.PATH_ATTR);
+ if (path == null || path.length() == 0) {
+ path = RegistryConstants.ROOT_PATH;
+ request.getSession().setAttribute(UIConstants.PATH_ATTR,
RegistryConstants.ROOT_PATH);
+ }
+
+ // set the user name for the session
+ SecureRegistry userRegistry =
+ (SecureRegistry)
request.getSession().getAttribute(ConsoleConstants.USER_REGISTRY);
+ if (userRegistry != null) {
+ request.getSession().setAttribute(UIConstants.USER_ATTR,
userRegistry.getUserID());
+ } else {
+ request.getSession().setAttribute(UIConstants.USER_ATTR,
RegistryConstants.ANONYMOUS_USER);
+ }
+
initContextRoot(request);
String uri = request.getRequestURI();
@@ -223,7 +247,6 @@
// process request regarding resource handling
- String path;
if (uri.equals("") || uri.endsWith(UIConstants.WEB_PATH +
RegistryConstants.PATH_SEPARATOR)) {
path = RegistryConstants.ROOT_PATH;
@@ -232,36 +255,18 @@
length(), uri.length());
}
+ // if user is browsing an old version of the resource, we append
it to the path, so that
+ // the backend registry gives the details of the version
String qPart = request.getQueryString();
if (qPart != null && qPart.startsWith("v")) {
path = path + "?" + qPart;
}
+ // whenever a user selects a URL for a resource path, we set that
path in the user's
+ // session. so the user's path is known from any part of the UI.
request.getSession().setAttribute(UIConstants.PATH_ATTR, path);
- actionInvoker.invokeActions(request);
-
- try {
- ResourceDetailsAction details = new ResourceDetailsAction();
- details.setPath(path);
- details.execute(request);
-
- CollectionViewAction collection = null;
- if (details.isCollection()) {
- collection = new CollectionViewAction();
- collection.setPath(path);
- collection.execute(request);
- }
-
- request.getSession().setAttribute(UIConstants.RESOURCE_BEAN,
details);
- request.getSession().setAttribute(UIConstants.COLLECTION_BEAN,
collection);
-
- request.getRequestDispatcher(UIConstants.RESOURCES_JSP)
- .forward(request, response);
-
- } catch (Exception e) {
- e.printStackTrace();
- }
+ forwardToResources(request, response, path);
} else if (controlPart.startsWith(RegistryConstants.PATH_SEPARATOR +
UIConstants.SYSTEM_PATH)) {
@@ -285,12 +290,7 @@
e.printStackTrace();
}
- String currentPath = (String)
request.getSession().getAttribute(UIConstants.PATH_ATTR);
- if (currentPath == null) {
- currentPath = RegistryConstants.ROOT_PATH;
- }
-
- forwardToResources(request, response, currentPath);
+ forwardToResources(request, response, path);
} else if (command.equals("/activity")) {
@@ -310,7 +310,6 @@
}
}
-
}
/**
@@ -429,6 +428,7 @@
private void forwardToEmptyActivity(HttpServletRequest request,
HttpServletResponse response) {
RecentActivityAction recentActivity = new RecentActivityAction();
+ recentActivity.setRequest(request);
request.getSession().setAttribute(UIConstants.ACTIVITY_BEAN,
recentActivity);
try {
@@ -443,6 +443,7 @@
private void forwardToNewAdvancedSearch(HttpServletRequest request,
HttpServletResponse response) {
AdvancedSearchAction advancedSearchAction = new AdvancedSearchAction();
+ advancedSearchAction.setRequest(request);
request.getSession().setAttribute(UIConstants.ADVANCED_SEARCH_BEAN,
advancedSearchAction);
try {
Modified:
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/UIConstants.java
==============================================================================
---
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/UIConstants.java
(original)
+++
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/UIConstants.java
Mon Dec 3 22:20:10 2007
@@ -27,6 +27,7 @@
public static final String WEB_PATH = "web";
public static final String SYSTEM_PATH = "system";
public static final String PATH_ATTR = "path";
+ public static final String USER_ATTR = "currentUser";
public static final String QUERY_ATTR = "regQuery";
public static final String RESOURCES_JSP = "/admin/registry-resources.jsp";
Modified:
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/AbstractRegistryAction.java
==============================================================================
---
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/AbstractRegistryAction.java
(original)
+++
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/AbstractRegistryAction.java
Mon Dec 3 22:20:10 2007
@@ -34,7 +34,7 @@
protected HttpServletRequest request = null;
- protected void setRequest(HttpServletRequest request) {
+ public void setRequest(HttpServletRequest request) {
this.request = request;
}
Modified: trunk/registry/modules/webapps/src/main/webapp/admin/header.jsp
==============================================================================
--- trunk/registry/modules/webapps/src/main/webapp/admin/header.jsp
(original)
+++ trunk/registry/modules/webapps/src/main/webapp/admin/header.jsp Mon Dec
3 22:20:10 2007
@@ -1,20 +1,15 @@
-<%@ page import="org.wso2.registry.web.actions.ResourceDetailsAction" %>
<%@ page import="org.wso2.registry.RegistryConstants" %>
<%@ page import="org.wso2.registry.web.UIConstants" %>
-<%@ page import="org.wso2.registry.Registry" %>
-<%@ page import="org.wso2.registry.web.ConsoleConstants" %>
-<%@ page import="org.wso2.registry.secure.SecureRegistry" %>
<div class="header">
<%
- SecureRegistry registry =
- (SecureRegistry)
request.getSession().getAttribute(ConsoleConstants.USER_REGISTRY);
String path = (String)
request.getSession().getAttribute(UIConstants.PATH_ATTR);
String webPath = "/wso2registry/web";
if (path != null) {
webPath = webPath + path;
}
- String userName = registry.getUserID();
+
+ String userName = (String)
request.getSession().getAttribute(UIConstants.USER_ATTR);
%>
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
Modified:
trunk/registry/modules/webapps/src/main/webapp/admin/registry-resources.jsp
==============================================================================
--- trunk/registry/modules/webapps/src/main/webapp/admin/registry-resources.jsp
(original)
+++ trunk/registry/modules/webapps/src/main/webapp/admin/registry-resources.jsp
Mon Dec 3 22:20:10 2007
@@ -80,7 +80,7 @@
<!-- Add resource div -->
<div class="add-resource-div" id="add-resource-div" style="display:none;">
- <form method="post" name="resourceupload" id="resourceupload"
action="/wso2registry/web/addResource"
+ <form method="post" name="resourceupload" id="resourceupload"
action="/wso2registry/system/addResource"
enctype="multipart/form-data">
<input type="hidden" name="path" value="<%=details.getPath()%>"/>
@@ -111,8 +111,8 @@
<!-- Add folder div -->
<div class="add-resource-div" id="add-folder-div" style="display:none;">
- <form name="collectionForm" method="get"
action="/wso2registry/web/<%=details.getRelativePath()%>">
- <input type="hidden" name="regAction" value="addCollection"/>
+ <form name="collectionForm" method="post"
action="/wso2registry/system/addCollection">
+ <input type="hidden" name="parentPath" value="<%=details.getPath()%>"/>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="100" valign="top">Name</td>
_______________________________________________
Registry-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/registry-dev