summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSidharth Singh2013-02-27 08:58:45 (EST)
committer Sven Rottstock2013-03-11 06:38:01 (EDT)
commit021162856042715b80627b6f86182d0d90a3cb85 (patch)
treec3484f8bda057ae06cc8920308f9e14105160366
parent6deee345cfbd56dc1f37dd26cb88af2b7dfa3451 (diff)
downloadorg.eclipse.stardust.ui.web-021162856042715b80627b6f86182d0d90a3cb85.zip
org.eclipse.stardust.ui.web-021162856042715b80627b6f86182d0d90a3cb85.tar.gz
org.eclipse.stardust.ui.web-021162856042715b80627b6f86182d0d90a3cb85.tar.bz2
Jira-ID: CRNT-27828
1)Added class DefaultPreferenceProviderUtils.java to read spring config "sungardSkinDefaultPreference" from camino.jar 2)Made changes to LoginDialogBean afterPropertiesSet to read skin preference from DefaultPreferenceProviderUtils.java 3)Refactored some code in PortalPluginSkinResourceResolver for forming the <key,value> pair of <skinFolder,FileList> 4)Made changes to trace.info in TechnicalUserUtils as existing message was misleading. git-svn-id: http://emeafrazerg/svn/ipp/product/trunk/stardust/ui.web@63308 8100b5e0-4d52-466c-ae9c-bdeccbdeaf6b
-rw-r--r--views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/common/PortalPluginSkinResourceResolver.java48
-rw-r--r--views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/common/TechnicalUserUtils.java4
-rw-r--r--views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/common/spi/theme/impl/IppThemeProvider.java11
-rw-r--r--views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/login/dialogs/LoginDialogBean.java48
-rw-r--r--views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/DefaultPreferenceProviderUtils.java37
5 files changed, 113 insertions, 35 deletions
diff --git a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/common/PortalPluginSkinResourceResolver.java b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/common/PortalPluginSkinResourceResolver.java
index 6615bba..b9ca8c5 100644
--- a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/common/PortalPluginSkinResourceResolver.java
+++ b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/common/PortalPluginSkinResourceResolver.java
@@ -78,7 +78,7 @@ public class PortalPluginSkinResourceResolver
List<Resource> extensionResources;
try
{
- extensionResources = discoverModelerExtensions(resolver, webContentBaseUri, pluginFolder, fileName);
+ extensionResources = discoverSkinExtensions(resolver, webContentBaseUri, pluginFolder, fileName);
}
// JBoss is throwing an IOException instead of FileNotFoundException if a
// file cannot be found
@@ -103,8 +103,38 @@ public class PortalPluginSkinResourceResolver
// Split the above path to create 2 paths ex: a) <views-common> b)
// skin1/images
String[] splitArr = extensionWebUri.split(pluginFolder + "/");
- String extensionWebUriKey = webUriPrefix.substring(0, webUriPrefix.lastIndexOf("/")) + pluginFolder
- + "/" + splitArr[1].substring(0, splitArr[1].indexOf("/"));
+ String extensionWebUriKey = (pluginFolder.startsWith(Constants.SKIN_FOLDER, 0) ? webUriPrefix
+ .substring(0, webUriPrefix.lastIndexOf("/")) : "") // if
+ // plugin-folder
+ // is
+ // plugin-id>/public/skins>
+ // skip this
+ // String
+ // manipulation
+ // which
+ // returns the
+ // <plugin-id>
+ + pluginFolder
+ + "/"
+ + (splitArr[1].contains("/") ? splitArr[1].substring(0, splitArr[1].indexOf("/")) : ""); // if
+ // splitArr[1]
+ // contains
+ // the
+ // fileName
+ // only
+ // i.e
+ // Red.css
+ // skip
+ // this
+ // manipulation
+ // which
+ // returns
+ // the
+ // parent
+ // folder
+ // for
+ // skinFile(i.e
+ // skin1/images)
List<String> resourceFile = allExtensions.get(extensionWebUriKey);
if (null == resourceFile)
@@ -113,7 +143,7 @@ public class PortalPluginSkinResourceResolver
allExtensions.put(extensionWebUriKey, resourceFile);
}
resourceFile.add(extensionResUri);
- trace.info("Discovered '" + pluginFolder + "' modeler extensions descriptor at " + extensionWebUri);
+ trace.info("Discovered '" + pluginFolder + "' plugin resource at " + extensionWebUri);
}
}
finally
@@ -132,22 +162,22 @@ public class PortalPluginSkinResourceResolver
/**
*
* @param resolver
- * @param modelerExtensionsBaseUri
+ * @param extensionBaseUri
* @param category
* @param fileName
* @return
* @throws IOException
*/
- private static List<Resource> discoverModelerExtensions(ResourcePatternResolver resolver,
- String modelerExtensionsBaseUri, String category, String fileName) throws IOException
+ private static List<Resource> discoverSkinExtensions(ResourcePatternResolver resolver,
+ String extensionBaseUri, String category, String fileName) throws IOException
{
List<Resource> extensions = CollectionUtils.newArrayList();
Resource[] jsModules = null;
if (null == fileName)
- jsModules = resolver.getResources(modelerExtensionsBaseUri + category.substring(category.indexOf("/") + 1)
+ jsModules = resolver.getResources(extensionBaseUri + category.substring(category.indexOf("/") + 1)
+ "/*/*.*");
else
- jsModules = resolver.getResources(modelerExtensionsBaseUri + category.substring(category.indexOf("/") + 1)
+ jsModules = resolver.getResources(extensionBaseUri + category.substring(category.indexOf("/") + 1)
+ "/**/" + fileName);
for (Resource jsModule : jsModules)
{
diff --git a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/common/TechnicalUserUtils.java b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/common/TechnicalUserUtils.java
index 7d88a68..caf4a15 100644
--- a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/common/TechnicalUserUtils.java
+++ b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/common/TechnicalUserUtils.java
@@ -65,11 +65,11 @@ public class TechnicalUserUtils
pwd = TECH_USER_PASSWORD;
realm = TECH_USER_REALM;
- trace.info("The default user credentials were used to initiate the 'Reset Password' request. Please configure a new technical user.");
+ trace.info("The default user credentials were used to initiate the 'Technical User login' request. Please configure a new technical user.");
}
else
{
- trace.debug("Technical User is found to be configured. Using the same to Reset Password");
+ trace.debug("Technical User is found to be configured. Using the same to login");
}
// Set the partition of Tech User same as the current user
diff --git a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/common/spi/theme/impl/IppThemeProvider.java b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/common/spi/theme/impl/IppThemeProvider.java
index 072d43d..68ce5b1 100644
--- a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/common/spi/theme/impl/IppThemeProvider.java
+++ b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/common/spi/theme/impl/IppThemeProvider.java
@@ -36,6 +36,7 @@ import org.eclipse.stardust.ui.web.viewscommon.common.Constants;
import org.eclipse.stardust.ui.web.viewscommon.common.PortalPluginSkinResourceResolver;
import org.eclipse.stardust.ui.web.viewscommon.login.dialogs.LoginDialogBean;
import org.eclipse.stardust.ui.web.viewscommon.utils.DMSHelper;
+import org.eclipse.stardust.ui.web.viewscommon.utils.DefaultPreferenceProviderUtils;
/**
* @author Subodh.Godbole
@@ -71,7 +72,7 @@ public class IppThemeProvider implements ThemeProvider
*/
public void loadTheme(String themeId)
{
- this.themeId = themeId;
+ this.themeId = StringUtils.isNotEmpty(themeId) ? themeId : DefaultPreferenceProviderUtils.getDefaultSkinPreference();
availableThemes = new ArrayList<Theme>();
themeStyleSheets = new ArrayList<String>();
availableThemes.add(new IppTheme("", MessagePropertiesBean.getInstance().getString(
@@ -130,9 +131,11 @@ public class IppThemeProvider implements ThemeProvider
{
this.themeId = key;
}
- // TODO - Added for test CRNT-27828 on JBoss, to change to trace.debug
- trace.info("Selected Skin Id is " + this.themeId);
- trace.info("Added " + fileName + " as plugin skin folders");
+ if(trace.isDebugEnabled())
+ {
+ trace.debug("Selected Skin Id is " + this.themeId);
+ trace.debug("Added " + fileName + " as plugin skin folders");
+ }
}
return availablePluginThemes;
diff --git a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/login/dialogs/LoginDialogBean.java b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/login/dialogs/LoginDialogBean.java
index 525517b..1f7c8c7 100644
--- a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/login/dialogs/LoginDialogBean.java
+++ b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/login/dialogs/LoginDialogBean.java
@@ -37,6 +37,7 @@ import org.eclipse.stardust.ui.web.viewscommon.common.TechnicalUserUtils;
import org.eclipse.stardust.ui.web.viewscommon.beans.ApplicationContext;
import org.eclipse.stardust.ui.web.viewscommon.beans.SessionContext;
import org.eclipse.stardust.ui.web.viewscommon.login.InfinityStartup;
+import org.eclipse.stardust.ui.web.viewscommon.utils.DefaultPreferenceProviderUtils;
import org.eclipse.stardust.ui.web.viewscommon.utils.ExceptionHandler;
import org.eclipse.stardust.ui.web.viewscommon.utils.UserUtils;
import org.springframework.beans.factory.InitializingBean;
@@ -130,6 +131,7 @@ public class LoginDialogBean implements Serializable, InitializingBean
{
try
{
+ // Login with technical user and read the skin preference from partition
SessionContext sessionCtx = TechnicalUserUtils.login(getLoginProperties());
UserPreferencesHelper userPrefsHelper = UserPreferencesHelper.getInstance(UserPreferencesEntries.M_PORTAL,
PreferenceScope.PARTITION);
@@ -137,32 +139,38 @@ public class LoginDialogBean implements Serializable, InitializingBean
UserPreferencesEntries.F_SKIN);
trace.info("Read login skin preference from partition -" + skinPreference);
TechnicalUserUtils.logout(sessionCtx);
- Map<String, List<String>> pluginAvailableSkins = null;
- if (skinPreference.contains(Constants.SKIN_FOLDER))
- {
- // if skinPreference =<plugin-id>/public/skins/<skinId>, directly retrieve the
- // skin
- pluginAvailableSkins = PortalPluginSkinResourceResolver.findPluginSkins(Constants.SKIN_FOLDER,
- loginStyleSheetName);
- }
- else
- {
- // If skinPreference =<skinId> (i.e loaded from
- // static Configuration Provider), search skin folder
- pluginAvailableSkins = PortalPluginSkinResourceResolver.findPluginSkins(Constants.SKIN_FOLDER, null);
- }
+ // If no preference is set, check if default is provided by spring configuration
+ skinPreference = StringUtils.isNotEmpty(skinPreference) ? skinPreference : DefaultPreferenceProviderUtils
+ .getDefaultSkinPreference();
- for (Map.Entry<String, List<String>> entry : pluginAvailableSkins.entrySet())
+ // If no preference is set, neither spring config available for default skin,
+ // skip setting pluginLoginStyleSheetPath
+ if (StringUtils.isNotEmpty(skinPreference))
{
- if (entry.getKey().endsWith(skinPreference))
+ Map<String, List<String>> pluginAvailableSkins = null;
+ if (skinPreference.contains(Constants.SKIN_FOLDER))
+ {
+ // if skinPreference =<plugin-id>/public/skins/<skinId>, directly retrieve
+ // the
+ // skin
+ pluginAvailableSkins = PortalPluginSkinResourceResolver.findPluginSkins(skinPreference,
+ loginStyleSheetName);
+ }
+ else
+ {
+ // If skinPreference =<skinId> (i.e loaded from
+ // static Configuration Provider), create skin folder path as
+ // <public/skins/<skinId>
+ String skinFolder = Constants.SKIN_FOLDER + "/" + skinPreference;
+ pluginAvailableSkins = PortalPluginSkinResourceResolver.findPluginSkins(skinFolder, loginStyleSheetName);
+ }
+
+ for (Map.Entry<String, List<String>> entry : pluginAvailableSkins.entrySet())
{
for (String filePath : entry.getValue())
{
String fileName = filePath.substring(filePath.lastIndexOf("/") + 1);
- if (fileName.equals(loginStyleSheetName))
- {
- pluginLoginStyleSheetPath = Constants.PLUGIN_ROOT_FOLDER_PATH + entry.getKey() + "/" + fileName;
- }
+ pluginLoginStyleSheetPath = Constants.PLUGIN_ROOT_FOLDER_PATH + entry.getKey() + "/" + fileName;
}
}
}
diff --git a/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/DefaultPreferenceProviderUtils.java b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/DefaultPreferenceProviderUtils.java
new file mode 100644
index 0000000..12d8f67
--- /dev/null
+++ b/views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/utils/DefaultPreferenceProviderUtils.java
@@ -0,0 +1,37 @@
+package org.eclipse.stardust.ui.web.viewscommon.utils;
+
+import org.eclipse.stardust.common.log.LogManager;
+import org.eclipse.stardust.common.log.Logger;
+import org.eclipse.stardust.ui.web.common.util.FacesUtils;
+
+/**
+ *
+ * @author Sidharth.Singh
+ *
+ */
+public class DefaultPreferenceProviderUtils
+{
+ public static final Logger trace = LogManager.getLogger(DefaultPreferenceProviderUtils.class);
+
+ /**
+ *
+ * @return
+ */
+ public static String getDefaultSkinPreference()
+ {
+ try
+ {
+ String defaultSkin = (String) FacesUtils.getBeanFromContext("sungardSkinDefaultPreference");
+ if (trace.isDebugEnabled())
+ {
+ trace.debug("Default Skin preference read from spring configuration is " + defaultSkin);
+ }
+ return defaultSkin;
+ }
+ catch (Exception e)
+ {
+ trace.debug("Unable to read spring configuration for default skin " + e.getLocalizedMessage());
+ }
+ return null;
+ }
+}