Index: .classpath =================================================================== --- .classpath (revision 0) +++ .classpath (revision 0) @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Index: .project =================================================================== --- .project (revision 0) +++ .project (revision 0) @@ -0,0 +1,23 @@ + + + plugin explorer + + + + + + org.eclipse.jdt.core.javabuilder + + + + + com.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder + + + + + + org.eclipse.jdt.core.javanature + com.atlassw.tools.eclipse.checkstyle.CheckstyleNature + + Index: .settings/org.eclipse.jdt.core.prefs =================================================================== --- .settings/org.eclipse.jdt.core.prefs (revision 0) +++ .settings/org.eclipse.jdt.core.prefs (revision 0) @@ -0,0 +1,12 @@ +#Tue Mar 02 11:21:55 CET 2010 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 Index: .checkstyle =================================================================== --- .checkstyle (revision 0) +++ .checkstyle (revision 0) @@ -0,0 +1,9 @@ + + + + + + + + + Index: main/plugin-explorer/sitemap.xmap =================================================================== --- main/plugin-explorer/sitemap.xmap (revision 2900) +++ main/plugin-explorer/sitemap.xmap (working copy) @@ -19,6 +19,7 @@ + @@ -91,6 +92,17 @@ + + + + + + + + + + + Index: main/plugin-explorer/i18n/messages_fr.xml =================================================================== --- main/plugin-explorer/i18n/messages_fr.xml (revision 2900) +++ main/plugin-explorer/i18n/messages_fr.xml (working copy) @@ -92,6 +92,13 @@ Passe en mode de vue détaillée + Ajout des identifiants de connexion + URL + Nom utilisateur + Mot de passe + Paramètres manquants + Merci de renseigner tous les champs. + Nouveau dossier Nouveau dossier Nom Index: main/plugin-explorer/i18n/messages_en.xml =================================================================== --- main/plugin-explorer/i18n/messages_en.xml (revision 2900) +++ main/plugin-explorer/i18n/messages_en.xml (working copy) @@ -92,6 +92,14 @@ Switchs to detailed view + Add the connection IDs + URL + User + Password + Missing Parameters + Please fill in all fields + + New folder New folder Name Index: main/plugin-explorer/src/org/ametys/plugins/explorer/resources/generators/ResourcesExplorerGenerator.java =================================================================== --- main/plugin-explorer/src/org/ametys/plugins/explorer/resources/generators/ResourcesExplorerGenerator.java (revision 2900) +++ main/plugin-explorer/src/org/ametys/plugins/explorer/resources/generators/ResourcesExplorerGenerator.java (working copy) @@ -28,10 +28,12 @@ import org.xml.sax.SAXException; import org.ametys.plugins.explorer.ExplorerNode; +import org.ametys.plugins.explorer.resources.ModifiableResource; import org.ametys.plugins.explorer.resources.Resource; import org.ametys.plugins.repository.AmetysObject; import org.ametys.plugins.repository.AmetysObjectIterable; import org.ametys.plugins.repository.AmetysObjectResolver; +import org.ametys.plugins.repository.ModifiableAmetysObject; import org.ametys.plugins.repository.TraversableAmetysObject; import org.ametys.runtime.user.User; import org.ametys.runtime.user.UsersManager; @@ -111,6 +113,16 @@ childAtts.addCDATAAttribute("name", node.getName()); childAtts.addCDATAAttribute("icon", node.getIcon()); childAtts.addCDATAAttribute("applicationId", node.getApplicationId()); + + if (node instanceof ModifiableAmetysObject) + { + childAtts.addCDATAAttribute("isModifiable", "true"); + } + else + { + childAtts.addCDATAAttribute("isModifiable", "false"); + } + boolean hasChildNodes = false; boolean hasResources = false; @@ -158,6 +170,16 @@ childAtts.addCDATAAttribute("size", String.valueOf(resource.getLength())); childAtts.addCDATAAttribute("author", name); childAtts.addCDATAAttribute("keywords", resource.getKeywordsAsString()); + + if (resource instanceof ModifiableResource) + { + childAtts.addCDATAAttribute("isModifiable", "true"); + } + else + { + childAtts.addCDATAAttribute("isModifiable", "false"); + } + XMLUtils.createElement(contentHandler, "Node", childAtts); } } Index: main/plugin-explorer/src/org/ametys/plugins/explorer/resources/actions/AddCMISCollectionAction.java =================================================================== --- main/plugin-explorer/src/org/ametys/plugins/explorer/resources/actions/AddCMISCollectionAction.java (revision 0) +++ main/plugin-explorer/src/org/ametys/plugins/explorer/resources/actions/AddCMISCollectionAction.java (revision 0) @@ -0,0 +1,106 @@ +package org.ametys.plugins.explorer.resources.actions; + +import java.util.HashMap; +import java.util.Map; + +import org.apache.avalon.framework.parameters.Parameters; +import org.apache.avalon.framework.service.ServiceException; +import org.apache.avalon.framework.service.ServiceManager; +import org.apache.cocoon.acting.ServiceableAction; +import org.apache.cocoon.environment.ObjectModelHelper; +import org.apache.cocoon.environment.Redirector; +import org.apache.cocoon.environment.Request; +import org.apache.cocoon.environment.SourceResolver; +import org.apache.commons.lang.IllegalClassException; +import org.apache.jackrabbit.util.Text; + +import org.ametys.plugins.explorer.cmis.CMISRootResourcesCollection; +import org.ametys.plugins.explorer.cmis.CMISTreeFactory; +import org.ametys.plugins.explorer.observation.ExplorerEvent; +import org.ametys.plugins.explorer.observation.ExplorerObservationManager; +import org.ametys.plugins.explorer.observation.ExplorerEvent.EventType; +import org.ametys.plugins.repository.AmetysObject; +import org.ametys.plugins.repository.AmetysObjectResolver; +import org.ametys.plugins.repository.ModifiableTraversableAmetysObject; +import org.ametys.runtime.user.CurrentUserProvider; + +/** + * Action for adding a CMIS resource collection. + * + */ +public class AddCMISCollectionAction extends ServiceableAction +{ + private AmetysObjectResolver _resolver; + private CurrentUserProvider _userProvider; + private ExplorerObservationManager _obsManager; + + @Override + public void service(ServiceManager sManager) throws ServiceException + { + super.service(sManager); + + _resolver = (AmetysObjectResolver) sManager.lookup(AmetysObjectResolver.ROLE); + _userProvider = (CurrentUserProvider) sManager.lookup(CurrentUserProvider.ROLE); + _obsManager = (ExplorerObservationManager) sManager.lookup(ExplorerObservationManager.ROLE); + } + + @Override + public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters parameters) throws Exception + { + Request request = ObjectModelHelper.getRequest(objectModel); + Map result = new HashMap(); + + String id = request.getParameter("id"); + String originalName = request.getParameter("name"); + + String url = request.getParameter("url"); + String user = request.getParameter("user"); + String password = request.getParameter("pwd"); + + boolean renameIfExists = request.getParameter("renameIfExists") == null ? false : Boolean.valueOf(request.getParameter("renameIfExists")); + assert id != null; + + String legalName = Text.escapeIllegalJcrChars(originalName); + + AmetysObject object = _resolver.resolveById(id); + if (!(object instanceof ModifiableTraversableAmetysObject)) + { + throw new IllegalClassException(ModifiableTraversableAmetysObject.class, object.getClass()); + } + + ModifiableTraversableAmetysObject collection = (ModifiableTraversableAmetysObject) object; + if (!renameIfExists && collection.hasChild(legalName)) + { + getLogger().warn("The object '" + object.getName() + "' can not be renamed in '" + originalName + "' : a object of same name already exists."); + result.put("message", "already-exist"); + return result; + } + + int index = 1; + while (collection.hasChild(legalName)) + { + legalName = Text.escapeIllegalJcrChars(originalName + " (" + index + ")"); + index++; + } + + CMISRootResourcesCollection child = collection.createChild(legalName, CMISTreeFactory.RESOURCESCOLLECTION_NODETYPE); + child.setCMISURL(url); + child.setUser(user); + child.setPassword(password); + child.saveChanges(); + + result.put("id", child.getId()); + result.put("parentID", id); + result.put("name", legalName); + + // Notify listeners + Map eventParams = new HashMap(); + eventParams.put("parentID", object.getId()); + eventParams.put("name", child.getName()); + eventParams.put("path", child.getPath()); + _obsManager.notifyEvent(new ExplorerEvent (EventType.COLLECTION_CREATE, _userProvider.getUser(), child.getId(), eventParams)); + + return result; + } + +} Index: main/plugin-explorer/src/org/ametys/plugins/explorer/ExplorerNodeGenerator.java =================================================================== --- main/plugin-explorer/src/org/ametys/plugins/explorer/ExplorerNodeGenerator.java (revision 2900) +++ main/plugin-explorer/src/org/ametys/plugins/explorer/ExplorerNodeGenerator.java (working copy) @@ -27,6 +27,7 @@ import org.ametys.plugins.explorer.resources.generators.ResourcesExplorerGenerator; import org.ametys.plugins.repository.AmetysObject; import org.ametys.plugins.repository.AmetysObjectIterable; +import org.ametys.plugins.repository.ModifiableAmetysObject; import org.ametys.plugins.repository.TraversableAmetysObject; /** @@ -86,6 +87,16 @@ childAtts.addCDATAAttribute("icon", node.getIcon()); childAtts.addCDATAAttribute("applicationId", node.getApplicationId()); + if (node instanceof ModifiableAmetysObject) + { + childAtts.addCDATAAttribute("isModifiable", "true"); + } + else + { + childAtts.addCDATAAttribute("isModifiable", "false"); + } + + boolean hasChild = false; for (AmetysObject child : ((TraversableAmetysObject) node).getChildren()) Index: main/plugin-explorer/plugin.xml =================================================================== --- main/plugin-explorer/plugin.xml (revision 2900) +++ main/plugin-explorer/plugin.xml (working copy) @@ -51,6 +51,15 @@ resource ametys:resource + + + cmis-root-collection + ametys:cmis-root-collection + resources_nodetypes.xml + + Index: main/plugin-explorer/resources/js/org/ametys/explorer/ResourcesExplorer.i18n.js =================================================================== --- main/plugin-explorer/resources/js/org/ametys/explorer/ResourcesExplorer.i18n.js (revision 2900) +++ main/plugin-explorer/resources/js/org/ametys/explorer/ResourcesExplorer.i18n.js (working copy) @@ -554,7 +554,7 @@ var appId = node.attributes.applicationId; if (this._applications[appId]) { - this._applications[appId].execCommand ('updateToolbar', {'id': node.id}); + this._applications[appId].execCommand ('updateToolbar', {'id': node.id, 'isModifiable': node.attributes['isModifiable']}); } } } @@ -607,7 +607,7 @@ var appId = node.attributes.applicationId; if (this._applications[appId]) { - this._applications[appId].execCommand ('updateToolbar', {'id': node.id, 'files': records}); + this._applications[appId].execCommand ('updateToolbar', {'id': node.id, 'files': records, 'isModifiable': node.attributes['isModifiable']}); } } } Index: main/plugin-explorer/resources/js/org/ametys/explorer/applications/resources/ResourcesActions.i18n.js =================================================================== --- main/plugin-explorer/resources/js/org/ametys/explorer/applications/resources/ResourcesActions.i18n.js (revision 2900) +++ main/plugin-explorer/resources/js/org/ametys/explorer/applications/resources/ResourcesActions.i18n.js (working copy) @@ -15,6 +15,7 @@ */ Ext.namespace('org.ametys.explorer.applications.resources'); +Ext.namespace('org.ametys.explorer.applications.resources.Folder.addCMIS'); Ext.namespace('org.ametys.explorer.applications.resources.Folder.add'); Ext.namespace('org.ametys.explorer.applications.resources.Folder.rename'); Ext.namespace('org.ametys.explorer.applications.resources.Folder.remove'); @@ -29,6 +30,50 @@ Ext.namespace('org.ametys.explorer.applications.resources.File.download'); /*------------------------------------------------------------------------*/ /** + * Create a new CMIS server + * @param {String} parentID The parent folder id + * @param {String} name The new folder name + * @param {function} callback The call back function + */ +org.ametys.explorer.applications.resources.Folder.addCMIS = function (parentID, name, callback, paramCon) +{ + // Appel Ajax + var params = {}; + params.id = parentID; + params.name = name; + params.renameIfExists = true; + params.url = paramCon.url; + params.user = paramCon.user; + params.pwd = paramCon.pwd; + + var serverMessage = new org.ametys.servercomm.ServerMessage('explorer', '/add-cmis-collection', + params, + org.ametys.servercomm.ServerComm.PRIORITY_MAJOR, + function (response, args) { + org.ametys.explorer.applications.resources.Folder.addCMISCb (response, args, callback); + }, + this, + []); + org.ametys.servercomm.ServerComm.getInstance().send(serverMessage); +} +org.ametys.explorer.applications.resources.Folder.addCMISCb = function (response, args, callback) +{ + if (org.ametys.servercomm.ServerComm.handleBadResponse("", response, "org.ametys.explorer.applications.resources.Folder.add")) + { + return; + } + + var id = response.selectSingleNode("ActionResult/id")[org.ametys.servercomm.ServerComm.xmlTextContent]; + var parentID = response.selectSingleNode("ActionResult/parentID")[org.ametys.servercomm.ServerComm.xmlTextContent]; + var name = response.selectSingleNode("ActionResult/name")[org.ametys.servercomm.ServerComm.xmlTextContent]; + + if (typeof callback == 'function') + { + callback (parentID, id, name); + } +} +/*------------------------------------------------------------------------*/ +/** * Create a new folder * @param {String} parentID The parent folder id * @param {String} name The new folder name Index: main/plugin-explorer/resources/js/org/ametys/explorer/applications/resources/toolbar/ToolbarActions.i18n.js =================================================================== --- main/plugin-explorer/resources/js/org/ametys/explorer/applications/resources/toolbar/ToolbarActions.i18n.js (revision 2900) +++ main/plugin-explorer/resources/js/org/ametys/explorer/applications/resources/toolbar/ToolbarActions.i18n.js (working copy) @@ -15,6 +15,7 @@ */ Ext.namespace('org.ametys.explorer.applications.resources.toolbar'); +Ext.namespace('org.ametys.explorer.applications.resources.toolbar.Folder.addCMIS'); Ext.namespace('org.ametys.explorer.applications.resources.toolbar.Folder.add'); Ext.namespace('org.ametys.explorer.applications.resources.toolbar.Folder.rename'); Ext.namespace('org.ametys.explorer.applications.resources.toolbar.Folder.remove'); @@ -29,6 +30,105 @@ /*------------------------------------------------------------------------*/ +org.ametys.explorer.applications.resources.toolbar.Folder.addCMIS = function (application) +{ + //DialogBox when adding nodes + addCMIS = new org.ametys.DialogBox ({ + + title : '', + + id: 'addCMISRep', + cls: 'text-dialog', + layout: 'form', + labelWidth: 100, + + width: 420, + height: 180, + autoScroll: false, + + items: [ + new org.ametys.form.TextField ({ + fieldLabel : '', + id: 'addCMIS-url', + width: 200, + allowBlank: true + }), + new org.ametys.form.TextField ({ + fieldLabel : '', + id: 'addCMIS-user', + width: 200, + allowBlank: true + }), + new org.ametys.form.PasswordField ({ + fieldLabel : '', + id: 'addCMIS-password', + width: 200, + allowBlank: true + }), + ], + closeAction: 'destroy', + buttons : [{ + text : "OK", + handler: _okAddCMISRep + },{ + text : "CANCEL", + handler: _cancelAddCMISRep + }] + }); + + Ext.getCmp('addCMISRep').show(); + + function _okAddCMISRep(){ + + var urlCMIS = Ext.getCmp('addCMIS-url'); + var userCMIS = Ext.getCmp('addCMIS-user'); + var pwdCMIS = Ext.getCmp('addCMIS-password'); + var url = urlCMIS.getValue(); + var user = userCMIS.getValue(); + var pwd = pwdCMIS.getValue(); + + if(url=="" || user=="" || pwd=="") + { + Ext.Msg.alert("", + ""); + } + else{ + var el = Ext.getCmp('addCMISRep'); + el.destroy(); + + var paramCon = {}; + paramCon.url = url; + paramCon.user = user; + paramCon.pwd = pwd; + + var node = application._explorer.getSelectedNode(); + if (node == null) + return; + + // Le noeud parent = id JCR du dossier qui va porter l'arborescence CMIS + var parentID = node.id; + org.ametys.explorer.applications.resources.Folder.addCMIS (parentID, + "", + function (parentID, id, name) { + org.ametys.explorer.applications.resources.toolbar.Folder._addCMISCb (parentID, id, name, application) + }, + paramCon + ); + } + } + + function _cancelAddCMISRep(){ + var el = Ext.getCmp('addCMISRep'); + el.destroy(); + } +} +org.ametys.explorer.applications.resources.toolbar.Folder._addCMISCb = function (parentID, id, name, application) +{ + // Rafraichi le noeud parent + application._explorer._refreshNode (parentID, application._explorer.renameNode, [id]); +} + +/*------------------------------------------------------------------------*/ org.ametys.explorer.applications.resources.toolbar.Folder.add = function (application) { var node = application._explorer.getSelectedNode(); Index: main/plugin-explorer/resources/js/org/ametys/explorer/applications/resources/ResourcesApplication.i18n.js =================================================================== --- main/plugin-explorer/resources/js/org/ametys/explorer/applications/resources/ResourcesApplication.i18n.js (revision 2900) +++ main/plugin-explorer/resources/js/org/ametys/explorer/applications/resources/ResourcesApplication.i18n.js (working copy) @@ -107,6 +107,17 @@ this._toolbar = new Ext.Toolbar ({ region: 'north', items : [{ + id: 'toolbar-btn-cmis-add', + icon: getPluginResourcesUrl ('explorer') + '/img/resources/folder_new_32.png', + tooltip : "", + scale: 'large', + application: this, + handler: function () { + org.ametys.explorer.applications.resources.toolbar.CMIS.add (this.application); + }, + disabled: true + }, + { id: 'toolbar-btn-folder-add', icon: getPluginResourcesUrl ('explorer') + '/img/resources/folder_new_32.png', tooltip : "", @@ -225,20 +236,21 @@ return this._toolbar; } -org.ametys.explorer.applications.resources.ResourcesApplication.prototype._updateToolbar = function (folder, files) +org.ametys.explorer.applications.resources.ResourcesApplication.prototype._updateToolbar = function (folder, files, isModifiable) { var isRoot = this._explorer._tree.getRootNode().id == folder; - this._toolbar.get('toolbar-btn-folder-add').setDisabled (folder == null); - this._toolbar.get('toolbar-btn-folder-rename').setDisabled (isRoot || folder == null); - this._toolbar.get('toolbar-btn-folder-delete').setDisabled (isRoot || folder == null); - this._toolbar.get('toolbar-btn-file-add').setDisabled (folder == null); - this._toolbar.get('toolbar-btn-file-rename').setDisabled (files == null || files.length == 0); - this._toolbar.get('toolbar-btn-file-delete').setDisabled (files == null || files.length == 0); + this._toolbar.get('toolbar-btn-cmis-add').setDisabled (folder == null || isModifiable == 'false'); + this._toolbar.get('toolbar-btn-folder-add').setDisabled (folder == null || isModifiable == 'false'); + this._toolbar.get('toolbar-btn-folder-rename').setDisabled (isRoot || folder == null || isModifiable == 'false'); + this._toolbar.get('toolbar-btn-folder-delete').setDisabled (isRoot || folder == null || isModifiable == 'false'); + this._toolbar.get('toolbar-btn-file-add').setDisabled (folder == null || isModifiable == 'false'); + this._toolbar.get('toolbar-btn-file-rename').setDisabled (files == null || files.length == 0 || isModifiable == 'false'); + this._toolbar.get('toolbar-btn-file-delete').setDisabled (files == null || files.length == 0 || isModifiable == 'false'); this._toolbar.get('toolbar-btn-file-download').setDisabled (files == null || files.length == 0); - this._toolbar.get('toolbar-btn-file-history').setDisabled (files == null || files.length == 0); - this._toolbar.get('toolbar-btn-file-cut').setDisabled (files == null || files.length == 0); - this._toolbar.get('toolbar-btn-file-paste').setDisabled (folder == null); + this._toolbar.get('toolbar-btn-file-history').setDisabled (files == null || files.length == 0 || isModifiable == 'false'); + this._toolbar.get('toolbar-btn-file-cut').setDisabled (files == null || files.length == 0 || isModifiable == 'false'); + this._toolbar.get('toolbar-btn-file-paste').setDisabled (folder == null || isModifiable == 'false'); } @@ -331,7 +343,7 @@ break; case 'updateToolbar': - this._updateToolbar (params.id, params.files); + this._updateToolbar (params.id, params.files, params.isModifiable); break; default: throw "The command '" + cmd + "' is unknown"; Index: main/plugin-explorer/resources/js/org/ametys/explorer/tree/ResourcesXmlLoader.js =================================================================== --- main/plugin-explorer/resources/js/org/ametys/explorer/tree/ResourcesXmlLoader.js (revision 2900) +++ main/plugin-explorer/resources/js/org/ametys/explorer/tree/ResourcesXmlLoader.js (working copy) @@ -34,7 +34,7 @@ * Override createNode function to always return a AsyncTreeNode */ org.ametys.explorer.tree.ResourcesXmlLoader.prototype.createNode = function(node) -{ +{ var attr = { tagName :node.tagName }; Index: main/plugin-explorer/resources_nodetypes.xml =================================================================== --- main/plugin-explorer/resources_nodetypes.xml (revision 2900) +++ main/plugin-explorer/resources_nodetypes.xml (working copy) @@ -15,6 +15,15 @@ limitations under the License. --> + + + nt:folder + ametys:object + + + + + nt:folder