Author: channa
Date: Mon Mar 24 23:31:49 2008
New Revision: 15057
Log:
Added auto suggest for user name field of mashup search.
Modified:
trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/userprofile/UserInformation.java
trunk/mashup/java/modules/coreservices/servicemetadatalister/src/org/wso2/mashup/coreservices/servicemetadatalister/ServiceMetaDataListerService.java
trunk/mashup/java/modules/www/css/styles.css
trunk/mashup/java/modules/www/js/services.js
trunk/mashup/java/modules/www/search.jsp
Modified:
trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java
==============================================================================
--- trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java
(original)
+++ trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java
Mon Mar 24 23:31:49 2008
@@ -105,6 +105,7 @@
public static final int MAX_RESULTS_COUNT = 1000; // Maximum results to
return.
public static final String IMPOSSIBLE_VALUE = "[EMAIL PROTECTED]@";
+ public static final String WILDCARD_VALUE = "*";
// Default user properties
public static final String SYSTEM_USER = "system";
Modified:
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/userprofile/UserInformation.java
==============================================================================
---
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/userprofile/UserInformation.java
(original)
+++
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/userprofile/UserInformation.java
Mon Mar 24 23:31:49 2008
@@ -22,6 +22,12 @@
private boolean userActive;
private boolean userDeletable;
private String fullName;
+ private String userName;
+
+ public UserInformation(String userName, String fullName) {
+ this.fullName = fullName;
+ this.userName = userName;
+ }
public UserInformation(String userFullName, boolean userActive, boolean
userDeleteable) {
this.userActive = userActive;
@@ -40,4 +46,8 @@
public String getFullName() {
return fullName;
}
+
+ public String getUserName() {
+ return userName;
+ }
}
Modified:
trunk/mashup/java/modules/coreservices/servicemetadatalister/src/org/wso2/mashup/coreservices/servicemetadatalister/ServiceMetaDataListerService.java
==============================================================================
---
trunk/mashup/java/modules/coreservices/servicemetadatalister/src/org/wso2/mashup/coreservices/servicemetadatalister/ServiceMetaDataListerService.java
(original)
+++
trunk/mashup/java/modules/coreservices/servicemetadatalister/src/org/wso2/mashup/coreservices/servicemetadatalister/ServiceMetaDataListerService.java
Mon Mar 24 23:31:49 2008
@@ -16,36 +16,21 @@
package org.wso2.mashup.coreservices.servicemetadatalister;
import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.description.AxisOperation;
import org.apache.axis2.description.AxisService;
import org.apache.axis2.description.Parameter;
import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.axis2.transport.http.util.URIEncoderDecoder;
-import org.wso2.javascript.rhino.JavaScriptEngineConstants;
import org.wso2.mashup.MashupConstants;
import org.wso2.mashup.MashupFault;
import org.wso2.mashup.utils.MashupUtils;
-import org.wso2.mashup.webapp.utils.RegistryUtils;
+import org.wso2.mashup.webapp.userprofile.UserInformation;
import org.wso2.registry.RegistryConstants;
-import org.wso2.registry.RegistryException;
-import org.wso2.registry.Resource;
-import org.wso2.registry.jdbc.JDBCRegistry;
+import org.wso2.registry.users.UserRealm;
+import org.wso2.registry.users.UserStoreException;
+import org.wso2.registry.users.UserStoreReader;
import org.wso2.wsas.ServerConstants;
-import org.wso2.wsas.ServerManager;
-import org.wso2.wsas.persistence.PersistenceManager;
-import org.wso2.wsas.persistence.dataobject.OperationDO;
-import org.wso2.wsas.persistence.dataobject.ServiceDO;
-import org.wso2.wsas.persistence.dataobject.ServiceIdentifierDO;
-import org.wso2.wsas.persistence.exception.ServiceNotFoundException;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.net.URL;
+
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Hashtable;
@@ -169,4 +154,33 @@
return retServiceArray;
}
+ /**
+ * Returns a list of usernames with associated full names, filtered based
on supplied prefix. Wildcard returns
+ * all names.
+ *
+ * @return array of UserInformation objects containing list of usernames
with full names.
+ */
+ public UserInformation[] getUserNames(String namePrefix) throws
MashupFault {
+ UserInformation[] userInfo = null;
+ ArrayList filteredNames = new ArrayList();
+ MessageContext msgCtx = MessageContext.getCurrentMessageContext();
+ UserRealm realm = (UserRealm)
msgCtx.getConfigurationContext().getAxisConfiguration()
+ .getParameterValue(RegistryConstants.REGISTRY_REALM);
+ try {
+ UserStoreReader storeReader = realm.getUserStoreReader();
+ String[] userNames = storeReader.getAllUserNames();
+ for (int i = 0; i < userNames.length; i++) {
+ if (namePrefix.equals(MashupConstants.WILDCARD_VALUE) ||
userNames[i].startsWith(namePrefix)) {
+ String fullName = (String)
storeReader.getUserProperties(userNames[i])
+ .get(MashupConstants.FULL_NAME);
+ filteredNames.add(new UserInformation(userNames[i],
fullName));
+ }
+ }
+ } catch (UserStoreException e) {
+ throw new MashupFault("Cannot get list of user names from
database", e);
+ }
+ userInfo = new UserInformation[filteredNames.size()];
+ filteredNames.toArray(userInfo);
+ return userInfo;
+ }
}
Modified: trunk/mashup/java/modules/www/css/styles.css
==============================================================================
--- trunk/mashup/java/modules/www/css/styles.css (original)
+++ trunk/mashup/java/modules/www/css/styles.css Mon Mar 24 23:31:49 2008
@@ -615,6 +615,15 @@
.nonemptyfield {
}
+.autosuggest {
+ border:solid 1px #cccccc;
+ background-color:#C8DD64;
+}
+
+.autosuggest a {
+ color:black;
+}
+
/*From WSAS Main*/
div#alertMessageBox {
Modified: trunk/mashup/java/modules/www/js/services.js
==============================================================================
--- trunk/mashup/java/modules/www/js/services.js (original)
+++ trunk/mashup/java/modules/www/js/services.js Mon Mar 24 23:31:49 2008
@@ -445,6 +445,21 @@
};
/**
+ * @description Gets a list of users registered on this server.
+ * @param {namePrefix} namePrefix to filter list of user names.
+ * @param {callback} callback User-defined callback function or object.
+ */
+wso2.mashup.services.getUserNames = function (namePrefix, callback) {
+ var callURL = serverURL + "/" + "ServiceMetaDataLister" + "/" ;
+
+ var body_xml = '<req:getUserNamesRequest
xmlns:req="http://servicemetadatalister.coreservices.mashup.wso2.org/xsd">\n' +
+ ' <req:namePrefix>' + namePrefix + '</req:namePrefix>\n' +
+ ' </req:getUserNamesRequest>\n';
+
+ new wso2.wsf.WSRequest(callURL, "getUserNames", body_xml, callback, "",
wso2.mashup.services.defaultErrHandler);
+};
+
+/**
* @description Method used to download a mashup from a remote server
* @method downloadService
* @public
Modified: trunk/mashup/java/modules/www/search.jsp
==============================================================================
--- trunk/mashup/java/modules/www/search.jsp (original)
+++ trunk/mashup/java/modules/www/search.jsp Mon Mar 24 23:31:49 2008
@@ -405,9 +405,14 @@
<title><%= bundle.getString("main.title")%> - Search</title>
<link href="css/styles.css" rel="stylesheet" type="text/css"/>
+ <script type="text/javascript"
src="../wsasadmin/global_params.js"></script>
+ <script type="text/javascript" src="../wsasadmin/js/main.js"></script>
+ <script type="text/javascript" src="js/wso2/WSRequest.js"></script>
+ <script type="text/javascript" src="js/mashup-main.js"></script>
<script language="javascript" src="js/common.js"
type="text/javascript"></script>
<script language="javascript" src="js/prototype.js"
type="text/javascript"></script>
<script language="javascript" src="js/utils.js"
type="text/javascript"></script>
+ <script language="javascript" src="js/services.js"
type="text/javascript"></script>
<script type="text/javascript">
userLoggedOn = <%=RegistryUtils.isLoggedIn(registry) %>;
@@ -477,7 +482,43 @@
$('activity-tab-right').className = "this-tab-right";
}
$(kind).show();
- }
+ }
+
+ function getUserNames(userName) {
+ var namePrefix = document.getElementById("user-mashups").value;
+
+ if (namePrefix.length > 0) {
+ wso2.mashup.services.getUserNames(namePrefix,
getUserNamesCallback);
+ }
+ }
+
+ function getUserNamesCallback() {
+ var xmlBodyContent;
+
+ var browser = WSRequest.util._getBrowser();
+ if (browser == "ie" || browser == "ie7") {
+ xmlBodyContent =
+ this.req.responseXML.getElementsByTagName("ns:return")[0];
+ } else {
+ xmlBodyContent =
+ this.req.responseXML.getElementsByTagName("return")[0];
+ }
+
+ var nameList = document.getElementById("nameList");
+ nameList.innerHTML = "";
+
+ var node = xmlBodyContent;
+ while (node != null) {
+ nameList.innerHTML += "<a href=\"javascript:assignSelected('"
+node.lastChild.firstChild.nodeValue + "');\">" +
node.firstChild.firstChild.nodeValue
+ + "</a><br/>";
+ node = node.nextSibling;
+ }
+ }
+
+ function assignSelected(userName) {
+ document.getElementById("user-mashups").value = userName;
+ document.getElementById("user-mashups-option").value = userName;
+ }
</script>
</head>
@@ -536,33 +577,44 @@
>
<form id="search-mashups" action="search.jsp" method="get">
<td>
- <input type="hidden" name="query" value="mashups"/>
- <select id="scope-mashups" name="scope" onchange="if
($('user-mashups-option').selected) $('user-mashups').show(); else
$('user-mashups').hide();">
- <option value=""
- <% if (searchScope == null || searchScope.equals(""))
{ %>selected="selected"<% } %>
- >
- Everyone's mashups
- </option>
- <% if (RegistryUtils.isLoggedIn(registry)) { %>
- <option value="<%=currentUser%>"
- <% if (searchScope != null &&
searchScope.equals(currentUser)) { %>selected="selected"<% } %>
- >
- My mashups
- </option>
- <% } %>
- <option id="user-mashups-option"
- value="<% if (searchScope != null) {
%><%=searchScope%><% } %>"
- <% if (searchScope != null && !searchScope.equals("")
&& !searchScope.equals(currentUser)) { %>selected="selected"<% } %>
- >
- Mashups by...
- </option>
-
- </select>
- <input type="text" id="user-mashups"
- onkeyup="$('user-mashups-option').value =
$('user-mashups').value"
- <% if (searchScope == null || searchScope.equals("") ||
searchScope.equals(currentUser)) { %>style="display:none"
- <% } else { %>value="<%=searchScope%>"<% } %>
- />
+ <table style="margin-top:-3px;">
+ <tr>
+ <td valign="top">
+ <input type="hidden" name="query" value="mashups"/>
+ <select id="scope-mashups" name="scope"
+ onchange="if
($('user-mashups-option').selected) $('user-mashups').show(); else
$('user-mashups').hide();">
+ <option value=""
+ <% if (searchScope == null ||
searchScope.equals("")) { %>selected="selected"<% } %>
+ >
+ Everyone's mashups
+ </option>
+ <% if (RegistryUtils.isLoggedIn(registry)) { %>
+ <option value="<%=currentUser%>"
+ <% if (searchScope != null &&
searchScope.equals(currentUser)) { %>selected="selected"<% } %>
+ >
+ My mashups
+ </option>
+ <% } %>
+ <option id="user-mashups-option"
+ value="<% if (searchScope != null) {
%><%=searchScope%><% } %>"
+ <% if (searchScope != null &&
!searchScope.equals("") && !searchScope.equals(currentUser)) {
%>selected="selected"<% } %>
+ >
+ Mashups by...
+ </option>
+
+ </select>
+ </td>
+ <td valign="top">
+ <input type="text" id="user-mashups" autocomplete="off"
+ onkeyup="$('user-mashups-option').value =
$('user-mashups').value"
+ onkeyDown="getUserNames(this)"
+ <% if (searchScope == null ||
searchScope.equals("") || searchScope.equals(currentUser)) {
%>style="display:none"
+ <% } else { %>value="<%=searchScope%>"<% } %>
+ />
+ <div align="left" id="nameList"
class="autosuggest"></div>
+ </td>
+ </tr>
+ </table>
</td>
<td>
<input id="searchMashups_for" type="text" name="for" size="50"
_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev