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:
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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 org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
|
||||
/**
|
||||
* UI Action Evaluator - Cancel editing document.
|
||||
*
|
||||
*/
|
||||
public class CancelEditingDocEvaluator extends BaseActionEvaluator
|
||||
{
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
|
||||
*/
|
||||
public boolean evaluate(Node node)
|
||||
{
|
||||
return (node.hasPermission(PermissionService.CANCEL_CHECK_OUT) &&
|
||||
node.hasAspect(ContentModel.ASPECT_WORKING_COPY));
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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 org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
|
||||
/**
|
||||
* UI Action Evaluator - Done editing document.
|
||||
*
|
||||
*/
|
||||
public class DoneEditingDocEvaluator extends BaseActionEvaluator
|
||||
{
|
||||
/**
|
||||
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
|
||||
*/
|
||||
public boolean evaluate(Node node)
|
||||
{
|
||||
return (node.hasPermission(PermissionService.CHECK_IN) &&
|
||||
node.hasAspect(ContentModel.ASPECT_WORKING_COPY) == true);
|
||||
}
|
||||
}
|
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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.model.ContentModel;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
|
||||
public class DownloadEvaluator extends BaseActionEvaluator
|
||||
{
|
||||
/**
|
||||
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
|
||||
*/
|
||||
public boolean evaluate(Node node)
|
||||
{
|
||||
FacesContext fc = FacesContext.getCurrentInstance();
|
||||
DictionaryService dd = Repository.getServiceRegistry(fc).getDictionaryService();
|
||||
|
||||
if (dd.isSubClass(node.getType(), ContentModel.TYPE_CONTENT))
|
||||
{
|
||||
return !node.isLocked();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -31,6 +31,7 @@ import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.coci.EditOnlineDialog;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
|
||||
@@ -59,7 +60,8 @@ public class EditDocCIFSEvaluator extends BaseActionEvaluator
|
||||
if (node.hasAspect(ApplicationModel.ASPECT_INLINEEDITABLE) == false &&
|
||||
"cifs".equals(Application.getClientConfig(fc).getEditLinkType()))
|
||||
{
|
||||
if (node.isWorkingCopyOwner() == true ||
|
||||
if ((node.isWorkingCopyOwner() == true && node.getProperties().get(ContentModel.PROP_WORKING_COPY_MODE) != null &&
|
||||
node.getProperties().get(ContentModel.PROP_WORKING_COPY_MODE).equals(EditOnlineDialog.ONLINE_EDITING))||
|
||||
(node.hasAspect(ContentModel.ASPECT_WORKING_COPY) && node.hasPermission(PermissionService.WRITE)) ||
|
||||
(node.isLocked() == false && node.hasAspect(ContentModel.ASPECT_WORKING_COPY) == false))
|
||||
{
|
||||
|
@@ -31,6 +31,7 @@ import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.coci.EditOnlineDialog;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
|
||||
@@ -63,10 +64,12 @@ public class EditDocHttpEvaluator extends BaseActionEvaluator
|
||||
// always be used otherwise the configured approach is used
|
||||
else if (dd.isSubClass(node.getType(), ContentModel.TYPE_CONTENT))
|
||||
{
|
||||
if (node.hasAspect(ApplicationModel.ASPECT_INLINEEDITABLE) == true ||
|
||||
"http".equals(Application.getClientConfig(fc).getEditLinkType()))
|
||||
if (node.hasAspect(ApplicationModel.ASPECT_INLINEEDITABLE) == true &&
|
||||
node.getProperties().get(ApplicationModel.PROP_EDITINLINE) != null &&
|
||||
((Boolean)node.getProperties().get(ApplicationModel.PROP_EDITINLINE)).booleanValue() == true)
|
||||
{
|
||||
if (node.isWorkingCopyOwner() == true ||
|
||||
if ((node.isWorkingCopyOwner() == true && node.getProperties().get(ContentModel.PROP_WORKING_COPY_MODE) != null &&
|
||||
node.getProperties().get(ContentModel.PROP_WORKING_COPY_MODE).equals(EditOnlineDialog.ONLINE_EDITING)) ||
|
||||
(node.hasAspect(ContentModel.ASPECT_WORKING_COPY) && node.hasPermission(PermissionService.WRITE)) ||
|
||||
(node.isLocked() == false && node.hasAspect(ContentModel.ASPECT_WORKING_COPY) == false))
|
||||
{
|
||||
|
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
|
||||
/**
|
||||
* UI Action Evaluator - Offline Document Editing.
|
||||
*/
|
||||
public class EditDocOfflineEvaluator extends CheckoutDocEvaluator
|
||||
{
|
||||
}
|
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* 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 java.util.Map;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.model.ApplicationModel;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.coci.EditOnlineDialog;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
|
||||
/**
|
||||
* UI Action Evaluator - Edit document online via CIFS.
|
||||
*
|
||||
*/
|
||||
public class EditDocOnlineCIFSEvaluator extends CheckoutDocEvaluator
|
||||
{
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
|
||||
*/
|
||||
public boolean evaluate(Node node)
|
||||
{
|
||||
FacesContext fc = FacesContext.getCurrentInstance();
|
||||
DictionaryService dd = Repository.getServiceRegistry(fc).getDictionaryService();
|
||||
|
||||
boolean result = false;
|
||||
|
||||
// if the node is inline editable, the inline online editing should always be used
|
||||
if (dd.isSubClass(node.getType(), ContentModel.TYPE_CONTENT))
|
||||
{
|
||||
Map<String, Object> props = node.getProperties();
|
||||
if ((node.hasAspect(ApplicationModel.ASPECT_INLINEEDITABLE) == false || props.get(ApplicationModel.PROP_EDITINLINE) == null ||
|
||||
((Boolean)props.get(ApplicationModel.PROP_EDITINLINE)).booleanValue() == false) && "cifs".equals(Application.getClientConfig(fc).getEditLinkType()))
|
||||
{
|
||||
if (node.hasAspect(ContentModel.ASPECT_WORKING_COPY))
|
||||
{
|
||||
if (props.get(ContentModel.PROP_WORKING_COPY_MODE) != null && props.get(ContentModel.PROP_WORKING_COPY_MODE).equals(EditOnlineDialog.ONLINE_EDITING))
|
||||
result = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = super.evaluate(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* 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 java.util.Map;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.model.ApplicationModel;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.web.bean.coci.EditOnlineDialog;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
|
||||
/**
|
||||
* UI Action Evaluator - Edit document online via http.
|
||||
*
|
||||
*/
|
||||
public class EditDocOnlineHttpEvaluator extends CheckoutDocEvaluator
|
||||
{
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
|
||||
*/
|
||||
public boolean evaluate(Node node)
|
||||
{
|
||||
FacesContext fc = FacesContext.getCurrentInstance();
|
||||
DictionaryService dd = Repository.getServiceRegistry(fc).getDictionaryService();
|
||||
|
||||
boolean result = false;
|
||||
|
||||
if(node.hasAspect(ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION))
|
||||
{
|
||||
// this branch from EditDocHttpEvaluator
|
||||
// skip, result = false
|
||||
}
|
||||
else if (dd.isSubClass(node.getType(), ContentModel.TYPE_CONTENT))
|
||||
{
|
||||
Map<String, Object> props = node.getProperties();
|
||||
if ((node.hasAspect(ApplicationModel.ASPECT_INLINEEDITABLE) &&
|
||||
props.get(ApplicationModel.PROP_EDITINLINE) != null &&
|
||||
((Boolean)props.get(ApplicationModel.PROP_EDITINLINE)).booleanValue() == true))
|
||||
{
|
||||
if (node.hasAspect(ContentModel.ASPECT_WORKING_COPY))
|
||||
{
|
||||
if (props.get(ContentModel.PROP_WORKING_COPY_MODE) != null && props.get(ContentModel.PROP_WORKING_COPY_MODE).equals(EditOnlineDialog.ONLINE_EDITING))
|
||||
result = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = super.evaluate(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* 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 java.util.Map;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.model.ApplicationModel;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.coci.EditOfflineDialog;
|
||||
import org.alfresco.web.bean.coci.EditOnlineDialog;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
|
||||
/**
|
||||
* UI Action Evaluator - Edit document online via WebDav.
|
||||
*
|
||||
*/
|
||||
public class EditDocOnlineWebDavEvaluator extends CheckoutDocEvaluator
|
||||
{
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
|
||||
*/
|
||||
public boolean evaluate(Node node)
|
||||
{
|
||||
FacesContext fc = FacesContext.getCurrentInstance();
|
||||
DictionaryService dd = Repository.getServiceRegistry(fc).getDictionaryService();
|
||||
|
||||
boolean result = false;
|
||||
|
||||
// if the node is inline editable, the inline online editing should always be used
|
||||
if (dd.isSubClass(node.getType(), ContentModel.TYPE_CONTENT))
|
||||
{
|
||||
Map<String, Object> props = node.getProperties();
|
||||
|
||||
if ((node.hasAspect(ApplicationModel.ASPECT_INLINEEDITABLE) == false || props.get(ApplicationModel.PROP_EDITINLINE) == null ||
|
||||
((Boolean)props.get(ApplicationModel.PROP_EDITINLINE)).booleanValue() == false) && "webdav".equals(Application.getClientConfig(fc).getEditLinkType()))
|
||||
{
|
||||
if (node.hasAspect(ContentModel.ASPECT_WORKING_COPY))
|
||||
{
|
||||
if (props.get(ContentModel.PROP_WORKING_COPY_MODE) != null && props.get(ContentModel.PROP_WORKING_COPY_MODE).equals(EditOnlineDialog.ONLINE_EDITING))
|
||||
result = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = super.evaluate(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@@ -31,6 +31,7 @@ import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.bean.coci.EditOnlineDialog;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
|
||||
@@ -59,7 +60,7 @@ public class EditDocWebDavEvaluator extends BaseActionEvaluator
|
||||
if (node.hasAspect(ApplicationModel.ASPECT_INLINEEDITABLE) == false &&
|
||||
"webdav".equals(Application.getClientConfig(fc).getEditLinkType()))
|
||||
{
|
||||
if (node.isWorkingCopyOwner() == true ||
|
||||
if ((node.isWorkingCopyOwner() == true && node.getProperties().get(ContentModel.PROP_WORKING_COPY_MODE).equals(EditOnlineDialog.ONLINE_EDITING)) ||
|
||||
(node.hasAspect(ContentModel.ASPECT_WORKING_COPY) && node.hasPermission(PermissionService.WRITE)) ||
|
||||
(node.isLocked() == false && node.hasAspect(ContentModel.ASPECT_WORKING_COPY) == false))
|
||||
{
|
||||
|
@@ -24,10 +24,13 @@
|
||||
*/
|
||||
package org.alfresco.web.action.evaluator;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.web.bean.coci.EditOfflineDialog;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
|
||||
@@ -47,10 +50,13 @@ public class UpdateDocEvaluator extends BaseActionEvaluator
|
||||
{
|
||||
DictionaryService dd = Repository.getServiceRegistry(
|
||||
FacesContext.getCurrentInstance()).getDictionaryService();
|
||||
|
||||
Map<String, Object> props = node.getProperties();
|
||||
|
||||
boolean isOfflineEditing = props.get(ContentModel.PROP_WORKING_COPY_MODE) != null && props.get(ContentModel.PROP_WORKING_COPY_MODE).equals(EditOfflineDialog.OFFLINE_EDITING);
|
||||
|
||||
return dd.isSubClass(node.getType(), ContentModel.TYPE_CONTENT) &&
|
||||
((node.isWorkingCopyOwner() == true ||
|
||||
(node.isLocked() == false &&
|
||||
node.hasAspect(ContentModel.ASPECT_WORKING_COPY) == false)));
|
||||
((node.isWorkingCopyOwner() == true && !isOfflineEditing) ||
|
||||
(node.isLocked() == false && node.hasAspect(ContentModel.ASPECT_WORKING_COPY) == false));
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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 java.util.Map;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.web.bean.coci.EditOfflineDialog;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
|
||||
/**
|
||||
* UI Action Evaluator - Upload new version
|
||||
*
|
||||
*/
|
||||
public class UploadNewVersionEvaluator extends BaseActionEvaluator
|
||||
{
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
|
||||
*/
|
||||
public boolean evaluate(Node node)
|
||||
{
|
||||
Map<String, Object> props = node.getProperties();
|
||||
|
||||
return (node.hasPermission(PermissionService.CHECK_IN) && node.hasAspect(ContentModel.ASPECT_WORKING_COPY) == true &&
|
||||
props.get(ContentModel.PROP_WORKING_COPY_MODE) != null && props.get(ContentModel.PROP_WORKING_COPY_MODE).equals(EditOfflineDialog.OFFLINE_EDITING));
|
||||
}
|
||||
|
||||
}
|
@@ -1699,7 +1699,7 @@ public class BrowseBean implements IContextListener, Serializable
|
||||
{
|
||||
// create the node ref, then our node representation
|
||||
NodeRef ref = new NodeRef(Repository.getStoreRef(), id);
|
||||
Node node = new Node(ref);
|
||||
Node node = new MapNode(ref);
|
||||
|
||||
// store the URL to for downloading the content
|
||||
if (ApplicationModel.TYPE_FILELINK.equals(node.getType()))
|
||||
@@ -1710,6 +1710,8 @@ public class BrowseBean implements IContextListener, Serializable
|
||||
{
|
||||
node.addPropertyResolver("url", this.resolverDownload);
|
||||
}
|
||||
node.addPropertyResolver("webdavUrl", this.resolverWebdavUrl);
|
||||
node.addPropertyResolver("cifsPath", this.resolverCifsPath);
|
||||
node.addPropertyResolver("fileType32", this.resolverFileType32);
|
||||
node.addPropertyResolver("mimetype", this.resolverMimetype);
|
||||
node.addPropertyResolver("encoding", this.resolverEncoding);
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
}
|
@@ -1,208 +1,222 @@
|
||||
/*
|
||||
* 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.repository;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* Lighweight client side representation of a node held in the repository, which
|
||||
* is modelled as a map for use in the data tables.
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class MapNode extends Node implements Map<String, Object>
|
||||
{
|
||||
private static final long serialVersionUID = 4051322327734433079L;
|
||||
|
||||
private boolean propsInitialised = false;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param nodeRef The NodeRef this Node wrapper represents
|
||||
*/
|
||||
public MapNode(NodeRef nodeRef)
|
||||
{
|
||||
super(nodeRef);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param nodeRef The NodeRef this Node wrapper represents
|
||||
* @param nodeService The node service to use to retrieve data for this node
|
||||
* @param initProps True to immediately init the properties of the node, false to do nothing
|
||||
*/
|
||||
public MapNode(NodeRef nodeRef, NodeService nodeService, boolean initProps)
|
||||
{
|
||||
super(nodeRef);
|
||||
if (initProps == true)
|
||||
{
|
||||
getProperties();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param nodeRef The NodeRef this Node wrapper represents
|
||||
* @param nodeService The node service to use to retrieve data for this node
|
||||
* @param props The properties of the node, already retrieved from NodeService
|
||||
*/
|
||||
public MapNode(NodeRef nodeRef, NodeService nodeService, Map<QName, Serializable> props)
|
||||
{
|
||||
super(nodeRef);
|
||||
|
||||
for (QName qname: props.keySet())
|
||||
{
|
||||
Serializable propValue = props.get(qname);
|
||||
this.properties.put(qname.toString(), propValue);
|
||||
}
|
||||
this.propsRetrieved = true;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Map implementation - allows the Node bean to be accessed using JSF expression syntax
|
||||
|
||||
/**
|
||||
* @see java.util.Map#clear()
|
||||
*/
|
||||
public void clear()
|
||||
{
|
||||
getProperties().clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.util.Map#containsKey(java.lang.Object)
|
||||
*/
|
||||
public boolean containsKey(Object key)
|
||||
{
|
||||
return getProperties().containsKey(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.util.Map#containsValue(java.lang.Object)
|
||||
*/
|
||||
public boolean containsValue(Object value)
|
||||
{
|
||||
return getProperties().containsKey(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.util.Map#entrySet()
|
||||
*/
|
||||
public Set entrySet()
|
||||
{
|
||||
return getProperties().entrySet();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.util.Map#get(java.lang.Object)
|
||||
*/
|
||||
public Object get(Object key)
|
||||
{
|
||||
Object obj = null;
|
||||
|
||||
// there are some things that aren't available as properties
|
||||
// but from method calls, so for these handle them individually
|
||||
Map<String, Object> props = getProperties();
|
||||
if (propsInitialised == false)
|
||||
{
|
||||
// well known properties required as publically accessable map attributes
|
||||
props.put("id", this.getId());
|
||||
props.put("name", this.getName()); // TODO: perf test pulling back single prop here instead of all!
|
||||
props.put("nodeRef", this.getNodeRef());
|
||||
|
||||
propsInitialised = true;
|
||||
}
|
||||
|
||||
return props.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.util.Map#isEmpty()
|
||||
*/
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return getProperties().isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.util.Map#keySet()
|
||||
*/
|
||||
public Set keySet()
|
||||
{
|
||||
return getProperties().keySet();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.util.Map#put(java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
public Object put(String key, Object value)
|
||||
{
|
||||
return getProperties().put(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.util.Map#putAll(java.util.Map)
|
||||
*/
|
||||
public void putAll(Map t)
|
||||
{
|
||||
getProperties().putAll(t);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.util.Map#remove(java.lang.Object)
|
||||
*/
|
||||
public Object remove(Object key)
|
||||
{
|
||||
return getProperties().remove(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.util.Map#size()
|
||||
*/
|
||||
public int size()
|
||||
{
|
||||
return getProperties().size();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.util.Map#values()
|
||||
*/
|
||||
public Collection values()
|
||||
{
|
||||
return getProperties().values();
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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.repository;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* Lighweight client side representation of a node held in the repository, which
|
||||
* is modelled as a map for use in the data tables.
|
||||
*
|
||||
* @author gavinc
|
||||
*/
|
||||
public class MapNode extends Node implements Map<String, Object>
|
||||
{
|
||||
private static final long serialVersionUID = 4051322327734433079L;
|
||||
|
||||
private boolean propsInitialised = false;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param nodeRef The NodeRef this Node wrapper represents
|
||||
*/
|
||||
public MapNode(NodeRef nodeRef)
|
||||
{
|
||||
super(nodeRef);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param nodeRef The NodeRef this Node wrapper represents
|
||||
* @param nodeService The node service to use to retrieve data for this node
|
||||
* @param initProps True to immediately init the properties of the node, false to do nothing
|
||||
*/
|
||||
public MapNode(NodeRef nodeRef, NodeService nodeService, boolean initProps)
|
||||
{
|
||||
super(nodeRef);
|
||||
if (initProps == true)
|
||||
{
|
||||
getProperties();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param nodeRef The NodeRef this Node wrapper represents
|
||||
* @param nodeService The node service to use to retrieve data for this node
|
||||
* @param props The properties of the node, already retrieved from NodeService
|
||||
*/
|
||||
public MapNode(NodeRef nodeRef, NodeService nodeService, Map<QName, Serializable> props)
|
||||
{
|
||||
super(nodeRef);
|
||||
|
||||
for (QName qname: props.keySet())
|
||||
{
|
||||
Serializable propValue = props.get(qname);
|
||||
this.properties.put(qname.toString(), propValue);
|
||||
}
|
||||
this.propsRetrieved = true;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Map implementation - allows the Node bean to be accessed using JSF expression syntax
|
||||
|
||||
/**
|
||||
* @see java.util.Map#clear()
|
||||
*/
|
||||
public void clear()
|
||||
{
|
||||
getProperties().clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.util.Map#containsKey(java.lang.Object)
|
||||
*/
|
||||
public boolean containsKey(Object key)
|
||||
{
|
||||
return getProperties().containsKey(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.util.Map#containsValue(java.lang.Object)
|
||||
*/
|
||||
public boolean containsValue(Object value)
|
||||
{
|
||||
return getProperties().containsKey(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.util.Map#entrySet()
|
||||
*/
|
||||
public Set entrySet()
|
||||
{
|
||||
return getProperties().entrySet();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.util.Map#get(java.lang.Object)
|
||||
*/
|
||||
public Object get(Object key)
|
||||
{
|
||||
Object obj = null;
|
||||
|
||||
// there are some things that aren't available as properties
|
||||
// but from method calls, so for these handle them individually
|
||||
Map<String, Object> props = getProperties();
|
||||
if (propsInitialised == false)
|
||||
{
|
||||
// well known properties required as publically accessable map attributes
|
||||
props.put("id", this.getId());
|
||||
props.put("name", this.getName()); // TODO: perf test pulling back single prop here instead of all!
|
||||
props.put("nodeRef", this.getNodeRef());
|
||||
|
||||
propsInitialised = true;
|
||||
}
|
||||
|
||||
if (key.equals("properties"))
|
||||
{
|
||||
return props;
|
||||
}
|
||||
else
|
||||
{
|
||||
return props.get(key);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.util.Map#isEmpty()
|
||||
*/
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return getProperties().isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.util.Map#keySet()
|
||||
*/
|
||||
public Set keySet()
|
||||
{
|
||||
return getProperties().keySet();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.util.Map#put(java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
public Object put(String key, Object value)
|
||||
{
|
||||
return getProperties().put(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.util.Map#putAll(java.util.Map)
|
||||
*/
|
||||
public void putAll(Map t)
|
||||
{
|
||||
getProperties().putAll(t);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.util.Map#remove(java.lang.Object)
|
||||
*/
|
||||
public Object remove(Object key)
|
||||
{
|
||||
return getProperties().remove(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.util.Map#size()
|
||||
*/
|
||||
public int size()
|
||||
{
|
||||
return getProperties().size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset()
|
||||
{
|
||||
super.reset();
|
||||
propsInitialised = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.util.Map#values()
|
||||
*/
|
||||
public Collection values()
|
||||
{
|
||||
return getProperties().values();
|
||||
}
|
||||
}
|
||||
|
@@ -56,9 +56,11 @@ public class UserPreferencesBean implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = -1262481849503163054L;
|
||||
|
||||
public static final String PREF_INTERFACELANGUAGE = "interface-language";
|
||||
|
||||
private static final String PREF_STARTLOCATION = "start-location";
|
||||
private static final String PREF_CONTENTFILTERLANGUAGE = "content-filter-language";
|
||||
public static final String PREF_INTERFACELANGUAGE = "interface-language";
|
||||
private static final String PREF_DOWNLOADAUTOMATICALLY = "download-automatically";
|
||||
|
||||
/**
|
||||
* Remplacement message for set the filter at 'all languages'.
|
||||
@@ -388,4 +390,28 @@ public class UserPreferencesBean implements Serializable
|
||||
}
|
||||
return contentFilterLanguagesService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return download files automatically for offline editing or not
|
||||
*/
|
||||
public boolean isDownloadAutomatically()
|
||||
{
|
||||
Boolean downloadAutomatically = (Boolean) PreferencesService.getPreferences().getValue(PREF_DOWNLOADAUTOMATICALLY);
|
||||
if (downloadAutomatically == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return downloadAutomatically.booleanValue();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param downloadAutomatically the boolean value to set
|
||||
*/
|
||||
public void setDownloadAutomatically(boolean downloadAutomatically)
|
||||
{
|
||||
PreferencesService.getPreferences().setValue(PREF_DOWNLOADAUTOMATICALLY, downloadAutomatically);
|
||||
}
|
||||
}
|
||||
|
@@ -27,11 +27,14 @@ package org.alfresco.web.ui.repo.tag;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.jsp.JspException;
|
||||
import javax.servlet.jsp.tagext.TagSupport;
|
||||
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.alfresco.web.bean.coci.CCProperties;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
@@ -57,6 +60,8 @@ public class PageTag extends TagSupport
|
||||
"/scripts/menu.js",
|
||||
// webdav javascript
|
||||
"/scripts/webdav.js",
|
||||
// functional for window.onload
|
||||
"/scripts/onload.js",
|
||||
// base yahoo file
|
||||
"/scripts/ajax/yahoo/yahoo/yahoo-min.js",
|
||||
// io handling (AJAX)
|
||||
@@ -268,11 +273,17 @@ public class PageTag extends TagSupport
|
||||
out.write(SCRIPTS_END);
|
||||
}
|
||||
|
||||
out.write("<script type=\"text/javascript\">"); // start - generate naked javascript code
|
||||
|
||||
// set the context path used by some Alfresco script objects
|
||||
out.write("<script type=\"text/javascript\">");
|
||||
out.write("setContextPath('");
|
||||
out.write(reqPath);
|
||||
out.write("');</script>\n");
|
||||
out.write("');");
|
||||
|
||||
// generate window onload code
|
||||
out.write(getWindowOnloadCode());
|
||||
|
||||
out.write("</script>\n"); // end - generate naked javascript code
|
||||
|
||||
if (!Application.inPortalServer())
|
||||
{
|
||||
@@ -352,4 +363,29 @@ public class PageTag extends TagSupport
|
||||
}
|
||||
return PageTag.alfresco;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method generate code for setting window.onload reference if we need (we need to open WebDav or Cifs url or may be else)
|
||||
* Using javascript code(function onloadFunc) from onload.js file
|
||||
* @return Returns window.onload javascript code
|
||||
*/
|
||||
private String getWindowOnloadCode()
|
||||
{
|
||||
CCProperties ccProps = (CCProperties) FacesHelper.getManagedBean(FacesContext.getCurrentInstance(), "CCProperties");
|
||||
|
||||
StringBuffer onloadCode = new StringBuffer();
|
||||
if (ccProps.getWebdavUrl() != null || ccProps.getCifsPath() != null)
|
||||
{
|
||||
String webdavUrl = (ccProps.getWebdavUrl() != null) ? (ccProps.getWebdavUrl()) : ("");
|
||||
String cifsPath = (ccProps.getCifsPath() != null) ? (ccProps.getCifsPath()) : ("");
|
||||
|
||||
onloadCode.append("window.onload=onloadFunc('").append(webdavUrl).append("','").append(cifsPath).append("');");
|
||||
|
||||
ccProps.setCifsPath(null); // we need reset cifsPath flag
|
||||
ccProps.setWebdavUrl(null); // we need reset webdavUrl flag
|
||||
}
|
||||
|
||||
return onloadCode.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user