[Registry-dev] svn commit r16651 - in trunk/registry/modules:
core/src/main/java/org/wso2/registry
webapps/src/main/java/org/wso2/registry/web
webapps/src/main/java/org/wso2/registry/web/actions
webapps/src/main/java/org/wso2/registry/web/utils
webapps/src/main/webapp/admin webapps/src/main/webapp/admin/ajax
webapps/src/main/webapp/admin/js
svn at wso2.org
svn at wso2.org
Wed May 7 21:55:18 PDT 2008
Author: chanaka
Date: Wed May 7 21:54:54 2008
New Revision: 16651
Log:
Introduced pagination to UI (resource page)
TODO:
1 - properly style the pagination
2 - Implement pagination in Search results
3 - Handle delete resource, add resource during pagination in a user friendly way.
Added:
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/CollectionPagesViewAction.java
Modified:
trunk/registry/modules/core/src/main/java/org/wso2/registry/RegistryConstants.java
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/utils/ResourcesUtil.java
trunk/registry/modules/webapps/src/main/webapp/admin/ajax/entry-list.jsp
trunk/registry/modules/webapps/src/main/webapp/admin/js/common.js
trunk/registry/modules/webapps/src/main/webapp/admin/registry-resources.jsp
Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/RegistryConstants.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/RegistryConstants.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/RegistryConstants.java Wed May 7 21:54:54 2008
@@ -73,6 +73,7 @@
public static final String PATH = "path";
public static final int ACTIVE_STATE = 100;
public static final int DELETED_STATE = 101;
+ public static final int ITEMPS_PER_PAGE = 10;
// dependency types for setting dependencies between resources
public static final String DEFAULT_DEPENDENCY = "default";
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 Wed May 7 21:54:54 2008
@@ -240,6 +240,16 @@
forwardToResources(request, response, path);
}
+ } else if (command.equals("/givePage")) {
+
+ try {
+ ResourcesUtil.givePage(request, response);
+ } catch (Exception e) {
+ // todo: implement a general AJAX error segment
+ setErrorMessage(request, e.getMessage());
+ forwardToResources(request, response, path);
+ }
+
} else if (command.equals("/addComment")) {
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 Wed May 7 21:54:54 2008
@@ -33,6 +33,7 @@
public static final String AJAX_COMMENTS_LIST = "ajaxComments";
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 RESOURCES_PATH = "resources";
public static final String VERSIONS_PATH = "versions";
Added: trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/CollectionPagesViewAction.java
==============================================================================
--- (empty file)
+++ trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/CollectionPagesViewAction.java Wed May 7 21:54:54 2008
@@ -0,0 +1,284 @@
+/*
+ * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * Licensed 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.wso2.registry.web.actions;
+
+import org.wso2.registry.*;
+import org.wso2.registry.servlet.utils.UserUtil;
+import org.wso2.registry.secure.AuthorizationFailedException;
+import org.wso2.registry.web.MediaTypesReader;
+import org.wso2.registry.web.actions.utils.ResourceData;
+import org.wso2.registry.web.actions.utils.ResourcePath;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.ArrayList;
+import java.util.List;
+
+public class CollectionPagesViewAction extends AbstractRegistryAction {
+
+// private Log log = LogFactory.getLog(CollectionViewAction.class);
+
+ private String path;
+ private List resourceDataList = new ArrayList();
+ private String parentPath;
+ private String status;
+ private String errorMessage;
+ private List navigatablePaths = new ArrayList();
+ private List collectionTypes = new ArrayList();
+ private String[] childPaths;
+
+ public String execute(HttpServletRequest request) throws RegistryException {
+
+ setRequest(request);
+
+ // get the resource for the path
+ // get all its children and fill ResourceOverview objects
+ // add ResourceOverview object to the resourceDataList list
+
+ Registry registry = getRegistry();
+
+ // if path is not set, we assume that root "/" is requested
+ if (path == null || path.length() == 0) {
+ path = RegistryConstants.ROOT_PATH;
+ }
+
+ if (path.equals(RegistryConstants.ROOT_PATH)) {
+
+ ResourcePath resourcePath = new ResourcePath();
+ resourcePath.setNavigateName("root");
+ resourcePath.setNavigatePath("#");
+
+ navigatablePaths.add(resourcePath);
+
+ } else {
+
+ // first add the root path
+ ResourcePath rootPath = new ResourcePath();
+ rootPath.setNavigateName("root");
+ rootPath.setNavigatePath(RegistryConstants.ROOT_PATH);
+ navigatablePaths.add(rootPath);
+
+ String preparedPath = path;
+ if (preparedPath.startsWith(RegistryConstants.PATH_SEPARATOR)) {
+ preparedPath = preparedPath.substring(RegistryConstants.PATH_SEPARATOR.length());
+ }
+
+ if (preparedPath.endsWith(RegistryConstants.PATH_SEPARATOR)) {
+ preparedPath = preparedPath.
+ substring(0, preparedPath.length() - RegistryConstants.PATH_SEPARATOR.length());
+ }
+
+ String[] parts = preparedPath.split(RegistryConstants.PATH_SEPARATOR);
+ for (int i = 0; i < parts.length; i++) {
+ ResourcePath resourcePath = new ResourcePath();
+ resourcePath.setNavigateName(parts[i]);
+
+ String tempPath = "";
+ for (int j = 0; j < i + 1; j++) {
+ tempPath = tempPath + RegistryConstants.PATH_SEPARATOR + parts[j];
+ }
+ resourcePath.setNavigatePath(tempPath);
+ navigatablePaths.add(resourcePath);
+ }
+ }
+
+
+
+ // construct the parent path
+ if (path.equals(RegistryConstants.ROOT_PATH)) {
+ parentPath = "root";
+ } else {
+ String formattedPath = path;
+ if (path.endsWith(RegistryConstants.PATH_SEPARATOR)) {
+ formattedPath = path.substring(
+ 0, path.length() - RegistryConstants.PATH_SEPARATOR.length());
+ }
+
+ if (formattedPath.lastIndexOf(RegistryConstants.PATH_SEPARATOR) == 0) {
+ parentPath = RegistryConstants.ROOT_PATH;
+ } else {
+ parentPath = formattedPath.substring(
+ 0, formattedPath.lastIndexOf(RegistryConstants.PATH_SEPARATOR));
+ }
+ }
+
+ Resource resource ;
+ try {
+ resource = registry.get(path);
+ } catch (AuthorizationFailedException e) {
+ status = "error";
+ errorMessage = "User " + getUserName() +
+ " does not have permission to browse this collection.";
+ return ERROR;
+ }
+
+ if (resource == null) {
+ status = "error";
+ errorMessage = "Requested collection at path " + path + " does not exists.";
+ return ERROR;
+ }
+
+ for (String childPath : childPaths) {
+
+ try {
+ Resource child = registry.get(childPath);
+
+ ResourceData resourceData = new ResourceData();
+ resourceData.setResourcePath(childPath);
+
+ if (childPath != null) {
+ String[] parts = childPath.split(RegistryConstants.PATH_SEPARATOR);
+ resourceData.setName(parts[parts.length - 1]);
+ }
+
+ resourceData.setResourceType(child instanceof Collection ?
+ ResourceData.COLLECTION : ResourceData.RESOURCE);
+ resourceData.setAuthorUserName(child.getAuthorUserName());
+ resourceData.setDescription(child.getDescription());
+ resourceData.setAverageRating(registry.getAverageRating(child.getPath()));
+ resourceData.setCreatedOn(child.getCreatedTime());
+ resourceData.setDeleteAllowed(
+ UserUtil.isDeleteAllowed(getUserName(), childPath, request));
+ calculateAverageStars(resourceData);
+
+ resourceDataList.add(resourceData);
+
+ } catch (AuthorizationFailedException ignore) {
+ // if we get an auth failed exception while accessing a child, we simply skip it.
+ // we are not showing unauthorized resources.
+ }
+
+
+ }
+
+ collectionTypes = MediaTypesReader.getCollectionMediaTypes(request);
+
+ status = "success";
+ return SUCCESS;
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public void setPath(String path) {
+
+ // we are handling only the current version in the human view
+ //if (path.indexOf("?") > 0) {
+ // path = path.split("\\?")[0];
+ //}
+
+ this.path = path;
+ }
+
+ public List getResourceDataList() {
+ return resourceDataList;
+ }
+
+ public void setResourceDataList(List resourceDataList) {
+ this.resourceDataList = resourceDataList;
+ }
+
+ public String getParentPath() {
+ return parentPath;
+ }
+
+ public void setParentPath(String parentPath) {
+ this.parentPath = parentPath;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+
+ public void setErrorMessage(String errorMessage) {
+ this.errorMessage = errorMessage;
+ }
+
+ public List getNavigatablePaths() {
+ return navigatablePaths;
+ }
+
+ public void setNavigatablePaths(List navigatablePaths) {
+ this.navigatablePaths = navigatablePaths;
+ }
+
+ public List getCollectionTypes() {
+ return collectionTypes;
+ }
+
+ public void setCollectionTypes(List collectionTypes) {
+ this.collectionTypes = collectionTypes;
+ }
+ public String[] getChildPaths() {
+ return childPaths;
+ }
+
+ public void setChildPaths(String[] childPaths) {
+ this.childPaths = childPaths;
+ }
+ private void calculateAverageStars(ResourceData resourceData) {
+
+ float tempRating = resourceData.getAverageRating() * 1000;
+ tempRating = Math.round(tempRating);
+ tempRating = tempRating / 1000;
+ resourceData.setAverageRating(tempRating);
+
+ float averageRating = resourceData.getAverageRating();
+ String[] averageStars = new String[5];
+
+ for (int i = 0; i < 5; i++) {
+
+ if (averageRating >= i + 1) {
+ averageStars[i] = "04";
+
+ } else if (averageRating <= i) {
+ averageStars[i] = "00";
+
+ } else {
+
+ float fraction = averageRating - i;
+
+ if (fraction <= 0.125) {
+ averageStars[i] = "00";
+
+ } else if (fraction > 0.125 && fraction <= 0.375) {
+ averageStars[i] = "01";
+
+ } else if (fraction > 0.375 && fraction <= 0.625) {
+ averageStars[i] = "02";
+
+ } else if (fraction > 0.625 && fraction <= 0.875) {
+ averageStars[i] = "03";
+
+ } else {
+ averageStars[i] = "04";
+
+ }
+ }
+ }
+
+ resourceData.setAverageStars(averageStars);
+ }
+}
Modified: trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/utils/ResourcesUtil.java
==============================================================================
--- trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/utils/ResourcesUtil.java (original)
+++ trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/utils/ResourcesUtil.java Wed May 7 21:54:54 2008
@@ -86,11 +86,18 @@
String versionPath = request.getParameter("versionPath");
userRegistry.restoreVersion(versionPath);
}
+ public static void givePage(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ String wantedPage = request.getParameter("wantedPage");
+ request.getSession().setAttribute(UIConstants.AJAX_GIVEPAGE_LIST, wantedPage);
+ request.getRequestDispatcher(UIConstants.AJAX_ENTRY_LIST_JSP).forward(request, response);
+ }
public static void renameResource(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String parentPath = request.getParameter("parentPath");
+ String wantedPage = request.getParameter("wantedPage");
if (!parentPath.endsWith(RegistryConstants.PATH_SEPARATOR)) {
parentPath = parentPath + RegistryConstants.PATH_SEPARATOR;
}
@@ -130,7 +137,7 @@
parentPath + ". Caused by: " + e.getMessage();
setErrorMessage(request, msg);
}
-
+ request.getSession().setAttribute(UIConstants.AJAX_GIVEPAGE_LIST, wantedPage);
request.getSession().setAttribute(UIConstants.RESOURCE_BEAN, resourceAction);
request.getSession().setAttribute(UIConstants.COLLECTION_BEAN, collectionView);
Modified: trunk/registry/modules/webapps/src/main/webapp/admin/ajax/entry-list.jsp
==============================================================================
--- trunk/registry/modules/webapps/src/main/webapp/admin/ajax/entry-list.jsp (original)
+++ trunk/registry/modules/webapps/src/main/webapp/admin/ajax/entry-list.jsp Wed May 7 21:54:54 2008
@@ -1,7 +1,12 @@
-<%@ page import="org.wso2.registry.web.actions.CollectionViewAction" %>
+<%@ page import="org.wso2.registry.Collection" %>
+<%@ page import="org.wso2.registry.Registry" %>
+<%@ page import="org.wso2.registry.RegistryConstants" %>
<%@ page import="org.wso2.registry.web.UIConstants" %>
+<%@ page import="org.wso2.registry.web.actions.CollectionPagesViewAction" %>
+<%@ page import="org.wso2.registry.web.actions.CollectionViewAction" %>
<%@ page import="org.wso2.registry.web.actions.ResourceDetailsAction" %>
<%@ page import="org.wso2.registry.web.actions.utils.ResourceData" %>
+<%@ page import="org.wso2.registry.web.utils.CommonUtil" %>
<%@ page import="java.util.Iterator" %>
<%--
Created by IntelliJ IDEA.
@@ -13,6 +18,8 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
+ String commingPage = (String) request.getSession().getAttribute(UIConstants.AJAX_GIVEPAGE_LIST);
+ int pageNumber=new Integer(commingPage).intValue();
CollectionViewAction collection = (CollectionViewAction) request.getSession().getAttribute(UIConstants.COLLECTION_BEAN);
ResourceDetailsAction details = (ResourceDetailsAction) request.getSession().getAttribute(UIConstants.RESOURCE_BEAN);
String errorMessage = (String) request.getSession().getAttribute(UIConstants.ERROR_MESSAGE);
@@ -25,64 +32,137 @@
<div class="error-message"><%=errorMessage%></div>
<% } %>
-<table cellpadding="0" cellspacing="0" border="0" style="width:100%;" class="data-table">
- <%
- if(!collection.getResourceDataList().isEmpty()) {
- %>
- <tr>
- <th>Name</th>
- <th>Created Date</th>
- <th>Author</th>
- <th>Rating</th>
- <th colspan="2" style="width:50px;">Action</th>
-
- </tr>
- <%
- }
- Iterator iterator = collection.getResourceDataList().iterator();
- int entryNumber = 0;
- while (iterator.hasNext()) {
- ResourceData resourceData = (ResourceData) iterator.next();
- entryNumber++;
- %>
- <tr id="1">
- <td>
- <% if (resourceData.getResourceType() == ResourceData.COLLECTION) { %>
- <img src="/wso2registry/admin/images/icon-folder-small.gif" style="margin-right:5px;" /><a href="/wso2registry/web/<%=resourceData.getRelativePath()%>" id="resourceView<%=entryNumber%>"><%=resourceData.getName()%></a>
- <input type="text" id="resourceEdit<%=entryNumber%>" style="display:none" value="<%=resourceData.getName()%>" />
+
+ <table cellpadding="0" cellspacing="0" border="0" style="width:100%;" class="data-table">
+ <%
+ if (!collection.getResourceDataList().isEmpty()) {
+ %>
+ <tr>
+ <th>Name</th>
+ <th>Created Date</th>
+ <th>Author</th>
+ <th>Rating</th>
+ <th style="width:50px;">Action</th>
+
+ </tr>
+ <%
+ }
+ Registry registry= CommonUtil.getUserRegistry(request);
+ int totalCount= collection.getResourceDataList().size();
+
+ int start;
+ int end;
+ int itemsPerPage= RegistryConstants.ITEMPS_PER_PAGE;
+
+
+ int numberOfPages = totalCount/itemsPerPage+1;
+
+ if(totalCount<itemsPerPage){
+ start=0;
+ end=totalCount;
+ }
+ else{
+ start=(pageNumber-1)*itemsPerPage;
+ end=(pageNumber-1)*itemsPerPage + itemsPerPage;
+ }
+
+ Collection col=registry.get(details.getPath(),start,end) ;
+ String[] childNodes=col.getChildren();
+ CollectionPagesViewAction childCollection=null;
+
+
+ if (details.isCollection()) {
+ childCollection = new CollectionPagesViewAction();
+ childCollection.setPath(details.getPath());
+ childCollection.setChildPaths(childNodes);
+ childCollection.execute(request);
+ }
+
+ Iterator iterator = childCollection.getResourceDataList().iterator();
+ int entryNumber = 0;
+ while (iterator.hasNext()) {
+ ResourceData resourceData = (ResourceData) iterator.next();
+ entryNumber++;
+ %>
+ <tr id="1">
+ <td>
+ <% if (resourceData.getResourceType() == ResourceData.COLLECTION) { %>
+ <img src="/wso2registry/admin/images/icon-folder-small.gif" style="margin-right:5px;"/><a
+ href="/wso2registry/web/<%=resourceData.getRelativePath()%>"
+ id="resourceView<%=entryNumber%>"><%=resourceData.getName()%>
+ </a>
+ <input type="text" id="resourceEdit<%=entryNumber%>" style="display:none"
+ value="<%=resourceData.getName()%>"/>
<% if (resourceData.isDeleteAllowed() && !details.isVersionView()) { %>|
- <a title="Edit Collection Name" onclick="showHideCommon('resourceEdit<%=entryNumber%>');showHideCommon('resourceView<%=entryNumber%>'); showHideCommon('resourceSaveButton<%=entryNumber%>');showHideCommon('resourceEditButton<%=entryNumber%>');$('resourceEdit<%=entryNumber%>').focus();" id="resourceEditButton<%=entryNumber%>"><img src="/wso2registry/admin/images/icon-edit.gif" border="0" align="top" id="resourceEditButton" /></a>
- <a onclick="renameResource('<%=details.getPath()%>', '<%=resourceData.getResourcePath()%>', 'resourceEdit<%=entryNumber%>');showHideCommon('resourceEdit<%=entryNumber%>');showHideCommon('resourceView<%=entryNumber%>'); showHideCommon('resourceSaveButton<%=entryNumber%>');showHideCommon('resourceEditButton<%=entryNumber%>');" id="resourceSaveButton<%=entryNumber%>" style="display:none;"><img border="0" align="top" title="Save" src="/wso2registry/admin/images/save-button.gif" /></a>
+ <a title="Edit Collection Name"
+ onclick="showHideCommon('resourceEdit<%=entryNumber%>');showHideCommon('resourceView<%=entryNumber%>'); showHideCommon('resourceSaveButton<%=entryNumber%>');showHideCommon('resourceEditButton<%=entryNumber%>');$('resourceEdit<%=entryNumber%>').focus();"
+ id="resourceEditButton<%=entryNumber%>"><img src="/wso2registry/admin/images/icon-edit.gif"
+ border="0" align="top" id="resourceEditButton"/></a>
+ <a onclick="renameResource('<%=details.getPath()%>', '<%=resourceData.getResourcePath()%>', 'resourceEdit<%=entryNumber%>',<%=pageNumber%>);showHideCommon('resourceEdit<%=entryNumber%>');showHideCommon('resourceView<%=entryNumber%>'); showHideCommon('resourceSaveButton<%=entryNumber%>');showHideCommon('resourceEditButton<%=entryNumber%>');"
+ id="resourceSaveButton<%=entryNumber%>" style="display:none;"><img border="0" align="top"
+ title="Save"
+ src="/wso2registry/admin/images/save-button.gif"/></a>
<% } %>
- <% } else { %>
- <div style="margin-left:20px;">
- <a href="/wso2registry/web/<%=resourceData.getRelativePath()%>" id="resourceView<%=entryNumber%>"><%=resourceData.getName()%></a>
- <input type="text" id="resourceEdit<%=entryNumber%>" style="display:none" value="<%=resourceData.getName()%>" />
- | <a href="/wso2registry/resources<%=resourceData.getResourcePath()%>" target="_blank" title="Download" ><img src="/wso2registry/admin/images/icon-download.jpg" border="0" align="top" /></a>
- <% if (resourceData.isDeleteAllowed() && !details.isVersionView()) { %>| <a title="Edit Resource Name" onclick="showHideCommon('resourceEdit<%=entryNumber%>');showHideCommon('resourceView<%=entryNumber%>'); showHideCommon('resourceSaveButton<%=entryNumber%>');showHideCommon('resourceEditButton<%=entryNumber%>');$('resourceEdit<%=entryNumber%>').focus();" id="resourceEditButton<%=entryNumber%>"><img src="/wso2registry/admin/images/icon-edit.gif" border="0" align="top" id="resourceEditButton" /></a>
- <a onclick="renameResource('<%=details.getPath()%>', '<%=resourceData.getResourcePath()%>', 'resourceEdit<%=entryNumber%>');showHideCommon('resourceEdit<%=entryNumber%>');showHideCommon('resourceView<%=entryNumber%>'); showHideCommon('resourceSaveButton<%=entryNumber%>');showHideCommon('resourceEditButton<%=entryNumber%>');" id="resourceSaveButton<%=entryNumber%>" style="display:none;"><img border="0" align="top" title="Save" src="/wso2registry/admin/images/save-button.gif" /></a>
+ <% } else { %>
+ <div style="margin-left:20px;">
+ <a href="/wso2registry/web/<%=resourceData.getRelativePath()%>"
+ id="resourceView<%=entryNumber%>"><%=resourceData.getName()%>
+ </a>
+ <input type="text" id="resourceEdit<%=entryNumber%>" style="display:none"
+ value="<%=resourceData.getName()%>"/>
+ | <a href="/wso2registry/resources<%=resourceData.getResourcePath()%>" target="_blank"
+ title="Download"><img src="/wso2registry/admin/images/icon-download.jpg" border="0"
+ align="top"/></a>
+ <% if (resourceData.isDeleteAllowed() && !details.isVersionView()) { %>| <a
+ title="Edit Resource Name"
+ onclick="showHideCommon('resourceEdit<%=entryNumber%>');showHideCommon('resourceView<%=entryNumber%>'); showHideCommon('resourceSaveButton<%=entryNumber%>');showHideCommon('resourceEditButton<%=entryNumber%>');$('resourceEdit<%=entryNumber%>').focus();"
+ id="resourceEditButton<%=entryNumber%>"><img
+ src="/wso2registry/admin/images/icon-edit.gif" border="0" align="top" id="resourceEditButton"/></a>
+ <a onclick="renameResource('<%=details.getPath()%>', '<%=resourceData.getResourcePath()%>', 'resourceEdit<%=entryNumber%>',<%=pageNumber%>);showHideCommon('resourceEdit<%=entryNumber%>');showHideCommon('resourceView<%=entryNumber%>'); showHideCommon('resourceSaveButton<%=entryNumber%>');showHideCommon('resourceEditButton<%=entryNumber%>');"
+ id="resourceSaveButton<%=entryNumber%>" style="display:none;"><img border="0" align="top"
+ title="Save"
+ src="/wso2registry/admin/images/save-button.gif"/></a>
+ <% } %>
+ </div>
<% } %>
- </div>
+ </td>
+ <td><%=resourceData.getFormattedCreatedOn()%>
+ </td>
+ <td><%=resourceData.getAuthorUserName()%>
+ </td>
+ <td>
+ <img src="/wso2registry/admin/images/r<%=resourceData.getAverageStars()[0]%>.gif" align="top"/>
+ <img src="/wso2registry/admin/images/r<%=resourceData.getAverageStars()[1]%>.gif" align="top"/>
+ <img src="/wso2registry/admin/images/r<%=resourceData.getAverageStars()[2]%>.gif" align="top"/>
+ <img src="/wso2registry/admin/images/r<%=resourceData.getAverageStars()[3]%>.gif" align="top"/>
+ <img src="/wso2registry/admin/images/r<%=resourceData.getAverageStars()[4]%>.gif" align="top"/>
+ (<%=resourceData.getAverageRating()%>)
+ </td>
+ <td align="left"><a href="/wso2registry/atom<%=resourceData.getResourcePath()%>" target="_blank"
+ title="Subscribe to this feed"><img border="0"
+ src="/wso2registry/admin/images/icon-feed-small.gif"/></a>
+
+ <% if (resourceData.isDeleteAllowed() && !details.isVersionView()) { %><a
+ href="/wso2registry/system/deleteResource?resourcePath=<%=resourceData.getResourcePath()%>"
+ title="Delete" style="margin-left:5px;"><img src="/wso2registry/admin/images/icon-trash.gif"
+ border="0"/></a> <% } %>
+ </td>
+
+ </tr>
+
+
+ <% }
+ if(totalCount<=itemsPerPage){
+ //No paging
+ }
+ else{
+ %>
+ <tr><td colspan="5">
+ <%
+ for(int pageItem=1;pageItem<=numberOfPages;pageItem++){ %>
+ <a class="pageLinks" onclick="navigatePages(<%=pageItem%>)" style="margin-left:5px;margin-right:5px;"><%=pageItem%></a>
+ <% }%>
+ </td></tr>
<% } %>
- </td>
- <td><%=resourceData.getFormattedCreatedOn()%></td>
- <td><%=resourceData.getAuthorUserName()%></td>
- <td>
- <img src="/wso2registry/admin/images/r<%=resourceData.getAverageStars()[0]%>.gif" align="top" />
- <img src="/wso2registry/admin/images/r<%=resourceData.getAverageStars()[1]%>.gif" align="top" />
- <img src="/wso2registry/admin/images/r<%=resourceData.getAverageStars()[2]%>.gif" align="top" />
- <img src="/wso2registry/admin/images/r<%=resourceData.getAverageStars()[3]%>.gif" align="top" />
- <img src="/wso2registry/admin/images/r<%=resourceData.getAverageStars()[4]%>.gif" align="top" />
- (<%=resourceData.getAverageRating()%>)
- </td>
- <td><a href="/wso2registry/atom<%=resourceData.getResourcePath()%>" target="_blank"><img border="0" src="/wso2registry/admin/images/icon-feed-small.gif"/></a>
- </td>
- <td>
- <% if (resourceData.isDeleteAllowed() && !details.isVersionView()) { %><a href="/wso2registry/system/deleteResource?resourcePath=<%=resourceData.getResourcePath()%>" title="Delete" style="margin-left:5px;"><img src="/wso2registry/admin/images/icon-trash.gif" border="0" /></a> <% } %>
- </td>
-
- </tr>
-
- <% } %>
-</table>
\ No newline at end of file
+ </table>
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 Wed May 7 21:54:54 2008
@@ -246,6 +246,7 @@
// remove the original object
obj.parentNode.removeChild(obj);
}
+
function processDescription() {
var normal_div=document.getElementById('descView');
@@ -452,7 +453,7 @@
$('associationPaths').value="";
new Ajax.Updater('associationDiv','/wso2registry/system/addAssociation', {method:'post',parameters:{resourcePath:resourcePath,type:type,associationPaths:associationPaths}}) ;
}
-function renameResource(parentPath, oldResourcePath, resourceEditDivID) {
+function renameResource(parentPath, oldResourcePath, resourceEditDivID,wantedPage) {
var reason="";
var reasonDiv=$('entryListReason');
@@ -463,11 +464,13 @@
return false;
}else{
var newName = document.getElementById(resourceEditDivID).value;
- new Ajax.Updater('entryList', '/wso2registry/system/renameResource', { method: 'post', parameters: {parentPath: parentPath, oldResourcePath: oldResourcePath, newName: newName} });
+ new Ajax.Updater('entryList', '/wso2registry/system/renameResource', { method: 'post', parameters: {parentPath: parentPath, oldResourcePath: oldResourcePath, newName: newName,wantedPage:wantedPage} });
}
}
-
+function navigatePages(wantedPage){
+ new Ajax.Updater('entryList', '/wso2registry/system/givePage', { method: 'post', parameters: {wantedPage: wantedPage} });
+}
function saveFriendlyName(userName) {
var reason="";
var reasonDiv=$('userReason');
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 Wed May 7 21:54:54 2008
@@ -1,7 +1,6 @@
-<%@ page import="org.wso2.registry.Association" %>
-<%@ page import="org.wso2.registry.Comment" %>
-<%@ page import="org.wso2.registry.Tag" %>
+<%@ page import="org.wso2.registry.*" %>
<%@ page import="org.wso2.registry.web.UIConstants" %>
+<%@ page import="org.wso2.registry.web.actions.CollectionPagesViewAction" %>
<%@ page import="org.wso2.registry.web.actions.CollectionViewAction" %>
<%@ page import="org.wso2.registry.web.actions.ResourceDetailsAction" %>
<%@ page import="org.wso2.registry.web.actions.utils.ResourceData" %>
@@ -202,7 +201,7 @@
<a href="/wso2registry/web<%=details.getPermalink()%>"><%=details.getServerBaseURL()%>
/wso2registry/web<%=details.getPermalink()%>
</a>
- <% } else { %>
+ <% } else { %>
/wso2registry/web<%=details.getPermalink()%>
<% } %>
</td>
@@ -215,7 +214,7 @@
<a target="_blank" href="/wso2registry/resources<%=details.getPermalink()%>">
<%=details.getServerBaseURL()%>/wso2registry/resources<%=details.getPermalink()%>
</a>
- <% } else { %>
+ <% } else { %>
<%=details.getServerBaseURL()%>/wso2registry/resources<%=details.getPermalink()%>
<% } %>
</td>
@@ -243,7 +242,7 @@
<td valign="top" style="width:10px;">
<% if (!details.isPutAllowed()) { %>
-
+
<%
} else if (details.isVersionView()) {
%>
@@ -567,7 +566,37 @@
</tr>
<%
}
- Iterator iterator = collection.getResourceDataList().iterator();
+ Registry registry=CommonUtil.getUserRegistry(request);
+ int totalCount= collection.getResourceDataList().size();
+
+
+ int start;
+ int end;
+ int itemsPerPage=RegistryConstants.ITEMPS_PER_PAGE;
+ int pageNumber = 1;
+ int numberOfPages = totalCount/itemsPerPage+1;
+
+ if(totalCount<itemsPerPage){
+ start=0;
+ end=totalCount;
+ }
+ else{
+ start=(pageNumber-1)*itemsPerPage;
+ end=(pageNumber-1)*itemsPerPage + itemsPerPage;
+ }
+ Collection col=registry.get(details.getPath(),start,end) ;
+ String[] childNodes=col.getChildren();
+ CollectionPagesViewAction childCollection=null;
+
+
+ if (details.isCollection()) {
+ childCollection = new CollectionPagesViewAction();
+ childCollection.setPath(details.getPath());
+ childCollection.setChildPaths(childNodes);
+ childCollection.execute(request);
+ }
+
+ Iterator iterator = childCollection.getResourceDataList().iterator();
int entryNumber = 0;
while (iterator.hasNext()) {
ResourceData resourceData = (ResourceData) iterator.next();
@@ -584,10 +613,10 @@
value="<%=resourceData.getName()%>"/>
<% if (resourceData.isDeleteAllowed() && !details.isVersionView()) { %>|
<a title="Edit Collection Name"
- onclick="showHideCommon('resourceEdit<%=entryNumber%>');showHideCommon('resourceView<%=entryNumber%>'); showHideCommon('resourceSaveButton<%=entryNumber%>');showHideCommon('resourceEditButton<%=entryNumber%>');$('resourceEdit<%=entryNumber%>').focus();"
+ onclick="showHideCommon('resourceEdit<%=entryNumber%>');showHideCommon('resourceView<%=entryNumber%>'); showHideCommon('resourceSaveButton<%=entryNumber%>');showHideCommon('resourceEditButton<%=entryNumber%>');$('resourceEdit<%=entryNumber%>').focus();"
id="resourceEditButton<%=entryNumber%>"><img src="/wso2registry/admin/images/icon-edit.gif"
border="0" align="top" id="resourceEditButton"/></a>
- <a onclick="renameResource('<%=details.getPath()%>', '<%=resourceData.getResourcePath()%>', 'resourceEdit<%=entryNumber%>');showHideCommon('resourceEdit<%=entryNumber%>');showHideCommon('resourceView<%=entryNumber%>'); showHideCommon('resourceSaveButton<%=entryNumber%>');showHideCommon('resourceEditButton<%=entryNumber%>');"
+ <a onclick="renameResource('<%=details.getPath()%>', '<%=resourceData.getResourcePath()%>', 'resourceEdit<%=entryNumber%>',<%=pageNumber%>);showHideCommon('resourceEdit<%=entryNumber%>');showHideCommon('resourceView<%=entryNumber%>'); showHideCommon('resourceSaveButton<%=entryNumber%>');showHideCommon('resourceEditButton<%=entryNumber%>');"
id="resourceSaveButton<%=entryNumber%>" style="display:none;"><img border="0" align="top"
title="Save"
src="/wso2registry/admin/images/save-button.gif"/></a>
@@ -607,7 +636,7 @@
onclick="showHideCommon('resourceEdit<%=entryNumber%>');showHideCommon('resourceView<%=entryNumber%>'); showHideCommon('resourceSaveButton<%=entryNumber%>');showHideCommon('resourceEditButton<%=entryNumber%>');$('resourceEdit<%=entryNumber%>').focus();"
id="resourceEditButton<%=entryNumber%>"><img
src="/wso2registry/admin/images/icon-edit.gif" border="0" align="top" id="resourceEditButton"/></a>
- <a onclick="renameResource('<%=details.getPath()%>', '<%=resourceData.getResourcePath()%>', 'resourceEdit<%=entryNumber%>');showHideCommon('resourceEdit<%=entryNumber%>');showHideCommon('resourceView<%=entryNumber%>'); showHideCommon('resourceSaveButton<%=entryNumber%>');showHideCommon('resourceEditButton<%=entryNumber%>');"
+ <a onclick="renameResource('<%=details.getPath()%>', '<%=resourceData.getResourcePath()%>', 'resourceEdit<%=entryNumber%>',<%=pageNumber%>);showHideCommon('resourceEdit<%=entryNumber%>');showHideCommon('resourceView<%=entryNumber%>'); showHideCommon('resourceSaveButton<%=entryNumber%>');showHideCommon('resourceEditButton<%=entryNumber%>');"
id="resourceSaveButton<%=entryNumber%>" style="display:none;"><img border="0" align="top"
title="Save"
src="/wso2registry/admin/images/save-button.gif"/></a>
@@ -640,7 +669,20 @@
</tr>
- <% } %>
+ <% }
+ if(totalCount<=itemsPerPage){
+ //No paging
+ }
+ else{
+ %>
+ <tr><td colspan="5">
+ <%
+ for(int pageItem=1;pageItem<=numberOfPages;pageItem++){ %>
+ <a class="pageLinks" onclick="navigatePages(<%=pageItem%>)" style="margin-left:5px;margin-right:5px;"><%=pageItem%></a>
+ <% }%>
+ </td></tr>
+ <% } %>
+
</table>
</div>
@@ -752,12 +794,12 @@
Go to the current version to add tags
<% } else { %>
-
+
<div id="tagAddTable" style="margin-top:5px;">
-
+
<input id="tfPath" type="hidden" name="resourcePath" value="<%=details.getPath()%>"/>
<input id="tfTag" type="text" name="tag" onkeypress="applyTag(event);"/>
-
+
<div style="font-style:italic;margin-top:5px;">
<img src="/wso2registry/admin/images/help-small.jpg" style="margin-right:5px;"/>Use commas ("one, two")
@@ -766,7 +808,7 @@
</div>
</div>
-
+
<% } %>
</div>
@@ -857,7 +899,7 @@
<td align="right" valign="top">
<table cellpadding="0" cellspacing="0" border="0" class="toolBarTable">
<tr>
-
+
<td>
<% if (details.isLoggedIn() && !details.isVersionView()) { %><a onclick="showHideCommon('add-lifecycle-div');expandIfNot('lifecycle');$('lifecycle').focus();"><img
src="/wso2registry/admin/images/universal-add.gif" border="0" valign="top"
More information about the Registry-dev
mailing list