Author: thomas.heute(a)jboss.com
Date: 2008-06-13 09:38:57 -0400 (Fri, 13 Jun 2008)
New Revision: 11039
Modified:
branches/JBoss_Portal_Branch_2_7/core-cms/src/main/org/jboss/portal/core/cms/servlet/CMSPreviewServlet.java
branches/JBoss_Portal_Branch_2_7/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java
branches/JBoss_Portal_Branch_2_7/core-cms/src/resources/portal-cms-sar/META-INF/jboss-service.xml
branches/JBoss_Portal_Branch_2_7/core-cms/src/resources/portal-cms-war/WEB-INF/jsp/cms/admin/pending_items.jsp
Log:
JBPORTAL-2042: Error when trying to preview a binary file submitted for approval
JBPORTAL-2043: During file upload a stack trace is shown when no file has been selected
Modified:
branches/JBoss_Portal_Branch_2_7/core-cms/src/main/org/jboss/portal/core/cms/servlet/CMSPreviewServlet.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-cms/src/main/org/jboss/portal/core/cms/servlet/CMSPreviewServlet.java 2008-06-13
13:38:48 UTC (rev 11038)
+++
branches/JBoss_Portal_Branch_2_7/core-cms/src/main/org/jboss/portal/core/cms/servlet/CMSPreviewServlet.java 2008-06-13
13:38:57 UTC (rev 11039)
@@ -32,6 +32,8 @@
import org.jboss.portal.cms.impl.jcr.JCRCMS;
import org.jboss.portal.cms.model.Content;
import org.jboss.portal.cms.model.File;
+import org.jboss.portal.cms.workflow.CMSWorkflowUtil;
+import org.jboss.portal.core.cms.ui.Util;
import org.jboss.portal.identity.IdentityContext;
import org.jboss.portal.identity.IdentityServiceController;
import org.jboss.portal.identity.User;
@@ -62,10 +64,16 @@
String path = request.getParameter("p");
String version = request.getParameter("v");
String language = request.getParameter("l");
+
+ String processId = request.getParameter("pid");
+
try
{
- MBeanServer mbeanServer = MBeanServerLocator.locateJBoss();
+ Content content = null;
+ if (processId == null)
+ {
+ MBeanServer mbeanServer = MBeanServerLocator.locateJBoss();
CMS CMSService = (CMS)MBeanProxy.get(CMS.class, new
ObjectName("portal:service=CMS"), mbeanServer);
IdentityServiceController identityService =
(IdentityServiceController)MBeanProxy.get(
IdentityServiceController.class, new
ObjectName("portal:service=Module,type=IdentityServiceController"),
mbeanServer);
@@ -75,8 +83,14 @@
Command getCMD = CMSService.getCommandFactory().createFileGetCommand(path,
version, new Locale(language));
File file = (File)CMSService.execute(getCMD);
- Content content = file.getContent();
-
+ content = file.getContent();
+ }
+ else
+ {
+ content = CMSWorkflowUtil.getPendingContent(Long.parseLong(processId),
path);
+ }
+
+
response.setContentType(content.getMimeType());
ServletOutputStream sout = response.getOutputStream();
InputStream is = content.getStream();
@@ -91,6 +105,7 @@
}
catch (Exception e)
{
+ e.printStackTrace();
try
{
response.sendError(HttpServletResponse.SC_NOT_FOUND, e.getMessage());
Modified:
branches/JBoss_Portal_Branch_2_7/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java 2008-06-13
13:38:48 UTC (rev 11038)
+++
branches/JBoss_Portal_Branch_2_7/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java 2008-06-13
13:38:57 UTC (rev 11039)
@@ -774,54 +774,63 @@
if (!item.isFormField())
{
String sFilename = item.getName();
- int backslashIndex = sFilename.lastIndexOf("\\");
- if (backslashIndex > -1) // getWindows
+ if (!"".equals(sFilename))
{
- sFilename = sFilename.substring(backslashIndex + 1);
- }
- else // unix
- {
- backslashIndex = sFilename.lastIndexOf("/");
- sFilename = sFilename.substring(backslashIndex + 1);
- }
+ int backslashIndex = sFilename.lastIndexOf("\\");
+ if (backslashIndex > -1) // getWindows
+ {
+ sFilename = sFilename.substring(backslashIndex + 1);
+ }
+ else // unix
+ {
+ backslashIndex = sFilename.lastIndexOf("/");
+ sFilename = sFilename.substring(backslashIndex + 1);
+ }
- File file = new FileImpl();
- Content content = new ContentImpl();
+ File file = new FileImpl();
+ Content content = new ContentImpl();
- String fileExt =
sFilename.substring(sFilename.lastIndexOf(".") + 1, sFilename.length());
- CMSMimeMappings mapper = new CMSMimeMappings();
- if (mapper.getMimeType(fileExt) != null)
- {
- content.setMimeType(mapper.getMimeType(fileExt));
- }
- else
- {
- content.setMimeType("application/octet-stream");
- }
+ String fileExt =
sFilename.substring(sFilename.lastIndexOf(".") + 1, sFilename.length());
+ CMSMimeMappings mapper = new CMSMimeMappings();
+ if (mapper.getMimeType(fileExt) != null)
+ {
+ content.setMimeType(mapper.getMimeType(fileExt));
+ }
+ else
+ {
+ content.setMimeType("application/octet-stream");
+ }
- String sBasePath = FileUtil.cleanDoubleSlashes(sPath + "/"
+ sFilename);
- file.setBasePath(sBasePath);
+ String sBasePath = FileUtil.cleanDoubleSlashes(sPath +
"/" + sFilename);
+ file.setBasePath(sBasePath);
- content.setTitle(sTitle);
- content.setDescription(sDescription);
- content.setBasePath(sBasePath + "/" + new
Locale(sLanguage));
- content.setBytes(item.get());
- file.setContent(new Locale(sLanguage), content);
+ content.setTitle(sTitle);
+ content.setDescription(sDescription);
+ content.setBasePath(sBasePath + "/" + new
Locale(sLanguage));
+ content.setBytes(item.get());
+ file.setContent(new Locale(sLanguage), content);
- Command existsCMD =
CMSService.getCommandFactory().createItemExistsCommand(content.getBasePath());
- Boolean bExists = (Boolean)CMSService.execute(existsCMD);
- if (bExists.booleanValue()) // if file exists, update contentNode
- {
- // force "make live"
- Command cmdUpdate =
CMSService.getCommandFactory().createUpdateFileCommand(file, content, true);
- CMSService.execute(cmdUpdate);
+ Command existsCMD =
CMSService.getCommandFactory().createItemExistsCommand(content.getBasePath());
+ Boolean bExists = (Boolean)CMSService.execute(existsCMD);
+ if (bExists.booleanValue()) // if file exists, update
contentNode
+ {
+ // force "make live"
+ Command cmdUpdate =
CMSService.getCommandFactory().createUpdateFileCommand(file, content, true);
+ CMSService.execute(cmdUpdate);
+ }
+ else // if file doesnt exist, create the file and the
contentNode.
+ {
+ Command newFileCMD =
CMSService.getCommandFactory().createNewFileCommand(file, content);
+ CMSService.execute(newFileCMD);
+ }
+ aRes.setRenderParameter("path", sBasePath);
}
- else // if file doesnt exist, create the file and the contentNode.
+ else
{
- Command newFileCMD =
CMSService.getCommandFactory().createNewFileCommand(file, content);
- CMSService.execute(newFileCMD);
+ aRes.setRenderParameter("op",
CMSAdminConstants.OP_UPLOADCONFIRM);
+ aRes.setRenderParameter("path", sPath);
+ return;
}
- aRes.setRenderParameter("path", sBasePath);
}
else
{
Modified:
branches/JBoss_Portal_Branch_2_7/core-cms/src/resources/portal-cms-sar/META-INF/jboss-service.xml
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-cms/src/resources/portal-cms-sar/META-INF/jboss-service.xml 2008-06-13
13:38:48 UTC (rev 11038)
+++
branches/JBoss_Portal_Branch_2_7/core-cms/src/resources/portal-cms-sar/META-INF/jboss-service.xml 2008-06-13
13:38:57 UTC (rev 11039)
@@ -64,9 +64,7 @@
<depends optional-attribute-name="AuthorizationManager"
proxy-type="attribute">portal:service=AuthorizationManager,type=cms</depends>
<!-- Add this to activate publish/approval workflow integration -->
- <!--
<depends optional-attribute-name="ApprovePublishWorkflow"
proxy-type="attribute">portal:service=ApprovePublish,type=Workflow</depends>
- -->
<depends optional-attribute-name="StackFactory"
proxy-type="attribute">portal:service=InterceptorStackFactory,type=Cms</depends>
<attribute name="DoChecking">true</attribute>
Modified:
branches/JBoss_Portal_Branch_2_7/core-cms/src/resources/portal-cms-war/WEB-INF/jsp/cms/admin/pending_items.jsp
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-cms/src/resources/portal-cms-war/WEB-INF/jsp/cms/admin/pending_items.jsp 2008-06-13
13:38:48 UTC (rev 11038)
+++
branches/JBoss_Portal_Branch_2_7/core-cms/src/resources/portal-cms-war/WEB-INF/jsp/cms/admin/pending_items.jsp 2008-06-13
13:38:57 UTC (rev 11039)
@@ -226,15 +226,36 @@
<!-- User who requested approval -->
<td><%= cour.getUserName() %>
</td>
- <td>
- <a href="<portlet:renderURL>
- <portlet:param name="op" value="<%=
CMSAdminConstants.OP_VIEWPENDINGPREVIEW %>"/>
- <portlet:param name="pid"
value="<%=cour.getProcessId()%>"/>
- <portlet:param name="path"
value="<%=linkPath%>"/>
- <portlet:param name="contentPath"
value="<%=cour.getPath()%>"/>
- </portlet:renderURL>"
-
<%if(contentBeingPreviewed.equals(cour.getProcessId())){%>style="color:
red;"<%}%>
- >${n:i18n("CMS_PREVIEW")}</a>
+ <td>
+ <%
+ if (cour.getMimeType().equals("text/html") ||
cour.getMimeType().equals("text/plain"))
+ {
+ %>
+ <a href="<portlet:renderURL>
+ <portlet:param name="op" value="<%=
CMSAdminConstants.OP_VIEWPENDINGPREVIEW %>"/>
+ <portlet:param name="pid"
value="<%=cour.getProcessId()%>"/>
+ <portlet:param name="path"
value="<%=linkPath%>"/>
+ <portlet:param name="contentPath"
value="<%=cour.getPath()%>"/>
+ </portlet:renderURL>"
+
<%if(contentBeingPreviewed.equals(cour.getProcessId())){%>style="color:
red;"<%}%>
+ >${n:i18n("CMS_PREVIEW")}</a>
+
+ <% }
+ else
+ {
+ //save the principal for the preview servlet
+ String remoteUser = request.getRemoteUser();
+ request.getSession().setAttribute("remoteUser", remoteUser);
+ %>
+ <a target="_blank"
+ href="<%= request.getContextPath() %>/cmspreview?pid=<%=
cour.getProcessId() %>&p=<%= cour.getPath()
%>"<%if(contentBeingPreviewed.equals(cour.getProcessId())){%>style="color:
red;"<%}%>
+ >${n:i18n("CMS_PREVIEW")}</a>
+ <%
+ }
+ %>
+
+
+
<a href="<portlet:actionURL>
<portlet:param name="op" value="<%=
CMSAdminConstants.OP_APPROVE %>"/>