diff --git a/config/alfresco/web-client-config-forum-actions.xml b/config/alfresco/web-client-config-forum-actions.xml index e731d57b32..75a13bafbe 100644 --- a/config/alfresco/web-client-config-forum-actions.xml +++ b/config/alfresco/web-client-config-forum-actions.xml @@ -182,6 +182,7 @@ + org.alfresco.web.action.evaluator.EditPostEvaluator Write diff --git a/source/java/org/alfresco/web/action/evaluator/EditPostEvaluator.java b/source/java/org/alfresco/web/action/evaluator/EditPostEvaluator.java new file mode 100644 index 0000000000..0e41fd04ac --- /dev/null +++ b/source/java/org/alfresco/web/action/evaluator/EditPostEvaluator.java @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2005-2012 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.web.action.evaluator; + +import org.alfresco.model.ContentModel; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.site.SiteModel; +import org.alfresco.service.cmr.security.PermissionService; +import org.alfresco.web.bean.repository.Node; + +/** + * UI Action Evaluator - Allow comment editing only to coordinators, site managers, creator and owner + */ +public class EditPostEvaluator extends BaseActionEvaluator +{ + private static final long serialVersionUID = -5544290216536965941L; + + /** + * @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node) + */ + public boolean evaluate(Node node) + { + String currentUser = AuthenticationUtil.getFullyAuthenticatedUser(); + return (currentUser.equalsIgnoreCase((String)node.getProperties().get(ContentModel.PROP_OWNER)) || + currentUser.equalsIgnoreCase((String)node.getProperties().get(ContentModel.PROP_CREATOR)) || + node.hasPermission(SiteModel.SITE_MANAGER) || + node.hasPermission(PermissionService.COORDINATOR)); + } +} diff --git a/source/java/org/alfresco/web/app/servlet/UploadContentServlet.java b/source/java/org/alfresco/web/app/servlet/UploadContentServlet.java index 996d327881..d6982d0930 100644 --- a/source/java/org/alfresco/web/app/servlet/UploadContentServlet.java +++ b/source/java/org/alfresco/web/app/servlet/UploadContentServlet.java @@ -22,6 +22,7 @@ import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; import java.nio.charset.Charset; +import java.util.Locale; import java.util.StringTokenizer; import javax.servlet.ServletException; @@ -31,16 +32,19 @@ import javax.servlet.http.HttpServletResponse; import org.alfresco.model.ContentModel; import org.alfresco.repo.content.encoding.ContentCharsetFinder; import org.alfresco.service.ServiceRegistry; +import org.alfresco.service.cmr.repository.ContentData; import org.alfresco.service.cmr.repository.ContentService; import org.alfresco.service.cmr.repository.ContentWriter; import org.alfresco.service.cmr.repository.MimetypeService; 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.security.AccessStatus; import org.alfresco.service.cmr.security.PermissionService; import org.alfresco.service.namespace.QName; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.springframework.extensions.surf.util.I18NUtil; /** * Servlet responsible for streaming content directly into the repository from the PUT request. @@ -84,6 +88,7 @@ public class UploadContentServlet extends BaseServlet protected static final String ARG_PROPERTY = "property"; protected static final String ARG_MIMETYPE = "mimetype"; protected static final String ARG_ENCODING = "encoding"; + protected static final String ARG_LOCALE = "locale"; /** * @see javax.servlet.http.HttpServlet#doPut(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) @@ -158,6 +163,7 @@ public class UploadContentServlet extends BaseServlet ContentService contentService = serviceRegistry.getContentService(); PermissionService permissionService = serviceRegistry.getPermissionService(); MimetypeService mimetypeService = serviceRegistry.getMimetypeService(); + NodeService nodeService = serviceRegistry.getNodeService(); InputStream is = req.getInputStream(); BufferedInputStream inputStream = new BufferedInputStream(is); @@ -189,6 +195,21 @@ public class UploadContentServlet extends BaseServlet encoding = charset.name(); } + // Get the locale + Locale locale = I18NUtil.parseLocale(req.getParameter(ARG_LOCALE)); + if (locale == null) + { + locale = I18NUtil.getContentLocale(); + if (nodeRef != null) + { + ContentData contentData = (ContentData) nodeService.getProperty(nodeRef, propertyQName); + if (contentData != null) + { + locale = contentData.getLocale(); + } + } + } + if (logger.isDebugEnabled()) { if (nodeRef != null) {logger.debug("Found NodeRef: " + nodeRef.toString());} @@ -196,6 +217,7 @@ public class UploadContentServlet extends BaseServlet logger.debug("File name: " + filename); logger.debug("Mimetype: " + mimetype); logger.debug("Encoding: " + encoding); + logger.debug("Locale: " + locale); } // Check that the user has the permissions to write the content @@ -227,9 +249,13 @@ public class UploadContentServlet extends BaseServlet return; } - // Set the mimetype and encoding + // Set the mimetype, encoding and locale writer.setMimetype(mimetype); writer.setEncoding(encoding); + if (locale != null) + { + writer.setLocale(locale); + } // Stream the content into the repository writer.putContent(inputStream);