[Registry-dev] svn commit r16843 - in
trunk/registry/modules/webapps/src/main:
java/org/wso2/registry/web java/org/wso2/registry/web/actions
webapp/admin webapp/admin/ajax webapp/admin/css webapp/admin/js
svn at wso2.org
svn at wso2.org
Mon May 12 01:13:52 PDT 2008
Author: chanaka
Date: Mon May 12 01:13:51 2008
New Revision: 16843
Log:
1 - Activity paging functionality added
2 - Resource tree for associations is added (But not fully integrated to UI)
Added:
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/ShowResourceTreeAction.java
trunk/registry/modules/webapps/src/main/webapp/admin/ajax/resource-tree.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/UIConstants.java
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/AssociationTreeViewAction.java
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/RecentActivityAction.java
trunk/registry/modules/webapps/src/main/webapp/admin/ajax/activity.jsp
trunk/registry/modules/webapps/src/main/webapp/admin/css/main.css
trunk/registry/modules/webapps/src/main/webapp/admin/js/common.js
trunk/registry/modules/webapps/src/main/webapp/admin/recent-activity.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 May 12 01:13:51 2008
@@ -125,7 +125,11 @@
response.sendRedirect("/wso2registry/web");
//forwardToResources(request, response, path);
- } else if (command.equals("/addUser")) {
+ }else if (command.equals("/activity")) {
+
+ forwardToActivity(request, response);
+
+ }else if (command.equals("/addUser")) {
AddUserAction addUserAction = new AddUserAction();
addUserAction.setNewUserName(request.getParameter("newUserName"));
@@ -549,11 +553,7 @@
response.sendRedirect("/wso2registry/web");
//forwardToResources(request, response, path);
- } else if (command.equals("/activity")) {
-
- forwardToActivity(request, response);
-
- } else if (command.equals("/associationTree")) {
+ } else if (command.equals("/associationTree")) {
forwardToAssociation(request, response,path);
@@ -629,7 +629,10 @@
response.sendRedirect("/wso2registry/system/people");
//forwardToUserManagement(request, response);
- } else if (command.equals("/search")) {
+ } else if(command.equals("/resourceTree")){
+ forwardToResourceTree(request,response,path);
+
+ }else if (command.equals("/search")) {
forwardToSearch(request, response);
@@ -936,6 +939,47 @@
e.printStackTrace();
}
}
+ private void forwardToResourceTree(HttpServletRequest request, HttpServletResponse response,String path) {
+
+
+ try {
+ ResourceDetailsAction details = new ResourceDetailsAction();
+ details.setPath(path);
+ details.execute(request);
+
+ ShowResourceTreeAction showResourceTreeAction = new ShowResourceTreeAction();
+ showResourceTreeAction.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.getSession().setAttribute(UIConstants.RESOURCE_TREE_BEAN,showResourceTreeAction);
+
+
+
+ } catch (Exception e) {
+ setErrorMessage(request, e.getMessage());
+ e.printStackTrace();
+ }
+
+
+ setAnnouncementsBean(request);
+
+ try {
+ request.getRequestDispatcher(UIConstants.RESOURCE_TREE_JSP).forward(request, response);
+
+ } catch (ServletException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
private void forwardToAdmin(HttpServletRequest request, HttpServletResponse response) {
AdminBean adminBean = AdminUtil.getAdminBean(request);
@@ -960,12 +1004,14 @@
String fromDate = request.getParameter("fromDate");
String toDate = request.getParameter("toDate");
String filter = request.getParameter("filter");
+ int page = Integer.parseInt(request.getParameter("page"));
recentActivityAction.setUserName(userName);
recentActivityAction.setResourcePath(path);
recentActivityAction.setFromDate(fromDate);
recentActivityAction.setToDate(toDate);
recentActivityAction.setFilter(filter);
+ recentActivityAction.setPage(page);
try {
recentActivityAction.execute(request);
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 May 12 01:13:51 2008
@@ -35,6 +35,7 @@
public static final String AJAX_ASSOCIATIONS_LIST = "ajaxAssociations";
public static final String AJAX_LIFECYCLE_LIST = "ajaxLifecycle";
public static final String AJAX_GIVEPAGE_LIST = "givePage";
+ public static final String RESOURCE_TREE_BEAN="resourceTreeBean";
public static final String RESOURCES_PATH = "resources";
public static final String VERSIONS_PATH = "versions";
@@ -60,6 +61,7 @@
public static final String USER_JSP = "/admin/user.jsp";
public static final String VERSIONS_JSP = "/admin/versions.jsp";
public static final String AJAX_RATING_JSP = "/admin/ajax_rating.jsp";
+ public static final String RESOURCE_TREE_JSP="/admin/ajax/resource-tree.jsp";
public static final String AJAX_PERMISSIONS_JSP = "/admin/permisions.jsp";
public static final String AJAX_DESCRIPTION_JSP = "/admin/ajax_desc.jsp";
public static final String AJAX_PROPERTIES_JSP = "/admin/ajax/resource-properties.jsp";
Modified: trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/AssociationTreeViewAction.java
==============================================================================
--- trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/AssociationTreeViewAction.java (original)
+++ trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/AssociationTreeViewAction.java Mon May 12 01:13:51 2008
@@ -18,13 +18,10 @@
public class AssociationTreeViewAction extends AbstractRegistryAction {
private String resourcePath;
- private String test;
-
public void execute(HttpServletRequest request) throws RegistryException {
setRequest(request);
- test="test";
}
public String calculateRelativePath(String resourcePath) {
@@ -58,11 +55,4 @@
this.resourcePath = resourcePath;
}
- public String getTest() {
- return test;
- }
-
- public void setTest(String test) {
- this.test = test;
- }
}
Modified: trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/RecentActivityAction.java
==============================================================================
--- trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/RecentActivityAction.java (original)
+++ trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/RecentActivityAction.java Mon May 12 01:13:51 2008
@@ -17,14 +17,22 @@
package org.wso2.registry.web.actions;
import org.wso2.registry.LogEntry;
+<<<<<<< .mine
+import org.wso2.registry.LogEntryCollection;
+import org.wso2.registry.RegistryConstants;
+import org.wso2.registry.RegistryException;
+=======
import org.wso2.registry.exceptions.RegistryException;
+>>>>>>> .r16838
import org.wso2.registry.session.UserRegistry;
import org.wso2.registry.web.utils.CommonUtil;
import javax.servlet.http.HttpServletRequest;
-import java.util.*;
import java.text.DateFormat;
import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
public class RecentActivityAction extends AbstractRegistryAction {
@@ -33,13 +41,21 @@
private String fromDate;
private String toDate;
private String filter;
+ private int totalCount;
+ private int page;
+ private int pageLen;
+ private int start;
private List activity = new ArrayList();
+
public String execute(HttpServletRequest request) throws Exception {
setRequest(request);
+ pageLen = RegistryConstants.ITEMPS_PER_PAGE;
+ start = (pageLen) * (page - 1);
+
if (resourcePath != null && resourcePath.equals("")) {
resourcePath = null;
}
@@ -81,8 +97,11 @@
}
UserRegistry userRegistry = (UserRegistry) getRegistry();
- LogEntry[] logs = userRegistry.getLogs(resourcePath, filterValue, userName, computeDate(fromDate), computeDate(toDate), true);
-
+ LogEntryCollection logsCollection = userRegistry.getLogCollection(resourcePath, filterValue, userName, computeDate(fromDate), computeDate(toDate), true);
+ LogEntry[] totalLogs =userRegistry.getLogs(resourcePath, filterValue, userName, computeDate(fromDate), computeDate(toDate), true);
+ totalCount = totalLogs.length;
+
+ LogEntry[] logs = logsCollection.getLogEntries(start, pageLen);
for (int i = 0; i < logs.length; i++) {
LogEntry logEntry = logs[i];
@@ -115,6 +134,37 @@
return SUCCESS;
}
+ public int getTotalCount() {
+ return totalCount;
+ }
+
+ public void setTotalCount(int totalCount) {
+ this.totalCount = totalCount;
+ }
+ public int getPageLen() {
+ return pageLen;
+ }
+
+ public void setPageLen(int pageLen) {
+ this.pageLen = pageLen;
+ }
+
+
+ public int getStart() {
+ return start;
+ }
+
+ public void setStart(int start) {
+ this.start = start;
+ }
+
+ public int getPage() {
+ return page;
+ }
+
+ public void setPage(int page) {
+ this.page = page;
+ }
public String getResourcePath() {
return resourcePath;
@@ -168,7 +218,6 @@
* Converts given strings to Dates
*
* @param dateString Allowed format mm/dd/yyyy
- *
* @return Date corresponding to the given string date
*/
private Date computeDate(String dateString) throws RegistryException {
Added: trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/ShowResourceTreeAction.java
==============================================================================
--- (empty file)
+++ trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/ShowResourceTreeAction.java Mon May 12 01:13:51 2008
@@ -0,0 +1,59 @@
+package org.wso2.registry.web.actions;
+
+import org.wso2.registry.*;
+import org.wso2.registry.web.UIConstants;
+import org.wso2.registry.web.actions.utils.ResourceData;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: chanaka jayasena
+ * Date: May 11, 2008
+ * Time: 1:47:55 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class ShowResourceTreeAction extends AbstractRegistryAction {
+ private String test;
+
+ public String execute(HttpServletRequest request) throws RegistryException {
+ test = "xxx";
+ setRequest(request);
+ return SUCCESS;
+ }
+ public Map<String, String[]> fetchChildren(String queryPath){
+
+ Map<String, String[]> childcollection=null;
+ try {
+ Registry registry = getRegistry();
+ String[] childPaths;
+ Resource resource;
+ resource = registry.get(queryPath);
+ childPaths = (String[])resource.getContent();
+ for(String childPath: childPaths){
+ String childName = null;
+
+ if (childPath != null) {
+ String[] parts = childPath.split(RegistryConstants.PATH_SEPARATOR);
+ childName = parts[parts.length - 1];
+ }
+ Resource child = registry.get(childPath);
+ String childResourceType = child instanceof Collection ? ResourceData.COLLECTION : ResourceData.RESOURCE;
+
+ String[] childData = {childPath,childResourceType };
+
+ childcollection.put(childName,childData);
+ }
+
+ } catch (RegistryException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+
+ return childcollection;
+ }
+
+
+}
+
Modified: trunk/registry/modules/webapps/src/main/webapp/admin/ajax/activity.jsp
==============================================================================
--- trunk/registry/modules/webapps/src/main/webapp/admin/ajax/activity.jsp (original)
+++ trunk/registry/modules/webapps/src/main/webapp/admin/ajax/activity.jsp Mon May 12 01:13:51 2008
@@ -1,3 +1,4 @@
+<%@ page import="org.wso2.registry.RegistryConstants" %>
<%@ page import="org.wso2.registry.web.UIConstants" %>
<%@ page import="org.wso2.registry.web.actions.RecentActivityAction" %>
<%@ page import="java.util.Iterator" %>
@@ -11,14 +12,36 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
RecentActivityAction recentActivity = (RecentActivityAction) request.getSession().getAttribute(UIConstants.ACTIVITY_BEAN);
+ int pageNumber=recentActivity.getPage();
+ int totalCount= recentActivity.getTotalCount();
%>
+<ul class="search-information">
+ <li></li>
+</ul>
<table cellpadding="0" cellspacing="0" border="0" style="width:100%" class="data-table">
- <%
+ <%
+
+ int start;
+
+ int itemsPerPage= RegistryConstants.ITEMPS_PER_PAGE;
+
+
+ int numberOfPages=1;
+ if(totalCount%itemsPerPage==0)numberOfPages= totalCount/itemsPerPage;
+ else numberOfPages= totalCount/itemsPerPage+1;
+
+ if(totalCount<itemsPerPage){
+ start=0;
+ }
+ else{
+ start=(pageNumber-1)*itemsPerPage;
+ }
Iterator i = recentActivity.getActivity().iterator();
if(!recentActivity.getActivity().isEmpty()){
%>
+
<tr>
- <th>Activities</th>
+ <th>Activities<%=totalCount%></th>
</tr>
@@ -31,6 +54,46 @@
<td><%=activity%></td>
</tr>
- <% } %>
+ <% }
+
+ if(totalCount<=itemsPerPage){
+ //No paging
+ }
+ else{
+ %>
+ <tr><td class="pagingRow">
+
+ <%
+ if(pageNumber==1){
+ %>
+ <span class="disableLink">< Prev</span>
+ <%
+ }
+ else{
+ %>
+ <a class="pageLinks" onclick="submitActivityForm(<%=(pageNumber-1)%>)">< Prev</a>
+ <%
+ }
+ for(int pageItem=1;pageItem<=numberOfPages;pageItem++){ %>
+
+ <a class="pageLinks" onclick="submitActivityForm(<%=pageItem%>)" style="margin-left:5px;margin-right:5px;"><%=pageItem%></a>
+ <% }
+
+ if(pageNumber==numberOfPages){
+ %>
+ <span class="disableLink">Next ></span>
+ <%
+ }
+ else{
+ %>
+ <a class="pageLinks" onclick="submitActivityForm(<%=(pageNumber+1)%>)">Next ></a>
+ <%
+ }
+ %>
+
+ </td></tr>
+ <% } %>
+
+
</table>
\ No newline at end of file
Added: trunk/registry/modules/webapps/src/main/webapp/admin/ajax/resource-tree.jsp
==============================================================================
--- (empty file)
+++ trunk/registry/modules/webapps/src/main/webapp/admin/ajax/resource-tree.jsp Mon May 12 01:13:51 2008
@@ -0,0 +1,20 @@
+<%@ page import="org.wso2.registry.web.UIConstants" %>
+<%@ page import="org.wso2.registry.web.actions.ShowResourceTreeAction" %>
+<%@ page import="java.util.Iterator" %>
+<%@ page import="java.util.Map" %>
+<%@ page import="org.wso2.registry.RegistryConstants" %>
+<%--
+ Created by IntelliJ IDEA.
+ User: chanaka jayasena
+ Date: May 11, 2008
+ Time: 12:17:20 PM
+ To change this template use File | Settings | File Templates.
+--%>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<%
+ ShowResourceTreeAction details = (ShowResourceTreeAction) request.getSession().getAttribute(UIConstants.RESOURCE_TREE_BEAN);
+%>
+<h1>Resource Tree</h1>
+
+<%=details.fetchChildren("/")%>
+
\ No newline at end of file
Modified: trunk/registry/modules/webapps/src/main/webapp/admin/css/main.css
==============================================================================
--- trunk/registry/modules/webapps/src/main/webapp/admin/css/main.css (original)
+++ trunk/registry/modules/webapps/src/main/webapp/admin/css/main.css Mon May 12 01:13:51 2008
@@ -803,4 +803,12 @@
border:1px solid #DDDDDD;
padding:2px 6px;
text-decoration:none;
+}
+.resourceTreePage{
+ border:solid 1px #cccccc;
+ position:absolute;
+ margin:30px;
+ margin-top:100px;
+ width:100%;
+ height:100%;
}
\ No newline at end of file
Modified: trunk/registry/modules/webapps/src/main/webapp/admin/js/common.js
==============================================================================
--- trunk/registry/modules/webapps/src/main/webapp/admin/js/common.js (original)
+++ trunk/registry/modules/webapps/src/main/webapp/admin/js/common.js Mon May 12 01:13:51 2008
@@ -747,31 +747,36 @@
}
}
-function submitActivityForm(){
- var reasonDiv=$('activityReason');
+function submitActivityForm(page){
+ var reasonDiv=document.getElementById('activityReason');
var reason="";
- var fromDate = $('fromDate');
- var toDate = $('toDate');
- var userName= $('userName');
- var path = $('path');
+ var fromDate = document.getElementById('fromDate');
+ var toDate = document.getElementById('toDate');
+ var userName= document.getElementById('user');
+ var path = document.getElementById('path');
var filterElement = document.getElementById('filter');
var filter =filterElement.options[filterElement.selectedIndex].value;
if(fromDate.value!="") reason +=validateDate(fromDate,"From");
if(toDate.value!="") reason +=validateDate(toDate,"To");
- if(userName.value!="") reason +=validateForInput($('userName'),"Username");
+ if(userName.value!="") reason +=validateForInput(userName,"Username");
if(path.value!="") reason +=validateForInput(path,"Path");
+ var fromDateValue = fromDate.value;
+ var toDateValue = toDate.value;
+ var userNameValue = userName.value;
+ var pathValue = path.value;
+
reasonDiv.innerHTML=reason;
if(reason!="") {
reasonDiv.style.display="block";
return false;
}
else {
-
- new Ajax.Updater('activityList', '/wso2registry/system/activity', { method: 'get', parameters: {fromDate: fromDate.value, toDate: toDate.value, userName:userName.value,path:path.value,filter:filter} });
+
+ new Ajax.Updater('activityList', '/wso2registry/system/activity', { method: 'post', parameters: {fromDate: fromDateValue, toDate: toDateValue, userName:userNameValue,path:pathValue,filter:filter,page:page} });
//document.forms["activityForm"].submit();
}
}
@@ -848,4 +853,7 @@
if (me.checked == true && peer.checked == true) {
peer.checked = false;
}
+}
+function showResourceTree(){
+ new Ajax.Updater('resourceTree', '/wso2registry/system/resourceTree', { method: 'get', parameters: {} });
}
\ No newline at end of file
Modified: trunk/registry/modules/webapps/src/main/webapp/admin/recent-activity.jsp
==============================================================================
--- trunk/registry/modules/webapps/src/main/webapp/admin/recent-activity.jsp (original)
+++ trunk/registry/modules/webapps/src/main/webapp/admin/recent-activity.jsp Mon May 12 01:13:51 2008
@@ -1,5 +1,6 @@
-<%@ page import="org.wso2.registry.web.actions.RecentActivityAction" %>
+<%@ page import="org.wso2.registry.RegistryConstants" %>
<%@ page import="org.wso2.registry.web.UIConstants" %>
+<%@ page import="org.wso2.registry.web.actions.RecentActivityAction" %>
<%@ page import="java.util.Iterator" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
@@ -71,7 +72,7 @@
<table cellpadding="0" cellspacing="0" border="0" class="form-table">
<tr>
<td style="width:100px;" valign="top">Username</td>
- <td><input type="text" name="userName" id="userName" /></td>
+ <td><input type="text" name="userName" id="user" /></td>
</tr>
<tr>
<td valign="top">Path</td>
@@ -124,14 +125,31 @@
<tr>
<td></td>
- <td><input class="button" type="button" onclick="submitActivityForm();" value="Search Activities"/></td>
+ <td><input class="button" type="button" onclick="submitActivityForm(1);" value="Search Activities"/></td>
</tr>
</table>
</form>
<div id="activityList">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%" class="data-table">
- <%
+ <% int totalCount= recentActivity.getActivity().size();
+
+
+ int start;
+
+ int itemsPerPage= RegistryConstants.ITEMPS_PER_PAGE;
+ int pageNumber = 1;
+
+ int numberOfPages=1;
+ if(totalCount%itemsPerPage==0)numberOfPages= totalCount/itemsPerPage;
+ else numberOfPages= totalCount/itemsPerPage+1;
+
+ if(totalCount<itemsPerPage){
+ start=0;
+ }
+ else{
+ start=(pageNumber-1)*itemsPerPage;
+ }
Iterator i = recentActivity.getActivity().iterator();
if(!recentActivity.getActivity().isEmpty()){
%>
@@ -151,6 +169,46 @@
<% } %>
+ <%
+ if(totalCount<=itemsPerPage){
+ //No paging
+ }
+ else{
+ %>
+ <tr><td class="pagingRow">
+
+ <%
+ if(pageNumber==1){
+ %>
+ <span class="disableLink">< Prev</span>
+ <%
+ }
+ else{
+ %>
+ <a class="pageLinks" onclick="submitActivityForm(<%=(pageNumber-1)%>)">< Prev</a>
+ <%
+ }
+ for(int pageItem=1;pageItem<=numberOfPages;pageItem++){ %>
+
+ <a class="pageLinks" onclick="submitActivityForm(<%=pageItem%>)" style="margin-left:5px;margin-right:5px;"><%=pageItem%></a>
+ <% }
+
+ if(pageNumber==numberOfPages){
+ %>
+ <span class="disableLink">Next ></span>
+ <%
+ }
+ else{
+ %>
+ <a class="pageLinks" onclick="submitActivityForm(<%=(pageNumber+1)%>)">Next ></a>
+ <%
+ }
+ %>
+
+ </td></tr>
+ <% } %>
+
+
</table>
</div>
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 May 12 01:13:51 2008
@@ -1062,7 +1062,7 @@
</tr>
<tr>
<th>Association Path:</th>
- <td><input type="text" id="associationPaths" name="associationPaths"/></td>
+ <td><input type="text" id="associationPaths" name="associationPaths"/> <!-- input type="button" value=".." onclick="showResourceTree();showHideCommon('resourceTree')" / --> </td>
</tr>
<tr>
<td></td>
@@ -1129,6 +1129,6 @@
<jsp:include page="footer.jsp"/>
</div>
-
+ <div id="resourceTree" style="display:none" class="resourceTreePage"></div>
</body>
</html>
More information about the Registry-dev
mailing list