Author: tyrell
Date: Wed Jan 23 07:18:34 2008
New Revision: 12776
Log:
Integrating live announcements. Fixing MASHUP-567.
Modified:
trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/utils/RegistryUtils.java
trunk/mashup/java/modules/www/taskbar.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
Wed Jan 23 07:18:34 2008
@@ -16,6 +16,9 @@
package org.wso2.mashup;
public interface MashupConstants {
+
+ public static String MASHUP_SERVER_VERSION = "Version";
+
public static String MASHUP_JS_SERVICE = "MashupJSService";
public static String CONTENT_TYPE_QUERY_PARAM = "content-type";
public static String REGISTRY_CONFIG = "RegistryConfig";
@@ -40,7 +43,7 @@
public static String SESSION_MANAGEMENT = "SessionManagement";
public static String REMEMBER_ME_PERIOD = "RememberMePeriod";
-
+
public static String QUARTZ_FUNCTION_SCHEDULER = "FunctionScheduler";
public static String QUARTZ_FUNCTION_SCHEDULER_JOB_IDS =
"FunctionSchedulerJobIds";
Modified:
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/utils/RegistryUtils.java
==============================================================================
---
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/utils/RegistryUtils.java
(original)
+++
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/utils/RegistryUtils.java
Wed Jan 23 07:18:34 2008
@@ -22,10 +22,20 @@
import org.wso2.mashup.utils.QueryResult;
import org.wso2.mashup.utils.QueryResults;
import org.wso2.mashup.webapp.userprofile.User;
-import org.wso2.registry.*;
+import org.wso2.registry.ActionConstants;
+import org.wso2.registry.LogEntry;
+import org.wso2.registry.Registry;
+import org.wso2.registry.RegistryConstants;
+import org.wso2.registry.RegistryException;
+import org.wso2.registry.Resource;
+import org.wso2.registry.announcement.Announcement;
import org.wso2.registry.jdbc.JDBCRegistry;
import org.wso2.registry.secure.SecureRegistry;
-import org.wso2.usermanager.*;
+import org.wso2.usermanager.AccessControlAdmin;
+import org.wso2.usermanager.Realm;
+import org.wso2.usermanager.UserManagerException;
+import org.wso2.usermanager.UserStoreAdmin;
+import org.wso2.usermanager.UserStoreReader;
import org.wso2.usermanager.acl.realm.AuthorizingRealmConfig;
import org.wso2.utils.ServerConfiguration;
import org.wso2.wsas.ServerManager;
@@ -36,7 +46,12 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.HashMap;
+import java.util.Map;
public class RegistryUtils {
@@ -56,7 +71,8 @@
Realm realm = (Realm)
context.getAttribute(RegistryConstants.REGISTRY_REALM);
- SecureRegistry secureRegistry =
createSecureRegistry(RegistryConstants.ANONYMOUS_USER, "guest", jdbcRegistry,
realm);
+ SecureRegistry secureRegistry =
createSecureRegistry(RegistryConstants.ANONYMOUS_USER,
+ "guest",
jdbcRegistry, realm);
request.getSession().setAttribute(MashupConstants.USER_REGISTRY,
secureRegistry);
@@ -65,7 +81,8 @@
return registry;
}
- public static SecureRegistry createSecureRegistry(String username, String
password, Registry registry,
+ public static SecureRegistry createSecureRegistry(String username, String
password,
+ Registry registry,
Realm realm) throws
MashupFault {
SecureRegistry secureRegistry = null;
try {
@@ -79,7 +96,8 @@
return secureRegistry;
}
- public static SecureRegistry createSecureRegistry(String username,
Registry registry, Realm realm)
+ public static SecureRegistry createSecureRegistry(String username,
Registry registry,
+ Realm realm)
throws MashupFault {
SecureRegistry secureRegistry = null;
try {
@@ -93,9 +111,11 @@
return secureRegistry;
}
- private static void setAdminBehaviour(SecureRegistry secureRegistry)
throws UserManagerException {
+ private static void setAdminBehaviour(SecureRegistry secureRegistry)
+ throws UserManagerException {
Realm userRealm = secureRegistry.getUserRealm();
- AuthorizingRealmConfig authorizingRealmConfig =
(AuthorizingRealmConfig)userRealm.getRealmConfiguration();
+ AuthorizingRealmConfig authorizingRealmConfig =
+ (AuthorizingRealmConfig) userRealm.getRealmConfiguration();
authorizingRealmConfig.setEnableAdminBehavior(true);
authorizingRealmConfig.setAdminRoleName(RegistryConstants.ADMIN_ROLE);
}
@@ -380,8 +400,8 @@
Map paramsMap = null;
if (params != null) {
paramsMap = new HashMap(params.length);
- for (int i =0; i < params.length; i++) {
- paramsMap.put(new Integer(i+1).toString(), params[i]);
+ for (int i = 0; i < params.length; i++) {
+ paramsMap.put(new Integer(i + 1).toString(), params[i]);
}
}
Resource resultsCollection = registry.executeQuery(queryPath,
paramsMap);
@@ -497,7 +517,7 @@
mashupCollection.setDirectory(true);
registry.put(MashupConstants.ALL_MASHUPS_PATH + "/" + userName,
mashupCollection);
- controlAdmin.authorizeUser(userName, MashupConstants.ALL_MASHUPS_PATH
, ActionConstants.GET);
+ controlAdmin.authorizeUser(userName, MashupConstants.ALL_MASHUPS_PATH,
ActionConstants.GET);
controlAdmin.authorizeUser(userName, MashupConstants.ALL_MASHUPS_PATH +
"/" + userName, ActionConstants.PUT);
controlAdmin.authorizeUser(userName, MashupConstants.ALL_MASHUPS_PATH +
@@ -646,7 +666,7 @@
try {
if (registry.get(path).getProperty(MashupConstants.FAULTY_MASHUP)
!= null) {
return true;
- }else{
+ } else {
return false;
}
} catch (RegistryException e) {
@@ -654,4 +674,29 @@
return false;
}
}
+
+
+ /**
+ * Gets product and version specific announcements from the pre determined
URL
+ *
+ * @return A string containing the announcement as HTML content, plugable
to a DIV in the UI. Can be blank.
+ */
+ public static String getAnnouncements() {
+ String response = "";
+
+ //Getting the server version from server.xml
+ ServerConfiguration serverConfig = ServerConfiguration.getInstance();
+ String serverVersion =
+ serverConfig
+
.getFirstProperty(MashupConstants.MASHUP_SERVER_VERSION);
+
+ String url = "http://wso2.com/announcements/mashup/" + serverVersion +
"/";
+
+ Announcement announcementFetcher = new Announcement();
+ if ((response = announcementFetcher.get(url)) == null) {
+ response = "";
+ }
+
+ return response;
+ }
}
Modified: trunk/mashup/java/modules/www/taskbar.jsp
==============================================================================
--- trunk/mashup/java/modules/www/taskbar.jsp (original)
+++ trunk/mashup/java/modules/www/taskbar.jsp Wed Jan 23 07:18:34 2008
@@ -319,5 +319,5 @@
</div>
<div class="rbbot"><div class="bg"><div class="rbFooter"></div></div></div>
</div>
-<div id="announcements"></div>
+<div id="announcements"><%=RegistryUtils.getAnnouncements()%></div>
_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev