summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSidharth Singh2012-12-19 09:07:37 (EST)
committer Stephan Born2013-01-25 12:36:30 (EST)
commit6d11c43beaad7b3701aee090dc65bc0515d37d8d (patch)
tree72919997129b19f7c3c72be8552aeb16e7a21622
parent4e85bf3792cd6141304837171d65a87103cb00b3 (diff)
downloadorg.eclipse.stardust.ui.web-6d11c43beaad7b3701aee090dc65bc0515d37d8d.zip
org.eclipse.stardust.ui.web-6d11c43beaad7b3701aee090dc65bc0515d37d8d.tar.gz
org.eclipse.stardust.ui.web-6d11c43beaad7b3701aee090dc65bc0515d37d8d.tar.bz2
Jira-ID: CRNT-27121
Made changes to read from resource in loadPluginSkin() of SkinContentServlet.java Changed the Map<String,List<String>>() to Map<String,List<Resource>> as SkinContentServlet.java requires the Resource file in PluginResourceUtils.java. Made changes in IppThemeProvider.jva to get the fileName from Resource file. git-svn-id: http://emeafrazerg/svn/ipp/product/trunk/stardust/ui.web@61653 8100b5e0-4d52-466c-ae9c-bdeccbdeaf6b
-rw-r--r--portal-api/src/main/java/org/eclipse/stardust/ui/client/dms/SkinContentServlet.java22
-rw-r--r--portal-api/src/main/java/org/eclipse/stardust/ui/client/util/PluginResourceUtils.java14
-rw-r--r--views-common/src/main/java/org/eclipse/stardust/ui/web/viewscommon/common/spi/theme/impl/IppThemeProvider.java54
3 files changed, 48 insertions, 42 deletions
diff --git a/portal-api/src/main/java/org/eclipse/stardust/ui/client/dms/SkinContentServlet.java b/portal-api/src/main/java/org/eclipse/stardust/ui/client/dms/SkinContentServlet.java
index 711c98b..a0433d1 100644
--- a/portal-api/src/main/java/org/eclipse/stardust/ui/client/dms/SkinContentServlet.java
+++ b/portal-api/src/main/java/org/eclipse/stardust/ui/client/dms/SkinContentServlet.java
@@ -10,9 +10,6 @@
*******************************************************************************/
package org.eclipse.stardust.ui.client.dms;
-import java.io.DataInputStream;
-import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -58,6 +55,7 @@ import org.eclipse.stardust.vfs.impl.jcr.JcrDocumentRepositoryService;
import org.eclipse.stardust.vfs.impl.jcr.web.AbstractVfsContentServlet;
import org.eclipse.stardust.vfs.jcr.ISessionFactory;
import org.eclipse.stardust.vfs.jcr.spring.JcrSpringSessionFactory;
+import org.springframework.core.io.Resource;
/**
@@ -268,35 +266,31 @@ public class SkinContentServlet extends AbstractVfsContentServlet
*/
private int loadPluginSkin(String skinFolder, String fileName, ContentDownloadController downloadManager) throws IOException
{
- Map<String, List<String>> pluginAvailableSkins = PluginResourceUtils
+ Map<String, List<Resource>> pluginAvailableSkins = PluginResourceUtils
.findPluginSkins(PLUGIN_FOLDER_PATH, fileName);
if (!CollectionUtils.isEmpty(pluginAvailableSkins))
{
- for (Map.Entry<String, List<String>> entry : pluginAvailableSkins.entrySet())
+ for (Map.Entry<String, List<Resource>> entry : pluginAvailableSkins.entrySet())
{
if (entry.getKey().equals(skinFolder))
{
- for (String filePath : entry.getValue())
+ for (Resource resource : entry.getValue())
{
- File file = new File(filePath);
- {
- downloadManager.setContentLength((int) file.length());
- downloadManager.setFilename(file.getName());
+ InputStream is = resource.getInputStream();
+
byte[] bbuf = new byte[4096];
- DataInputStream in = new DataInputStream(new FileInputStream(file));
int length = 0;
OutputStream op = downloadManager.getContentOutputStream();
- while ((in != null) && ((length = in.read(bbuf)) != -1))
+ while ((is != null) && ((length = is.read(bbuf)) != -1))
{
op.write(bbuf, 0, length);
}
- in.close();
+ is.close();
op.flush();
op.close();
}
- }
}
else
{
diff --git a/portal-api/src/main/java/org/eclipse/stardust/ui/client/util/PluginResourceUtils.java b/portal-api/src/main/java/org/eclipse/stardust/ui/client/util/PluginResourceUtils.java
index f48790b..013270e 100644
--- a/portal-api/src/main/java/org/eclipse/stardust/ui/client/util/PluginResourceUtils.java
+++ b/portal-api/src/main/java/org/eclipse/stardust/ui/client/util/PluginResourceUtils.java
@@ -46,9 +46,9 @@ public class PluginResourceUtils
* @param fileName
* @return
*/
- public static Map<String, List<String>> findPluginSkins(String pluginFolder, String fileName)
+ public static Map<String, List<Resource>> findPluginSkins(String pluginFolder, String fileName)
{
- Map<String, List<String>> allExtensions = new TreeMap<String, List<String>>(new Comparator<String>()
+ Map<String, List<Resource>> allExtensions = new TreeMap<String, List<Resource>>(new Comparator<String>()
{
public int compare(String a, String b)
{
@@ -97,18 +97,16 @@ public class PluginResourceUtils
// 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("/"));
- File extResourceFile = extensionResource.getFile();
- List<String> resourceFile = allExtensions.get(extensionWebUri);
+ List<Resource> resourceFile = allExtensions.get(extensionWebUri);
if (null == resourceFile)
{
resourceFile = CollectionUtils.newArrayList();
allExtensions.put(extensionWebUriKey, resourceFile);
}
- resourceFile.add(extResourceFile.getPath());
+ resourceFile.add(extensionResource);
trace.info("Discovered '" + pluginFolder + "' modeler extensions descriptor at " + extensionWebUri);
}
}
@@ -140,9 +138,9 @@ public class PluginResourceUtils
List<Resource> extensions = CollectionUtils.newArrayList();
Resource[] jsModules = null;
if (null == fileName)
- jsModules = resolver.getResources(modelerExtensionsBaseUri + category + "/*/*.*");
+ jsModules = resolver.getResources(modelerExtensionsBaseUri + category.substring(category.indexOf("/")+1) + "/*/*.*");
else
- jsModules = resolver.getResources(modelerExtensionsBaseUri + category + "/**/" + fileName);
+ jsModules = resolver.getResources(modelerExtensionsBaseUri + category.substring(category.indexOf("/")+1) + "/**/" + fileName);
for (Resource jsModule : jsModules)
{
extensions.add(jsModule);
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 2953fdf..05cfacf 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
@@ -22,6 +22,8 @@ import java.util.Set;
import org.eclipse.stardust.common.CollectionUtils;
import org.eclipse.stardust.common.StringUtils;
import org.eclipse.stardust.common.config.Parameters;
+import org.eclipse.stardust.common.log.LogManager;
+import org.eclipse.stardust.common.log.Logger;
import org.eclipse.stardust.engine.api.runtime.Document;
import org.eclipse.stardust.engine.api.runtime.DocumentManagementService;
import org.eclipse.stardust.engine.api.runtime.Folder;
@@ -35,6 +37,7 @@ import org.eclipse.stardust.ui.web.viewscommon.beans.SessionContext;
import org.eclipse.stardust.ui.web.viewscommon.common.Constants;
import org.eclipse.stardust.ui.web.viewscommon.login.dialogs.LoginDialogBean;
import org.eclipse.stardust.ui.web.viewscommon.utils.DMSHelper;
+import org.springframework.core.io.Resource;
@@ -46,6 +49,7 @@ import org.eclipse.stardust.ui.web.viewscommon.utils.DMSHelper;
public class IppThemeProvider implements ThemeProvider
{
private static final long serialVersionUID = 1L;
+ public static final Logger trace = LogManager.getLogger(IppThemeProvider.class);
public static final String THEME_SERVLET_PATH = "/skins/";
@@ -54,7 +58,7 @@ public class IppThemeProvider implements ThemeProvider
private String themeId;
private String loginStyleSheet;
private List<String> themeStyleSheets;
- private Map<String, List<String>> pluginAvailableSkins;
+ private Map<String, List<Resource>> pluginAvailableSkins;
/**
*
@@ -117,7 +121,7 @@ public class IppThemeProvider implements ThemeProvider
pluginAvailableSkins = PluginResourceUtils.findPluginSkins(Constants.PLUGIN_FOLDER_PATH, null);
- for (Map.Entry<String, List<String>> entry : pluginAvailableSkins.entrySet())
+ for (Map.Entry<String, List<Resource>> entry : pluginAvailableSkins.entrySet())
{
String key = entry.getKey();
availablePluginThemes.add(new IppTheme(key, key.substring(key.lastIndexOf("/")+1)));
@@ -172,36 +176,46 @@ public class IppThemeProvider implements ThemeProvider
/**
* When folderId is in pattern <plugin-id>/public/skins/<skinId>, Plugin skins are
* loader ex. <views-common/public/skins/red>
+ *
*/
private void loadPluginThemeStyleSheets()
{
- String skinFolderId = themeId;
- List<String> pluginStyleSheets = new ArrayList<String>();
-
- if (StringUtils.isNotEmpty(skinFolderId))
+ try
{
- Set<String> allSkinFolders = pluginAvailableSkins.keySet();
- for (String skinFolder : allSkinFolders)
+ String skinFolderId = themeId;
+ List<String> pluginStyleSheets = new ArrayList<String>();
+
+ if (StringUtils.isNotEmpty(skinFolderId))
{
- if (skinFolder.equals(skinFolderId))
+ Set<String> allSkinFolders = pluginAvailableSkins.keySet();
+ for (String skinFolder : allSkinFolders)
{
- List<String> documents = pluginAvailableSkins.get(skinFolder);
- for (String skinFile : documents)
+ if (skinFolder.equals(skinFolderId))
{
- if (skinFile.toLowerCase().endsWith(".css") && !loginStyleSheet.equals(skinFile))
+ List<Resource> documents = pluginAvailableSkins.get(skinFolder);
+ for (Resource skinFile : documents)
{
- // path : a string concat of plugin-root (/plugin) + folderId +
- // skinFile(say camino.css) ex:
- // "/plugin/views-common/public/skins/red/camino.css"
- String path = Constants.PLUGIN_ROOT_FOLDER_PATH + skinFolderId + "/"
- + skinFile.substring(skinFile.lastIndexOf("\\") + 1);
- pluginStyleSheets.add(path);
+ String filePath = skinFile.getURI().toString();
+ System.out.println("File Path is @@@@@@@@@" + filePath);
+ if (filePath.toLowerCase().endsWith(".css") && !loginStyleSheet.equals(skinFile))
+ {
+ // path : a string concat of plugin-root (/plugin) + folderId +
+ // skinFile(say camino.css) ex:
+ // "/plugin/views-common/public/skins/red/camino.css"
+ String path = Constants.PLUGIN_ROOT_FOLDER_PATH + skinFolderId + "/"
+ + filePath.substring(filePath.lastIndexOf("/") + 1);
+ pluginStyleSheets.add(path);
+ }
}
+ break;
}
- break;
}
+ themeStyleSheets.addAll(pluginStyleSheets);
}
- themeStyleSheets.addAll(pluginStyleSheets);
+ }
+ catch (Exception e)
+ {
+ trace.error("Error occured in reading plugin theme files" + e.getLocalizedMessage());
}
}