Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/rc/RCML.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/rc/RCML.java?rev=617035&r1=617034&r2=617035&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/rc/RCML.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/rc/RCML.java Wed Jan 30 23:44:03 2008
@@ -14,431 +14,365 @@
* limitations under the License.
*
*/
-
/* $Id$ */
-
package org.apache.lenya.cms.rc;
-
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Vector;
-
import javax.xml.parsers.ParserConfigurationException;
-
import org.apache.lenya.xml.DocumentHelper;
import org.apache.lenya.xml.NamespaceHelper;
import org.apache.lenya.xml.XPointerFactory;
-import org.apache.log4j.Category;
+import org.apache.log4j.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-
/**
* Handle with the RCML file
*/
public class RCML {
- private static Category log = Category.getInstance(RCML.class);
-
- public static final short co = 0;
- public static final short ci = 1;
-
- private File rcmlFile;
- private Document document = null;
- private boolean dirty = false;
- private int maximalNumberOfEntries = 5;
-
- private static Map ELEMENTS = new HashMap();
- protected static final String ELEMENT_CHECKIN = "CheckIn";
- protected static final String ELEMENT_CHECKOUT = "CheckOut";
- protected static final String ELEMENT_BACKUP = "Backup";
-
- {
- ELEMENTS.put(new Short(ci), ELEMENT_CHECKIN);
- ELEMENTS.put(new Short(co), ELEMENT_CHECKOUT);
- }
-
- /**
- * Creates a new RCML object.
- */
- public RCML() {
- /*Deprecated
- maximalNumberOfEntries = new org.apache.lenya.xml.Configuration().maxNumberOfRollbacks;
- */
- maximalNumberOfEntries = 10;
- maximalNumberOfEntries = (2 * maximalNumberOfEntries) + 1;
- }
-
- /**
- * create a RCML-File if no one exists already
- *
- * @param rcmlDirectory The rcml directory.
- * @param filename The path of the file from the publication (e.g. for file with
- * absolute path home/.../jakarta-tomcat-4.1.24/webapps/lenya/lenya/pubs/{publication id}/content/authoring/foo/bar.xml
- * the filename is content/authoring/foo/bar.xml)
- * @param rootDirectory The publication directory
- *
- * @throws Exception if an error occurs
- */
- public RCML(String rcmlDirectory, String filename, String rootDirectory) throws Exception {
- this();
- rcmlFile = new File(rcmlDirectory, filename + ".rcml");
-
- if (!rcmlFile.isFile()) {
- // The rcml file does not yet exist, so we create it now...
- //
- File dataFile = new File(rootDirectory, filename);
- long lastModified = 0;
-
- if (dataFile.isFile()) {
- lastModified = dataFile.lastModified();
- }
-
- initDocument();
-
- // Create a "fake" checkin entry so it looks like the
- // system checked the document in. We use the filesystem
- // modification date as checkin time.
- //
- checkOutIn(RCML.ci, RevisionController.systemUsername, lastModified, false);
-
- File parent = new File(rcmlFile.getParent());
- parent.mkdirs();
-
- write();
- } else {
- document = DocumentHelper.readDocument(rcmlFile);
- }
- }
-
- /**
- * initialise the RCML-document. Delete all entries
- */
- public void initDocument() throws ParserConfigurationException {
- document = DocumentHelper.createDocument(null, "XPSRevisionControl", null);
- }
-
- /**
- * Call the methode write, if the document is dirty
- *
- * @throws IOException if an error occurs
- * @throws Exception if an error occurs
- */
- protected void finalize() throws IOException, Exception {
- if (this.isDirty()) {
- log.debug("RCML.finalize(): calling write()");
- write();
- }
- }
- /**
- * Write the xml RCML-document in the RCML-file.
- *
- * @throws IOException if an error occurs
- * @throws Exception if an error occurs
- */
- public void write() throws IOException, Exception {
- DocumentHelper.writeDocument(document, rcmlFile);
- clearDirty();
- }
-
- /**
- * Write a new entry for a check out or a check in the RCML-File made by the user with identity
- * at time
- *
- * @param type co for a check out, ci for a check in
- * @param identity The identity of the user
- * @param time Time at which the check in/out is made
- *
- * @throws IOException if an error occurs
- * @throws Exception if an error occurs
- */
- public void checkOutIn(short type, String identity, long time, boolean backup)
- throws IOException, Exception {
-
- if (type != co && type != ci) {
- throw new IllegalArgumentException(
- "ERROR: " + this.getClass().getName() + ".checkOutIn(): No such type");
- }
-
- NamespaceHelper helper = new NamespaceHelper(null, "", document);
-
- Element identityElement = helper.createElement("Identity", identity);
- Element timeElement = helper.createElement("Time", "" + time);
-
- String elementName = (String) ELEMENTS.get(new Short(type));
- Element checkOutElement = helper.createElement(elementName);
-
- checkOutElement.appendChild(identityElement);
- checkOutElement.appendChild(timeElement);
-
- if (backup) {
- Element backupElement = helper.createElement(ELEMENT_BACKUP);
- checkOutElement.appendChild(backupElement);
- }
-
- Element root = document.getDocumentElement();
- root.insertBefore(checkOutElement, root.getFirstChild());
-
- setDirty();
-
- // If this is a checkout, we write back the changed state
- // to the file immediately because otherwise another
- // process might read the file and think there is no open
- // checkout (as it is only visible in our private DOM tree
- // at this time).
- //
- // If, however, this is a checkin, we do not yet write it
- // out because then another process might again check it
- // out immediately and manipulate the file contents
- // *before* our caller has finished writing back the
- // changed data to the destination file. We therefore rely
- // on either our caller invoking the write() method when
- // finished or the garbage collector calling the finalize()
- // method.
- //
- if (type == co) {
- write();
- }
- }
-
- /**
- * get the latest check out
- *
- * @return CheckOutEntry The entry of the check out
- *
- * @throws Exception if an error occurs
- */
- public CheckOutEntry getLatestCheckOutEntry() throws Exception {
- XPointerFactory xpf = new XPointerFactory();
-
- Vector firstCheckOut =
- xpf.select(
- document.getDocumentElement(),
- "xpointer(/XPSRevisionControl/CheckOut[1]/Identity)xpointer(/XPSRevisionControl/CheckOut[1]/Time)");
-
- if (firstCheckOut.size() == 0) {
- // No checkout at all
- //
- return null;
- }
-
- String[] fcoValues = xpf.getNodeValues(firstCheckOut);
- long fcoTime = new Long(fcoValues[1]).longValue();
-
- return new CheckOutEntry(fcoValues[0], fcoTime);
- }
-
- /**
- * get the latest check in
- *
- * @return CheckInEntry The entry of the check in
- *
- * @throws Exception if an error occurs
- */
- public CheckInEntry getLatestCheckInEntry() throws Exception {
- XPointerFactory xpf = new XPointerFactory();
-
- Vector firstCheckIn =
- xpf.select(
- document.getDocumentElement(),
- "xpointer(/XPSRevisionControl/CheckIn[1]/Identity)xpointer(/XPSRevisionControl/CheckIn[1]/Time)");
-
- if (firstCheckIn.size() == 0) {
- // No checkin at all
- //
- return null;
- }
-
- String[] fciValues = xpf.getNodeValues(firstCheckIn);
- long fciTime = new Long(fciValues[1]).longValue();
-
- return new CheckInEntry(fciValues[0], fciTime);
- }
-
- /**
- * get the latest entry (a check out or check in)
- *
- * @return RCMLEntry The entry of the check out/in
- *
- * @throws Exception if an error occurs
- */
- public RCMLEntry getLatestEntry() throws Exception {
- CheckInEntry cie = getLatestCheckInEntry();
- CheckOutEntry coe = getLatestCheckOutEntry();
-
- if ((cie != null) && (coe != null)) {
- if (cie.getTime() > coe.getTime()) {
- return cie;
- } else {
- return coe;
- }
- }
-
- if (cie != null) {
+ private static Logger log = Logger.getLogger(RCML.class);
+ public static final short co = 0;
+ public static final short ci = 1;
+ private File rcmlFile;
+ private Document document = null;
+ private boolean dirty = false;
+ private int maximalNumberOfEntries = 5;
+ private static Map ELEMENTS = new HashMap();
+ protected static final String ELEMENT_CHECKIN = "CheckIn";
+ protected static final String ELEMENT_CHECKOUT = "CheckOut";
+ protected static final String ELEMENT_BACKUP = "Backup";
+ {
+ ELEMENTS.put(new Short(ci), ELEMENT_CHECKIN);
+ ELEMENTS.put(new Short(co), ELEMENT_CHECKOUT);
+ }
+ /**
+ * Creates a new RCML object.
+ */
+ public RCML() {
+ /*
+ * Deprecated maximalNumberOfEntries = new org.apache.lenya.xml.Configuration().maxNumberOfRollbacks;
+ */
+ maximalNumberOfEntries = 10;
+ maximalNumberOfEntries = (2 * maximalNumberOfEntries) + 1;
+ }
+ /**
+ * create a RCML-File if no one exists already
+ *
+ * @param rcmlDirectory
+ * The rcml directory.
+ * @param filename
+ * The path of the file from the publication (e.g. for file with absolute path home/.../jakarta-tomcat-4.1.24/webapps/lenya/lenya/pubs/{publication id}/content/authoring/foo/bar.xml the filename is content/authoring/foo/bar.xml)
+ * @param rootDirectory
+ * The publication directory
+ *
+ * @throws Exception
+ * if an error occurs
+ */
+ public RCML(String rcmlDirectory, String filename, String rootDirectory) throws Exception {
+ this();
+ rcmlFile = new File(rcmlDirectory, filename + ".rcml");
+ if(!rcmlFile.isFile()){
+ // The rcml file does not yet exist, so we create it now...
+ //
+ File dataFile = new File(rootDirectory, filename);
+ long lastModified = 0;
+ if(dataFile.isFile()){
+ lastModified = dataFile.lastModified();
+ }
+ initDocument();
+ // Create a "fake" checkin entry so it looks like the
+ // system checked the document in. We use the filesystem
+ // modification date as checkin time.
+ //
+ checkOutIn(RCML.ci, RevisionController.systemUsername, lastModified, false);
+ File parent = new File(rcmlFile.getParent());
+ parent.mkdirs();
+ write();
+ }else{
+ document = DocumentHelper.readDocument(rcmlFile);
+ }
+ }
+ /**
+ * initialise the RCML-document. Delete all entries
+ */
+ public void initDocument() throws ParserConfigurationException {
+ document = DocumentHelper.createDocument(null, "XPSRevisionControl", null);
+ }
+ /**
+ * Call the methode write, if the document is dirty
+ *
+ * @throws IOException
+ * if an error occurs
+ * @throws Exception
+ * if an error occurs
+ */
+ protected void finalize() throws IOException, Exception {
+ if(this.isDirty()){
+ log.debug("RCML.finalize(): calling write()");
+ write();
+ }
+ }
+ /**
+ * Write the xml RCML-document in the RCML-file.
+ *
+ * @throws IOException
+ * if an error occurs
+ * @throws Exception
+ * if an error occurs
+ */
+ public void write() throws IOException, Exception {
+ DocumentHelper.writeDocument(document, rcmlFile);
+ clearDirty();
+ }
+ /**
+ * Write a new entry for a check out or a check in the RCML-File made by the user with identity at time
+ *
+ * @param type
+ * co for a check out, ci for a check in
+ * @param identity
+ * The identity of the user
+ * @param time
+ * Time at which the check in/out is made
+ *
+ * @throws IOException
+ * if an error occurs
+ * @throws Exception
+ * if an error occurs
+ */
+ public void checkOutIn(short type, String identity, long time, boolean backup) throws IOException, Exception {
+ if(type != co && type != ci){
+ throw new IllegalArgumentException("ERROR: " + this.getClass().getName() + ".checkOutIn(): No such type");
+ }
+ NamespaceHelper helper = new NamespaceHelper(null, "", document);
+ Element identityElement = helper.createElement("Identity", identity);
+ Element timeElement = helper.createElement("Time", "" + time);
+ String elementName = (String) ELEMENTS.get(new Short(type));
+ Element checkOutElement = helper.createElement(elementName);
+ checkOutElement.appendChild(identityElement);
+ checkOutElement.appendChild(timeElement);
+ if(backup){
+ Element backupElement = helper.createElement(ELEMENT_BACKUP);
+ checkOutElement.appendChild(backupElement);
+ }
+ Element root = document.getDocumentElement();
+ root.insertBefore(checkOutElement, root.getFirstChild());
+ setDirty();
+ // If this is a checkout, we write back the changed state
+ // to the file immediately because otherwise another
+ // process might read the file and think there is no open
+ // checkout (as it is only visible in our private DOM tree
+ // at this time).
+ //
+ // If, however, this is a checkin, we do not yet write it
+ // out because then another process might again check it
+ // out immediately and manipulate the file contents
+ // *before* our caller has finished writing back the
+ // changed data to the destination file. We therefore rely
+ // on either our caller invoking the write() method when
+ // finished or the garbage collector calling the finalize()
+ // method.
+ //
+ if(type == co){
+ write();
+ }
+ }
+ /**
+ * get the latest check out
+ *
+ * @return CheckOutEntry The entry of the check out
+ *
+ * @throws Exception
+ * if an error occurs
+ */
+ public CheckOutEntry getLatestCheckOutEntry() throws Exception {
+ XPointerFactory xpf = new XPointerFactory();
+ Vector firstCheckOut = xpf.select(document.getDocumentElement(), "xpointer(/XPSRevisionControl/CheckOut[1]/Identity)xpointer(/XPSRevisionControl/CheckOut[1]/Time)");
+ if(firstCheckOut.size() == 0){
+ // No checkout at all
+ //
+ return null;
+ }
+ String[] fcoValues = xpf.getNodeValues(firstCheckOut);
+ long fcoTime = new Long(fcoValues[1]).longValue();
+ return new CheckOutEntry(fcoValues[0], fcoTime);
+ }
+ /**
+ * get the latest check in
+ *
+ * @return CheckInEntry The entry of the check in
+ *
+ * @throws Exception
+ * if an error occurs
+ */
+ public CheckInEntry getLatestCheckInEntry() throws Exception {
+ XPointerFactory xpf = new XPointerFactory();
+ Vector firstCheckIn = xpf.select(document.getDocumentElement(), "xpointer(/XPSRevisionControl/CheckIn[1]/Identity)xpointer(/XPSRevisionControl/CheckIn[1]/Time)");
+ if(firstCheckIn.size() == 0){
+ // No checkin at all
+ //
+ return null;
+ }
+ String[] fciValues = xpf.getNodeValues(firstCheckIn);
+ long fciTime = new Long(fciValues[1]).longValue();
+ return new CheckInEntry(fciValues[0], fciTime);
+ }
+ /**
+ * get the latest entry (a check out or check in)
+ *
+ * @return RCMLEntry The entry of the check out/in
+ *
+ * @throws Exception
+ * if an error occurs
+ */
+ public RCMLEntry getLatestEntry() throws Exception {
+ CheckInEntry cie = getLatestCheckInEntry();
+ CheckOutEntry coe = getLatestCheckOutEntry();
+ if((cie != null) && (coe != null)){
+ if(cie.getTime() > coe.getTime()){
return cie;
- } else {
+ }else{
return coe;
- }
- }
-
- /**
- * get all check in and check out
- *
- * @return Vector of all check out and check in entries in this RCML-file
- *
- * @throws Exception if an error occurs
- */
- public Vector getEntries() throws Exception {
- XPointerFactory xpf = new XPointerFactory();
-
- Vector entries =
- xpf.select(
- document.getDocumentElement(),
- "xpointer(/XPSRevisionControl/CheckOut|/XPSRevisionControl/CheckIn)");
- Vector RCMLEntries = new Vector();
-
- for (int i = 0; i < entries.size(); i++) {
- Element elem = (Element) entries.get(i);
- String time = elem.getElementsByTagName("Time").item(0).getFirstChild().getNodeValue();
- String identity =
- elem.getElementsByTagName("Identity").item(0).getFirstChild().getNodeValue();
-
- if (elem.getTagName().equals("CheckOut")) {
- RCMLEntries.add(new CheckOutEntry(identity, new Long(time).longValue()));
- } else {
- RCMLEntries.add(new CheckInEntry(identity, new Long(time).longValue()));
- }
- }
-
- return RCMLEntries;
- }
-
- /**
- * Prune the list of entries and delete the corresponding backups. Limit the number of entries to the value
- * maximalNumberOfEntries (2maxNumberOfRollbacks(configured)+1)
- *
- * @param backupDir The backup directory
- *
- * @throws Exception if an error occurs
- */
- public void pruneEntries(String backupDir) throws Exception {
- XPointerFactory xpf = new XPointerFactory();
-
- Vector entries =
- xpf.select(
- document.getDocumentElement(),
- "xpointer(/XPSRevisionControl/CheckOut|/XPSRevisionControl/CheckIn)");
-
- for (int i = maximalNumberOfEntries; i < entries.size(); i++) {
- Element current = (Element) entries.get(i);
-
- // remove the backup file associated with this entry
- String time =
- current.getElementsByTagName("Time").item(0).getFirstChild().getNodeValue();
- File backupFile = new File(backupDir + "/" + time + ".bak");
- backupFile.delete();
- // remove the entry from the list
- current.getParentNode().removeChild(current);
- }
- }
-
- /**
- * Get a clone document
- *
- * @return org.w3c.dom.Document The clone document
- *
- * @throws Exception if an error occurs
- */
- public org.w3c.dom.Document getDOMDocumentClone() throws Exception {
- Document documentClone = DocumentHelper.createDocument(null, "dummy", null);
- documentClone.removeChild(documentClone.getDocumentElement());
- documentClone.appendChild(documentClone.importNode(document.getDocumentElement(), true));
-
- return documentClone;
- }
-
- /**
- * Check if the document is dirty
- *
- * @return boolean dirty
- */
- public boolean isDirty() {
- return dirty;
- }
-
- /**
- * Set the value dirty to true
- */
- protected void setDirty() {
- dirty = true;
- }
-
- /**
- * Set the value dirty to false
- */
- protected void clearDirty() {
- dirty = false;
- }
-
- /**
- * Delete the latest check in
- *
- * @throws Exception if an error occurs
- */
- public void deleteFirstCheckIn() throws Exception {
- XPointerFactory xpf = new XPointerFactory();
- Node root = document.getDocumentElement();
- Vector firstCheckIn = xpf.select(root, "xpointer(/XPSRevisionControl/CheckIn[1])");
- root.removeChild((Node) firstCheckIn.elementAt(0));
- root.removeChild(root.getFirstChild()); // remove EOL (end of line)
- setDirty();
- }
-
- /**
- * get the time's value of the backups
- *
- * @return String[] the times
- *
- * @throws Exception if an error occurs
- */
- public String[] getBackupsTime() throws Exception {
- XPointerFactory xpf = new XPointerFactory();
-
- Vector entries =
- xpf.select(
- document.getDocumentElement(),
- "xpointer(/XPSRevisionControl/CheckIn)");
- ArrayList times = new ArrayList();
-
- for (int i = 0; i < entries.size(); i++) {
- Element elem = (Element) entries.get(i);
- String time = elem.getElementsByTagName("Time").item(0).getFirstChild().getNodeValue();
- NodeList backupNodes = elem.getElementsByTagName(ELEMENT_BACKUP);
- if (backupNodes != null && backupNodes.getLength()>0) {
- times.add(time);
- }
- }
- return (String[]) times.toArray(new String[times.size()]);
-
- }
-
- /**
- * delete the rcml file and the directory if this one is empty
- *
- * @return boolean true, if the file was deleted
- */
- public boolean delete() {
- File rcmlFile = this.rcmlFile;
- File directory = rcmlFile.getParentFile();
- boolean deleted = rcmlFile.delete();
- if (directory.exists()
- && directory.isDirectory()
- && directory.listFiles().length == 0) {
- directory.delete();
- }
- return deleted;
- }
+ }
+ }
+ if(cie != null){
+ return cie;
+ }else{
+ return coe;
+ }
+ }
+ /**
+ * get all check in and check out
+ *
+ * @return Vector of all check out and check in entries in this RCML-file
+ *
+ * @throws Exception
+ * if an error occurs
+ */
+ public Vector getEntries() throws Exception {
+ XPointerFactory xpf = new XPointerFactory();
+ Vector entries = xpf.select(document.getDocumentElement(), "xpointer(/XPSRevisionControl/CheckOut|/XPSRevisionControl/CheckIn)");
+ Vector RCMLEntries = new Vector();
+ for(int i = 0; i < entries.size(); i++){
+ Element elem = (Element) entries.get(i);
+ String time = elem.getElementsByTagName("Time").item(0).getFirstChild().getNodeValue();
+ String identity = elem.getElementsByTagName("Identity").item(0).getFirstChild().getNodeValue();
+ if(elem.getTagName().equals("CheckOut")){
+ RCMLEntries.add(new CheckOutEntry(identity, new Long(time).longValue()));
+ }else{
+ RCMLEntries.add(new CheckInEntry(identity, new Long(time).longValue()));
+ }
+ }
+ return RCMLEntries;
+ }
+ /**
+ * Prune the list of entries and delete the corresponding backups. Limit the number of entries to the value maximalNumberOfEntries (2maxNumberOfRollbacks(configured)+1)
+ *
+ * @param backupDir
+ * The backup directory
+ *
+ * @throws Exception
+ * if an error occurs
+ */
+ public void pruneEntries(String backupDir) throws Exception {
+ XPointerFactory xpf = new XPointerFactory();
+ Vector entries = xpf.select(document.getDocumentElement(), "xpointer(/XPSRevisionControl/CheckOut|/XPSRevisionControl/CheckIn)");
+ for(int i = maximalNumberOfEntries; i < entries.size(); i++){
+ Element current = (Element) entries.get(i);
+ // remove the backup file associated with this entry
+ String time = current.getElementsByTagName("Time").item(0).getFirstChild().getNodeValue();
+ File backupFile = new File(backupDir + "/" + time + ".bak");
+ backupFile.delete();
+ // remove the entry from the list
+ current.getParentNode().removeChild(current);
+ }
+ }
+ /**
+ * Get a clone document
+ *
+ * @return org.w3c.dom.Document The clone document
+ *
+ * @throws Exception
+ * if an error occurs
+ */
+ public org.w3c.dom.Document getDOMDocumentClone() throws Exception {
+ Document documentClone = DocumentHelper.createDocument(null, "dummy", null);
+ documentClone.removeChild(documentClone.getDocumentElement());
+ documentClone.appendChild(documentClone.importNode(document.getDocumentElement(), true));
+ return documentClone;
+ }
+ /**
+ * Check if the document is dirty
+ *
+ * @return boolean dirty
+ */
+ public boolean isDirty() {
+ return dirty;
+ }
+ /**
+ * Set the value dirty to true
+ */
+ protected void setDirty() {
+ dirty = true;
+ }
+ /**
+ * Set the value dirty to false
+ */
+ protected void clearDirty() {
+ dirty = false;
+ }
+ /**
+ * Delete the latest check in
+ *
+ * @throws Exception
+ * if an error occurs
+ */
+ public void deleteFirstCheckIn() throws Exception {
+ XPointerFactory xpf = new XPointerFactory();
+ Node root = document.getDocumentElement();
+ Vector firstCheckIn = xpf.select(root, "xpointer(/XPSRevisionControl/CheckIn[1])");
+ root.removeChild((Node) firstCheckIn.elementAt(0));
+ root.removeChild(root.getFirstChild()); // remove EOL (end of line)
+ setDirty();
+ }
+ /**
+ * get the time's value of the backups
+ *
+ * @return String[] the times
+ *
+ * @throws Exception
+ * if an error occurs
+ */
+ public String[] getBackupsTime() throws Exception {
+ XPointerFactory xpf = new XPointerFactory();
+ Vector entries = xpf.select(document.getDocumentElement(), "xpointer(/XPSRevisionControl/CheckIn)");
+ ArrayList times = new ArrayList();
+ for(int i = 0; i < entries.size(); i++){
+ Element elem = (Element) entries.get(i);
+ String time = elem.getElementsByTagName("Time").item(0).getFirstChild().getNodeValue();
+ NodeList backupNodes = elem.getElementsByTagName(ELEMENT_BACKUP);
+ if(backupNodes != null && backupNodes.getLength() > 0){
+ times.add(time);
+ }
+ }
+ return (String[]) times.toArray(new String[times.size()]);
+ }
+ /**
+ * delete the rcml file and the directory if this one is empty
+ *
+ * @return boolean true, if the file was deleted
+ */
+ public boolean delete() {
+ File rcmlFile = this.rcmlFile;
+ File directory = rcmlFile.getParentFile();
+ boolean deleted = rcmlFile.delete();
+ if(directory.exists() && directory.isDirectory() && directory.listFiles().length == 0){
+ directory.delete();
+ }
+ return deleted;
+ }
}
Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/rc/RevisionControlException.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/rc/RevisionControlException.java?rev=617035&r1=617034&r2=617035&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/rc/RevisionControlException.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/rc/RevisionControlException.java Wed Jan 30 23:44:03 2008
@@ -14,46 +14,46 @@
* limitations under the License.
*
*/
-
/* $Id$ */
-
package org.apache.lenya.cms.rc;
-
/**
* A revision control exception.
*/
public class RevisionControlException extends Exception {
-
- /**
- * Ctor.
- */
- public RevisionControlException() {
- super();
- }
-
- /**
- * Ctor.
- * @param message The message.
- */
- public RevisionControlException(String message) {
- super(message);
- }
-
- /**
- * Ctor.
- * @param cause The cause.
- */
- public RevisionControlException(Throwable cause) {
- super(cause);
- }
-
- /**
- * Ctor.
- * @param message The message.
- * @param cause The cause.
- */
- public RevisionControlException(String message, Throwable cause) {
- super(message, cause);
- }
-
+ private static final long serialVersionUID = 1L;
+ /**
+ * Ctor.
+ */
+ public RevisionControlException() {
+ super();
+ }
+ /**
+ * Ctor.
+ *
+ * @param message
+ * The message.
+ */
+ public RevisionControlException(String message) {
+ super(message);
+ }
+ /**
+ * Ctor.
+ *
+ * @param cause
+ * The cause.
+ */
+ public RevisionControlException(Throwable cause) {
+ super(cause);
+ }
+ /**
+ * Ctor.
+ *
+ * @param message
+ * The message.
+ * @param cause
+ * The cause.
+ */
+ public RevisionControlException(String message, Throwable cause) {
+ super(message, cause);
+ }
}
Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/rc/RevisionController.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/rc/RevisionController.java?rev=617035&r1=617034&r2=617035&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/rc/RevisionController.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/rc/RevisionController.java Wed Jan 30 23:44:03 2008
@@ -14,11 +14,8 @@
* limitations under the License.
*
*/
-
/* $Id$ */
-
package org.apache.lenya.cms.rc;
-
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -26,754 +23,569 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Date;
-
-import org.apache.lenya.cms.publication.Document;
-import org.apache.lenya.cms.publication.Publication;
import org.apache.lenya.util.XPSFileOutputStream;
-import org.apache.log4j.Category;
-
+import org.apache.log4j.Logger;
/**
- * Controller for the reserved check-in, check-out, the backup versions and the rollback
+ * Controller for the reserved check-in, check-out, the backup versions and the rollback
*/
public class RevisionController {
- private static Category log = Category.getInstance(RevisionController.class);
-
- // System username. This is used for
- // - creating dummy checkin events in a new RCML file
- // when it is created on-the-fly
- // - system override on checkin, i.e. you can force
- // a checkin into the repository if you use this
- // username as identity parameter to reservedCheckIn()
- //
- public static final String systemUsername = "System";
-
- private String rcmlDir = null;
- private String rootDir = null;
- private String backupDir = null;
-
- /**
- * Creates a new RevisionController object.
- *
- */
- public RevisionController() {
- Configuration conf = new Configuration();
- rcmlDir = conf.getRcmlDirectory();
- if (!new File(rcmlDir).exists())
- log.error("No such directory: " + rcmlDir);
- backupDir = conf.getBackupDirectory();
- if (!new File(backupDir).exists())
- log.error("No such directory: " + backupDir);
- rootDir = "conf.rootDirectory";
- }
-
- /**
- * Creates a new RevisionController object.
- *
- * @param rcmlDirectory The directory for the RCML files
- * @param backupDirectory The directory for the backup versions
- * @param rootDirectory The publication directory
- */
- public RevisionController(String rcmlDirectory, String backupDirectory, String rootDirectory) {
- this.rcmlDir = rcmlDirectory;
- this.backupDir = backupDirectory;
- this.rootDir = rootDirectory;
- }
-
- /**
- * Creates a new RevisionController object.
- *
- * @param rootDir The publication directory
- */
- public RevisionController(String rootDir) {
- this();
- this.rootDir = rootDir;
- }
-
- /**
- * Shows Configuration
- *
- * @return String The rcml directory, the backup directory, the publication directory
- */
- public String toString() {
- return "rcmlDir=" + rcmlDir + " , rcbakDir=" + backupDir + " , rootDir=" + rootDir;
- }
-
- /**
- * Get the RCML File for the file source
- *
- * @param source The path of the file from the publication.
- *
- * @return RCML The corresponding RCML file.
- *
- * @throws FileNotFoundException if an error occurs
- * @throws IOException if an error occurs
- * @throws Exception if an error occurs
- */
-/*
- public RCML getRCML(Document doc) throws FileNotFoundException, IOException, Exception {
- return new RCML(rcmlDir, doc.getDocumentAreaPath(), rootDir);
- }
-*/
-
- /**
- * @deprecated please use getRCML(Document doc)
- * Get the RCML File for the file source
- *
- * @param source The path of the file from the publication.
- *
- * @return RCML The corresponding RCML file.
- *
- * @throws FileNotFoundException if an error occurs
- * @throws IOException if an error occurs
- * @throws Exception if an error occurs
- */
- public RCML getRCML(String source) throws FileNotFoundException, IOException, Exception {
- return new RCML(rcmlDir, source, rootDir);
- }
-
- /**
- * Try to make a reserved check out of the file source for a user with identity
- *
- * @param source The filename of the file to check out
- * @param identity The identity of the user
- * @return File File to check out
- * @throws Exception if an error occurs
- */
-/*
- public File reservedCheckOut(Document doc, String identity) throws Exception {
-
- RCML rcml = new RCML(rcmlDir, doc.getDocumentAreaPath(), rootDir);
-
- RCMLEntry entry = rcml.getLatestEntry();
-
- // The same user is allowed to check out repeatedly without
- // having to check back in first.
- //
- if (entry != null) {
- log.debug("entry: " + entry);
- log.debug("entry.type:" + entry.getType());
- log.debug("entry.identity" + entry.getIdentity());
- }
-
- if ((entry != null)
- && (entry.getType() != RCML.ci)
- && !entry.getIdentity().equals(identity)) {
- throw new FileReservedCheckOutException(rootDir + doc.getDocumentAreaPath(), rcml);
- }
-
- rcml.checkOutIn(RCML.co, identity, new Date().getTime(), false);
-
- return doc.getFile();
- }
-*/
-
- /**
- * @deprecated reservedCheckOut(Document, String)
- * Try to make a reserved check out of the file source for a user with identity
- *
- * @param source The filename of the file to check out
- * @param identity The identity of the user
- * @return File File to check out
- * @throws Exception if an error occurs
- */
- public File reservedCheckOut(String source, String identity) throws Exception {
-
- File file = new File(rootDir + source);
- /*
- if (!file.isFile()) {
- throw new FileNotFoundException(file.getAbsolutePath());
- }
- */
-
- RCML rcml = new RCML(rcmlDir, source, rootDir);
-
- RCMLEntry entry = rcml.getLatestEntry();
-
- // The same user is allowed to check out repeatedly without
- // having to check back in first.
- //
- if (entry != null) {
- log.debug("entry: " + entry);
- log.debug("entry.type:" + entry.getType());
- log.debug("entry.identity" + entry.getIdentity());
- }
-
- if ((entry != null)
- && (entry.getType() != RCML.ci)
- && !entry.getIdentity().equals(identity)) {
- throw new FileReservedCheckOutException(rootDir + source, rcml);
- }
-
- rcml.checkOutIn(RCML.co, identity, new Date().getTime(), false);
-
- return file;
- }
-
- /**
- * Checks if a source can be checked out.
- * @param source The source.
- * @param identity The identity who requests checking out.
- * @return A boolean value.
- * @throws Exception when something went wrong.
- */
-/*
- public boolean canCheckOut(Document doc, String identity) throws Exception {
-
- RCML rcml = new RCML(rcmlDir, doc.getDocumentAreaPath(), rootDir);
-
- RCMLEntry entry = rcml.getLatestEntry();
-
- // The same user is allowed to check out repeatedly without
- // having to check back in first.
- //
- if (entry != null) {
- log.debug("entry: " + entry);
- log.debug("entry.type:" + entry.getType());
- log.debug("entry.identity" + entry.getIdentity());
- }
-
- boolean checkedOutByOther =
- entry != null && entry.getType() != RCML.ci && !entry.getIdentity().equals(identity);
-
- return !checkedOutByOther;
- }
-*/
-
- /**
- * @deprecated please use canCheckOut(Document, String)
- * Checks if a source can be checked out.
- * @param source The source.
- * @param identity The identity who requests checking out.
- * @return A boolean value.
- * @throws Exception when something went wrong.
- */
- public boolean canCheckOut(String source, String identity) throws Exception {
- RCML rcml = new RCML(rcmlDir, source, rootDir);
-
- RCMLEntry entry = rcml.getLatestEntry();
-
- // The same user is allowed to check out repeatedly without
- // having to check back in first.
- //
- if (entry != null) {
- log.debug("entry: " + entry);
- log.debug("entry.type:" + entry.getType());
- log.debug("entry.identity" + entry.getIdentity());
- }
-
- boolean checkedOutByOther =
- entry != null && entry.getType() != RCML.ci && !entry.getIdentity().equals(identity);
-
- return !checkedOutByOther;
- }
-
- /**
- * Try to make a reserved check in of the file destination for a user with identity. A backup
- * copy can be made.
- *
- * @param destination The file we want to check in
- * @param identity The identity of the user
- * @param backup if true, a backup will be created, else no backup will be made.
- *
- * @return long The time.
- *
- * @exception FileReservedCheckInException if the document couldn't be checked in (for instance
- * because it is already checked out by someone other ...)
- * @exception Exception if other problems occur
- */
-/*
- public long reservedCheckIn(Document doc, String identity, boolean backup)
- throws FileReservedCheckInException, Exception {
-
- RCML rcml = new RCML(rcmlDir, doc.getDocumentAreaPath(), rootDir);
-
- CheckOutEntry coe = rcml.getLatestCheckOutEntry();
- CheckInEntry cie = rcml.getLatestCheckInEntry();
-
- // If there has never been a checkout for this object
- // *or* if the user attempting the checkin right now
- // is the system itself, we will skip any checks and proceed
- // right away to the actual checkin.
- // In all other cases we enforce the revision control
- // rules inside this if clause:
- //
- if (!((coe == null) || identity.equals(RevisionController.systemUsername))) {
- if ((cie != null) && (cie.getTime() > coe.getTime())) {
- // We have case 1
- if (!cie.getIdentity().equals(identity)) {
- // Case 1.2., abort...
- //
- throw new FileReservedCheckInException(rootDir + doc.getDocumentAreaPath(), rcml);
- }
- } else {
- // Case 2
- if (!coe.getIdentity().equals(identity)) {
- // Case 2.2., abort...
- //
- throw new FileReservedCheckInException(rootDir + doc.getDocumentAreaPath(), rcml);
- }
+ private static Logger log = Logger.getLogger(RevisionController.class);
+ // System username. This is used for
+ // - creating dummy checkin events in a new RCML file
+ // when it is created on-the-fly
+ // - system override on checkin, i.e. you can force
+ // a checkin into the repository if you use this
+ // username as identity parameter to reservedCheckIn()
+ //
+ public static final String systemUsername = "System";
+ private String rcmlDir = null;
+ private String rootDir = null;
+ private String backupDir = null;
+ /**
+ * Creates a new RevisionController object.
+ *
+ */
+ public RevisionController() {
+ Configuration conf = new Configuration();
+ rcmlDir = conf.getRcmlDirectory();
+ if(!new File(rcmlDir).exists())
+ log.error("No such directory: " + rcmlDir);
+ backupDir = conf.getBackupDirectory();
+ if(!new File(backupDir).exists())
+ log.error("No such directory: " + backupDir);
+ rootDir = "conf.rootDirectory";
+ }
+ /**
+ * Creates a new RevisionController object.
+ *
+ * @param rcmlDirectory
+ * The directory for the RCML files
+ * @param backupDirectory
+ * The directory for the backup versions
+ * @param rootDirectory
+ * The publication directory
+ */
+ public RevisionController(String rcmlDirectory, String backupDirectory, String rootDirectory) {
+ this.rcmlDir = rcmlDirectory;
+ this.backupDir = backupDirectory;
+ this.rootDir = rootDirectory;
+ }
+ /**
+ * Creates a new RevisionController object.
+ *
+ * @param rootDir
+ * The publication directory
+ */
+ public RevisionController(String rootDir) {
+ this();
+ this.rootDir = rootDir;
+ }
+ /**
+ * Shows Configuration
+ *
+ * @return String The rcml directory, the backup directory, the publication directory
+ */
+ public String toString() {
+ return "rcmlDir=" + rcmlDir + " , rcbakDir=" + backupDir + " , rootDir=" + rootDir;
+ }
+ /**
+ * Get the RCML File for the file source
+ *
+ * @param source
+ * The path of the file from the publication.
+ *
+ * @return RCML The corresponding RCML file.
+ *
+ * @throws FileNotFoundException
+ * if an error occurs
+ * @throws IOException
+ * if an error occurs
+ * @throws Exception
+ * if an error occurs
+ */
+ /*
+ * public RCML getRCML(Document doc) throws FileNotFoundException, IOException, Exception { return new RCML(rcmlDir, doc.getDocumentAreaPath(), rootDir); }
+ */
+ /**
+ * @deprecated please use getRCML(Document doc) Get the RCML File for the file source
+ *
+ * @param source
+ * The path of the file from the publication.
+ *
+ * @return RCML The corresponding RCML file.
+ *
+ * @throws FileNotFoundException
+ * if an error occurs
+ * @throws IOException
+ * if an error occurs
+ * @throws Exception
+ * if an error occurs
+ */
+ public RCML getRCML(String source) throws FileNotFoundException, IOException, Exception {
+ return new RCML(rcmlDir, source, rootDir);
+ }
+ /**
+ * Try to make a reserved check out of the file source for a user with identity
+ *
+ * @param source
+ * The filename of the file to check out
+ * @param identity
+ * The identity of the user
+ * @return File File to check out
+ * @throws Exception
+ * if an error occurs
+ */
+ /*
+ * public File reservedCheckOut(Document doc, String identity) throws Exception {
+ *
+ * RCML rcml = new RCML(rcmlDir, doc.getDocumentAreaPath(), rootDir);
+ *
+ * RCMLEntry entry = rcml.getLatestEntry();
+ * // The same user is allowed to check out repeatedly without // having to check back in first. // if (entry != null) { log.debug("entry: " + entry); log.debug("entry.type:" + entry.getType()); log.debug("entry.identity" + entry.getIdentity()); }
+ *
+ * if ((entry != null) && (entry.getType() != RCML.ci) && !entry.getIdentity().equals(identity)) { throw new FileReservedCheckOutException(rootDir + doc.getDocumentAreaPath(), rcml); }
+ *
+ * rcml.checkOutIn(RCML.co, identity, new Date().getTime(), false);
+ *
+ * return doc.getFile(); }
+ */
+ /**
+ * @deprecated reservedCheckOut(Document, String) Try to make a reserved check out of the file source for a user with identity
+ *
+ * @param source
+ * The filename of the file to check out
+ * @param identity
+ * The identity of the user
+ * @return File File to check out
+ * @throws Exception
+ * if an error occurs
+ */
+ public File reservedCheckOut(String source, String identity) throws Exception {
+ File file = new File(rootDir + source);
+ /*
+ * if (!file.isFile()) { throw new FileNotFoundException(file.getAbsolutePath()); }
+ */
+ RCML rcml = new RCML(rcmlDir, source, rootDir);
+ RCMLEntry entry = rcml.getLatestEntry();
+ // The same user is allowed to check out repeatedly without
+ // having to check back in first.
+ //
+ if(entry != null){
+ log.debug("entry: " + entry);
+ log.debug("entry.type:" + entry.getType());
+ log.debug("entry.identity" + entry.getIdentity());
+ }
+ if((entry != null) && (entry.getType() != RCML.ci) && !entry.getIdentity().equals(identity)){
+ throw new FileReservedCheckOutException(rootDir + source, rcml);
+ }
+ rcml.checkOutIn(RCML.co, identity, new Date().getTime(), false);
+ return file;
+ }
+ /**
+ * Checks if a source can be checked out.
+ *
+ * @param source
+ * The source.
+ * @param identity
+ * The identity who requests checking out.
+ * @return A boolean value.
+ * @throws Exception
+ * when something went wrong.
+ */
+ /*
+ * public boolean canCheckOut(Document doc, String identity) throws Exception {
+ *
+ * RCML rcml = new RCML(rcmlDir, doc.getDocumentAreaPath(), rootDir);
+ *
+ * RCMLEntry entry = rcml.getLatestEntry();
+ * // The same user is allowed to check out repeatedly without // having to check back in first. // if (entry != null) { log.debug("entry: " + entry); log.debug("entry.type:" + entry.getType()); log.debug("entry.identity" + entry.getIdentity()); }
+ *
+ * boolean checkedOutByOther = entry != null && entry.getType() != RCML.ci && !entry.getIdentity().equals(identity);
+ *
+ * return !checkedOutByOther; }
+ */
+ /**
+ * @deprecated please use canCheckOut(Document, String) Checks if a source can be checked out.
+ * @param source
+ * The source.
+ * @param identity
+ * The identity who requests checking out.
+ * @return A boolean value.
+ * @throws Exception
+ * when something went wrong.
+ */
+ public boolean canCheckOut(String source, String identity) throws Exception {
+ RCML rcml = new RCML(rcmlDir, source, rootDir);
+ RCMLEntry entry = rcml.getLatestEntry();
+ // The same user is allowed to check out repeatedly without
+ // having to check back in first.
+ //
+ if(entry != null){
+ log.debug("entry: " + entry);
+ log.debug("entry.type:" + entry.getType());
+ log.debug("entry.identity" + entry.getIdentity());
+ }
+ boolean checkedOutByOther = entry != null && entry.getType() != RCML.ci && !entry.getIdentity().equals(identity);
+ return !checkedOutByOther;
+ }
+ /**
+ * Try to make a reserved check in of the file destination for a user with identity. A backup copy can be made.
+ *
+ * @param destination
+ * The file we want to check in
+ * @param identity
+ * The identity of the user
+ * @param backup
+ * if true, a backup will be created, else no backup will be made.
+ *
+ * @return long The time.
+ *
+ * @exception FileReservedCheckInException
+ * if the document couldn't be checked in (for instance because it is already checked out by someone other ...)
+ * @exception Exception
+ * if other problems occur
+ */
+ /*
+ * public long reservedCheckIn(Document doc, String identity, boolean backup) throws FileReservedCheckInException, Exception {
+ *
+ * RCML rcml = new RCML(rcmlDir, doc.getDocumentAreaPath(), rootDir);
+ *
+ * CheckOutEntry coe = rcml.getLatestCheckOutEntry(); CheckInEntry cie = rcml.getLatestCheckInEntry();
+ * // If there has never been a checkout for this object // *or* if the user attempting the checkin right now // is the system itself, we will skip any checks and proceed // right away to the actual checkin. // In all other cases we enforce the revision control // rules inside this if clause: // if (!((coe == null) || identity.equals(RevisionController.systemUsername))) { if ((cie != null) && (cie.getTime() > coe.getTime())) { // We have case 1 if (!cie.getIdentity().equals(identity)) { // Case 1.2., abort... // throw new FileReservedCheckInException(rootDir + doc.getDocumentAreaPath(), rcml); } } else { // Case 2 if (!coe.getIdentity().equals(identity)) { // Case 2.2., abort... // throw new FileReservedCheckInException(rootDir + doc.getDocumentAreaPath(), rcml); } } }
+ *
+ * File originalFile = doc.getFile(); long time = new Date().getTime();
+ *
+ * if (backup && originalFile.isFile()) { File backupFile = new File(backupDir, doc.getDocumentAreaPath() + ".bak." + time); File parent = new File(backupFile.getParent());
+ *
+ * if (!parent.isDirectory()) { parent.mkdirs(); }
+ *
+ * log.info( "Backup: copy " + originalFile.getAbsolutePath() + " to " + backupFile.getAbsolutePath());
+ *
+ * InputStream in = new FileInputStream(originalFile.getAbsolutePath());
+ *
+ * OutputStream out = new XPSFileOutputStream(backupFile.getAbsolutePath()); byte[] buffer = new byte[512]; int length;
+ *
+ * while ((length = in.read(buffer)) != -1) { out.write(buffer, 0, length); }
+ *
+ * out.close(); }
+ *
+ * rcml.checkOutIn(RCML.ci, identity, time, backup); rcml.pruneEntries(backupDir); rcml.write();
+ * // FIXME: If we reuse the observer pattern as implemented in // xps this would be the place to notify the observers, // e.g. like so: // StatusChangeSignalHandler.emitSignal("file:" + originalFile.getAbsolutePath(), // "reservedCheckIn"); return time; }
+ */
+ /**
+ * @deprecated please use reservedCheckIn(Document, String, boolean) Try to make a reserved check in of the file destination for a user with identity. A backup copy can be made.
+ *
+ * @param destination
+ * The file we want to check in
+ * @param identity
+ * The identity of the user
+ * @param backup
+ * if true, a backup will be created, else no backup will be made.
+ *
+ * @return long The time.
+ *
+ * @exception FileReservedCheckInException
+ * if the document couldn't be checked in (for instance because it is already checked out by someone other ...)
+ * @exception Exception
+ * if other problems occur
+ */
+ public long reservedCheckIn(String destination, String identity, boolean backup) throws FileReservedCheckInException, Exception {
+ RCML rcml = new RCML(rcmlDir, destination, rootDir);
+ CheckOutEntry coe = rcml.getLatestCheckOutEntry();
+ CheckInEntry cie = rcml.getLatestCheckInEntry();
+ // If there has never been a checkout for this object
+ // *or* if the user attempting the checkin right now
+ // is the system itself, we will skip any checks and proceed
+ // right away to the actual checkin.
+ // In all other cases we enforce the revision control
+ // rules inside this if clause:
+ //
+ if(!((coe == null) || identity.equals(RevisionController.systemUsername))){
+ /*
+ * Possible cases and rules:
+ *
+ * 1.) we were able to read the latest checkin and it is later than latest checkout (i.e. there is no open checkout to match this checkin, an unusual case) 1.1.) identity of latest checkin is equal to current user -> checkin allowed, same user may check in repeatedly 1.2.) identity of latest checkin is not equal to current user -> checkin rejected, may not overwrite the revision which another user checked in previously 2.) there was no checkin or the latest checkout is later than latest checkin (i.e. there is an open checkout) 2.1.) identity of latest checkout is equal to current user -> checkin allowed, user checked out and may check in again (the most common case) 2.2.) identity of latest checkout is not equal to current user -> checkin rejected, may not check in while another
user is working on this document
+ *
+ */
+ if((cie != null) && (cie.getTime() > coe.getTime())){
+ // We have case 1
+ if(!cie.getIdentity().equals(identity)){
+ // Case 1.2., abort...
+ //
+ throw new FileReservedCheckInException(rootDir + destination, rcml);
}
- }
-
- File originalFile = doc.getFile();
- long time = new Date().getTime();
-
- if (backup && originalFile.isFile()) {
- File backupFile = new File(backupDir, doc.getDocumentAreaPath() + ".bak." + time);
- File parent = new File(backupFile.getParent());
-
- if (!parent.isDirectory()) {
- parent.mkdirs();
+ }else{
+ // Case 2
+ if(!coe.getIdentity().equals(identity)){
+ // Case 2.2., abort...
+ //
+ throw new FileReservedCheckInException(rootDir + destination, rcml);
}
-
- log.info(
- "Backup: copy "
- + originalFile.getAbsolutePath()
- + " to "
- + backupFile.getAbsolutePath());
-
- InputStream in = new FileInputStream(originalFile.getAbsolutePath());
-
- OutputStream out = new XPSFileOutputStream(backupFile.getAbsolutePath());
- byte[] buffer = new byte[512];
- int length;
-
- while ((length = in.read(buffer)) != -1) {
- out.write(buffer, 0, length);
- }
-
- out.close();
- }
-
- rcml.checkOutIn(RCML.ci, identity, time, backup);
- rcml.pruneEntries(backupDir);
- rcml.write();
-
- // FIXME: If we reuse the observer pattern as implemented in
- // xps this would be the place to notify the observers,
- // e.g. like so:
- // StatusChangeSignalHandler.emitSignal("file:" + originalFile.getAbsolutePath(),
- // "reservedCheckIn");
- return time;
- }
-*/
-
- /**
- * @deprecated please use reservedCheckIn(Document, String, boolean)
- * Try to make a reserved check in of the file destination for a user with identity. A backup
- * copy can be made.
- *
- * @param destination The file we want to check in
- * @param identity The identity of the user
- * @param backup if true, a backup will be created, else no backup will be made.
- *
- * @return long The time.
- *
- * @exception FileReservedCheckInException if the document couldn't be checked in (for instance
- * because it is already checked out by someone other ...)
- * @exception Exception if other problems occur
- */
- public long reservedCheckIn(String destination, String identity, boolean backup)
- throws FileReservedCheckInException, Exception {
- RCML rcml = new RCML(rcmlDir, destination, rootDir);
-
- CheckOutEntry coe = rcml.getLatestCheckOutEntry();
- CheckInEntry cie = rcml.getLatestCheckInEntry();
-
- // If there has never been a checkout for this object
- // *or* if the user attempting the checkin right now
- // is the system itself, we will skip any checks and proceed
- // right away to the actual checkin.
- // In all other cases we enforce the revision control
- // rules inside this if clause:
- //
- if (!((coe == null) || identity.equals(RevisionController.systemUsername))) {
- /*
- * Possible cases and rules:
- *
- * 1.) we were able to read the latest checkin and it is later than latest checkout
- * (i.e. there is no open checkout to match this checkin, an unusual case)
- * 1.1.) identity of latest checkin is equal to current user
- * -> checkin allowed, same user may check in repeatedly
- * 1.2.) identity of latest checkin is not equal to current user
- * -> checkin rejected, may not overwrite the revision which
- * another user checked in previously
- * 2.) there was no checkin or the latest checkout is later than latest checkin
- * (i.e. there is an open checkout)
- * 2.1.) identity of latest checkout is equal to current user
- * -> checkin allowed, user checked out and may check in again
- * (the most common case)
- * 2.2.) identity of latest checkout is not equal to current user
- * -> checkin rejected, may not check in while another
- * user is working on this document
- *
- */
- if ((cie != null) && (cie.getTime() > coe.getTime())) {
- // We have case 1
- if (!cie.getIdentity().equals(identity)) {
- // Case 1.2., abort...
- //
- throw new FileReservedCheckInException(rootDir + destination, rcml);
- }
- } else {
- // Case 2
- if (!coe.getIdentity().equals(identity)) {
- // Case 2.2., abort...
- //
- throw new FileReservedCheckInException(rootDir + destination, rcml);
- }
- }
- }
-
- File originalFile = new File(rootDir, destination);
- long time = new Date().getTime();
-
- if (backup && originalFile.isFile()) {
- File backupFile = new File(backupDir, destination + ".bak." + time);
- File parent = new File(backupFile.getParent());
-
- if (!parent.isDirectory()) {
- parent.mkdirs();
- }
-
- log.info(
- "Backup: copy "
- + originalFile.getAbsolutePath()
- + " to "
- + backupFile.getAbsolutePath());
-
- InputStream in = new FileInputStream(originalFile.getAbsolutePath());
-
- OutputStream out = new XPSFileOutputStream(backupFile.getAbsolutePath());
- byte[] buffer = new byte[512];
- int length;
-
- while ((length = in.read(buffer)) != -1) {
- out.write(buffer, 0, length);
- }
-
- out.close();
- }
-
- rcml.checkOutIn(RCML.ci, identity, time, backup);
- rcml.pruneEntries(backupDir);
- rcml.write();
-
- // FIXME: If we reuse the observer pattern as implemented in
- // xps this would be the place to notify the observers,
- // e.g. like so:
- // StatusChangeSignalHandler.emitSignal("file:" + originalFile.getAbsolutePath(),
- // "reservedCheckIn");
- return time;
- }
-
- /**
- * Get the absolute path of a backup version
- *
- * @param time The time of the backup
- * @param filename The path of the file from the {publication}
- *
- * @return String The absolute path of the backup version
- */
- public String getBackupFilename(long time, String filename) {
- File backup = new File(backupDir, filename + ".bak." + time);
-
- return backup.getAbsolutePath();
- }
-
- /**
- * Get the file of a backup version
- *
- * @param time The time of the backup
- * @param filename The path of the file from the {publication}
- *
- * @return File The file of the backup version
- */
-/*
- public File getBackupFile(long time, Document doc) {
- File backup = new File(backupDir, doc.getDocumentAreaPath() + ".bak." + time);
- return backup;
- }
-*/
-
- /**
- * @deprecated getBackupFile(long, Document)
- * Get the file of a backup version
- *
- * @param time The time of the backup
- * @param filename The path of the file from the {publication}
- *
- * @return File The file of the backup version
- */
- public File getBackupFile(long time, String filename) {
- File backup = new File(backupDir, filename + ".bak." + time);
-
- return backup;
- }
-
- /**
- * Rolls back to the given point in time.
- *
- * @param destination File which will be rolled back
- * @param identity The identity of the user
- * @param backupFlag If true, a backup of the current version will be made before the rollback
- * @param time The time point of the desired version
- *
- * @return long The time of the version to roll back to.
- *
- * @exception FileReservedCheckInException if the current version couldn't be checked in again
- * @exception FileReservedCheckOutException if the current version couldn't be checked out
- * @exception FileNotFoundException if a file couldn't be found
- * @exception Exception if another problem occurs
- */
-/*
- public long rollback(Document doc, String identity, boolean backupFlag, long time)
- throws
- FileReservedCheckInException,
- FileReservedCheckOutException,
- FileNotFoundException,
- Exception {
-
- // Make sure the old version exists
- //
- File backup = new File(backupDir, doc.getDocumentAreaPath() + ".bak." + time);
- File current = doc.getFile();
-
- if (!backup.isFile()) {
- throw new FileNotFoundException(backup.getAbsolutePath());
- }
-
- if (!current.isFile()) {
- throw new FileNotFoundException(current.getAbsolutePath());
- }
-
- // Try to check out current version
- //
- reservedCheckOut(doc, identity);
-
- // Now roll back to the old state
- //
- FileInputStream in = new FileInputStream(backup.getAbsolutePath());
-
- XPSFileOutputStream out = new XPSFileOutputStream(current.getAbsolutePath());
- byte[] buffer = new byte[512];
- int length;
-
- while ((length = in.read(buffer)) != -1) {
+ }
+ }
+ File originalFile = new File(rootDir, destination);
+ long time = new Date().getTime();
+ if(backup && originalFile.isFile()){
+ File backupFile = new File(backupDir, destination + ".bak." + time);
+ File parent = new File(backupFile.getParent());
+ if(!parent.isDirectory()){
+ parent.mkdirs();
+ }
+ log.info("Backup: copy " + originalFile.getAbsolutePath() + " to " + backupFile.getAbsolutePath());
+ InputStream in = new FileInputStream(originalFile.getAbsolutePath());
+ OutputStream out = new XPSFileOutputStream(backupFile.getAbsolutePath());
+ byte[] buffer = new byte[512];
+ int length;
+ while((length = in.read(buffer)) != -1){
out.write(buffer, 0, length);
- }
-
- out.close();
-
- // Try to check back in, this might cause
- // a backup of the current version to be created if
- // desired by the user.
- //
- long newtime = reservedCheckIn(doc, identity, backupFlag);
-
- return newtime;
- }
-*/
-
- /**
- * @deprecated please use rollback(Document, String, boolean, long)
- * Rolls back to the given point in time.
- *
- * @param destination File which will be rolled back
- * @param identity The identity of the user
- * @param backupFlag If true, a backup of the current version will be made before the rollback
- * @param time The time point of the desired version
- *
- * @return long The time of the version to roll back to.
- *
- * @exception FileReservedCheckInException if the current version couldn't be checked in again
- * @exception FileReservedCheckOutException if the current version couldn't be checked out
- * @exception FileNotFoundException if a file couldn't be found
- * @exception Exception if another problem occurs
- */
- public long rollback(String destination, String identity, boolean backupFlag, long time)
- throws
- FileReservedCheckInException,
- FileReservedCheckOutException,
- FileNotFoundException,
- Exception {
- // Make sure the old version exists
- //
- File backup = new File(backupDir, destination + ".bak." + time);
- File current = new File(rootDir, destination);
-
- if (!backup.isFile()) {
- throw new FileNotFoundException(backup.getAbsolutePath());
- }
-
- if (!current.isFile()) {
- throw new FileNotFoundException(current.getAbsolutePath());
- }
-
- // Try to check out current version
- //
- reservedCheckOut(destination, identity);
-
- // Now roll back to the old state
- //
- FileInputStream in = new FileInputStream(backup.getAbsolutePath());
-
- XPSFileOutputStream out = new XPSFileOutputStream(current.getAbsolutePath());
- byte[] buffer = new byte[512];
- int length;
-
- while ((length = in.read(buffer)) != -1) {
- out.write(buffer, 0, length);
- }
-
- out.close();
-
- // Try to check back in, this might cause
- // a backup of the current version to be created if
- // desired by the user.
- //
- long newtime = reservedCheckIn(destination, identity, backupFlag);
-
- return newtime;
- }
-
- /**
- * Delete the check in and roll back the file to the backup at time
- *
- * @param time The time point of the back version we want to retrieve
- * @param destination The File for which we want undo the check in
- *
- * @exception Exception FileNotFoundException if the back version or the current version
- * couldn't be found
- */
- public void undoCheckIn(long time, String destination) throws Exception {
- File backup = new File(backupDir + "/" + destination + ".bak." + time);
- File current = new File(rootDir + destination);
-
- RCML rcml = new RCML(rcmlDir, destination, rootDir);
-
- if (!backup.isFile()) {
- throw new FileNotFoundException(backup.getAbsolutePath());
- }
-
- if (!current.isFile()) {
- throw new FileNotFoundException(current.getAbsolutePath());
- }
-
- FileInputStream in = new FileInputStream(backup.getAbsolutePath());
-
- XPSFileOutputStream out = new XPSFileOutputStream(current.getAbsolutePath());
- byte[] buffer = new byte[512];
- int length;
-
- while ((length = in.read(buffer)) != -1) {
- out.write(buffer, 0, length);
- }
-
- log.info("Undo: copy " + backup.getAbsolutePath() + " " + current.getAbsolutePath());
-
- rcml.deleteFirstCheckIn();
- out.close();
- }
-
- /**
- * delete the revisions
- * @param filename of the document
- * @throws RevisionControlException when somthing went wrong
- */
-/*
- public void deleteRevisions(Document doc) throws RevisionControlException{
- try {
- RCML rcml = this.getRCML(doc);
- String[] times = rcml.getBackupsTime();
- for (int i=0; i < times.length; i++) {
- long time = new Long(times[i]).longValue();
- File backup = this.getBackupFile(time, doc);
- File parentDirectory = null;
- parentDirectory = backup.getParentFile();
- boolean deleted = backup.delete();
- if (!deleted) {
- throw new RevisionControlException("The backup file, "+backup.getCanonicalPath()+" could not be deleted!");
- }
- if (parentDirectory != null
- && parentDirectory.exists()
- && parentDirectory.isDirectory()
- && parentDirectory.listFiles().length == 0) {
- parentDirectory.delete();
- }
- }
- } catch (Exception e) {
- throw new RevisionControlException(e);
- }
- }
-*/
-
- /**
- * @deprecated please use deleteRevisions(Document)
- * delete the revisions
- * @param filename of the document
- * @throws RevisionControlException when somthing went wrong
- */
- public void deleteRevisions(String filename) throws RevisionControlException{
- try {
- RCML rcml = this.getRCML(filename);
- String[] times = rcml.getBackupsTime();
- for (int i=0; i < times.length; i++) {
- long time = new Long(times[i]).longValue();
- File backup = this.getBackupFile(time, filename);
- File parentDirectory = null;
- parentDirectory = backup.getParentFile();
- boolean deleted = backup.delete();
- if (!deleted) {
- throw new RevisionControlException("The backup file, "+backup.getCanonicalPath()+" could not be deleted!");
- }
- if (parentDirectory != null
- && parentDirectory.exists()
- && parentDirectory.isDirectory()
- && parentDirectory.listFiles().length == 0) {
- parentDirectory.delete();
- }
- }
- } catch (Exception e) {
- throw new RevisionControlException(e);
- }
- }
-
- /**
- * delete the rcml file
- * @param filename of the document
- * @throws RevisionControlException if something went wrong
- */
-/*
- public void deleteRCML(Document doc) throws RevisionControlException{
- try {
- RCML rcml = this.getRCML(doc);
- boolean deleted = rcml.delete();
- if (!deleted) {
- throw new RevisionControlException("The rcml file could not be deleted!");
+ }
+ out.close();
+ }
+ rcml.checkOutIn(RCML.ci, identity, time, backup);
+ rcml.pruneEntries(backupDir);
+ rcml.write();
+ // FIXME: If we reuse the observer pattern as implemented in
+ // xps this would be the place to notify the observers,
+ // e.g. like so:
+ // StatusChangeSignalHandler.emitSignal("file:" + originalFile.getAbsolutePath(),
+ // "reservedCheckIn");
+ return time;
+ }
+ /**
+ * Get the absolute path of a backup version
+ *
+ * @param time
+ * The time of the backup
+ * @param filename
+ * The path of the file from the {publication}
+ *
+ * @return String The absolute path of the backup version
+ */
+ public String getBackupFilename(long time, String filename) {
+ File backup = new File(backupDir, filename + ".bak." + time);
+ return backup.getAbsolutePath();
+ }
+ /**
+ * Get the file of a backup version
+ *
+ * @param time
+ * The time of the backup
+ * @param filename
+ * The path of the file from the {publication}
+ *
+ * @return File The file of the backup version
+ */
+ /*
+ * public File getBackupFile(long time, Document doc) { File backup = new File(backupDir, doc.getDocumentAreaPath() + ".bak." + time); return backup; }
+ */
+ /**
+ * @deprecated getBackupFile(long, Document) Get the file of a backup version
+ *
+ * @param time
+ * The time of the backup
+ * @param filename
+ * The path of the file from the {publication}
+ *
+ * @return File The file of the backup version
+ */
+ public File getBackupFile(long time, String filename) {
+ File backup = new File(backupDir, filename + ".bak." + time);
+ return backup;
+ }
+ /**
+ * Rolls back to the given point in time.
+ *
+ * @param destination
+ * File which will be rolled back
+ * @param identity
+ * The identity of the user
+ * @param backupFlag
+ * If true, a backup of the current version will be made before the rollback
+ * @param time
+ * The time point of the desired version
+ *
+ * @return long The time of the version to roll back to.
+ *
+ * @exception FileReservedCheckInException
+ * if the current version couldn't be checked in again
+ * @exception FileReservedCheckOutException
+ * if the current version couldn't be checked out
+ * @exception FileNotFoundException
+ * if a file couldn't be found
+ * @exception Exception
+ * if another problem occurs
+ */
+ /*
+ * public long rollback(Document doc, String identity, boolean backupFlag, long time) throws FileReservedCheckInException, FileReservedCheckOutException, FileNotFoundException, Exception {
+ * // Make sure the old version exists // File backup = new File(backupDir, doc.getDocumentAreaPath() + ".bak." + time); File current = doc.getFile();
+ *
+ * if (!backup.isFile()) { throw new FileNotFoundException(backup.getAbsolutePath()); }
+ *
+ * if (!current.isFile()) { throw new FileNotFoundException(current.getAbsolutePath()); }
+ * // Try to check out current version // reservedCheckOut(doc, identity);
+ * // Now roll back to the old state // FileInputStream in = new FileInputStream(backup.getAbsolutePath());
+ *
+ * XPSFileOutputStream out = new XPSFileOutputStream(current.getAbsolutePath()); byte[] buffer = new byte[512]; int length;
+ *
+ * while ((length = in.read(buffer)) != -1) { out.write(buffer, 0, length); }
+ *
+ * out.close();
+ * // Try to check back in, this might cause // a backup of the current version to be created if // desired by the user. // long newtime = reservedCheckIn(doc, identity, backupFlag);
+ *
+ * return newtime; }
+ */
+ /**
+ * @deprecated please use rollback(Document, String, boolean, long) Rolls back to the given point in time.
+ *
+ * @param destination
+ * File which will be rolled back
+ * @param identity
+ * The identity of the user
+ * @param backupFlag
+ * If true, a backup of the current version will be made before the rollback
+ * @param time
+ * The time point of the desired version
+ *
+ * @return long The time of the version to roll back to.
+ *
+ * @exception FileReservedCheckInException
+ * if the current version couldn't be checked in again
+ * @exception FileReservedCheckOutException
+ * if the current version couldn't be checked out
+ * @exception FileNotFoundException
+ * if a file couldn't be found
+ * @exception Exception
+ * if another problem occurs
+ */
+ public long rollback(String destination, String identity, boolean backupFlag, long time) throws FileReservedCheckInException, FileReservedCheckOutException, FileNotFoundException, Exception {
+ // Make sure the old version exists
+ //
+ File backup = new File(backupDir, destination + ".bak." + time);
+ File current = new File(rootDir, destination);
+ if(!backup.isFile()){
+ throw new FileNotFoundException(backup.getAbsolutePath());
+ }
+ if(!current.isFile()){
+ throw new FileNotFoundException(current.getAbsolutePath());
+ }
+ // Try to check out current version
+ //
+ reservedCheckOut(destination, identity);
+ // Now roll back to the old state
+ //
+ FileInputStream in = new FileInputStream(backup.getAbsolutePath());
+ XPSFileOutputStream out = new XPSFileOutputStream(current.getAbsolutePath());
+ byte[] buffer = new byte[512];
+ int length;
+ while((length = in.read(buffer)) != -1){
+ out.write(buffer, 0, length);
+ }
+ out.close();
+ // Try to check back in, this might cause
+ // a backup of the current version to be created if
+ // desired by the user.
+ //
+ long newtime = reservedCheckIn(destination, identity, backupFlag);
+ return newtime;
+ }
+ /**
+ * Delete the check in and roll back the file to the backup at time
+ *
+ * @param time
+ * The time point of the back version we want to retrieve
+ * @param destination
+ * The File for which we want undo the check in
+ *
+ * @exception Exception
+ * FileNotFoundException if the back version or the current version couldn't be found
+ */
+ public void undoCheckIn(long time, String destination) throws Exception {
+ File backup = new File(backupDir + "/" + destination + ".bak." + time);
+ File current = new File(rootDir + destination);
+ RCML rcml = new RCML(rcmlDir, destination, rootDir);
+ if(!backup.isFile()){
+ throw new FileNotFoundException(backup.getAbsolutePath());
+ }
+ if(!current.isFile()){
+ throw new FileNotFoundException(current.getAbsolutePath());
+ }
+ FileInputStream in = new FileInputStream(backup.getAbsolutePath());
+ XPSFileOutputStream out = new XPSFileOutputStream(current.getAbsolutePath());
+ byte[] buffer = new byte[512];
+ int length;
+ while((length = in.read(buffer)) != -1){
+ out.write(buffer, 0, length);
+ }
+ log.info("Undo: copy " + backup.getAbsolutePath() + " " + current.getAbsolutePath());
+ rcml.deleteFirstCheckIn();
+ out.close();
+ }
+ /**
+ * delete the revisions
+ *
+ * @param filename
+ * of the document
+ * @throws RevisionControlException
+ * when somthing went wrong
+ */
+ /*
+ * public void deleteRevisions(Document doc) throws RevisionControlException{ try { RCML rcml = this.getRCML(doc); String[] times = rcml.getBackupsTime(); for (int i=0; i < times.length; i++) { long time = new Long(times[i]).longValue(); File backup = this.getBackupFile(time, doc); File parentDirectory = null; parentDirectory = backup.getParentFile(); boolean deleted = backup.delete(); if (!deleted) { throw new RevisionControlException("The backup file, "+backup.getCanonicalPath()+" could not be deleted!"); } if (parentDirectory != null && parentDirectory.exists() && parentDirectory.isDirectory() && parentDirectory.listFiles().length == 0) { parentDirectory.delete(); } } } catch (Exception e) { throw new RevisionControlException(e); } }
+ */
+ /**
+ * @deprecated please use deleteRevisions(Document) delete the revisions
+ * @param filename
+ * of the document
+ * @throws RevisionControlException
+ * when somthing went wrong
+ */
+ public void deleteRevisions(String filename) throws RevisionControlException {
+ try{
+ RCML rcml = this.getRCML(filename);
+ String[] times = rcml.getBackupsTime();
+ for(int i = 0; i < times.length; i++){
+ long time = new Long(times[i]).longValue();
+ File backup = this.getBackupFile(time, filename);
+ File parentDirectory = null;
+ parentDirectory = backup.getParentFile();
+ boolean deleted = backup.delete();
+ if(!deleted){
+ throw new RevisionControlException("The backup file, " + backup.getCanonicalPath() + " could not be deleted!");
}
- } catch (Exception e) {
- throw new RevisionControlException(e);
- }
- }
-*/
-
- /**
- * @deprecated please use deleteRCML(Document)
- * delete the rcml file
- * @param filename of the document
- * @throws RevisionControlException if something went wrong
- */
- public void deleteRCML(String filename) throws RevisionControlException{
- try {
- RCML rcml = this.getRCML(filename);
- boolean deleted = rcml.delete();
- if (!deleted) {
- throw new RevisionControlException("The rcml file could not be deleted!");
+ if(parentDirectory != null && parentDirectory.exists() && parentDirectory.isDirectory() && parentDirectory.listFiles().length == 0){
+ parentDirectory.delete();
}
- } catch (Exception e) {
- throw new RevisionControlException(e);
- }
- }
-
+ }
+ }catch(Exception e){
+ throw new RevisionControlException(e);
+ }
+ }
+ /**
+ * delete the rcml file
+ *
+ * @param filename
+ * of the document
+ * @throws RevisionControlException
+ * if something went wrong
+ */
+ /*
+ * public void deleteRCML(Document doc) throws RevisionControlException{ try { RCML rcml = this.getRCML(doc); boolean deleted = rcml.delete(); if (!deleted) { throw new RevisionControlException("The rcml file could not be deleted!"); } } catch (Exception e) { throw new RevisionControlException(e); } }
+ */
+ /**
+ * @deprecated please use deleteRCML(Document) delete the rcml file
+ * @param filename
+ * of the document
+ * @throws RevisionControlException
+ * if something went wrong
+ */
+ public void deleteRCML(String filename) throws RevisionControlException {
+ try{
+ RCML rcml = this.getRCML(filename);
+ boolean deleted = rcml.delete();
+ if(!deleted){
+ throw new RevisionControlException("The rcml file could not be deleted!");
+ }
+ }catch(Exception e){
+ throw new RevisionControlException(e);
+ }
+ }
}
Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/scheduler/AbstractSchedulerListener.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/scheduler/AbstractSchedulerListener.java?rev=617035&r1=617034&r2=617035&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/scheduler/AbstractSchedulerListener.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/scheduler/AbstractSchedulerListener.java Wed Jan 30 23:44:03 2008
@@ -14,96 +14,80 @@
* limitations under the License.
*
*/
-
/* $Id$ */
-
package org.apache.lenya.cms.scheduler;
-
-import org.apache.log4j.Category;
+import org.apache.log4j.Logger;
import org.quartz.SchedulerException;
import org.quartz.SchedulerListener;
import org.quartz.Trigger;
-
public class AbstractSchedulerListener implements SchedulerListener {
-
- private static final Category log = Category.getInstance(AbstractSchedulerListener.class);
-
- /**
- * @see org.quartz.SchedulerListener#jobScheduled(org.quartz.Trigger)
- */
- public void jobScheduled(Trigger trigger) {
- log.debug("Job scheduled");
- log.debug(" Trigger: [" + trigger + "]");
- }
-
- /**
- * @see org.quartz.SchedulerListener#jobUnscheduled(java.lang.String, java.lang.String)
- */
- public void jobUnscheduled(String name, String group) {
- log.debug("Job unscheduled.");
- log.debug(" Trigger name: [" + name + "]");
- log.debug(" Trigger group: [" + group + "]");
- }
-
- /**
- * @see org.quartz.SchedulerListener#triggerFinalized(org.quartz.Trigger)
- */
- public void triggerFinalized(Trigger trigger) {
- log.debug("Trigger finalized.");
- log.debug(" Trigger: [" + trigger + "]");
- }
-
- /**
- * @see org.quartz.SchedulerListener#triggersPaused(java.lang.String, java.lang.String)
- */
- public void triggersPaused(String name, String group) {
- log.debug("Triggers paused.");
- log.debug(" Trigger name: [" + name + "]");
- log.debug(" Trigger group: [" + group + "]");
- }
-
- /**
- * @see org.quartz.SchedulerListener#triggersResumed(java.lang.String, java.lang.String)
- */
- public void triggersResumed(String name, String group) {
- log.debug("Triggers resumed.");
- log.debug(" Trigger name: [" + name + "]");
- log.debug(" Trigger group: [" + group + "]");
- }
-
- /**
- * @see org.quartz.SchedulerListener#jobsPaused(java.lang.String, java.lang.String)
- */
- public void jobsPaused(String name, String group) {
- log.debug("Jobs paused.");
- log.debug(" Job name: [" + name + "]");
- log.debug(" Job group: [" + group + "]");
- }
-
- /**
- * @see org.quartz.SchedulerListener#jobsResumed(java.lang.String, java.lang.String)
- */
- public void jobsResumed(String name, String group) {
- log.debug("Jobs resumed.");
- log.debug(" Job name: [" + name + "]");
- log.debug(" Job group: [" + group + "]");
- }
-
- /**
- * @see org.quartz.SchedulerListener#schedulerError(java.lang.String,
- * org.quartz.SchedulerException)
- */
- public void schedulerError(String message, SchedulerException exception) {
- log.debug("Scheduler exception occured.");
- log.debug(" Message: [" + message + "]");
- log.debug(exception);
- }
-
- /**
- * @see org.quartz.SchedulerListener#schedulerShutdown()
- */
- public void schedulerShutdown() {
- log.debug("Scheduler shut down.");
- }
-
+ private static Logger log = Logger.getLogger(AbstractSchedulerListener.class);
+ /**
+ * @see org.quartz.SchedulerListener#jobScheduled(org.quartz.Trigger)
+ */
+ public void jobScheduled(Trigger trigger) {
+ log.debug("Job scheduled");
+ log.debug(" Trigger: [" + trigger + "]");
+ }
+ /**
+ * @see org.quartz.SchedulerListener#jobUnscheduled(java.lang.String, java.lang.String)
+ */
+ public void jobUnscheduled(String name, String group) {
+ log.debug("Job unscheduled.");
+ log.debug(" Trigger name: [" + name + "]");
+ log.debug(" Trigger group: [" + group + "]");
+ }
+ /**
+ * @see org.quartz.SchedulerListener#triggerFinalized(org.quartz.Trigger)
+ */
+ public void triggerFinalized(Trigger trigger) {
+ log.debug("Trigger finalized.");
+ log.debug(" Trigger: [" + trigger + "]");
+ }
+ /**
+ * @see org.quartz.SchedulerListener#triggersPaused(java.lang.String, java.lang.String)
+ */
+ public void triggersPaused(String name, String group) {
+ log.debug("Triggers paused.");
+ log.debug(" Trigger name: [" + name + "]");
+ log.debug(" Trigger group: [" + group + "]");
+ }
+ /**
+ * @see org.quartz.SchedulerListener#triggersResumed(java.lang.String, java.lang.String)
+ */
+ public void triggersResumed(String name, String group) {
+ log.debug("Triggers resumed.");
+ log.debug(" Trigger name: [" + name + "]");
+ log.debug(" Trigger group: [" + group + "]");
+ }
+ /**
+ * @see org.quartz.SchedulerListener#jobsPaused(java.lang.String, java.lang.String)
+ */
+ public void jobsPaused(String name, String group) {
+ log.debug("Jobs paused.");
+ log.debug(" Job name: [" + name + "]");
+ log.debug(" Job group: [" + group + "]");
+ }
+ /**
+ * @see org.quartz.SchedulerListener#jobsResumed(java.lang.String, java.lang.String)
+ */
+ public void jobsResumed(String name, String group) {
+ log.debug("Jobs resumed.");
+ log.debug(" Job name: [" + name + "]");
+ log.debug(" Job group: [" + group + "]");
+ }
+ /**
+ * @see org.quartz.SchedulerListener#schedulerError(java.lang.String, org.quartz.SchedulerException)
+ */
+ public void schedulerError(String message, SchedulerException exception) {
+ log.debug("Scheduler exception occured.");
+ log.debug(" Message: [" + message + "]");
+ log.debug(exception);
+ }
+ /**
+ * @see org.quartz.SchedulerListener#schedulerShutdown()
+ */
+ public void schedulerShutdown() {
+ log.debug("Scheduler shut down.");
+ }
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.