mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
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:
@@ -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
|
||||
|
Reference in New Issue
Block a user