diff --git a/config/alfresco/templates/RSS_2.0_recent_docs.ftl b/config/alfresco/templates/RSS_2.0_recent_docs.ftl
index 4e4e68a4e8..62957c681d 100644
--- a/config/alfresco/templates/RSS_2.0_recent_docs.ftl
+++ b/config/alfresco/templates/RSS_2.0_recent_docs.ftl
@@ -5,7 +5,7 @@
Copyright (c) 2005 Alfresco Software, Inc. All rights reserved.
<#assign hostname="http://localhost:8080/alfresco">
<#assign spaceref="${hostname}/navigate/browse/${space.nodeRef.storeRef.protocol}/${space.nodeRef.storeRef.identifier}/${space.nodeRef.id}">
- <#assign datetimeformat="EEE, dd MMM yyyy hh:mm:ss zzz">
+ <#assign datetimeformat="EEE, dd MMM yyyy HH:mm:ss zzz">
${spaceref}
Recent Changes to '${space.name}'en-us
diff --git a/source/java/org/alfresco/web/app/servlet/AuthenticationHelper.java b/source/java/org/alfresco/web/app/servlet/AuthenticationHelper.java
index 0b5359b62a..b4c3aac76b 100644
--- a/source/java/org/alfresco/web/app/servlet/AuthenticationHelper.java
+++ b/source/java/org/alfresco/web/app/servlet/AuthenticationHelper.java
@@ -231,14 +231,58 @@ public final class AuthenticationHelper
// setup the authentication context
WebApplicationContext wc = WebApplicationContextUtils.getRequiredWebApplicationContext(context);
AuthenticationService auth = (AuthenticationService)wc.getBean(AUTHENTICATION_SERVICE);
+ UserTransaction tx = null;
try
{
auth.validate(ticket);
+
+ HttpSession session = httpRequest.getSession();
+ User user = (User)session.getAttribute(AuthenticationHelper.AUTHENTICATION_USER);
+ if (user == null)
+ {
+ // need to create the User instance if not already available
+ String currentUsername = auth.getCurrentUserName();
+
+ ServiceRegistry services = BaseServlet.getServiceRegistry(context);
+ tx = services.getTransactionService().getUserTransaction();
+ tx.begin();
+
+ NodeService nodeService = services.getNodeService();
+ PersonService personService = (PersonService)wc.getBean(PERSON_SERVICE);
+ NodeRef personRef = personService.getPerson(currentUsername);
+ user = new User(currentUsername, auth.getCurrentTicket(), personRef);
+ NodeRef homeRef = (NodeRef)nodeService.getProperty(personRef, ContentModel.PROP_HOMEFOLDER);
+
+ // check that the home space node exists - else Login cannot proceed
+ if (nodeService.exists(homeRef) == false)
+ {
+ throw new InvalidNodeRefException(homeRef);
+ }
+ user.setHomeSpaceId(homeRef.getId());
+
+ tx.commit();
+ tx = null; // clear this so we know not to rollback
+
+ // store the User object in the Session - the authentication servlet will then proceed
+ session.setAttribute(AuthenticationHelper.AUTHENTICATION_USER, user);
+ }
}
catch (AuthenticationException authErr)
{
return AuthenticationStatus.Failure;
}
+ catch (Throwable e)
+ {
+ // Some other kind of serious failure
+ AuthenticationService unprotAuthService = (AuthenticationService)wc.getBean(UNPROTECTED_AUTH_SERVICE);
+ unprotAuthService.invalidateTicket(unprotAuthService.getCurrentTicket());
+ unprotAuthService.clearCurrentSecurityContext();
+ return AuthenticationStatus.Failure;
+ }
+ finally
+ {
+ try { if (tx != null) {tx.rollback();} } catch (Exception tex) {}
+ }
// Set the current locale
I18NUtil.setLocale(Application.getLanguage(httpRequest.getSession()));
diff --git a/source/java/org/alfresco/web/app/servlet/CommandServlet.java b/source/java/org/alfresco/web/app/servlet/CommandServlet.java
index 5935fbb028..1260a4971e 100644
--- a/source/java/org/alfresco/web/app/servlet/CommandServlet.java
+++ b/source/java/org/alfresco/web/app/servlet/CommandServlet.java
@@ -114,7 +114,7 @@ public class CommandServlet extends BaseServlet
// validate that the processor has everything it needs to run the command
ServiceRegistry serviceRegistry = getServiceRegistry(getServletContext());
- if (processor.validateArguments(serviceRegistry, args) == false)
+ if (processor.validateArguments(serviceRegistry, command, args) == false)
{
redirectToLoginPage(req, res, getServletContext());
return;
diff --git a/source/java/org/alfresco/web/app/servlet/TemplateContentServlet.java b/source/java/org/alfresco/web/app/servlet/TemplateContentServlet.java
index 6e7777b02f..9c5c5d7703 100644
--- a/source/java/org/alfresco/web/app/servlet/TemplateContentServlet.java
+++ b/source/java/org/alfresco/web/app/servlet/TemplateContentServlet.java
@@ -25,7 +25,6 @@ import java.util.StringTokenizer;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
import javax.transaction.UserTransaction;
import org.alfresco.error.AlfrescoRuntimeException;
@@ -35,11 +34,13 @@ import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.repository.TemplateException;
+import org.alfresco.service.cmr.repository.TemplateImageResolver;
import org.alfresco.service.cmr.repository.TemplateNode;
import org.alfresco.service.cmr.repository.TemplateService;
import org.alfresco.service.cmr.security.AccessStatus;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.web.app.Application;
+import org.alfresco.web.ui.common.Utils;
import org.alfresco.web.ui.repo.component.template.DefaultModelHelper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -164,7 +165,7 @@ public class TemplateContentServlet extends BaseServlet
}
// create the model - put the supplied noderef in as space/document as appropriate
- Object model = getModel(serviceRegistry, req.getSession(), nodeRef);
+ Object model = getModel(serviceRegistry, req, res, nodeRef);
// process the template against the node content directly to the response output stream
// assuming the repo is capable of streaming in chunks, this should allow large files
@@ -218,19 +219,28 @@ public class TemplateContentServlet extends BaseServlet
*
* @return an object model ready for executing template against
*/
- private Object getModel(ServiceRegistry services, HttpSession session, NodeRef nodeRef)
+ private Object getModel(ServiceRegistry services, HttpServletRequest req, HttpServletResponse res, NodeRef nodeRef)
{
// build FreeMarker default model and merge
- Map root = DefaultModelHelper.buildDefaultModel(services, Application.getCurrentUser(session));
+ Map root = DefaultModelHelper.buildDefaultModel(services, Application.getCurrentUser(req.getSession()));
// put the current NodeRef in as "space" and "document"
- TemplateNode node = new TemplateNode(nodeRef, services, DefaultModelHelper.imageResolver);
+ TemplateNode node = new TemplateNode(nodeRef, services, this.imageResolver);
root.put("space", node);
root.put("document", node);
return root;
}
+ /** Template Image resolver helper */
+ private TemplateImageResolver imageResolver = new TemplateImageResolver()
+ {
+ public String resolveImagePathForName(String filename, boolean small)
+ {
+ return Utils.getFileTypeImage(getServletContext(), filename, small);
+ }
+ };
+
/**
* Helper to generate a URL to process a template against a node.
*
diff --git a/source/java/org/alfresco/web/app/servlet/command/BaseNodeCommandProcessor.java b/source/java/org/alfresco/web/app/servlet/command/BaseNodeCommandProcessor.java
index 6a8997393d..7e91411979 100644
--- a/source/java/org/alfresco/web/app/servlet/command/BaseNodeCommandProcessor.java
+++ b/source/java/org/alfresco/web/app/servlet/command/BaseNodeCommandProcessor.java
@@ -37,9 +37,9 @@ public abstract class BaseNodeCommandProcessor implements CommandProcessor
protected NodeRef targetRef;
/**
- * @see org.alfresco.web.app.servlet.command.CommandProcessor#validateArguments(org.alfresco.service.ServiceRegistry, java.lang.String[])
+ * @see org.alfresco.web.app.servlet.command.CommandProcessor#validateArguments(org.alfresco.service.ServiceRegistry, java.lang.String, java.lang.String[])
*/
- public boolean validateArguments(ServiceRegistry serviceRegistry, String[] args)
+ public boolean validateArguments(ServiceRegistry serviceRegistry, String command, String[] args)
{
if (args.length < 3)
{
diff --git a/source/java/org/alfresco/web/app/servlet/command/CommandProcessor.java b/source/java/org/alfresco/web/app/servlet/command/CommandProcessor.java
index 10e0f3111e..54747eabde 100644
--- a/source/java/org/alfresco/web/app/servlet/command/CommandProcessor.java
+++ b/source/java/org/alfresco/web/app/servlet/command/CommandProcessor.java
@@ -42,11 +42,13 @@ public interface CommandProcessor
* convert the supplied arguments to the objects it expects, and also check any permissions
* that are required by the current user to execute the command.
*
+ * @param serviceRegistry ServiceRegistry instance
+ * @param command Name of the command the arguments are for
* @param args String[] of the remaining URL arguments to the command servlet.
*
* @return true if the command can be executed by the current user given the supplied args.
*/
- public boolean validateArguments(ServiceRegistry serviceRegistry, String[] args);
+ public boolean validateArguments(ServiceRegistry serviceRegistry, String command, String[] args);
/**
* Process the supplied command name. It is the responsibility of the Command Processor
diff --git a/source/java/org/alfresco/web/ui/common/Utils.java b/source/java/org/alfresco/web/ui/common/Utils.java
index 3c1ca43d96..7f7ee84716 100644
--- a/source/java/org/alfresco/web/ui/common/Utils.java
+++ b/source/java/org/alfresco/web/ui/common/Utils.java
@@ -40,6 +40,7 @@ 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;
@@ -1111,6 +1112,39 @@ public final class Utils
* @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);
+ }
+
+ /**
+ * 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);
+ }
+
+ /**
+ * 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);
+ }
+
+ private static String getFileTypeImage(FacesContext fc, ServletContext sc, String name, boolean small)
{
String image = (small ? DEFAULT_FILE_IMAGE16 : DEFAULT_FILE_IMAGE32);
@@ -1130,7 +1164,8 @@ public final class Utils
image = (small ? IMAGE_PREFIX16 : IMAGE_PREFIX32) + ext + IMAGE_POSTFIX;
// does this image exist on the web-server?
- if (FacesContext.getCurrentInstance().getExternalContext().getResourceAsStream(image) != null)
+ 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);