[Yanel-commits] rev 41124 - public/yanel/contributions/resources/xinha/src/java/org/wyona/yanel/impl/resources/xinha

michi at wyona.com michi at wyona.com
Fri Jan 23 12:45:21 CET 2009


Author: michi
Date: 2009-01-23 12:45:20 +0100 (Fri, 23 Jan 2009)
New Revision: 41124

Modified:
   public/yanel/contributions/resources/xinha/src/java/org/wyona/yanel/impl/resources/xinha/XinhaResource.java
Log:
checkout added

Modified: public/yanel/contributions/resources/xinha/src/java/org/wyona/yanel/impl/resources/xinha/XinhaResource.java
===================================================================
--- public/yanel/contributions/resources/xinha/src/java/org/wyona/yanel/impl/resources/xinha/XinhaResource.java	2009-01-23 11:28:18 UTC (rev 41123)
+++ public/yanel/contributions/resources/xinha/src/java/org/wyona/yanel/impl/resources/xinha/XinhaResource.java	2009-01-23 11:45:20 UTC (rev 41124)
@@ -25,6 +25,7 @@
 import org.wyona.yanel.core.ResourceConfiguration;
 import org.wyona.yanel.core.api.attributes.CreatableV2;
 import org.wyona.yanel.core.api.attributes.ModifiableV2;
+import org.wyona.yanel.core.api.attributes.VersionableV2;
 import org.wyona.yanel.core.api.attributes.ViewableV2;
 import org.wyona.yanel.core.attributes.viewable.View;
 import org.wyona.yanel.core.map.Realm;
@@ -251,6 +252,23 @@
             Resource resToEdit = getResToEdit();
             if (ResourceAttributeHelper.hasAttributeImplemented(resToEdit, "Modifiable", "2")) {
                 try {
+
+                    if (ResourceAttributeHelper.hasAttributeImplemented(resToEdit, "Versionable", "2")) {
+                        VersionableV2 versionable = (VersionableV2)resToEdit;
+                        String userID = getEnvironment().getIdentity().getUsername();
+                        if (versionable.isCheckedOut()) {
+                            String checkoutUserID = versionable.getCheckoutUserID();
+                            if (checkoutUserID.equals(userID)) {
+                                log.warn("Resource " + resToEdit.getPath() + " is already checked out by this user: " + checkoutUserID);
+                            } else {
+                                addError("Resource is already checked out by another user: " + checkoutUserID);
+                                return null;
+                            }
+                        } else {
+                            versionable.checkout(userID);
+                        }
+                    }
+
                     InputStream is = ((ModifiableV2) resToEdit).getInputStream();
                     resourceContent = IOUtils.toString(is);
                 } catch (Exception e) {



More information about the Yanel-commits mailing list