Author: sohil.shah(a)jboss.com
Date: 2007-09-18 13:36:25 -0400 (Tue, 18 Sep 2007)
New Revision: 8332
Added:
branches/JBoss_Portal_Branch_2_6/cms/src/bin/prueba.zip
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/command/MakeLiveVersionCommand.java
Modified:
branches/JBoss_Portal_Branch_2_6/
branches/JBoss_Portal_Branch_2_6/cms/build.xml
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/CommandFactory.java
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCommandFactory.java
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/command/StoreArchiveCommand.java
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/test/cms/commands/TestFileArchiveUpload.java
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/test/cms/commands/TestFileGetVersion.java
branches/JBoss_Portal_Branch_2_6/core-cms/build.xml
branches/JBoss_Portal_Branch_2_6/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java
branches/JBoss_Portal_Branch_2_6/core-cms/src/resources/portal-cms-war/WEB-INF/jsp/cms/admin/viewfile.jsp
Log:
JBPORTAL-1124 - CMS needs to allow admins to make pages as live w/o editing the page and
JBPORTAL-1693 - Upload Archive throws exception if zip file entries contain special
characters in filename
Property changes on: branches/JBoss_Portal_Branch_2_6
___________________________________________________________________
Name: svn:ignore
- .project
.classpath
thirdparty
eclipseBin
myworkspace
bin
*.settings
miscellaneous
local-tests
localbin
+ .project
.classpath
thirdparty
eclipseBin
myworkspace
bin
*.settings
miscellaneous
local-tests
localbin
localBin
Modified: branches/JBoss_Portal_Branch_2_6/cms/build.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/cms/build.xml 2007-09-18 17:26:04 UTC (rev 8331)
+++ branches/JBoss_Portal_Branch_2_6/cms/build.xml 2007-09-18 17:36:25 UTC (rev 8332)
@@ -97,6 +97,7 @@
<path refid="apache.log4j.classpath"/>
<path refid="apache.collections.classpath"/>
<path refid="apache.lucene.classpath"/>
+ <path refid="apache.ant.classpath"/>
<path refid="jboss.jbossxb.classpath"/>
<path refid="jboss.cache.classpath"/>
<path refid="oswego.concurrent.classpath"/>
@@ -212,6 +213,7 @@
<copy todir="${build.resources}/test/jcr/">
<fileset dir="${source.bin}" includes="ziptest.zip"/>
+ <fileset dir="${source.bin}" includes="prueba.zip"/>
<fileset dir="${source.bin}"
includes="headerpage.html"/>
<fileset dir="${source.bin}"
includes="headerpage_good.html"/>
</copy>
@@ -419,8 +421,8 @@
<test todir="${test.reports}"
name="org.jboss.portal.test.cms.commands.TestFileCreate"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.cms.commands.TestFileUpdate"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.cms.commands.TestFileArchiveUpload"/>
- <test todir="${test.reports}"
name="org.jboss.portal.test.cms.commands.TestFileGet"/>
- <test todir="${test.reports}"
name="org.jboss.portal.test.cms.commands.TestFileGetVersion"/>
+ <test todir="${test.reports}"
name="org.jboss.portal.test.cms.commands.TestFileGetVersion"/>
+ <test todir="${test.reports}"
name="org.jboss.portal.test.cms.commands.TestFileGet"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.cms.commands.TestFileGetList"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.cms.commands.TestFileCopy"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.cms.commands.TestFileCreateFailed"/>
@@ -437,9 +439,8 @@
<!-- cms fine grained security related tests -->
<test todir="${test.reports}"
name="org.jboss.portal.test.cms.security.TestReadAccess"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.cms.security.TestWriteAccess"/>
- <test todir="${test.reports}"
name="org.jboss.portal.test.cms.security.TestManageAccess"/>
-
-
+ <test todir="${test.reports}"
name="org.jboss.portal.test.cms.security.TestManageAccess"/>
+
<!-- cms workflow related tests -->
<test todir="${test.reports}"
name="org.jboss.portal.test.cms.workflow.TestApprovedPublish"/>
<test todir="${test.reports}"
name="org.jboss.portal.test.cms.workflow.TestDeniedPublish"/>
Added: branches/JBoss_Portal_Branch_2_6/cms/src/bin/prueba.zip
===================================================================
(Binary files differ)
Property changes on: branches/JBoss_Portal_Branch_2_6/cms/src/bin/prueba.zip
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified:
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/CommandFactory.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/CommandFactory.java 2007-09-18
17:26:04 UTC (rev 8331)
+++
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/CommandFactory.java 2007-09-18
17:36:25 UTC (rev 8332)
@@ -85,5 +85,7 @@
Command createGetArchiveCommand(String sRootPath, String sLanguage);
- Command createSearchCommand(JCRQuery query);
+ Command createSearchCommand(JCRQuery query);
+
+ Command createMakeLiveVersionCommand(String filePath, String language, String
version);
}
Modified:
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCommandFactory.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCommandFactory.java 2007-09-18
17:26:04 UTC (rev 8331)
+++
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCommandFactory.java 2007-09-18
17:36:25 UTC (rev 8332)
@@ -48,6 +48,7 @@
import org.jboss.portal.cms.impl.jcr.command.RenameCommand;
import org.jboss.portal.cms.impl.jcr.command.SearchCommand;
import org.jboss.portal.cms.impl.jcr.command.StoreArchiveCommand;
+import org.jboss.portal.cms.impl.jcr.command.MakeLiveVersionCommand;
import org.jboss.portal.cms.impl.jcr.composite.NewFileCommand;
import org.jboss.portal.cms.impl.jcr.composite.UpdateFileCommand;
import org.jboss.portal.cms.model.Content;
@@ -185,4 +186,9 @@
{
return new SearchCommand(query);
}
+
+ public Command createMakeLiveVersionCommand(String filePath, String language, String
version)
+ {
+ return new MakeLiveVersionCommand(filePath,language,version);
+ }
}
Added:
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/command/MakeLiveVersionCommand.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/command/MakeLiveVersionCommand.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/command/MakeLiveVersionCommand.java 2007-09-18
17:36:25 UTC (rev 8332)
@@ -0,0 +1,88 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This 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 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software 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 this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.cms.impl.jcr.command;
+
+import org.apache.log4j.Logger;
+
+import org.jboss.portal.cms.CMSException;
+import org.jboss.portal.cms.impl.jcr.JCRCommand;
+
+import javax.jcr.Node;
+import javax.jcr.Session;
+import javax.jcr.version.VersionHistory;
+
+
+/**
+ * Makes the specified version of the file a "LIVE" version
+ *
+ * @author <a href="mailto:sohil.shah@jboss.com">Sohil Shah</a>
+ */
+public class MakeLiveVersionCommand extends JCRCommand
+{
+ /**
+ *
+ */
+ private static Logger log = Logger.getLogger(MakeLiveVersionCommand.class);
+
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 6853173755818339647L;
+ String msFilePath = null;
+ String language = null;
+ String version = null;
+
+ /**
+ *
+ * @param sFilePath
+ * @param language
+ * @param version
+ */
+ public MakeLiveVersionCommand(String sFilePath, String language, String version)
+ {
+ this.msFilePath = sFilePath;
+ this.version = version;
+ this.language = language;
+ }
+
+ /**
+ *
+ */
+ public Object execute()
+ {
+ String versionMadeLive = null;
+ try
+ {
+ Session session = context.getSession();
+ Node fileNode =
(Node)session.getItem(this.msFilePath+"/"+this.language);
+
+ VersionHistory vh = fileNode.getVersionHistory();
+ vh.addVersionLabel(this.version, "LIVE", true);
+ versionMadeLive = this.version;
+ }
+ catch (Exception e)
+ {
+ log.error(this,e);
+ throw new CMSException(e);
+ }
+ return versionMadeLive;
+ }
+}
Modified:
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/command/StoreArchiveCommand.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/command/StoreArchiveCommand.java 2007-09-18
17:26:04 UTC (rev 8331)
+++
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/command/StoreArchiveCommand.java 2007-09-18
17:36:25 UTC (rev 8332)
@@ -40,14 +40,17 @@
import java.util.List;
import java.util.Locale;
import java.util.Enumeration;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
+
+import org.apache.tools.zip.ZipFile;
+import org.apache.tools.zip.ZipEntry;
+
import java.util.StringTokenizer;
/**
* Saves an uploaded archive to the repo.
*
* @author <a href="mailto:roy@jboss.org">Roy Russo</a>
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
*/
public class StoreArchiveCommand extends JCRCommand
{
@@ -83,7 +86,7 @@
ZipFile zipFile = new ZipFile(tmpFile);
ZipEntry zipEntry;
- Enumeration entries = zipFile.entries();
+ Enumeration entries = zipFile.getEntries();
while(entries.hasMoreElements())
{
zipEntry = (ZipEntry)entries.nextElement();
Modified:
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/test/cms/commands/TestFileArchiveUpload.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/test/cms/commands/TestFileArchiveUpload.java 2007-09-18
17:26:04 UTC (rev 8331)
+++
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/test/cms/commands/TestFileArchiveUpload.java 2007-09-18
17:36:25 UTC (rev 8332)
@@ -54,6 +54,8 @@
String sJPG = "/hibernate_logo.gif";
String sText = "/training.txt";
+
+ String foreignArchive = "resources/test/jcr/prueba.zip";
/**
@@ -79,6 +81,7 @@
InputStream is = IOTools.safeBufferedWrapper(new FileInputStream(sZipFile));
Command storearchiveCMD =
service.getCommandFactory().createStoreArchiveCommand("", is, "en");
List contentsToVersion = (List)service.execute(storearchiveCMD);
+ is.close();
Command createVersions = service.getCommandFactory()
.createContentCreateNewVersionCommand(contentsToVersion, true);
@@ -105,7 +108,12 @@
Folder whopper3 = (Folder)service.execute(listCMD3);
List folders3 = whopper3.getFolders();
List files3 = whopper3.getFiles();
-
+
+ //Create and Test an archive containing foreign files
+ is = IOTools.safeBufferedWrapper(new FileInputStream(this.foreignArchive));
+ storearchiveCMD =
service.getCommandFactory().createStoreArchiveCommand("", is, "en");
+ contentsToVersion = (List)service.execute(storearchiveCMD);
+ assertTrue("Foreign Archive Creation Failed",(contentsToVersion != null
&& !contentsToVersion.isEmpty() && contentsToVersion.size() == 2));
is.close();
}
}
Modified:
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/test/cms/commands/TestFileGetVersion.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/test/cms/commands/TestFileGetVersion.java 2007-09-18
17:26:04 UTC (rev 8331)
+++
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/test/cms/commands/TestFileGetVersion.java 2007-09-18
17:36:25 UTC (rev 8332)
@@ -31,7 +31,6 @@
import org.jboss.portal.cms.model.File;
import java.util.Locale;
-import java.util.Map;
/**
@@ -76,10 +75,29 @@
public void testFileGetVersion() throws CMSException
{
createFile();
+
// get specific file version
Command getCMDV = service.getCommandFactory().createFileGetCommand(sFilePath,
"1.0", Locale.ENGLISH);
File Vnewfile = (File)service.execute(getCMDV);
assertTrue("Incorrect version number for file object",
Vnewfile.getContent().getVersionNumber().equals("1.0"));
+
+ //Update this file and create a new version that goes "LIVE"
+ this.updateFile(Vnewfile);
+
+ //Make sure a new version 1.1 is created and thats the one that is
"LIVE"
+ getCMDV = service.getCommandFactory().createFileGetCommand(sFilePath,
Locale.ENGLISH);
+ Vnewfile = (File)service.execute(getCMDV);
+ assertTrue("Incorrect version number for file object",
Vnewfile.getContent().getVersionNumber().equals("1.1"));
+
+ //Now switch to 1.0 as being the "LIVE" version
+ Command makeLiveCommand =
service.getCommandFactory().createMakeLiveVersionCommand(sFilePath,
Locale.ENGLISH.getLanguage(), "1.0");
+ String liveVersion = (String)service.execute(makeLiveCommand);
+ assertEquals("Incorrect version number is
'LIVE'",liveVersion,"1.0");
+
+ //Verify that 1.0 is the "LIVE" version and not 1.1
+ getCMDV = service.getCommandFactory().createFileGetCommand(sFilePath,
Locale.ENGLISH);
+ Vnewfile = (File)service.execute(getCMDV);
+ assertEquals("Incorrect version number for file object
("+liveVersion+")", Vnewfile.getContent().getVersionNumber(),
liveVersion);
}
/**
@@ -117,4 +135,14 @@
Command newFileSPCMD = service.getCommandFactory().createNewFileCommand(file,
contentSP);
service.execute(newFileSPCMD);
}
+
+ /**
+ *
+ * @throws CMSException
+ */
+ private void updateFile(File updatedFile) throws CMSException
+ {
+ Command updateFileCMD =
service.getCommandFactory().createUpdateFileCommand(updatedFile, updatedFile.getContent(),
true);
+ service.execute(updateFileCMD);
+ }
}
Modified: branches/JBoss_Portal_Branch_2_6/core-cms/build.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-cms/build.xml 2007-09-18 17:26:04 UTC (rev
8331)
+++ branches/JBoss_Portal_Branch_2_6/core-cms/build.xml 2007-09-18 17:36:25 UTC (rev
8332)
@@ -253,6 +253,7 @@
<fileset dir="${jcr.jcr.lib}"
includes="jcr-1.0.jar"/>
<fileset dir="${apache.collections.lib}"
includes="commons-collections.jar"/>
<fileset dir="${apache.lucene.lib}"
includes="lucene.jar"/>
+ <fileset dir="${apache.ant.lib}" includes="ant.jar"/>
<!-- cms indexing integration -->
<fileset dir="${jackrabbit.jackrabbit.lib}"
includes="jackrabbit-index-filters.jar"/>
Modified:
branches/JBoss_Portal_Branch_2_6/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java 2007-09-18
17:26:04 UTC (rev 8331)
+++
branches/JBoss_Portal_Branch_2_6/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java 2007-09-18
17:36:25 UTC (rev 8332)
@@ -620,7 +620,7 @@
javax.portlet.PortletRequestDispatcher prd =
getPortletContext().getRequestDispatcher(CMSAdminConstants.CMS_JSP_PATH +
"/pending_items.jsp");
prd.include(rReq, rRes);
- }
+ }
}
public void processAction(final JBossActionRequest aReq, final JBossActionResponse
aRes) throws PortletException
@@ -1239,6 +1239,19 @@
aRes.setRenderParameter("path",
aReq.getParameter("path"));
aRes.setRenderParameter("op", CMSAdminConstants.OP_VIEWFILE);
}
+ else if(CMSAdminConstants.OP_MAKELIVE.equals(op))
+ {
+ String path = aReq.getParameter("path");
+ String language = aReq.getParameter("language");
+ String version = aReq.getParameter("version");
+
+ //Perform the change in live version here
+ Command makeLiveCommand =
CMSService.getCommandFactory().createMakeLiveVersionCommand(path, language, version);
+ CMSService.execute(makeLiveCommand);
+
+ aRes.setRenderParameter("path", path);
+ aRes.setRenderParameter("op", CMSAdminConstants.OP_VIEWFILE);
+ }
}
else
{
Modified:
branches/JBoss_Portal_Branch_2_6/core-cms/src/resources/portal-cms-war/WEB-INF/jsp/cms/admin/viewfile.jsp
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core-cms/src/resources/portal-cms-war/WEB-INF/jsp/cms/admin/viewfile.jsp 2007-09-18
17:26:04 UTC (rev 8331)
+++
branches/JBoss_Portal_Branch_2_6/core-cms/src/resources/portal-cms-war/WEB-INF/jsp/cms/admin/viewfile.jsp 2007-09-18
17:36:25 UTC (rev 8332)
@@ -265,8 +265,18 @@
<img src="<%= renderRequest.getContextPath() +
CMSAdminConstants.DEFAULT_IMAGES_PATH%>/live.gif"
alt="${n:i18n("CMS_LIVEVERSION")}"
border="0"/>
<%
- }
+ }else{
%>
+ <a href="<portlet:actionURL>
+ <portlet:param name="op" value="<%=
CMSAdminConstants.OP_MAKELIVE %>"/>
+ <portlet:param name="path" value="<%= sCurrPath
%>"/>
+ <portlet:param name="language" value="<%=
content.getLocale().getLanguage() %>"/>
+ <portlet:param name="version" value="<%=
version.getVersionNumber() %>"/>
+ </portlet:actionURL>"
+ >
+ <img src="<%= renderRequest.getContextPath() +
CMSAdminConstants.DEFAULT_IMAGES_PATH%>/up.gif"
alt="${n:i18n("CMS_LIVEVERSION")}" border="0"/>
+ </a>
+ <%}%>
</td>
<td>
<%