You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2005/04/01 17:51:02 UTC
svn commit: r159699 - in lenya/trunk/src:
java/org/apache/lenya/cms/publication/ java/org/apache/lenya/cms/rc/
java/org/apache/lenya/cms/site/tree/ java/org/apache/lenya/cms/usecase/
java/org/apache/lenya/transaction/
webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/
Author: andreas
Date: Fri Apr 1 07:51:00 2005
New Revision: 159699
URL: http://svn.apache.org/viewcvs?view=rev&rev=159699
Log:
resolve latest RC versions correctly
Modified:
lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java
lenya/trunk/src/java/org/apache/lenya/cms/rc/RCML.java
lenya/trunk/src/java/org/apache/lenya/cms/site/tree/DefaultSiteTree.java
lenya/trunk/src/java/org/apache/lenya/cms/usecase/AbstractUsecase.java
lenya/trunk/src/java/org/apache/lenya/transaction/UnitOfWorkImpl.java
lenya/trunk/src/webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/Deactivate.java
lenya/trunk/src/webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java
Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java?view=diff&r1=159698&r2=159699
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java Fri Apr 1 07:51:00 2005
@@ -587,11 +587,14 @@
checkin(true);
}
+ private boolean isCheckedOut = false;
+
protected void checkin(boolean backup) throws TransactionException {
try {
String userName = getUserId();
boolean newVersion = getIdentityMap().getUnitOfWork().isDirty(this);
getRevisionController().reservedCheckIn(getRCPath(), userName, backup, newVersion);
+ this.isCheckedOut = false;
} catch (Exception e) {
throw new TransactionException(e);
}
@@ -616,6 +619,7 @@
try {
String userName = getUserId();
getRevisionController().reservedCheckOut(getRCPath(), userName);
+ this.isCheckedOut = true;
} catch (Exception e) {
throw new TransactionException(e);
}
@@ -625,12 +629,7 @@
* @see org.apache.lenya.transaction.Transactionable#isCheckedOut()
*/
public boolean isCheckedOut() throws TransactionException {
- try {
- String userName = getUserId();
- return !getRevisionController().canCheckOut(getRCPath(), userName);
- } catch (Exception e) {
- throw new TransactionException(e);
- }
+ return this.isCheckedOut;
}
/**
@@ -735,8 +734,7 @@
*/
public int getVersion() throws TransactionException {
try {
- String fileName = getRCPath();
- return getRevisionController().getLatestVersion(fileName);
+ return getRevisionController().getLatestVersion(getRCPath());
} catch (Exception e) {
throw new TransactionException(e);
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/rc/RCML.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/rc/RCML.java?view=diff&r1=159698&r2=159699
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/rc/RCML.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/rc/RCML.java Fri Apr 1 07:51:00 2005
@@ -256,7 +256,7 @@
"/XPSRevisionControl/CheckIn[1]/Identity/text()");
Node time = XPathAPI.selectSingleNode(parent, "/XPSRevisionControl/CheckIn[1]/Time/text()");
Node versionNode = XPathAPI.selectSingleNode(parent,
- "/XPSRevisionControl/CheckOut[1]/Version/text()");
+ "/XPSRevisionControl/CheckIn[1]/Version/text()");
if (identity == null && time == null) {
// No checkout at all
Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/tree/DefaultSiteTree.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/tree/DefaultSiteTree.java?view=diff&r1=159698&r2=159699
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/tree/DefaultSiteTree.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/tree/DefaultSiteTree.java Fri Apr 1 07:51:00 2005
@@ -571,6 +571,7 @@
String userName = getUserID();
boolean newVersion = this.identityMap.getUnitOfWork().isDirty(this);
getRevisionController().reservedCheckIn(getRCPath(), userName, backup, newVersion);
+ isCheckedOut = false;
} catch (Exception e) {
throw new TransactionException(e);
}
@@ -597,6 +598,7 @@
try {
String userName = getUserID();
getRevisionController().reservedCheckOut(getRCPath(), userName);
+ isCheckedOut = true;
} catch (Exception e) {
throw new TransactionException(e);
}
@@ -605,17 +607,14 @@
protected String getRCPath() {
return this.area + "/" + SITE_TREE_FILENAME;
}
+
+ private boolean isCheckedOut = false;
/**
* @see org.apache.lenya.transaction.Transactionable#isCheckedOut()
*/
public boolean isCheckedOut() throws TransactionException {
- try {
- String userName = getUserID();
- return !getRevisionController().canCheckOut(getRCPath(), userName);
- } catch (Exception e) {
- throw new TransactionException(e);
- }
+ return isCheckedOut;
}
private Lock lock;
@@ -694,8 +693,7 @@
*/
public int getVersion() throws TransactionException {
try {
- String fileName = this.treefile.getCanonicalPath();
- return getRevisionController().getLatestVersion(fileName);
+ return getRevisionController().getLatestVersion(getRCPath());
} catch (Exception e) {
throw new TransactionException(e);
}
Modified: lenya/trunk/src/java/org/apache/lenya/cms/usecase/AbstractUsecase.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/usecase/AbstractUsecase.java?view=diff&r1=159698&r2=159699
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/usecase/AbstractUsecase.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/usecase/AbstractUsecase.java Fri Apr 1 07:51:00 2005
@@ -37,6 +37,7 @@
import org.apache.lenya.ac.Identity;
import org.apache.lenya.cms.publication.DocumentIdentityMap;
import org.apache.lenya.transaction.AbstractOperation;
+import org.apache.lenya.transaction.LockException;
/**
* Abstract usecase implementation.
@@ -207,6 +208,8 @@
getUnitOfWork().commit();
}
+ } catch (LockException e) {
+ addErrorMessage("The operation could not be completed because an involved object was changed by another user.");
} catch (Exception e) {
getLogger().error(e.getMessage(), e);
addErrorMessage(e.getMessage() + " - Please consult the logfiles.");
Modified: lenya/trunk/src/java/org/apache/lenya/transaction/UnitOfWorkImpl.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/transaction/UnitOfWorkImpl.java?view=diff&r1=159698&r2=159699
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/transaction/UnitOfWorkImpl.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/transaction/UnitOfWorkImpl.java Fri Apr 1 07:51:00 2005
@@ -111,6 +111,7 @@
throw new LockException("Cannot commit transaction: The object [" + t
+ "] was modified after it has been locked.");
}
+ t.checkout();
}
for (Iterator i = this.newObjects.iterator(); i.hasNext();) {
Modified: lenya/trunk/src/webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/Deactivate.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/Deactivate.java?view=diff&r1=159698&r2=159699
==============================================================================
--- lenya/trunk/src/webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/Deactivate.java (original)
+++ lenya/trunk/src/webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/Deactivate.java Fri Apr 1 07:51:00 2005
@@ -19,6 +19,7 @@
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceSelector;
import org.apache.lenya.cms.publication.Document;
+import org.apache.lenya.cms.publication.DocumentBuildException;
import org.apache.lenya.cms.publication.DocumentManager;
import org.apache.lenya.cms.publication.Publication;
import org.apache.lenya.cms.publication.PublicationException;
@@ -44,6 +45,7 @@
*/
protected void doCheckPreconditions() throws Exception {
super.doCheckPreconditions();
+
if (getErrorMessages().isEmpty()) {
if (!getSourceDocument().getArea().equals(Publication.AUTHORING_AREA)) {
@@ -68,6 +70,14 @@
}
}
+ // get involved objects to lock them
+ Document doc = getSourceDocument();
+ try {
+ Document liveVersion = doc.getIdentityMap().getAreaVersion(doc, Publication.LIVE_AREA);
+ getInvolvedDocuments(liveVersion);
+ } catch (DocumentBuildException e) {
+ throw new RuntimeException(e);
+ }
}
}
@@ -138,6 +148,20 @@
getLogger().debug("Subtree deactivation: [" + isSubtreeEnabled() + "]");
}
+ DocumentSet set = getInvolvedDocuments(document);
+ try {
+ set.visit(this);
+ } catch (PublicationException e) {
+ throw new RuntimeException(e);
+ }
+
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Publishing completed.");
+ }
+ }
+
+ protected DocumentSet getInvolvedDocuments(Document document) {
+ DocumentSet set;
ServiceSelector selector = null;
SiteManager siteManager = null;
try {
@@ -146,11 +170,10 @@
.getSiteManagerHint());
Document[] descendants = siteManager.getRequiringResources(document);
- DocumentSet set = new DocumentSet(descendants);
+ set = new DocumentSet(descendants);
set.add(document);
siteManager.sortAscending(set);
set.reverse();
- set.visit(this);
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
@@ -161,10 +184,7 @@
this.manager.release(selector);
}
}
-
- if (getLogger().isDebugEnabled()) {
- getLogger().debug("Publishing completed.");
- }
+ return set;
}
/**
Modified: lenya/trunk/src/webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java?view=diff&r1=159698&r2=159699
==============================================================================
--- lenya/trunk/src/webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java (original)
+++ lenya/trunk/src/webapp/lenya/pubs/default/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java Fri Apr 1 07:51:00 2005
@@ -26,6 +26,7 @@
import org.apache.avalon.framework.service.ServiceSelector;
import org.apache.lenya.cms.publication.Document;
+import org.apache.lenya.cms.publication.DocumentBuildException;
import org.apache.lenya.cms.publication.DocumentIdentityMap;
import org.apache.lenya.cms.publication.DocumentManager;
import org.apache.lenya.cms.publication.Publication;
@@ -60,6 +61,15 @@
Date now = new GregorianCalendar().getTime();
DateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
setParameter(SCHEDULE_TIME, format.format(now));
+
+ // resolve involved documents to lock them
+ Document doc = getSourceDocument();
+ try {
+ Document liveVersion = doc.getIdentityMap().getAreaVersion(doc, Publication.LIVE_AREA);
+ getInvolvedDocuments(liveVersion);
+ } catch (DocumentBuildException e) {
+ throw new RuntimeException(e);
+ }
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org