mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merge Offline Edit dev branch to HEAD
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@8527 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -32,6 +32,7 @@ import javax.faces.context.FacesContext;
|
||||
import org.alfresco.service.cmr.coci.CheckOutCheckInService;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.version.VersionService;
|
||||
import org.alfresco.service.cmr.workflow.WorkflowService;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
@@ -41,8 +42,11 @@ public class CCProperties implements Serializable
|
||||
|
||||
private static final long serialVersionUID = -79530354521757202L;
|
||||
|
||||
/** The VersionOperationsService to be used by the bean */
|
||||
/** The VersionOperationsService to be used by the bean */
|
||||
transient protected CheckOutCheckInService versionOperationsService;
|
||||
|
||||
/** The VersionQueryService to be used by the bean */
|
||||
transient protected VersionService versionQueryService;
|
||||
|
||||
/** The ContentService to be used by the bean */
|
||||
transient protected ContentService contentService;
|
||||
@@ -65,6 +69,8 @@ public class CCProperties implements Serializable
|
||||
/** transient form and upload properties */
|
||||
private File file;
|
||||
private String fileName;
|
||||
private String webdavUrl;
|
||||
private String cifsPath;
|
||||
private boolean keepCheckedOut = false;
|
||||
private boolean minorChange = true;
|
||||
private boolean isWorkflowAction = false;
|
||||
@@ -99,6 +105,28 @@ public class CCProperties implements Serializable
|
||||
{
|
||||
this.versionOperationsService = versionOperationsService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the VersionQueryService.
|
||||
*/
|
||||
public VersionService getVersionQueryService()
|
||||
{
|
||||
if (this.versionQueryService == null)
|
||||
{
|
||||
this.versionQueryService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getVersionService();
|
||||
}
|
||||
|
||||
return this.versionQueryService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param versionQueryService
|
||||
* The VersionQueryService to set.
|
||||
*/
|
||||
public void setVersionQueryService(VersionService versionQueryService)
|
||||
{
|
||||
this.versionQueryService = versionQueryService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the ContentService.
|
||||
@@ -367,4 +395,36 @@ public class CCProperties implements Serializable
|
||||
{
|
||||
this.copyLocation = copyLocation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns WebDav url for online editing. If webdav online editing didn't yet started, returns null
|
||||
*/
|
||||
public String getWebdavUrl()
|
||||
{
|
||||
return webdavUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param webdavUrl The webdav url. Using only for online editing
|
||||
*/
|
||||
public void setWebdavUrl(String webdavUrl)
|
||||
{
|
||||
this.webdavUrl = webdavUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns CIFS path for online editing. If cifs online editing didn't yet started, returns null
|
||||
*/
|
||||
public String getCifsPath()
|
||||
{
|
||||
return cifsPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cifsPath The cifs path. Using only for online editing
|
||||
*/
|
||||
public void setCifsPath(String cifsPath)
|
||||
{
|
||||
this.cifsPath = cifsPath;
|
||||
}
|
||||
}
|
||||
|
117
source/java/org/alfresco/web/bean/coci/CancelEditingDialog.java
Normal file
117
source/java/org/alfresco/web/bean/coci/CancelEditingDialog.java
Normal file
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* 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.coci;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
public class CancelEditingDialog extends CheckinCheckoutDialog
|
||||
{
|
||||
public static final String LBL_CANCEL_EDITING = "cancel_editing";
|
||||
public static final String MSG_CANCEL_EDITING_FOR = "cancel_editing_for";
|
||||
|
||||
private static Log logger = LogFactory.getLog(CheckinCheckoutDialog.class);
|
||||
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome) throws Exception
|
||||
{
|
||||
undoCheckoutFile(context, outcome);
|
||||
return "dialog:close[2]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContainerTitle()
|
||||
{
|
||||
return Application.getMessage(FacesContext.getCurrentInstance(), MSG_CANCEL_EDITING_FOR) + " '" + property.getDocument().getName() + "'";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getFinishButtonDisabled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFinishButtonLabel()
|
||||
{
|
||||
return Application.getMessage(FacesContext.getCurrentInstance(), LBL_CANCEL_EDITING);
|
||||
}
|
||||
|
||||
/**
|
||||
* Action to undo the checkout of a locked document. This document may
|
||||
* either by the original copy or the working copy node. Therefore calculate
|
||||
* which it is, if the working copy is found then we simply cancel checkout
|
||||
* on that document. If the original copy is found then we need to find the
|
||||
* appropriate working copy and perform the action on that node.
|
||||
*/
|
||||
public String undoCheckoutFile(FacesContext context, String outcome)
|
||||
{
|
||||
Node node = property.getDocument();
|
||||
if (node != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (node.hasAspect(ContentModel.ASPECT_WORKING_COPY))
|
||||
{
|
||||
this.property.getVersionOperationsService().cancelCheckout(node.getNodeRef());
|
||||
}
|
||||
else if (node.hasAspect(ContentModel.ASPECT_LOCKABLE))
|
||||
{
|
||||
// TODO: find the working copy for this document and cancel
|
||||
// the checkout on it
|
||||
// is this possible? as currently only the workingcopy
|
||||
// aspect has the copyReference
|
||||
// attribute - this means we cannot find out where the copy
|
||||
// is to cancel it!
|
||||
// can we construct an XPath node lookup?
|
||||
throw new RuntimeException("NOT IMPLEMENTED");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalStateException("Node supplied for undo checkout has neither Working Copy or Locked aspect!");
|
||||
}
|
||||
|
||||
resetState();
|
||||
}
|
||||
catch (Throwable err)
|
||||
{
|
||||
Utils.addErrorMessage(Application.getMessage(FacesContext.getCurrentInstance(), MSG_ERROR_CANCELCHECKOUT) + err.getMessage(), err);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.warn("WARNING: undoCheckout called without a current WorkingDocument!");
|
||||
}
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
||||
}
|
@@ -265,7 +265,7 @@ public class CheckinCheckoutDialog extends BaseDialogBean
|
||||
* @param id GUID of the node to setup as the content document context
|
||||
* @return The Node
|
||||
*/
|
||||
private Node setupContentDocument(String id)
|
||||
protected Node setupContentDocument(String id)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Setup for action, setting current document to: " + id);
|
||||
|
210
source/java/org/alfresco/web/bean/coci/DoneEditingDialog.java
Normal file
210
source/java/org/alfresco/web/bean/coci/DoneEditingDialog.java
Normal file
@@ -0,0 +1,210 @@
|
||||
/*
|
||||
* 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.coci;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import javax.faces.application.NavigationHandler;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.event.ActionEvent;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.version.Version;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.web.app.AlfrescoNavigationHandler;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
|
||||
/**
|
||||
* This bean class handle done-editing(commit) dialog.
|
||||
*
|
||||
*/
|
||||
public class DoneEditingDialog extends CheckinCheckoutDialog
|
||||
{
|
||||
|
||||
private final static String MSG_DONE = "done";
|
||||
private static final String MSG_CHECK_IN = "check_in";
|
||||
private final static String MSG_MISSING_ORIGINAL_NODE = "missing_original_node";
|
||||
|
||||
private final static String DIALOG_NAME = AlfrescoNavigationHandler.DIALOG_PREFIX + "doneEditingFile";
|
||||
|
||||
/**
|
||||
* this flag indicates occurrence when source node isn't versionable, but working copy yet is versionable
|
||||
*/
|
||||
private boolean sourceVersionable;
|
||||
|
||||
/**
|
||||
* this field contains reference to source node for working copy
|
||||
*/
|
||||
private NodeRef sourceNodeRef;
|
||||
|
||||
/**
|
||||
* @return Returns label for new version with major changes
|
||||
*/
|
||||
public String getMajorNewVersionLabel()
|
||||
{
|
||||
String label = getCurrentVersionLabel();
|
||||
StringTokenizer st = new StringTokenizer(label, ".");
|
||||
return (Integer.valueOf(st.nextToken()) + 1) + ".0";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns label for new version with minor changes
|
||||
*/
|
||||
public String getMinorNewVersionLabel()
|
||||
{
|
||||
String label = getCurrentVersionLabel();
|
||||
StringTokenizer st = new StringTokenizer(label, ".");
|
||||
return st.nextToken() + "." + (Integer.valueOf(st.nextToken()) + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns flag, which indicates occurrence when source node is versionable
|
||||
*/
|
||||
public boolean isSourceVersionable()
|
||||
{
|
||||
return sourceVersionable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns true if source node for selected working copy founded
|
||||
*/
|
||||
public boolean isSourceFounded()
|
||||
{
|
||||
return (sourceNodeRef != null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method for handling done-editing action(e.g. "done_editing_doc")
|
||||
* @param event Action Event
|
||||
*/
|
||||
public void handle(ActionEvent event)
|
||||
{
|
||||
setupContentAction(event);
|
||||
|
||||
FacesContext fc = FacesContext.getCurrentInstance();
|
||||
NavigationHandler nh = fc.getApplication().getNavigationHandler();
|
||||
// if content is versionable then check-in else move to dialog for filling version info
|
||||
if (isVersionable())
|
||||
{
|
||||
nh.handleNavigation(fc, null, DIALOG_NAME);
|
||||
}
|
||||
else
|
||||
{
|
||||
checkinFileOK(fc, null);
|
||||
nh.handleNavigation(fc, null, AlfrescoNavigationHandler.DIALOG_PREFIX + "browse");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupContentAction(ActionEvent event)
|
||||
{
|
||||
super.setupContentAction(event);
|
||||
|
||||
Node node = property.getDocument();
|
||||
if (node != null)
|
||||
{
|
||||
sourceNodeRef = getSourceNodeRef(node.getNodeRef());
|
||||
if (sourceNodeRef != null)
|
||||
sourceVersionable = getNodeService().hasAspect(sourceNodeRef, ContentModel.ASPECT_VERSIONABLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFinishButtonLabel()
|
||||
{
|
||||
return Application.getMessage(FacesContext.getCurrentInstance(), MSG_DONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getFinishButtonDisabled()
|
||||
{
|
||||
return !isSourceFounded();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContainerTitle()
|
||||
{
|
||||
if (isSourceFounded())
|
||||
{
|
||||
return Application.getMessage(FacesContext.getCurrentInstance(), MSG_CHECK_IN) + " '" + getNodeService().getProperty(sourceNodeRef, ContentModel.PROP_NAME) + "'";
|
||||
}
|
||||
else
|
||||
{
|
||||
String message = Application.getMessage(FacesContext.getCurrentInstance(), MSG_MISSING_ORIGINAL_NODE);
|
||||
Utils.addErrorMessage(message);
|
||||
return message;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetState()
|
||||
{
|
||||
super.resetState();
|
||||
|
||||
sourceVersionable = false;
|
||||
sourceNodeRef = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome) throws Exception
|
||||
{
|
||||
return checkinFileOK(context, outcome);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns version label for source node for working copy. Null indicates error
|
||||
*/
|
||||
private String getCurrentVersionLabel()
|
||||
{
|
||||
if (isSourceFounded())
|
||||
{
|
||||
Version curVersion = property.getVersionQueryService().getCurrentVersion(sourceNodeRef);
|
||||
return curVersion.getVersionLabel();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param workingCopyNodeRef node reference to working copy
|
||||
* @return Returns node reference to node, which is source for working copy node. Null indicates error
|
||||
*/
|
||||
private NodeRef getSourceNodeRef(NodeRef workingCopyNodeRef)
|
||||
{
|
||||
if (getNodeService().hasAspect(workingCopyNodeRef, ContentModel.ASPECT_COPIEDFROM) == true)
|
||||
{
|
||||
Map<QName, Serializable> workingCopyProperties = getNodeService().getProperties(workingCopyNodeRef);
|
||||
return (NodeRef) workingCopyProperties.get(ContentModel.PROP_COPY_REFERENCE);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
209
source/java/org/alfresco/web/bean/coci/EditOfflineDialog.java
Normal file
209
source/java/org/alfresco/web/bean/coci/EditOfflineDialog.java
Normal file
@@ -0,0 +1,209 @@
|
||||
/*
|
||||
* 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.coci;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.event.ActionEvent;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.app.servlet.DownloadContentServlet;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.users.UserPreferencesBean;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
import org.alfresco.web.ui.common.component.UIActionLink;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
public class EditOfflineDialog extends CheckinCheckoutDialog
|
||||
{
|
||||
public static final String OFFLINE_EDITING = "offlineEditing";
|
||||
public static final String CLOSE = "close";
|
||||
public static final String MSG_ERROR_CHECKOUT = "error_checkout";
|
||||
public static final String OFFLINE_TITLE = "offline_title";
|
||||
|
||||
private static Log logger = LogFactory.getLog(EditOfflineDialog.class);
|
||||
|
||||
private boolean continueCountdown;
|
||||
protected UserPreferencesBean userPreferencesBean;
|
||||
|
||||
@Override
|
||||
public void init(Map<String, String> parameters)
|
||||
{
|
||||
super.init(parameters);
|
||||
continueCountdown = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restored()
|
||||
{
|
||||
super.restored();
|
||||
continueCountdown = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContainerTitle()
|
||||
{
|
||||
FacesContext fc = FacesContext.getCurrentInstance();
|
||||
String pattern = Application.getMessage(fc, OFFLINE_TITLE);
|
||||
return MessageFormat.format(pattern, property.getDocument().getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome) throws Exception
|
||||
{
|
||||
return outcome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCancelButtonLabel()
|
||||
{
|
||||
return Application.getMessage(FacesContext.getCurrentInstance(), CLOSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Action listener for handle offline editing action. E.g "edit_doc_offline"
|
||||
* action
|
||||
*
|
||||
* @param event ActionEvent
|
||||
*/
|
||||
public void setupContentAction(ActionEvent event)
|
||||
{
|
||||
UIActionLink link = (UIActionLink) event.getComponent();
|
||||
Map<String, String> params = link.getParameterMap();
|
||||
String id = params.get("id");
|
||||
if (id != null && id.length() != 0)
|
||||
{
|
||||
super.setupContentDocument(id);
|
||||
checkoutFile(property.getDocument());
|
||||
if (userPreferencesBean.isDownloadAutomatically())
|
||||
{
|
||||
FacesContext fc = FacesContext.getCurrentInstance();
|
||||
this.navigator.setupDispatchContext(property.getDocument());
|
||||
fc.getApplication().getNavigationHandler().handleNavigation(fc, null,
|
||||
"dialog:editOfflineDialog");
|
||||
}
|
||||
else
|
||||
{
|
||||
FacesContext fc = FacesContext.getCurrentInstance();
|
||||
fc.getApplication().getNavigationHandler().handleNavigation(fc, null,
|
||||
"dialog:close:browse");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
property.setDocument(null);
|
||||
}
|
||||
super.resetState();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checkout document to the same space as original one and then add the
|
||||
* OFFLINE_EDITING property.
|
||||
*/
|
||||
private void checkoutFile(Node node)
|
||||
{
|
||||
if (node != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Trying to checkout content node Id: " + node.getId());
|
||||
NodeRef workingCopyRef = null;
|
||||
// checkout the content to the current space
|
||||
workingCopyRef = property.getVersionOperationsService().checkout(node.getNodeRef());
|
||||
getNodeService().setProperty(workingCopyRef, ContentModel.PROP_WORKING_COPY_MODE,
|
||||
OFFLINE_EDITING);
|
||||
// set the working copy Node instance
|
||||
Node workingCopy = new Node(workingCopyRef);
|
||||
property.setWorkingDocument(workingCopy);
|
||||
|
||||
// create content URL to the content download servlet with ID and
|
||||
// expected filename
|
||||
String url = DownloadContentServlet.generateDownloadURL(workingCopyRef, workingCopy
|
||||
.getName());
|
||||
|
||||
workingCopy.getProperties().put("url", url);
|
||||
workingCopy.getProperties().put("fileType32",
|
||||
Utils.getFileTypeImage(workingCopy.getName(), false));
|
||||
}
|
||||
catch (Throwable err)
|
||||
{
|
||||
Utils.addErrorMessage(Application.getMessage(FacesContext.getCurrentInstance(),
|
||||
MSG_ERROR_CHECKOUT)
|
||||
+ err.getMessage(), err);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.warn("WARNING: checkoutFile called without a current Document!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String cancel()
|
||||
{
|
||||
super.cancel();
|
||||
return "dialog:close:browse";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return userPreferencesBean bean with current user's preferences
|
||||
*/
|
||||
public UserPreferencesBean getUserPreferencesBean()
|
||||
{
|
||||
return userPreferencesBean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param userPreferencesBean bean with current user's preferences to set
|
||||
*/
|
||||
public void setUserPreferencesBean(UserPreferencesBean userPreferencesBean)
|
||||
{
|
||||
this.userPreferencesBean = userPreferencesBean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return continueCountdown
|
||||
*/
|
||||
public boolean isContinueCountdown()
|
||||
{
|
||||
return continueCountdown;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param continueCountdown
|
||||
*/
|
||||
public void setContinueCountdown(boolean continueCountdown)
|
||||
{
|
||||
this.continueCountdown = continueCountdown;
|
||||
}
|
||||
|
||||
}
|
183
source/java/org/alfresco/web/bean/coci/EditOnlineDialog.java
Normal file
183
source/java/org/alfresco/web/bean/coci/EditOnlineDialog.java
Normal file
@@ -0,0 +1,183 @@
|
||||
/*
|
||||
* 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.coci;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.event.ActionEvent;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.ui.common.component.UIActionLink;
|
||||
|
||||
/**
|
||||
* This is fiction dialog class for provides method for online editing. He
|
||||
* doesn't have entry in web-client-config-dialogs.xml
|
||||
*
|
||||
*/
|
||||
public class EditOnlineDialog extends CCCheckoutFileDialog
|
||||
{
|
||||
|
||||
public final static String ONLINE_EDITING = "onlineEditing";
|
||||
|
||||
/**
|
||||
* Action listener for handle webdav online editing action. E.g "edit_doc_online_webdav" action
|
||||
*
|
||||
* @param event ActionEvent
|
||||
*/
|
||||
public void handleWebdavEditing(ActionEvent event)
|
||||
{
|
||||
handle(event);
|
||||
|
||||
Node workingCopyNode = property.getDocument();
|
||||
if (workingCopyNode != null)
|
||||
{
|
||||
UIActionLink link = (UIActionLink) event.getComponent();
|
||||
Map<String, String> params = link.getParameterMap();
|
||||
String webdavUrl = params.get("webdavUrl");
|
||||
|
||||
if (webdavUrl != null)
|
||||
{
|
||||
// modify webDav for editing working copy
|
||||
property.setWebdavUrl(webdavUrl.substring(0, webdavUrl.lastIndexOf("/") + 1) + workingCopyNode.getName());
|
||||
}
|
||||
|
||||
FacesContext fc = FacesContext.getCurrentInstance();
|
||||
|
||||
fc.getApplication().getNavigationHandler().handleNavigation(fc, null,"dialog:close:browse");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Action listener for handle cifs online editing action. E.g "edit_doc_online_cifs" action
|
||||
*
|
||||
* @param event ActionEvent
|
||||
*/
|
||||
public void handleCifsEditing(ActionEvent event)
|
||||
{
|
||||
handle(event);
|
||||
|
||||
Node workingCopyNode = property.getDocument();
|
||||
if (workingCopyNode != null)
|
||||
{
|
||||
UIActionLink link = (UIActionLink) event.getComponent();
|
||||
Map<String, String> params = link.getParameterMap();
|
||||
String cifsPath = params.get("cifsPath");
|
||||
|
||||
if (cifsPath != null)
|
||||
{
|
||||
// modify cifsPath for editing working copy
|
||||
property.setCifsPath(cifsPath.substring(0, cifsPath.lastIndexOf("/") + 1) + workingCopyNode.getName());
|
||||
}
|
||||
|
||||
FacesContext fc = FacesContext.getCurrentInstance();
|
||||
|
||||
fc.getApplication().getNavigationHandler().handleNavigation(fc, null,"dialog:close:browse");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Action listener for handle http online(inline) editing action. E.g "edit_doc_online_http" action
|
||||
*
|
||||
* @param event ActionEvent
|
||||
*/
|
||||
public void handleHttpEditing(ActionEvent event)
|
||||
{
|
||||
handle(event);
|
||||
|
||||
Node workingCopyNode = property.getDocument();
|
||||
if (workingCopyNode != null)
|
||||
{
|
||||
|
||||
ContentReader reader = property.getContentService().getReader(workingCopyNode.getNodeRef(), ContentModel.PROP_CONTENT);
|
||||
if (reader != null)
|
||||
{
|
||||
String mimetype = reader.getMimetype();
|
||||
|
||||
// calculate which editor screen to display
|
||||
if (MimetypeMap.MIMETYPE_TEXT_PLAIN.equals(mimetype) || MimetypeMap.MIMETYPE_XML.equals(mimetype) || MimetypeMap.MIMETYPE_TEXT_CSS.equals(mimetype)
|
||||
|| MimetypeMap.MIMETYPE_JAVASCRIPT.equals(mimetype))
|
||||
{
|
||||
// make content available to the text editing screen
|
||||
property.setEditorOutput(reader.getContentString());
|
||||
|
||||
// navigate to appropriate screen
|
||||
FacesContext fc = FacesContext.getCurrentInstance();
|
||||
fc.getApplication().getNavigationHandler().handleNavigation(fc, null, "dialog:close:browse");
|
||||
this.navigator.setupDispatchContext(workingCopyNode);
|
||||
fc.getApplication().getNavigationHandler().handleNavigation(fc, null, "dialog:editTextInline");
|
||||
}
|
||||
else
|
||||
{
|
||||
// make content available to the html editing screen
|
||||
property.setDocumentContent(reader.getContentString());
|
||||
property.setEditorOutput(null);
|
||||
|
||||
// navigate to appropriate screen
|
||||
FacesContext fc = FacesContext.getCurrentInstance();
|
||||
fc.getApplication().getNavigationHandler().handleNavigation(fc, null, "dialog:close:browse");
|
||||
this.navigator.setupDispatchContext(workingCopyNode);
|
||||
fc.getApplication().getNavigationHandler().handleNavigation(fc, null, "dialog:editHtmlInline");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Base handling method.
|
||||
*
|
||||
* @param event ActionEvent
|
||||
*/
|
||||
public void handle(ActionEvent event)
|
||||
{
|
||||
super.setupContentAction(event);
|
||||
|
||||
Node node = property.getDocument();
|
||||
if (node != null)
|
||||
{
|
||||
// if current content is already working copy then we don't checkout
|
||||
if (node.hasAspect(ContentModel.ASPECT_WORKING_COPY) == false)
|
||||
{
|
||||
// if checkout is successful, then checkoutFile sets property workingDocument
|
||||
checkoutFile(FacesContext.getCurrentInstance(), null);
|
||||
|
||||
Node workingCopyNode = property.getWorkingDocument();
|
||||
|
||||
if (workingCopyNode != null)
|
||||
{
|
||||
// set working copy node as document for editing
|
||||
property.setDocument(workingCopyNode);
|
||||
getNodeService().setProperty(workingCopyNode.getNodeRef(), ContentModel.PROP_WORKING_COPY_MODE, ONLINE_EDITING);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* 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.coci;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.web.app.Application;
|
||||
|
||||
public class UploadNewVersionDialog extends DoneEditingDialog
|
||||
{
|
||||
|
||||
private final static String MSG_UPLOAD_NEW_VERSION = "upload_new_version";
|
||||
private final static String MSG_OF = "of";
|
||||
|
||||
private boolean finishedEditing = false;
|
||||
|
||||
public void setFinishedEditing(boolean finished)
|
||||
{
|
||||
this.finishedEditing = finished;
|
||||
}
|
||||
|
||||
public boolean isFinishedEditing()
|
||||
{
|
||||
return finishedEditing;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getFinishButtonDisabled()
|
||||
{
|
||||
return property.getFile() == null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getContainerTitle()
|
||||
{
|
||||
return Application.getMessage(FacesContext.getCurrentInstance(), MSG_UPLOAD_NEW_VERSION) + " " + Application.getMessage(FacesContext.getCurrentInstance(), MSG_OF) + " '"
|
||||
+ property.getDocument().getName() + "'";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome) throws Exception
|
||||
{
|
||||
property.setKeepCheckedOut(!finishedEditing);
|
||||
return checkinFileOK(context, outcome);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetState()
|
||||
{
|
||||
super.resetState();
|
||||
finishedEditing = false;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user