mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Portlet webscript updates:
MySpaces portlet changed to use ajax update to main list div. Upload file now refreshes list after upload complete. Manual refresh icon added to MySpaces and MyDocs portlets. Removed video preview from pop-up panel in portlets (unstable in Firefox). Manic scrollbar flicking fixed in MyDocs and MySpaces portlets. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5736 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -55,6 +55,8 @@ import org.apache.commons.fileupload.FileItem;
|
||||
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
|
||||
import org.apache.commons.fileupload.servlet.ServletFileUpload;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
@@ -64,6 +66,17 @@ import org.w3c.dom.Node;
|
||||
*/
|
||||
public class FileUploadBean
|
||||
{
|
||||
private static Log logger = LogFactory.getLog(FileUploadBean.class);
|
||||
|
||||
/**
|
||||
* Ajax method to upload a file. A multi-part form is required as the input.
|
||||
*
|
||||
* "return-page" =
|
||||
* "currentPath" =
|
||||
* and the file item itself
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@InvokeCommand.ResponseMimetype(value=MimetypeMap.MIMETYPE_HTML)
|
||||
public void uploadFile() throws Exception
|
||||
{
|
||||
@@ -76,7 +89,6 @@ public class FileUploadBean
|
||||
|
||||
List<FileItem> fileItems = upload.parseRequest(request);
|
||||
FileUploadBean bean = new FileUploadBean();
|
||||
String uploadId = null;
|
||||
String currentPath = null;
|
||||
String filename = null;
|
||||
String returnPage = null;
|
||||
@@ -84,10 +96,6 @@ public class FileUploadBean
|
||||
|
||||
for (FileItem item : fileItems)
|
||||
{
|
||||
if (item.isFormField() && item.getFieldName().equals("upload-id"))
|
||||
{
|
||||
uploadId = item.getString();
|
||||
}
|
||||
if (item.isFormField() && item.getFieldName().equals("return-page"))
|
||||
{
|
||||
returnPage = item.getString();
|
||||
@@ -103,10 +111,13 @@ public class FileUploadBean
|
||||
item.write(file);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Ajax file upload request: " + filename + " to path: " + currentPath + " return page: " + returnPage);
|
||||
|
||||
try
|
||||
{
|
||||
if (file != null)
|
||||
if (file != null && currentPath != null && currentPath.length() != 0)
|
||||
{
|
||||
// convert cm:name based path to a NodeRef
|
||||
StringTokenizer t = new StringTokenizer(currentPath, "/");
|
||||
@@ -188,6 +199,9 @@ public class FileUploadBean
|
||||
Node scriptText = result.createTextNode(returnPage);
|
||||
scriptEl.appendChild(scriptText);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("File upload request complete.");
|
||||
|
||||
ResponseWriter out = fc.getResponseWriter();
|
||||
XMLUtil.print(result, out);
|
||||
out.close();
|
||||
|
@@ -26,6 +26,7 @@ package org.alfresco.web.bean.ajax;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -60,7 +61,8 @@ public class NodeInfoBean
|
||||
|
||||
/**
|
||||
* Returns information on the node identified by the 'noderef'
|
||||
* parameter found in the ExternalContext.
|
||||
* parameter found in the ExternalContext. If no noderef is supplied, then the template
|
||||
* is executed without context.
|
||||
* <p>
|
||||
* The result is the formatted HTML to show on the client.
|
||||
*/
|
||||
@@ -69,28 +71,26 @@ public class NodeInfoBean
|
||||
FacesContext context = FacesContext.getCurrentInstance();
|
||||
ResponseWriter out = context.getResponseWriter();
|
||||
|
||||
String strNodeRef = (String)context.getExternalContext().getRequestParameterMap().get("noderef");
|
||||
if (strNodeRef == null || strNodeRef.length() == 0)
|
||||
{
|
||||
throw new IllegalArgumentException("'noderef' parameter is missing");
|
||||
}
|
||||
|
||||
String strTemplate = (String)context.getExternalContext().getRequestParameterMap().get("template");
|
||||
Map<String, String> requestMap = context.getExternalContext().getRequestParameterMap();
|
||||
String strNodeRef = (String)requestMap.get("noderef");
|
||||
String strTemplate = (String)requestMap.get("template");
|
||||
if (strTemplate == null || strTemplate.length() == 0)
|
||||
{
|
||||
strTemplate = "node_summary_panel.ftl";
|
||||
}
|
||||
|
||||
NodeRef nodeRef = new NodeRef(strNodeRef);
|
||||
if (this.nodeService.exists(nodeRef))
|
||||
NodeRef nodeRef = null;
|
||||
if (strNodeRef != null && strNodeRef.length() != 0)
|
||||
{
|
||||
Repository.getServiceRegistry(context).getTemplateService().processTemplate(
|
||||
"/alfresco/templates/client/" + strTemplate, getModel(nodeRef), out);
|
||||
}
|
||||
else
|
||||
{
|
||||
out.write("<span class='errorMessage'>Node could not be found in the repository!</span>");
|
||||
nodeRef = new NodeRef(strNodeRef);
|
||||
if (this.nodeService.exists(nodeRef) == false)
|
||||
{
|
||||
out.write("<span class='errorMessage'>Node could not be found in the repository!</span>");
|
||||
return;
|
||||
}
|
||||
}
|
||||
Repository.getServiceRegistry(context).getTemplateService().processTemplate(
|
||||
"/alfresco/templates/client/" + strTemplate, getModel(nodeRef, requestMap), out);
|
||||
}
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ public class NodeInfoBean
|
||||
// ------------------------------------------------------------------------------
|
||||
// Helper methods
|
||||
|
||||
private Map<String, Object> getModel(NodeRef nodeRef)
|
||||
private Map<String, Object> getModel(NodeRef nodeRef, Map<String, String> requestMap)
|
||||
{
|
||||
FacesContext context = FacesContext.getCurrentInstance();
|
||||
Map<String, Object> model = new HashMap<String, Object>(8, 1.0f);
|
||||
@@ -119,10 +119,21 @@ public class NodeInfoBean
|
||||
model.put("cropContent", new CropContentMethod());
|
||||
model.put("url", new BaseTemplateContentServlet.URLHelper(
|
||||
context.getExternalContext().getRequestContextPath()));
|
||||
model.put("node", new TemplateNode(
|
||||
nodeRef,
|
||||
Repository.getServiceRegistry(context),
|
||||
this.imageResolver));
|
||||
if (nodeRef != null)
|
||||
{
|
||||
model.put("node", new TemplateNode(
|
||||
nodeRef,
|
||||
Repository.getServiceRegistry(context),
|
||||
this.imageResolver));
|
||||
}
|
||||
|
||||
// add URL arguments as a map called 'args' to the root of the model
|
||||
Map<String, String> args = new HashMap<String, String>(4, 1.0f);
|
||||
for (String name : requestMap.keySet())
|
||||
{
|
||||
args.put(name, requestMap.get(name));
|
||||
}
|
||||
model.put("args", args);
|
||||
|
||||
return model;
|
||||
}
|
||||
|
@@ -26,6 +26,7 @@ package org.alfresco.web.scripts;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import freemarker.template.TemplateBooleanModel;
|
||||
import freemarker.template.TemplateMethodModelEx;
|
||||
import freemarker.template.TemplateModelException;
|
||||
import freemarker.template.TemplateScalarModel;
|
||||
@@ -64,17 +65,22 @@ public final class ScriptUrlMethod implements TemplateMethodModelEx
|
||||
{
|
||||
String result = "";
|
||||
|
||||
if (args.size() == 1)
|
||||
if (args.size() != 0)
|
||||
{
|
||||
Object arg0 = args.get(0);
|
||||
boolean prefixServiceUrl = true;
|
||||
if (args.size() == 2 && args.get(1) instanceof TemplateBooleanModel)
|
||||
{
|
||||
prefixServiceUrl = ((TemplateBooleanModel)args.get(1)).getAsBoolean();
|
||||
}
|
||||
if (arg0 instanceof TemplateScalarModel)
|
||||
{
|
||||
String arg = ((TemplateScalarModel)arg0).getAsString();
|
||||
String url = req.getServicePath();
|
||||
String url = prefixServiceUrl ? req.getServicePath() : "";
|
||||
url += arg;
|
||||
url += (arg.length() > 0) ? "&" : "";
|
||||
url += (arg.length() != 0) ? "&" : "";
|
||||
url += "guest=" + (req.isGuest() ? "true" : "");
|
||||
url += (req.getFormat().length() > 0) ? "&format=" + req.getFormat() : "";
|
||||
url += (req.getFormat().length() != 0) ? "&format=" + req.getFormat() : "";
|
||||
result = res.encodeScriptUrl(url);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user