You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by ed...@apache.org on 2005/02/09 18:22:02 UTC
svn commit: r153090 -
lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/publication/task/PublicationTask.java
Author: edith
Date: Wed Feb 9 09:21:59 2005
New Revision: 153090
URL: http://svn.apache.org/viewcvs?view=rev&rev=153090
Log:
introduce method for the checkIn/Out of document; needed when the publication of a document to set the date, publisher, ...
Modified:
lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/publication/task/PublicationTask.java
Modified: lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/publication/task/PublicationTask.java
URL: http://svn.apache.org/viewcvs/lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/publication/task/PublicationTask.java?view=diff&r1=153089&r2=153090
==============================================================================
--- lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/publication/task/PublicationTask.java (original)
+++ lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/publication/task/PublicationTask.java Wed Feb 9 09:21:59 2005
@@ -15,7 +15,7 @@
*
*/
-/* $Id: PublicationTask.java,v 1.7 2004/03/01 16:18:27 gregor Exp $ */
+/* $Id$ */
package org.apache.lenya.cms.publication.task;
@@ -31,6 +31,10 @@
import org.apache.lenya.cms.publication.Publication;
import org.apache.lenya.cms.publication.PublicationFactory;
import org.apache.lenya.cms.publication.ResourcesManager;
+import org.apache.lenya.cms.rc.FileReservedCheckInException;
+import org.apache.lenya.cms.rc.RCEnvironment;
+import org.apache.lenya.cms.rc.RevisionControlException;
+import org.apache.lenya.cms.rc.RevisionController;
import org.apache.lenya.cms.task.AbstractTask;
import org.apache.lenya.cms.task.ExecutionException;
import org.apache.lenya.cms.task.Task;
@@ -275,4 +279,86 @@
return roles;
}
+ private RevisionController revisionController;
+
+ /**
+ * Returns the revision controller.
+ * @return A revision controller.
+ * @throws ExecutionException
+ * @throws IOException when something went wrong.
+ */
+ protected RevisionController getRevisionController() throws RevisionControlException, ExecutionException {
+ if (revisionController == null) {
+ File publicationDir = publication.getDirectory();
+ RCEnvironment rcEnvironment;
+ try {
+ File servletContext = publication.getServletContext();
+ rcEnvironment = RCEnvironment.getInstance(servletContext.getCanonicalPath());
+ } catch (IOException e) {
+ throw new RevisionControlException(e);
+ }
+
+ File rcmlDirectory = new File(publicationDir, rcEnvironment.getRCMLDirectory());
+ File backupDirectory = new File(publicationDir, rcEnvironment.getBackupDirectory());
+
+ revisionController =
+ new RevisionController(
+ rcmlDirectory.getAbsolutePath(),
+ backupDirectory.getAbsolutePath(),
+ publicationDir.getAbsolutePath());
+ }
+ return revisionController;
+ }
+
+ /**
+ * Returns the revision file path of a document.
+ * @param document The document.
+ * @return A string.
+ * @throws IOException when something went wrong.
+ */
+ protected String getRevisionFilePath(Document document) throws IOException {
+ String path = document.getFile().getCanonicalPath()
+ .substring(publication.getDirectory().getCanonicalPath().length());
+ return path;
+ }
+
+
+ /**
+ * Checks if the document can be checked out.
+ * @param document The document
+ * @return A boolean value.
+ * @throws ExecutionException when something went wrong.
+ * @throws IOException when something went wrong.
+ * @throws Exception when something went wrong.
+ */
+ protected boolean canCheckOut(Document document) throws ExecutionException, IOException, Exception{
+ String userId = getParameters().getParameter(PARAMETER_USER_ID);
+ String path = getRevisionFilePath(document);
+ return getRevisionController().canCheckOut(path, userId);
+ }
+
+ /**Checks in a document and creates a revision, if backup is true.
+ * @param document
+ * @param backup A boolean Value
+ * @throws FileReservedCheckInException when something went wrong.
+ * @throws Exception when something went wrong.
+ */
+ protected void reservedCheckIn(Document document, boolean backup)
+ throws FileReservedCheckInException, Exception {
+ String userId = getParameters().getParameter(PARAMETER_USER_ID);
+ String path = getRevisionFilePath(document);
+ getRevisionController().reservedCheckIn(path, userId, backup);
+ }
+
+ /**
+ * Checks out a document.
+ * @param document The document
+ * @throws IOException when something went wrong.
+ * @throws Exception when something went wrong.
+ */
+ protected void reservedCheckOut(Document document) throws IOException, Exception {
+ String userId = getParameters().getParameter(PARAMETER_USER_ID);
+ String path = getRevisionFilePath(document);
+ getRevisionController().reservedCheckOut(path, userId);
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org