Moved web script classes and definitions out of web-client project and into remote-api

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@8956 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2008-04-29 19:41:59 +00:00
parent 3e209ce97e
commit 44ed636ca7
234 changed files with 79 additions and 14714 deletions

View File

@@ -32,7 +32,6 @@ import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@@ -49,7 +48,6 @@ import javax.faces.el.EvaluationException;
import javax.faces.el.MethodBinding;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.ActionEvent;
import javax.servlet.ServletContext;
import org.alfresco.config.ConfigElement;
import org.alfresco.error.AlfrescoRuntimeException;
@@ -67,7 +65,6 @@ import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.model.FileInfo;
import org.alfresco.service.cmr.model.FileNotFoundException;
import org.alfresco.service.cmr.repository.FileTypeImageSize;
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
import org.alfresco.service.cmr.repository.NoTransformerException;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -98,17 +95,6 @@ public final class Utils
private static final String MSG_DATE_PATTERN = "date_pattern";
private static final String MSG_DATE_TIME_PATTERN = "date_time_pattern";
private static final String IMAGE_PREFIX16 = "/images/filetypes/";
private static final String IMAGE_PREFIX32 = "/images/filetypes32/";
private static final String IMAGE_PREFIX64 = "/images/filetypes64/";
private static final String IMAGE_POSTFIX_GIF = ".gif";
private static final String IMAGE_POSTFIX_PNG = ".png";
private static final String DEFAULT_FILE_IMAGE16 = IMAGE_PREFIX16 + "_default" + IMAGE_POSTFIX_GIF;
private static final String DEFAULT_FILE_IMAGE32 = IMAGE_PREFIX32 + "_default" + IMAGE_POSTFIX_GIF;
private static final String DEFAULT_FILE_IMAGE64 = IMAGE_PREFIX64 + "_default" + IMAGE_POSTFIX_PNG;
private static final Map<String, String> s_fileExtensionMap = new HashMap<String, String>(89, 1.0f);
private static final Log logger = LogFactory.getLog(Utils.class);
private static final Set<String> safeTags = new HashSet<String>();
@@ -1326,137 +1312,7 @@ public final class Utils
return parsed;
}
/**
* Return the image path to the filetype icon for the specified file name string
*
* @param name File name to build filetype icon path for
* @param small True for the small 16x16 icon or false for the large 32x32
*
* @return the image path for the specified node type or the default icon if not found
*/
public static String getFileTypeImage(String name, boolean small)
{
return getFileTypeImage(FacesContext.getCurrentInstance(), null, name,
(small ? FileTypeImageSize.Small : FileTypeImageSize.Medium));
}
/**
* Return the image path to the filetype icon for the specified file name string
*
* @param fc FacesContext
* @param name File name to build filetype icon path for
* @param small True for the small 16x16 icon or false for the large 32x32
*
* @return the image path for the specified node type or the default icon if not found
*/
public static String getFileTypeImage(FacesContext fc, String name, boolean small)
{
return getFileTypeImage(fc, null, name, (small ? FileTypeImageSize.Small : FileTypeImageSize.Medium));
}
/**
* Return the image path to the filetype icon for the specified file name string
*
* @param fc FacesContext
* @param name File name to build filetype icon path for
* @param size Size of the icon to return
*
* @return the image path for the specified node type or the default icon if not found
*/
public static String getFileTypeImage(FacesContext fc, String name, FileTypeImageSize size)
{
return getFileTypeImage(fc, null, name, size);
}
/**
* Return the image path to the filetype icon for the specified file name string
*
* @param sc ServletContext
* @param name File name to build filetype icon path for
* @param small True for the small 16x16 icon or false for the large 32x32
*
* @return the image path for the specified node type or the default icon if not found
*/
public static String getFileTypeImage(ServletContext sc, String name, boolean small)
{
return getFileTypeImage(null, sc, name, (small ? FileTypeImageSize.Small : FileTypeImageSize.Medium));
}
/**
* Return the image path to the filetype icon for the specified file name string
*
* @param sc ServletContext
* @param name File name to build filetype icon path for
* @param size Size of the icon to return
*
* @return the image path for the specified node type or the default icon if not found
*/
public static String getFileTypeImage(ServletContext sc, String name, FileTypeImageSize size)
{
return getFileTypeImage(null, sc, name, size);
}
private static String getFileTypeImage(FacesContext fc, ServletContext sc, String name, FileTypeImageSize size)
{
String image = null;
String defaultImage = null;
switch (size)
{
case Small:
defaultImage = DEFAULT_FILE_IMAGE16; break;
case Medium:
defaultImage = DEFAULT_FILE_IMAGE32; break;
case Large:
defaultImage = DEFAULT_FILE_IMAGE64; break;
}
int extIndex = name.lastIndexOf('.');
if (extIndex != -1 && name.length() > extIndex + 1)
{
String ext = name.substring(extIndex + 1).toLowerCase();
String key = ext + ' ' + size.toString();
// found file extension for appropriate size image
synchronized (s_fileExtensionMap)
{
image = s_fileExtensionMap.get(key);
if (image == null)
{
// not found create for first time
if (size != FileTypeImageSize.Large)
{
image = (size == FileTypeImageSize.Small ? IMAGE_PREFIX16 : IMAGE_PREFIX32) +
ext + IMAGE_POSTFIX_GIF;
}
else
{
image = IMAGE_PREFIX64 + ext + IMAGE_POSTFIX_PNG;
}
// does this image exist on the web-server?
if ((fc != null && fc.getExternalContext().getResourceAsStream(image) != null) ||
(sc != null && sc.getResourceAsStream(image) != null))
{
// found the image for this extension - save it for later
s_fileExtensionMap.put(key, image);
}
else if ((fc == null) && (sc == null))
{
// we have neither FacesContext nor ServerContext so return the default image but don't cache it
image = defaultImage;
}
else
{
// not found, save the default image for this extension instead
s_fileExtensionMap.put(key, defaultImage);
image = defaultImage;
}
}
}
}
return (image != null ? image : defaultImage);
}
/**
* Given a ConfigElement instance retrieve the display label, this could be

View File

@@ -27,7 +27,6 @@ package org.alfresco.web.ui.repo.component;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.faces.context.FacesContext;
@@ -37,10 +36,9 @@ import org.alfresco.config.Config;
import org.alfresco.config.ConfigService;
import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.web.scripts.bean.SearchProxy;
import org.alfresco.repo.web.scripts.config.OpenSearchConfigElement;
import org.alfresco.repo.web.scripts.config.OpenSearchConfigElement.EngineConfig;
import org.alfresco.web.app.Application;
import org.alfresco.web.config.OpenSearchConfigElement;
import org.alfresco.web.config.OpenSearchConfigElement.EngineConfig;
import org.alfresco.web.ui.common.Utils;
import org.alfresco.web.ui.common.component.SelfRenderingComponent;
import org.springframework.web.jsf.FacesContextUtils;

View File

@@ -40,7 +40,7 @@ import javax.faces.event.ActionEvent;
import javax.faces.event.FacesEvent;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.web.scripts.FileTypeImageUtils;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.web.app.Application;
@@ -207,7 +207,7 @@ public class UIClipboardShelfItem extends UIShelfItem
}
else
{
String image = Utils.getFileTypeImage(item.getName(), true);
String image = FileTypeImageUtils.getFileTypeImage(item.getName(), true);
out.write(Utils.buildImageTag(context, image, null, "absmiddle"));
}

View File

@@ -39,6 +39,7 @@ import javax.faces.event.ActionEvent;
import javax.faces.event.FacesEvent;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.web.scripts.FileTypeImageUtils;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Node;
@@ -204,7 +205,7 @@ public class UIShortcutsShelfItem extends UIShelfItem
}
else if (dd.isSubClass(item.getType(), ContentModel.TYPE_CONTENT))
{
String image = Utils.getFileTypeImage(item.getName(), true);
String image = FileTypeImageUtils.getFileTypeImage(item.getName(), true);
out.write(Utils.buildImageTag(context, image, null, "absmiddle"));
}

View File

@@ -28,6 +28,7 @@ import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.repo.web.scripts.FileTypeImageUtils;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.FileTypeImageSize;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -35,7 +36,6 @@ import org.alfresco.service.cmr.repository.TemplateImageResolver;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.repository.User;
import org.alfresco.web.ui.common.Utils;
/**
* Helper class to generate the default template model.
@@ -106,7 +106,7 @@ public class DefaultModelHelper
{
public String resolveImagePathForName(String filename, FileTypeImageSize size)
{
return Utils.getFileTypeImage(FacesContext.getCurrentInstance(), filename, size);
return FileTypeImageUtils.getFileTypeImage(FacesContext.getCurrentInstance(), filename, size);
}
};
}

View File

@@ -31,6 +31,7 @@ import java.util.StringTokenizer;
import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;
import org.alfresco.repo.web.scripts.FileTypeImageUtils;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.FileTypeImageSize;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -298,7 +299,7 @@ public class UITemplate extends SelfRenderingComponent
{
public String resolveImagePathForName(String filename, FileTypeImageSize size)
{
return Utils.getFileTypeImage(FacesContext.getCurrentInstance(), filename, size);
return FileTypeImageUtils.getFileTypeImage(FacesContext.getCurrentInstance(), filename, size);
}
};
}

View File

@@ -46,6 +46,7 @@ import javax.transaction.UserTransaction;
import org.alfresco.model.WCMAppModel;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.web.scripts.FileTypeImageUtils;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.avmsync.AVMDifference;
@@ -812,7 +813,7 @@ public class UIUserSandboxes extends SelfRenderingComponent implements Serializa
if (node.isFile())
{
out.write(linkPrefix);
out.write(Utils.buildImageTag(fc, Utils.getFileTypeImage(fc, name, true), ""));
out.write(Utils.buildImageTag(fc, FileTypeImageUtils.getFileTypeImage(fc, name, true), ""));
out.write("</a></td><td>");
out.write(linkPrefix);
out.write(name);
@@ -872,7 +873,7 @@ public class UIUserSandboxes extends SelfRenderingComponent implements Serializa
out.write("<td width=16>");
if (node.isDeletedFile())
{
out.write(Utils.buildImageTag(fc, Utils.getFileTypeImage(fc, name, true), ""));
out.write(Utils.buildImageTag(fc, FileTypeImageUtils.getFileTypeImage(fc, name, true), ""));
out.write("</td><td style='color:#aaaaaa'>");
out.write(name + " [" + bundle.getString(MSG_DELETED_ITEM) + "]");
out.write("</a>");