mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged 2.1 to HEAD
8639: Fixed WCM-1138 (Need a way to remove AVM locks through the UI) 8749: Fixed AR-2177, WCM-1059, WCM-1137 and improved fix for WCM-1089, all to do with locking issues on the create and edit web content wizards. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@8773 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1185,6 +1185,9 @@ delete_rendition_confirm=Are you sure you want to remove \"{0}\", \"{1}\", and i
|
|||||||
delete_folder=Delete Folder
|
delete_folder=Delete Folder
|
||||||
delete_avm_folder_info=To remove this folder and its contents from the sandbox, click OK.
|
delete_avm_folder_info=To remove this folder and its contents from the sandbox, click OK.
|
||||||
delete_avm_folder_confirm=Are you sure you want to remove \"{0}\" and its contents from the sandbox?
|
delete_avm_folder_confirm=Are you sure you want to remove \"{0}\" and its contents from the sandbox?
|
||||||
|
unlock_file=Unlock File
|
||||||
|
unlock_file_info=To remove the lock from this file click OK.
|
||||||
|
unlock_file_confirm=Are you sure you want to remove the lock from \"{0}\"?
|
||||||
error_delete_folder=Unable to delete Folder due to system error:
|
error_delete_folder=Unable to delete Folder due to system error:
|
||||||
create_web_content=Create Web Content
|
create_web_content=Create Web Content
|
||||||
create_web_content_title=Create Web Content Wizard
|
create_web_content_title=Create Web Content Wizard
|
||||||
|
@@ -171,6 +171,10 @@
|
|||||||
<dialog name="deleteLayeredFolderBrowse" page="/jsp/dialog/delete.jsp" managed-bean="DeleteLayeredFolderBrowseDialog"
|
<dialog name="deleteLayeredFolderBrowse" page="/jsp/dialog/delete.jsp" managed-bean="DeleteLayeredFolderBrowseDialog"
|
||||||
icon="/images/icons/delete_large.gif" title-id="delete_layered_folder"
|
icon="/images/icons/delete_large.gif" title-id="delete_layered_folder"
|
||||||
description-id="delete_layered_folder_info" />
|
description-id="delete_layered_folder_info" />
|
||||||
|
|
||||||
|
<dialog name="unlockAvmFile" page="/jsp/dialog/delete.jsp" managed-bean="UnlockFileDialog"
|
||||||
|
icon="/images/icons/unlock_large.gif" title-id="unlock_file"
|
||||||
|
description-id="unlock_file_info" />
|
||||||
|
|
||||||
<dialog name="promptForWebForm" page="/jsp/wcm/prompt-for-web-form.jsp" managed-bean="PromptForWebFormDialog"
|
<dialog name="promptForWebForm" page="/jsp/wcm/prompt-for-web-form.jsp" managed-bean="PromptForWebFormDialog"
|
||||||
icon="/images/icons/details_large.gif" title-id="prompt_for_web_form"
|
icon="/images/icons/details_large.gif" title-id="prompt_for_web_form"
|
||||||
|
@@ -77,6 +77,21 @@
|
|||||||
</params>
|
</params>
|
||||||
</action>
|
</action>
|
||||||
|
|
||||||
|
<!-- Unlock AVM file -->
|
||||||
|
<action id="unlock_file">
|
||||||
|
<permissions>
|
||||||
|
<permission allow="true">Delete</permission>
|
||||||
|
</permissions>
|
||||||
|
<evaluator>org.alfresco.web.action.evaluator.WCMUnlockEvaluator</evaluator>
|
||||||
|
<label-id>unlock</label-id>
|
||||||
|
<image>/images/icons/unlock.gif</image>
|
||||||
|
<action-listener>#{AVMBrowseBean.setupContentAction}</action-listener>
|
||||||
|
<action>dialog:unlockAvmFile</action>
|
||||||
|
<params>
|
||||||
|
<param name="id">#{actionContext.id}</param>
|
||||||
|
</params>
|
||||||
|
</action>
|
||||||
|
|
||||||
<!-- Submit AVM node -->
|
<!-- Submit AVM node -->
|
||||||
<action id="submit">
|
<action id="submit">
|
||||||
<permissions>
|
<permissions>
|
||||||
@@ -329,6 +344,7 @@
|
|||||||
<action idref="cut_avm_node" />
|
<action idref="cut_avm_node" />
|
||||||
<action idref="copy_avm_node" />
|
<action idref="copy_avm_node" />
|
||||||
<action idref="file_details" />
|
<action idref="file_details" />
|
||||||
|
<action idref="unlock_file" />
|
||||||
<action idref="delete_file_browse" />
|
<action idref="delete_file_browse" />
|
||||||
</action-group>
|
</action-group>
|
||||||
|
|
||||||
|
@@ -0,0 +1,83 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
* As a special exception to the terms and conditions of version 2.0 of
|
||||||
|
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||||
|
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||||
|
* FLOSS exception. You should have recieved a copy of the text describing
|
||||||
|
* the FLOSS exception, and it is also available here:
|
||||||
|
* http://www.alfresco.com/legal/licensing"
|
||||||
|
*/
|
||||||
|
package org.alfresco.web.action.evaluator;
|
||||||
|
|
||||||
|
import javax.faces.context.FacesContext;
|
||||||
|
|
||||||
|
import org.alfresco.repo.avm.AVMNodeConverter;
|
||||||
|
import org.alfresco.service.cmr.avm.AVMService;
|
||||||
|
import org.alfresco.service.cmr.avm.locking.AVMLock;
|
||||||
|
import org.alfresco.service.cmr.avm.locking.AVMLockingService;
|
||||||
|
import org.alfresco.util.Pair;
|
||||||
|
import org.alfresco.web.app.servlet.FacesHelper;
|
||||||
|
import org.alfresco.web.bean.repository.Node;
|
||||||
|
import org.alfresco.web.bean.repository.Repository;
|
||||||
|
import org.alfresco.web.bean.wcm.AVMBrowseBean;
|
||||||
|
import org.alfresco.web.bean.wcm.AVMUtil;
|
||||||
|
import org.alfresco.web.bean.wcm.WebProject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UI Action Evaluator - return true if the node is not part of an in-progress
|
||||||
|
* WCM workflow and is locked
|
||||||
|
*
|
||||||
|
* @author Gavin Cornwell
|
||||||
|
*/
|
||||||
|
public class WCMUnlockEvaluator extends BaseActionEvaluator
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
|
||||||
|
*/
|
||||||
|
public boolean evaluate(final Node node)
|
||||||
|
{
|
||||||
|
boolean proceed = false;
|
||||||
|
|
||||||
|
FacesContext context = FacesContext.getCurrentInstance();
|
||||||
|
AVMService avmService = Repository.getServiceRegistry(context).getAVMService();
|
||||||
|
AVMLockingService avmLockingService = Repository.getServiceRegistry(context).getAVMLockingService();
|
||||||
|
AVMBrowseBean avmBrowseBean = (AVMBrowseBean)FacesHelper.getManagedBean(context, AVMBrowseBean.BEAN_NAME);
|
||||||
|
|
||||||
|
Pair<Integer, String> p = AVMNodeConverter.ToAVMVersionPath(node.getNodeRef());
|
||||||
|
String path = p.getSecond();
|
||||||
|
|
||||||
|
if (avmService.lookup(p.getFirst(), path) != null)
|
||||||
|
{
|
||||||
|
String relPath = AVMUtil.getStoreRelativePath(path);
|
||||||
|
|
||||||
|
WebProject webProject = avmBrowseBean.getWebProject();
|
||||||
|
if (webProject == null)
|
||||||
|
{
|
||||||
|
// when in a workflow context, the WebProject may not be accurate on the browsebean
|
||||||
|
// so get the web project associated with the path
|
||||||
|
webProject = new WebProject(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
// determine if the item is locked
|
||||||
|
AVMLock lock = avmLockingService.getLock(webProject.getStoreId(), relPath);
|
||||||
|
proceed = (lock != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
return proceed;
|
||||||
|
}
|
||||||
|
}
|
@@ -54,6 +54,7 @@ import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransacti
|
|||||||
import org.alfresco.service.cmr.avm.AVMExistsException;
|
import org.alfresco.service.cmr.avm.AVMExistsException;
|
||||||
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
|
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
|
||||||
import org.alfresco.service.cmr.avm.AVMService;
|
import org.alfresco.service.cmr.avm.AVMService;
|
||||||
|
import org.alfresco.service.cmr.avm.locking.AVMLock;
|
||||||
import org.alfresco.service.cmr.avm.locking.AVMLockingService;
|
import org.alfresco.service.cmr.avm.locking.AVMLockingService;
|
||||||
import org.alfresco.service.cmr.avmsync.AVMDifference;
|
import org.alfresco.service.cmr.avmsync.AVMDifference;
|
||||||
import org.alfresco.service.cmr.avmsync.AVMSyncService;
|
import org.alfresco.service.cmr.avmsync.AVMSyncService;
|
||||||
@@ -101,6 +102,7 @@ public class CreateWebContentWizard extends CreateContentWizard
|
|||||||
transient private Document instanceDataDocument = null;
|
transient private Document instanceDataDocument = null;
|
||||||
protected boolean formSelectDisabled = false;
|
protected boolean formSelectDisabled = false;
|
||||||
protected boolean startWorkflow = false;
|
protected boolean startWorkflow = false;
|
||||||
|
protected List<String> locksToReturnToMainStoreOnCancel = null;
|
||||||
|
|
||||||
transient private AVMLockingService avmLockingService;
|
transient private AVMLockingService avmLockingService;
|
||||||
transient private AVMService avmService;
|
transient private AVMService avmService;
|
||||||
@@ -213,6 +215,7 @@ public class CreateWebContentWizard extends CreateContentWizard
|
|||||||
this.createMimeTypes = null;
|
this.createMimeTypes = null;
|
||||||
this.formChoices = null;
|
this.formChoices = null;
|
||||||
this.filePickerBean.clearUploadedFiles();
|
this.filePickerBean.clearUploadedFiles();
|
||||||
|
this.locksToReturnToMainStoreOnCancel = new ArrayList<String>(4);
|
||||||
|
|
||||||
// check for a form ID being passed in as a parameter
|
// check for a form ID being passed in as a parameter
|
||||||
if (this.parameters.get(UIUserSandboxes.PARAM_FORM_NAME) != null)
|
if (this.parameters.get(UIUserSandboxes.PARAM_FORM_NAME) != null)
|
||||||
@@ -347,6 +350,32 @@ public class CreateWebContentWizard extends CreateContentWizard
|
|||||||
return super.back();
|
return super.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String cancel()
|
||||||
|
{
|
||||||
|
if (this.formInstanceData != null && this.renditions != null)
|
||||||
|
{
|
||||||
|
if (this.locksToReturnToMainStoreOnCancel.size() > 0)
|
||||||
|
{
|
||||||
|
for (String path : this.locksToReturnToMainStoreOnCancel)
|
||||||
|
{
|
||||||
|
String storeId = AVMUtil.getStoreId(path);
|
||||||
|
String storePath = AVMUtil.getStoreRelativePath(path);
|
||||||
|
String storeName = AVMUtil.getStoreName(path);
|
||||||
|
String mainStore = AVMUtil.getCorrespondingMainStoreName(storeName);
|
||||||
|
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
logger.debug("transferring lock from " + storeName + " to " + mainStore +
|
||||||
|
" for path: " + path + " as user chose to cancel");
|
||||||
|
|
||||||
|
this.getAvmLockingService().modifyLock(storeId, storePath, null, mainStore, null, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String finishImpl(final FacesContext context, String outcome)
|
protected String finishImpl(final FacesContext context, String outcome)
|
||||||
throws Exception
|
throws Exception
|
||||||
@@ -482,10 +511,34 @@ public class CreateWebContentWizard extends CreateContentWizard
|
|||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
logger.debug("creating file " + fileName + " in " + path);
|
logger.debug("creating file " + fileName + " in " + path);
|
||||||
|
|
||||||
|
// get current username for lock checks
|
||||||
|
String username = Application.getCurrentUser(FacesContext.getCurrentInstance()).getUserName();
|
||||||
|
|
||||||
// put the content of the file into the AVM store
|
// put the content of the file into the AVM store
|
||||||
|
String filePath = AVMNodeConverter.ExtendAVMPath(path, fileName);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
getAvmService().createFile(path, fileName, new ByteArrayInputStream((this.content == null ? "" : this.content).getBytes("UTF-8")));
|
String storeId = AVMUtil.getStoreId(filePath);
|
||||||
|
String storePath = AVMUtil.getStoreRelativePath(filePath);
|
||||||
|
String storeName = AVMUtil.getStoreName(filePath);
|
||||||
|
AVMLock lock = this.getAvmLockingService().getLock(storeId, storePath);
|
||||||
|
if (lock != null && lock.getStore().equals(storeName) == false)
|
||||||
|
{
|
||||||
|
if (lock.getOwners().contains(username))
|
||||||
|
{
|
||||||
|
// lock already exists on path, check it's owned by the current user
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
logger.debug("transferring lock from " + lock.getStore() + " to " + storeName + " for path: " + filePath);
|
||||||
|
|
||||||
|
// add the path to the list of locks to return to the preview store if cancel is pressed
|
||||||
|
this.locksToReturnToMainStoreOnCancel.add(filePath);
|
||||||
|
this.getAvmLockingService().modifyLock(storeId, storePath, null, storeName, null, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// create the file
|
||||||
|
getAvmService().createFile(path, fileName,
|
||||||
|
new ByteArrayInputStream((this.content == null ? "" : this.content).getBytes("UTF-8")));
|
||||||
}
|
}
|
||||||
catch (AVMExistsException avmee)
|
catch (AVMExistsException avmee)
|
||||||
{
|
{
|
||||||
@@ -495,7 +548,7 @@ public class CreateWebContentWizard extends CreateContentWizard
|
|||||||
}
|
}
|
||||||
|
|
||||||
// remember the created path
|
// remember the created path
|
||||||
this.createdPath = AVMNodeConverter.ExtendAVMPath(path, fileName);
|
this.createdPath = filePath;
|
||||||
|
|
||||||
// add titled aspect for the read/edit properties screens
|
// add titled aspect for the read/edit properties screens
|
||||||
final NodeRef formInstanceDataNodeRef = AVMNodeConverter.ToNodeRef(-1, this.createdPath);
|
final NodeRef formInstanceDataNodeRef = AVMNodeConverter.ToNodeRef(-1, this.createdPath);
|
||||||
@@ -517,6 +570,29 @@ public class CreateWebContentWizard extends CreateContentWizard
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
path = ret.getOutputPathForRendition(this.formInstanceData, cwd);
|
path = ret.getOutputPathForRendition(this.formInstanceData, cwd);
|
||||||
|
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
logger.debug("About to render path: " + path);
|
||||||
|
|
||||||
|
String storeId = AVMUtil.getStoreId(path);
|
||||||
|
String storePath = AVMUtil.getStoreRelativePath(path);
|
||||||
|
String storeName = AVMUtil.getStoreName(path);
|
||||||
|
AVMLock lock = this.getAvmLockingService().getLock(storeId, storePath);
|
||||||
|
if (lock != null && lock.getStore().equals(storeName) == false)
|
||||||
|
{
|
||||||
|
// see if the lock belongs to the current user, if it does modify the lock to point to the preview store
|
||||||
|
if (lock.getOwners().contains(username))
|
||||||
|
{
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
logger.debug("transferring lock from " + lock.getStore() + " to " + storeName + " for path: " + path);
|
||||||
|
|
||||||
|
// add the path to the list of locks to return to the main store if cancel is pressed
|
||||||
|
this.locksToReturnToMainStoreOnCancel.add(path);
|
||||||
|
this.getAvmLockingService().modifyLock(storeId, storePath, null, storeName, null, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// generate the rendition
|
||||||
this.renditions.add(ret.render(this.formInstanceData, path));
|
this.renditions.add(ret.render(this.formInstanceData, path));
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
@@ -1,259 +1,297 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
* as published by the Free Software Foundation; either version 2
|
* as published by the Free Software Foundation; either version 2
|
||||||
* of the License, or (at your option) any later version.
|
* of the License, or (at your option) any later version.
|
||||||
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
|
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
* As a special exception to the terms and conditions of version 2.0 of
|
* As a special exception to the terms and conditions of version 2.0 of
|
||||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||||
* FLOSS exception. You should have recieved a copy of the text describing
|
* FLOSS exception. You should have recieved a copy of the text describing
|
||||||
* the FLOSS exception, and it is also available here:
|
* the FLOSS exception, and it is also available here:
|
||||||
* http://www.alfresco.com/legal/licensing
|
* http://www.alfresco.com/legal/licensing
|
||||||
*/
|
*/
|
||||||
package org.alfresco.web.bean.wcm;
|
package org.alfresco.web.bean.wcm;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.LinkedList;
|
||||||
import java.util.Map;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import org.alfresco.repo.content.MimetypeMap;
|
|
||||||
import org.alfresco.service.cmr.avm.locking.AVMLock;
|
import org.alfresco.repo.content.MimetypeMap;
|
||||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
import org.alfresco.service.cmr.avm.locking.AVMLock;
|
||||||
import org.alfresco.web.app.Application;
|
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||||
import org.alfresco.web.forms.Form;
|
import org.alfresco.web.app.Application;
|
||||||
import org.alfresco.web.forms.FormInstanceData;
|
import org.alfresco.web.forms.Form;
|
||||||
import org.alfresco.web.forms.FormNotFoundException;
|
import org.alfresco.web.forms.FormInstanceData;
|
||||||
import org.alfresco.web.forms.Rendition;
|
import org.alfresco.web.forms.FormNotFoundException;
|
||||||
import org.alfresco.web.forms.XMLUtil;
|
import org.alfresco.web.forms.Rendition;
|
||||||
import org.alfresco.web.ui.common.Utils;
|
import org.alfresco.web.forms.XMLUtil;
|
||||||
import org.apache.commons.logging.Log;
|
import org.alfresco.web.ui.common.Utils;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
/**
|
|
||||||
* Bean implementation for the "Edit Web Content Wizard" dialog
|
/**
|
||||||
*/
|
* Bean implementation for the "Edit Web Content Wizard" dialog
|
||||||
public class EditWebContentWizard extends CreateWebContentWizard
|
*/
|
||||||
{
|
public class EditWebContentWizard extends CreateWebContentWizard
|
||||||
private static final long serialVersionUID = 439996926303151006L;
|
{
|
||||||
|
private static final long serialVersionUID = 439996926303151006L;
|
||||||
private static final Log logger = LogFactory.getLog(EditWebContentWizard.class);
|
|
||||||
|
private static final Log logger = LogFactory.getLog(EditWebContentWizard.class);
|
||||||
private AVMNode avmNode;
|
|
||||||
private Form form;
|
private AVMNode avmNode;
|
||||||
|
private Form form;
|
||||||
private boolean wasFormLockPresent = false;
|
|
||||||
private boolean wasRenditionLockPresent = false;
|
protected List<String> locksPresentAtInit = null;
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
// Wizard implementation
|
// Wizard implementation
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(final Map<String, String> parameters)
|
public void init(final Map<String, String> parameters)
|
||||||
{
|
{
|
||||||
super.init(parameters);
|
super.init(parameters);
|
||||||
this.avmNode = this.avmBrowseBean.getAvmActionNode();
|
this.avmNode = this.avmBrowseBean.getAvmActionNode();
|
||||||
if (this.avmNode == null)
|
if (this.avmNode == null)
|
||||||
{
|
{
|
||||||
throw new IllegalArgumentException("Edit Form wizard requires action node context.");
|
throw new IllegalArgumentException("Edit Form wizard requires action node context.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
logger.debug("path is " + this.avmNode.getPath());
|
logger.debug("path is " + this.avmNode.getPath());
|
||||||
|
|
||||||
this.createdPath = AVMUtil.getCorrespondingPathInPreviewStore(this.avmNode.getPath());
|
this.createdPath = AVMUtil.getCorrespondingPathInPreviewStore(this.avmNode.getPath());
|
||||||
this.formInstanceData = this.getFormsService().getFormInstanceData(-1, this.createdPath);
|
this.formInstanceData = this.getFormsService().getFormInstanceData(-1, this.createdPath);
|
||||||
final WebProject webProject = new WebProject(this.createdPath);
|
final WebProject webProject = new WebProject(this.createdPath);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
this.formName = this.formInstanceData.getForm().getName();
|
this.formName = this.formInstanceData.getForm().getName();
|
||||||
this.form = webProject.getForm(this.formName);
|
this.form = webProject.getForm(this.formName);
|
||||||
}
|
}
|
||||||
catch (FormNotFoundException fnfe)
|
catch (FormNotFoundException fnfe)
|
||||||
{
|
{
|
||||||
Utils.addErrorMessage(fnfe.getMessage(), fnfe);
|
Utils.addErrorMessage(fnfe.getMessage(), fnfe);
|
||||||
}
|
}
|
||||||
this.content = this.getAvmService().getContentReader(-1, this.createdPath).getContentString();
|
this.content = this.getAvmService().getContentReader(-1, this.createdPath).getContentString();
|
||||||
this.fileName = this.formInstanceData.getName();
|
this.fileName = this.formInstanceData.getName();
|
||||||
this.mimeType = MimetypeMap.MIMETYPE_XML;
|
this.mimeType = MimetypeMap.MIMETYPE_XML;
|
||||||
this.wasFormLockPresent = false;
|
|
||||||
this.wasRenditionLockPresent = false;
|
// calculate which locks are present at init time
|
||||||
}
|
this.locksPresentAtInit = new ArrayList<String>(4);
|
||||||
|
AVMLock lock = this.getAvmLockingService().getLock(AVMUtil.getStoreId(this.createdPath),
|
||||||
@Override
|
AVMUtil.getStoreRelativePath(this.createdPath));
|
||||||
public String cancel()
|
if (lock != null)
|
||||||
{
|
{
|
||||||
if (this.formInstanceData != null && this.renditions != null)
|
this.locksPresentAtInit.add(this.createdPath);
|
||||||
{
|
|
||||||
if (this.wasFormLockPresent == false)
|
if (logger.isDebugEnabled())
|
||||||
{
|
logger.debug("Lock exists for xml instance " + this.createdPath + " at initialisation");
|
||||||
// there wasn't a lock on the form at the start of the
|
}
|
||||||
// wizard so remove the one present now
|
|
||||||
if (logger.isDebugEnabled())
|
for (final Rendition r : this.formInstanceData.getRenditions())
|
||||||
logger.debug("removing form instance data lock from " +
|
{
|
||||||
AVMUtil.getCorrespondingPathInMainStore(this.createdPath) +
|
String path = r.getPath();
|
||||||
" as user chose to cancel");
|
lock = this.getAvmLockingService().getLock(AVMUtil.getStoreId(path),
|
||||||
|
AVMUtil.getStoreRelativePath(path));
|
||||||
this.getAvmLockingService().removeLock(AVMUtil.getStoreId(this.createdPath),
|
if (lock != null)
|
||||||
AVMUtil.getStoreRelativePath(this.createdPath));
|
{
|
||||||
}
|
this.locksPresentAtInit.add(path);
|
||||||
|
|
||||||
if (this.wasRenditionLockPresent == false)
|
if (logger.isDebugEnabled())
|
||||||
{
|
logger.debug("Lock exists for rendition " + path + " at initialisation");
|
||||||
// there weren't locks on renditions at the start of
|
}
|
||||||
// the wizard so remove the ones present now
|
}
|
||||||
for (Rendition r : this.renditions)
|
}
|
||||||
{
|
|
||||||
if (logger.isDebugEnabled())
|
@Override
|
||||||
logger.debug("removing lock from " +
|
public String cancel()
|
||||||
AVMUtil.getCorrespondingPathInMainStore(r.getPath()) +
|
{
|
||||||
" as user chose to cancel");
|
if (this.formInstanceData != null && this.renditions != null)
|
||||||
|
{
|
||||||
this.getAvmLockingService().removeLock(AVMUtil.getStoreId(r.getPath()),
|
if (this.locksPresentAtInit.contains(this.createdPath) == false)
|
||||||
AVMUtil.getStoreRelativePath(r.getPath()));
|
{
|
||||||
}
|
// there wasn't a lock on the form at the start of the
|
||||||
}
|
// wizard so remove the one present now
|
||||||
}
|
if (logger.isDebugEnabled())
|
||||||
|
logger.debug("removing form instance data lock from " +
|
||||||
return super.cancel();
|
AVMUtil.getCorrespondingPathInMainStore(this.createdPath) +
|
||||||
}
|
" as user chose to cancel and it wasn't present at initialisation");
|
||||||
|
|
||||||
@Override
|
this.getAvmLockingService().removeLock(AVMUtil.getStoreId(this.createdPath),
|
||||||
public String back()
|
AVMUtil.getStoreRelativePath(this.createdPath));
|
||||||
{
|
}
|
||||||
if ("content".equals(Application.getWizardManager().getCurrentStepName()))
|
|
||||||
{
|
for (Rendition r : this.renditions)
|
||||||
//override in order not to delete these items
|
{
|
||||||
this.formInstanceData = null;
|
String path = r.getPath();
|
||||||
this.renditions = null;
|
|
||||||
}
|
if (this.locksPresentAtInit.contains(path) == false)
|
||||||
return super.back();
|
{
|
||||||
}
|
// there wasn't a lock on the rendition at the start of
|
||||||
|
// the wizard so remove the one present now
|
||||||
@Override
|
if (logger.isDebugEnabled())
|
||||||
protected void saveContent()
|
logger.debug("removing lock from rendition " +
|
||||||
throws Exception
|
AVMUtil.getCorrespondingPathInMainStore(path) +
|
||||||
{
|
" as user chose to cancel and it wasn't present at initialisation");
|
||||||
if (logger.isDebugEnabled())
|
|
||||||
logger.debug("saving " + this.createdPath);
|
this.getAvmLockingService().removeLock(AVMUtil.getStoreId(path),
|
||||||
|
AVMUtil.getStoreRelativePath(path));
|
||||||
AVMLock lock = this.getAvmLockingService().getLock(AVMUtil.getStoreId(this.createdPath),
|
}
|
||||||
AVMUtil.getStoreRelativePath(this.createdPath));
|
}
|
||||||
if (lock != null)
|
}
|
||||||
{
|
|
||||||
if (logger.isDebugEnabled())
|
return super.cancel();
|
||||||
logger.debug("transferring lock from " + lock.getStore() +
|
}
|
||||||
" to " + AVMUtil.getStoreName(this.createdPath));
|
|
||||||
|
@Override
|
||||||
this.getAvmLockingService().modifyLock(AVMUtil.getStoreId(this.createdPath),
|
public String back()
|
||||||
AVMUtil.getStoreRelativePath(this.createdPath),
|
{
|
||||||
null,
|
if ("content".equals(Application.getWizardManager().getCurrentStepName()))
|
||||||
AVMUtil.getStoreName(this.createdPath),
|
{
|
||||||
null,
|
//override in order not to delete these items
|
||||||
null);
|
this.formInstanceData = null;
|
||||||
|
this.renditions = null;
|
||||||
// set the lock present flag
|
}
|
||||||
this.wasFormLockPresent = true;
|
return super.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
final ContentWriter writer = this.getAvmService().getContentWriter(this.createdPath);
|
@Override
|
||||||
this.content = XMLUtil.toString(this.getInstanceDataDocument(), false);
|
protected void saveContent()
|
||||||
writer.putContent(this.content);
|
throws Exception
|
||||||
|
{
|
||||||
// XXXarielb might not need to do this reload
|
if (logger.isDebugEnabled())
|
||||||
this.formInstanceData = this.getFormsService().getFormInstanceData(-1, this.createdPath);
|
logger.debug("saving " + this.createdPath);
|
||||||
for (final Rendition r : this.formInstanceData.getRenditions())
|
|
||||||
{
|
AVMLock lock = this.getAvmLockingService().getLock(AVMUtil.getStoreId(this.createdPath),
|
||||||
lock = this.getAvmLockingService().getLock(AVMUtil.getStoreId(r.getPath()),
|
AVMUtil.getStoreRelativePath(this.createdPath));
|
||||||
AVMUtil.getStoreRelativePath(r.getPath()));
|
if (lock != null)
|
||||||
if (lock != null)
|
{
|
||||||
{
|
if (logger.isDebugEnabled())
|
||||||
if (logger.isDebugEnabled())
|
logger.debug("transferring lock from " + lock.getStore() +
|
||||||
logger.debug("transferring lock from " + lock.getStore() +
|
" to " + AVMUtil.getStoreName(this.createdPath));
|
||||||
" to " + AVMUtil.getStoreName(r.getPath()));
|
|
||||||
|
this.getAvmLockingService().modifyLock(AVMUtil.getStoreId(this.createdPath),
|
||||||
this.getAvmLockingService().modifyLock(AVMUtil.getStoreId(r.getPath()),
|
AVMUtil.getStoreRelativePath(this.createdPath),
|
||||||
AVMUtil.getStoreRelativePath(r.getPath()),
|
null,
|
||||||
null,
|
AVMUtil.getStoreName(this.createdPath),
|
||||||
AVMUtil.getStoreName(r.getPath()),
|
null,
|
||||||
null,
|
null);
|
||||||
null);
|
}
|
||||||
|
|
||||||
// set the lock present flag
|
final ContentWriter writer = this.getAvmService().getContentWriter(this.createdPath);
|
||||||
this.wasRenditionLockPresent = true;
|
this.content = XMLUtil.toString(this.getInstanceDataDocument(), false);
|
||||||
}
|
writer.putContent(this.content);
|
||||||
}
|
|
||||||
final List<FormInstanceData.RegenerateResult> result = this.formInstanceData.regenerateRenditions();
|
// XXXarielb might not need to do this reload
|
||||||
this.renditions = new LinkedList<Rendition>();
|
this.formInstanceData = this.getFormsService().getFormInstanceData(-1, this.createdPath);
|
||||||
for (FormInstanceData.RegenerateResult rr : result)
|
for (final Rendition r : this.formInstanceData.getRenditions())
|
||||||
{
|
{
|
||||||
if (rr.getException() != null)
|
lock = this.getAvmLockingService().getLock(AVMUtil.getStoreId(r.getPath()),
|
||||||
{
|
AVMUtil.getStoreRelativePath(r.getPath()));
|
||||||
Utils.addErrorMessage("error regenerating rendition using " + rr.getRenderingEngineTemplate().getName() +
|
if (lock != null)
|
||||||
": " + rr.getException().getMessage(),
|
{
|
||||||
rr.getException());
|
if (logger.isDebugEnabled())
|
||||||
}
|
logger.debug("transferring lock from " + lock.getStore() +
|
||||||
else
|
" to " + AVMUtil.getStoreName(r.getPath()));
|
||||||
{
|
|
||||||
final Rendition r = rr.getRendition();
|
this.getAvmLockingService().modifyLock(AVMUtil.getStoreId(r.getPath()),
|
||||||
this.renditions.add(r);
|
AVMUtil.getStoreRelativePath(r.getPath()),
|
||||||
|
null,
|
||||||
if (logger.isDebugEnabled())
|
AVMUtil.getStoreName(r.getPath()),
|
||||||
logger.debug("transferring lock for " + r.getPath() +
|
null,
|
||||||
" back to " + AVMUtil.getCorrespondingMainStoreName(AVMUtil.getStoreName(r.getPath())));
|
null);
|
||||||
|
}
|
||||||
this.getAvmLockingService().modifyLock(AVMUtil.getStoreId(r.getPath()),
|
}
|
||||||
AVMUtil.getStoreRelativePath(r.getPath()),
|
|
||||||
null,
|
final List<FormInstanceData.RegenerateResult> result = this.formInstanceData.regenerateRenditions();
|
||||||
AVMUtil.getCorrespondingMainStoreName(AVMUtil.getStoreName(r.getPath())),
|
this.renditions = new LinkedList<Rendition>();
|
||||||
null,
|
for (FormInstanceData.RegenerateResult rr : result)
|
||||||
null);
|
{
|
||||||
}
|
if (rr.getException() != null)
|
||||||
}
|
{
|
||||||
|
Utils.addErrorMessage("error regenerating rendition using " + rr.getRenderingEngineTemplate().getName() +
|
||||||
if (logger.isDebugEnabled())
|
": " + rr.getException().getMessage(),
|
||||||
logger.debug("transferring form instance data lock back to " +
|
rr.getException());
|
||||||
AVMUtil.getCorrespondingMainStoreName(AVMUtil.getStoreName(this.createdPath)));
|
|
||||||
|
// if the renditions were locked before the regenerate, move the lock back to main store
|
||||||
this.getAvmLockingService().modifyLock(AVMUtil.getStoreId(this.createdPath),
|
String path = rr.getPath();
|
||||||
AVMUtil.getStoreRelativePath(this.createdPath),
|
|
||||||
null,
|
if (this.locksPresentAtInit.contains(path))
|
||||||
AVMUtil.getCorrespondingMainStoreName(AVMUtil.getStoreName(this.createdPath)),
|
{
|
||||||
null,
|
if (logger.isDebugEnabled())
|
||||||
null);
|
logger.debug("transferring existing lock for " + path +
|
||||||
}
|
" back to " + AVMUtil.getCorrespondingMainStoreName(AVMUtil.getStoreName(path)));
|
||||||
|
|
||||||
/** Indicates whether or not the wizard is currently in edit mode */
|
this.getAvmLockingService().modifyLock(AVMUtil.getStoreId(path),
|
||||||
@Override
|
AVMUtil.getStoreRelativePath(path),
|
||||||
public boolean getEditMode()
|
null,
|
||||||
{
|
AVMUtil.getCorrespondingMainStoreName(AVMUtil.getStoreName(path)),
|
||||||
return true;
|
null,
|
||||||
}
|
null);
|
||||||
|
}
|
||||||
@Override
|
}
|
||||||
public boolean getSubmittable()
|
else
|
||||||
{
|
{
|
||||||
return !AVMUtil.isWorkflowStore(AVMUtil.getStoreName(this.createdPath));
|
final Rendition r = rr.getRendition();
|
||||||
}
|
this.renditions.add(r);
|
||||||
|
|
||||||
/**
|
if (logger.isDebugEnabled())
|
||||||
* Overridden to avoid calling getWebProject since potentially there is no web project
|
logger.debug("transferring lock for " + r.getPath() +
|
||||||
* context in workflow scenario.
|
" back to " + AVMUtil.getCorrespondingMainStoreName(AVMUtil.getStoreName(r.getPath())));
|
||||||
*/
|
|
||||||
@Override
|
this.getAvmLockingService().modifyLock(AVMUtil.getStoreId(r.getPath()),
|
||||||
public Form getForm()
|
AVMUtil.getStoreRelativePath(r.getPath()),
|
||||||
{
|
null,
|
||||||
return this.form;
|
AVMUtil.getCorrespondingMainStoreName(AVMUtil.getStoreName(r.getPath())),
|
||||||
}
|
null,
|
||||||
}
|
null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
logger.debug("transferring form instance data lock back to " +
|
||||||
|
AVMUtil.getCorrespondingMainStoreName(AVMUtil.getStoreName(this.createdPath)));
|
||||||
|
|
||||||
|
this.getAvmLockingService().modifyLock(AVMUtil.getStoreId(this.createdPath),
|
||||||
|
AVMUtil.getStoreRelativePath(this.createdPath),
|
||||||
|
null,
|
||||||
|
AVMUtil.getCorrespondingMainStoreName(AVMUtil.getStoreName(this.createdPath)),
|
||||||
|
null,
|
||||||
|
null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Indicates whether or not the wizard is currently in edit mode */
|
||||||
|
@Override
|
||||||
|
public boolean getEditMode()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getSubmittable()
|
||||||
|
{
|
||||||
|
return !AVMUtil.isWorkflowStore(AVMUtil.getStoreName(this.createdPath));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Overridden to avoid calling getWebProject since potentially there is no web project
|
||||||
|
* context in workflow scenario.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Form getForm()
|
||||||
|
{
|
||||||
|
return this.form;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
145
source/java/org/alfresco/web/bean/wcm/UnlockFileDialog.java
Normal file
145
source/java/org/alfresco/web/bean/wcm/UnlockFileDialog.java
Normal file
@@ -0,0 +1,145 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
* As a special exception to the terms and conditions of version 2.0 of
|
||||||
|
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||||
|
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||||
|
* FLOSS exception. You should have recieved a copy of the text describing
|
||||||
|
* the FLOSS exception, and it is also available here:
|
||||||
|
* http://www.alfresco.com/legal/licensing"
|
||||||
|
*/
|
||||||
|
package org.alfresco.web.bean.wcm;
|
||||||
|
|
||||||
|
import java.text.MessageFormat;
|
||||||
|
|
||||||
|
import javax.faces.context.FacesContext;
|
||||||
|
|
||||||
|
import org.alfresco.service.cmr.avm.AVMService;
|
||||||
|
import org.alfresco.service.cmr.avm.locking.AVMLockingService;
|
||||||
|
import org.alfresco.web.app.Application;
|
||||||
|
import org.alfresco.web.bean.dialog.BaseDialogBean;
|
||||||
|
import org.alfresco.web.bean.repository.Repository;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bean implementation for the AVM "Unlock File" dialog
|
||||||
|
*
|
||||||
|
* @author Gavin Cornwell
|
||||||
|
*/
|
||||||
|
public class UnlockFileDialog extends BaseDialogBean
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = -2985826502913718770L;
|
||||||
|
|
||||||
|
private static final Log logger = LogFactory.getLog(UnlockFileDialog.class);
|
||||||
|
|
||||||
|
protected AVMService avmService;
|
||||||
|
protected AVMLockingService lockingService;
|
||||||
|
protected AVMBrowseBean avmBrowseBean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param avmBrowseBean The avmBrowseBean to set.
|
||||||
|
*/
|
||||||
|
public void setAvmBrowseBean(AVMBrowseBean avmBrowseBean)
|
||||||
|
{
|
||||||
|
this.avmBrowseBean = avmBrowseBean;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param avmService The avmService to set.
|
||||||
|
*/
|
||||||
|
public void setAvmService(AVMService avmService)
|
||||||
|
{
|
||||||
|
this.avmService = avmService;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected AVMService getAvmService()
|
||||||
|
{
|
||||||
|
if (this.avmService == null)
|
||||||
|
{
|
||||||
|
this.avmService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getAVMService();
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.avmService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param lockingService The avmLockingService to set.
|
||||||
|
*/
|
||||||
|
public void setAvmLockingService(AVMLockingService lockingService)
|
||||||
|
{
|
||||||
|
this.lockingService = lockingService;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected AVMLockingService getAvmLockingService()
|
||||||
|
{
|
||||||
|
if (this.lockingService == null)
|
||||||
|
{
|
||||||
|
this.lockingService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getAVMLockingService();
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.lockingService;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------
|
||||||
|
// Dialog implementation
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String finishImpl(final FacesContext context, final String outcome)
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
// get the content to delete
|
||||||
|
final AVMNode node = this.avmBrowseBean.getAvmActionNode();
|
||||||
|
if (node == null)
|
||||||
|
{
|
||||||
|
logger.warn("WARNING: unlock called without a current AVM Node!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
logger.debug("Trying to unlock AVM node: " + node.getPath());
|
||||||
|
|
||||||
|
this.getAvmLockingService().removeLock(this.avmBrowseBean.getWebProject().getStoreId(),
|
||||||
|
AVMUtil.getStoreRelativePath(node.getPath()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return outcome;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getFinishButtonDisabled()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------
|
||||||
|
// Bean Getters and Setters
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the confirmation to display to the user before deleting the content.
|
||||||
|
*
|
||||||
|
* @return The formatted message to display
|
||||||
|
*/
|
||||||
|
public String getConfirmMessage()
|
||||||
|
{
|
||||||
|
String unlockConfirmMsg = Application.getMessage(FacesContext.getCurrentInstance(),
|
||||||
|
"unlock_file_confirm");
|
||||||
|
|
||||||
|
return MessageFormat.format(unlockConfirmMsg,
|
||||||
|
new Object[] {this.avmBrowseBean.getAvmActionNode().getName()});
|
||||||
|
}
|
||||||
|
}
|
@@ -47,29 +47,39 @@ public interface FormInstanceData
|
|||||||
private static final long serialVersionUID = -3827878774655260635L;
|
private static final long serialVersionUID = -3827878774655260635L;
|
||||||
|
|
||||||
private final RenderingEngineTemplate ret;
|
private final RenderingEngineTemplate ret;
|
||||||
|
private final String path;
|
||||||
private final Rendition r;
|
private final Rendition r;
|
||||||
private final Exception e;
|
private final Exception e;
|
||||||
|
|
||||||
public RegenerateResult(final RenderingEngineTemplate ret,
|
public RegenerateResult(final RenderingEngineTemplate ret,
|
||||||
|
final String path,
|
||||||
final Rendition r)
|
final Rendition r)
|
||||||
{
|
{
|
||||||
this.ret = ret;
|
this.ret = ret;
|
||||||
this.r = r;
|
this.r = r;
|
||||||
this.e = null;
|
this.e = null;
|
||||||
|
this.path = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RegenerateResult(final RenderingEngineTemplate ret,
|
public RegenerateResult(final RenderingEngineTemplate ret,
|
||||||
|
final String path,
|
||||||
final Exception e)
|
final Exception e)
|
||||||
{
|
{
|
||||||
this.ret = ret;
|
this.ret = ret;
|
||||||
this.e = e;
|
this.e = e;
|
||||||
this.r = null;
|
this.r = null;
|
||||||
|
this.path = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RenderingEngineTemplate getRenderingEngineTemplate()
|
public RenderingEngineTemplate getRenderingEngineTemplate()
|
||||||
{
|
{
|
||||||
return this.ret;
|
return this.ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getPath()
|
||||||
|
{
|
||||||
|
return this.path;
|
||||||
|
}
|
||||||
|
|
||||||
public Rendition getRendition()
|
public Rendition getRendition()
|
||||||
{
|
{
|
||||||
|
@@ -41,6 +41,8 @@ import org.alfresco.repo.domain.PropertyValue;
|
|||||||
import org.alfresco.service.ServiceRegistry;
|
import org.alfresco.service.ServiceRegistry;
|
||||||
import org.alfresco.service.cmr.avm.AVMNotFoundException;
|
import org.alfresco.service.cmr.avm.AVMNotFoundException;
|
||||||
import org.alfresco.service.cmr.avm.AVMService;
|
import org.alfresco.service.cmr.avm.AVMService;
|
||||||
|
import org.alfresco.service.cmr.avm.locking.AVMLock;
|
||||||
|
import org.alfresco.service.cmr.avm.locking.AVMLockingService;
|
||||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.StoreRef;
|
import org.alfresco.service.cmr.repository.StoreRef;
|
||||||
@@ -61,8 +63,8 @@ import org.xml.sax.SAXException;
|
|||||||
/* package */ class FormInstanceDataImpl implements FormInstanceData
|
/* package */ class FormInstanceDataImpl implements FormInstanceData
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = -7806221587661854013L;
|
private static final long serialVersionUID = -7806221587661854013L;
|
||||||
|
|
||||||
private static final Log LOGGER = LogFactory.getLog(RenditionImpl.class);
|
private static final Log logger = LogFactory.getLog(RenditionImpl.class);
|
||||||
|
|
||||||
private final NodeRef nodeRef;
|
private final NodeRef nodeRef;
|
||||||
private transient FormsService formsService;
|
private transient FormsService formsService;
|
||||||
@@ -175,9 +177,10 @@ import org.xml.sax.SAXException;
|
|||||||
public List<FormInstanceData.RegenerateResult> regenerateRenditions()
|
public List<FormInstanceData.RegenerateResult> regenerateRenditions()
|
||||||
throws FormNotFoundException
|
throws FormNotFoundException
|
||||||
{
|
{
|
||||||
if (LOGGER.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
LOGGER.debug("regenerating renditions of " + this);
|
logger.debug("regenerating renditions of " + this);
|
||||||
|
|
||||||
|
AVMLockingService avmLockService = this.getServiceRegistry().getAVMLockingService();
|
||||||
final AVMService avmService = this.getServiceRegistry().getAVMService();
|
final AVMService avmService = this.getServiceRegistry().getAVMService();
|
||||||
PropertyValue pv = avmService.getNodeProperty(
|
PropertyValue pv = avmService.getNodeProperty(
|
||||||
AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getFirst(),
|
AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getFirst(),
|
||||||
@@ -191,6 +194,8 @@ import org.xml.sax.SAXException;
|
|||||||
new HashSet<RenderingEngineTemplate>(this.getForm().getRenderingEngineTemplates());
|
new HashSet<RenderingEngineTemplate>(this.getForm().getRenderingEngineTemplates());
|
||||||
final List<RegenerateResult> result = new LinkedList<RegenerateResult>();
|
final List<RegenerateResult> result = new LinkedList<RegenerateResult>();
|
||||||
// regenerate existing renditions
|
// regenerate existing renditions
|
||||||
|
boolean renditionLockedBefore = false;
|
||||||
|
String path = null;
|
||||||
for (final Rendition r : this.getRenditions())
|
for (final Rendition r : this.getRenditions())
|
||||||
{
|
{
|
||||||
final RenderingEngineTemplate ret = r.getRenderingEngineTemplate();
|
final RenderingEngineTemplate ret = r.getRenderingEngineTemplate();
|
||||||
@@ -200,14 +205,36 @@ import org.xml.sax.SAXException;
|
|||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LOGGER.debug("regenerating rendition " + r + " using template " + ret);
|
if (logger.isDebugEnabled())
|
||||||
|
logger.debug("regenerating rendition " + r + " using template " + ret);
|
||||||
|
|
||||||
|
renditionLockedBefore = false;
|
||||||
|
path = r.getPath();
|
||||||
|
AVMLock lock = avmLockService.getLock(AVMUtil.getStoreId(path), AVMUtil.getStoreRelativePath(path));
|
||||||
|
if (lock != null)
|
||||||
|
{
|
||||||
|
renditionLockedBefore = true;
|
||||||
|
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
logger.debug("Lock already exists for " + path);
|
||||||
|
}
|
||||||
|
|
||||||
ret.render(this, r);
|
ret.render(this, r);
|
||||||
allRets.remove(ret);
|
allRets.remove(ret);
|
||||||
result.add(new RegenerateResult(ret, r));
|
result.add(new RegenerateResult(ret, path, r));
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
result.add(new RegenerateResult(ret, e));
|
result.add(new RegenerateResult(ret, path, e));
|
||||||
|
|
||||||
|
// remove lock if there wasn't one before
|
||||||
|
if (renditionLockedBefore == false)
|
||||||
|
{
|
||||||
|
avmLockService.removeLock(AVMUtil.getStoreId(path), AVMUtil.getStoreRelativePath(path));
|
||||||
|
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
logger.debug("Removed lock for " + path + " as it failed to generate");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -216,15 +243,36 @@ import org.xml.sax.SAXException;
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
final String path = ret.getOutputPathForRendition(this, originalParentAvmPath);
|
renditionLockedBefore = false;
|
||||||
LOGGER.debug("regenerating rendition of " + this.getPath() +
|
path = ret.getOutputPathForRendition(this, originalParentAvmPath);
|
||||||
" at " + path + " using template " + ret);
|
|
||||||
|
|
||||||
result.add(new RegenerateResult(ret, ret.render(this, path)));
|
if (logger.isDebugEnabled())
|
||||||
|
logger.debug("regenerating rendition of " + this.getPath() +
|
||||||
|
" at " + path + " using template " + ret);
|
||||||
|
|
||||||
|
AVMLock lock = avmLockService.getLock(AVMUtil.getStoreId(path), AVMUtil.getStoreRelativePath(path));
|
||||||
|
if (lock != null)
|
||||||
|
{
|
||||||
|
renditionLockedBefore = true;
|
||||||
|
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
logger.debug("Lock already exists for " + path);
|
||||||
|
}
|
||||||
|
|
||||||
|
result.add(new RegenerateResult(ret, path, ret.render(this, path)));
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
result.add(new RegenerateResult(ret, e));
|
result.add(new RegenerateResult(ret, path, e));
|
||||||
|
|
||||||
|
// remove lock if there wasn't one before
|
||||||
|
if (renditionLockedBefore == false)
|
||||||
|
{
|
||||||
|
avmLockService.removeLock(AVMUtil.getStoreId(path), AVMUtil.getStoreRelativePath(path));
|
||||||
|
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
logger.debug("Removed lock for " + path + " as it failed to generate");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -244,7 +292,8 @@ import org.xml.sax.SAXException;
|
|||||||
{
|
{
|
||||||
if (avmService.lookup(-1, storeName + ':' + (String)path) == null)
|
if (avmService.lookup(-1, storeName + ':' + (String)path) == null)
|
||||||
{
|
{
|
||||||
LOGGER.debug("ignoring dangling rendition at " + storeName + ':' + (String)path);
|
if (logger.isDebugEnabled())
|
||||||
|
logger.debug("ignoring dangling rendition at " + storeName + ':' + (String)path);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -255,9 +304,10 @@ import org.xml.sax.SAXException;
|
|||||||
{
|
{
|
||||||
if (!this.equals(r.getPrimaryFormInstanceData()))
|
if (!this.equals(r.getPrimaryFormInstanceData()))
|
||||||
{
|
{
|
||||||
LOGGER.debug("rendition " + r +
|
if (logger.isDebugEnabled())
|
||||||
" points at form instance data " + r.getPrimaryFormInstanceData() +
|
logger.debug("rendition " + r +
|
||||||
" instead of " + this + ". Not including in renditions list.");
|
" points at form instance data " + r.getPrimaryFormInstanceData() +
|
||||||
|
" instead of " + this + ". Not including in renditions list.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -3673,6 +3673,27 @@
|
|||||||
<value>#{NodeService}</value>
|
<value>#{NodeService}</value>
|
||||||
</managed-property>
|
</managed-property>
|
||||||
</managed-bean>
|
</managed-bean>
|
||||||
|
|
||||||
|
<managed-bean>
|
||||||
|
<description>
|
||||||
|
The bean that backs up the Unlock File Dialog
|
||||||
|
</description>
|
||||||
|
<managed-bean-name>UnlockFileDialog</managed-bean-name>
|
||||||
|
<managed-bean-class>org.alfresco.web.bean.wcm.UnlockFileDialog</managed-bean-class>
|
||||||
|
<managed-bean-scope>session</managed-bean-scope>
|
||||||
|
<managed-property>
|
||||||
|
<property-name>avmService</property-name>
|
||||||
|
<value>#{AVMLockingAwareService}</value>
|
||||||
|
</managed-property>
|
||||||
|
<managed-property>
|
||||||
|
<property-name>avmLockingService</property-name>
|
||||||
|
<value>#{AVMLockingService}</value>
|
||||||
|
</managed-property>
|
||||||
|
<managed-property>
|
||||||
|
<property-name>avmBrowseBean</property-name>
|
||||||
|
<value>#{AVMBrowseBean}</value>
|
||||||
|
</managed-property>
|
||||||
|
</managed-bean>
|
||||||
|
|
||||||
<managed-bean>
|
<managed-bean>
|
||||||
<description>
|
<description>
|
||||||
|
BIN
source/web/images/icons/unlock_large.gif
Normal file
BIN
source/web/images/icons/unlock_large.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
Reference in New Issue
Block a user