mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged BRANCHES/DEV/BELARUS/HEAD_2010_09_21 to HEAD:
22696: Restores original fixes for ETHREEOH-3850, ETHREEOH-3834 that got lost during various merges back to HEAD, fixes ALF-4675 and ALF-3043 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@22703 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -51,6 +51,7 @@ import org.alfresco.service.cmr.avmsync.AVMDifference;
|
||||
import org.alfresco.service.cmr.avmsync.AVMSyncService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.wcm.util.WCMUtil;
|
||||
import org.alfresco.web.app.AlfrescoNavigationHandler;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
@@ -371,6 +372,27 @@ public class CreateWebContentWizard extends CreateContentWizard
|
||||
}
|
||||
}
|
||||
this.getAvmSyncService().update(diffList, null, true, true, true, true, null, null);
|
||||
|
||||
for (final AVMDifference diff : diffList)
|
||||
{
|
||||
final String path = diff.getDestinationPath();
|
||||
String storeId = AVMUtil.getStoreId(path);
|
||||
String storePath = AVMUtil.getStoreRelativePath(path);
|
||||
String storeName = AVMUtil.getStoreName(path);
|
||||
|
||||
String lockOwner = getAvmLockingService().getLockOwner(storeId, storePath);
|
||||
Map<String, String> lockData = getAvmLockingService().getLockData(storeId, storePath);
|
||||
String fromStoreName = lockData.get(WCMUtil.LOCK_KEY_STORE_NAME);
|
||||
lockData.put(WCMUtil.LOCK_KEY_STORE_NAME, storeName);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("modifying lock on " + path + ". chaging store from " + fromStoreName + " to " + storeName);
|
||||
}
|
||||
|
||||
this.getAvmLockingService().modifyLock(storeId, AVMUtil.getStoreRelativePath(diff.getSourcePath()), lockOwner, storeId, AVMUtil.getStoreRelativePath(path), lockData);
|
||||
}
|
||||
|
||||
if (this.startWorkflow)
|
||||
{
|
||||
final List<AVMNodeDescriptor> submitNodes = new ArrayList<AVMNodeDescriptor>(1 + this.getUploadedFiles().size() + this.getRenditions().size());
|
||||
|
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
package org.alfresco.web.bean.wcm;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -25,6 +26,7 @@ import java.util.Set;
|
||||
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.wcm.util.WCMUtil;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.forms.Form;
|
||||
import org.alfresco.web.forms.FormInstanceData;
|
||||
@@ -82,6 +84,32 @@ public class EditWebContentWizard extends CreateWebContentWizard
|
||||
}
|
||||
this.content = this.getAvmService().getContentReader(-1, this.createdPath).getContentString();
|
||||
this.mimeType = MimetypeMap.MIMETYPE_XML;
|
||||
|
||||
// calculate which locks are present at init time
|
||||
this.existingLocks = new HashSet<String>(4);
|
||||
String lock = this.getAvmLockingService().getLockOwner(AVMUtil.getStoreId(this.createdPath),
|
||||
AVMUtil.getStoreRelativePath(this.createdPath));
|
||||
if (lock != null)
|
||||
{
|
||||
this.existingLocks.add(this.createdPath);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Lock exists for xml instance " + this.createdPath + " at initialisation");
|
||||
}
|
||||
|
||||
for (final Rendition r : this.formInstanceData.getRenditions())
|
||||
{
|
||||
String path = r.getPath();
|
||||
lock = this.getAvmLockingService().getLockOwner(AVMUtil.getStoreId(path),
|
||||
AVMUtil.getStoreRelativePath(path));
|
||||
if (lock != null)
|
||||
{
|
||||
this.existingLocks.add(path);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Lock exists for rendition " + path + " at initialisation");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -143,6 +171,21 @@ public class EditWebContentWizard extends CreateWebContentWizard
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("saving " + this.createdPath);
|
||||
|
||||
String storeId = AVMUtil.getStoreId(this.createdPath);
|
||||
String storePath = AVMUtil.getStoreRelativePath(this.createdPath);
|
||||
String storeName = AVMUtil.getStoreName(this.createdPath);
|
||||
String lockOwner = this.getAvmLockingService().getLockOwner(storeId, storePath);
|
||||
Map<String, String> lockData = this.getAvmLockingService().getLockData(storeId, storePath);
|
||||
|
||||
if (lockOwner != null)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("transferring lock from " + lockData.get(WCMUtil.LOCK_KEY_STORE_NAME) + " to " + storeName);
|
||||
|
||||
lockData.put(WCMUtil.LOCK_KEY_STORE_NAME, AVMUtil.getStoreName(this.createdPath));
|
||||
this.getAvmLockingService().modifyLock(storeId, storePath, lockOwner, storeId, storePath, lockData);
|
||||
}
|
||||
|
||||
final ContentWriter writer = this.getAvmService().getContentWriter(this.createdPath, true);
|
||||
this.content = XMLUtil.toString(this.getInstanceDataDocument(), false);
|
||||
writer.putContent(this.content);
|
||||
@@ -158,11 +201,51 @@ public class EditWebContentWizard extends CreateWebContentWizard
|
||||
Utils.addErrorMessage("error regenerating rendition using " + rr.getRenderingEngineTemplate().getName() +
|
||||
": " + rr.getException().getMessage(),
|
||||
rr.getException());
|
||||
|
||||
// if the renditions were locked before the regenerate, move the lock back to main store
|
||||
String path = rr.getPath();
|
||||
|
||||
if (rr.getLockOwner() != null)
|
||||
{
|
||||
this.existingLocks.add(path);
|
||||
}
|
||||
|
||||
if (this.existingLocks.contains(path))
|
||||
{
|
||||
String renditionStoreId = AVMUtil.getStoreId(path);
|
||||
String renditionStorePath = AVMUtil.getStoreRelativePath(path);
|
||||
String renditionStoreName = AVMUtil.getCorrespondingMainStoreName(AVMUtil.getStoreName(path));
|
||||
Map<String, String> renditionlockData = this.getAvmLockingService().getLockData(AVMUtil.getStoreId(path), AVMUtil.getStoreRelativePath(path));
|
||||
renditionlockData.put(WCMUtil.LOCK_KEY_STORE_NAME, renditionStoreName);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("transferring existing lock for " + path + " back to " + renditionStoreName);
|
||||
|
||||
this.getAvmLockingService().modifyLock(renditionStoreId, renditionStorePath, lockOwner, renditionStoreId, renditionStorePath, renditionlockData);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
final Rendition r = rr.getRendition();
|
||||
this.renditions.add(r);
|
||||
|
||||
String path = r.getPath();
|
||||
|
||||
if (rr.getLockOwner() != null)
|
||||
{
|
||||
this.existingLocks.add(path);
|
||||
}
|
||||
|
||||
String renditionStoreId = AVMUtil.getStoreId(path);
|
||||
String renditionStorePath = AVMUtil.getStoreRelativePath(path);
|
||||
String renditionStoreName = AVMUtil.getCorrespondingMainStoreName(AVMUtil.getStoreName(path));
|
||||
Map<String, String> renditionlockData = this.getAvmLockingService().getLockData(AVMUtil.getStoreId(path), AVMUtil.getStoreRelativePath(path));
|
||||
renditionlockData.put(WCMUtil.LOCK_KEY_STORE_NAME, renditionStoreName);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("transferring lock for " + path + " back to " + renditionStoreName);
|
||||
|
||||
this.getAvmLockingService().modifyLock(renditionStoreId, renditionStorePath, lockOwner, renditionStoreId, renditionStorePath, renditionlockData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user