diff --git a/.github/workflows/test-ci-mac.yml b/.github/workflows/test-ci-mac.yml new file mode 100644 index 0000000..832a2a5 --- /dev/null +++ b/.github/workflows/test-ci-mac.yml @@ -0,0 +1,35 @@ +name: Test CI Mac + +on: [push, pull_request] + +jobs: + build: + runs-on: macos-latest + + strategy: + max-parallel: 4 + matrix: + python-version: ["3.10", "3.11"] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install system dependencies + run: | + brew update + brew install p7zip libarchive libmagic + + - name: Set up venv + run: | + python3 -m venv venv + source venv/bin/activate + pip install -e .[system_provided,testing] + + - name: Run tests + run: venv/bin/pytest -n 3 -vvs . diff --git a/requirements.txt b/requirements.txt index 2b171e0..079327b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,7 +9,7 @@ chardet==5.0.0 charset-normalizer==2.1.0 click==8.1.3 colorama==0.4.5 -commoncode==31.0.2 +commoncode==31.2.1 construct==2.10.68 container-inspector==31.1.0 cryptography==37.0.4 diff --git a/setup.cfg b/setup.cfg index cae2e90..8117ce7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -67,7 +67,7 @@ python_requires = >=3.7 install_requires = attrs >= 18.1,!=20.1.0;python_version<'3.11' attrs >= 22.1.0;python_version>='3.11' - commoncode >= 31.0.2 + commoncode >= 31.2.1 plugincode >= 32.0.0 typecode >= 30.0.1 @@ -81,6 +81,11 @@ full = extractcode_libarchive >= 3.5.1.210525 typecode[full] >= 30.0.1 +system_provided = + extractcode_7z_system_provided >= 32.0.0 + extractcode_libarchive_system_provided >= 32.0.0 + typecode_libmagic_system_provided >= 32.0.0 + patch = patch >= 1.16 diff --git a/src/extractcode/archive.py b/src/extractcode/archive.py index d52399e..d60e341 100644 --- a/src/extractcode/archive.py +++ b/src/extractcode/archive.py @@ -11,28 +11,26 @@ import os from collections import namedtuple -from commoncode import fileutils from commoncode import filetype +from commoncode import fileutils from commoncode import functional from commoncode.ignore import is_ignored from typecode import contenttype from extractcode import all_kinds -from extractcode import regular -from extractcode import package from extractcode import docs -from extractcode import regular_nested from extractcode import file_system -from extractcode import patches -from extractcode import special_package - from extractcode import libarchive2 +from extractcode import package from extractcode import patch +from extractcode import patches +from extractcode import regular +from extractcode import regular_nested from extractcode import sevenzip +from extractcode import special_package from extractcode import vmimage - -from extractcode.uncompress import uncompress_gzip from extractcode.uncompress import uncompress_bzip2 +from extractcode.uncompress import uncompress_gzip logger = logging.getLogger(__name__) TRACE = False @@ -1096,7 +1094,7 @@ def try_to_extract(location, target_dir, extractor): # note that there are v1, v2 and v3 formats. name='QEMU QCOW2 disk image', filetypes=('qemu qcow2 image', 'qemu qcow image',), - mimetypes=('application/octet-stream',), + mimetypes=('application/octet-stream', 'application/x-qemu-disk'), extensions=('.qcow2', '.qcow', '.qcow2c', '.img',), kind=file_system, extractors=[extract_vm_image], diff --git a/tests/data/patch/patches/windows/plugin explorer.patch.expected b/tests/data/patch/patches/windows/plugin explorer.patch.expected index cf7260c..b3aa98d 100644 --- a/tests/data/patch/patches/windows/plugin explorer.patch.expected +++ b/tests/data/patch/patches/windows/plugin explorer.patch.expected @@ -1,792 +1,792 @@ [ [ - ".classpath", - ".classpath", + ".classpath", + ".classpath", [ - "Index: .classpath", - "===================================================================", - "--- .classpath", - "+++ .classpath", - "@@ -0,0 +1,48 @@", - "+", - "+", - "+\t", - "+\t", - "+\t", - "+\t", - "+\t", - "+\t", - "+\t", - "+\t", - "+\t", - "+\t", - "+\t", - "+\t", - "+\t", - "+\t", - "+\t", - "+\t", - "+\t", - "+\t", - "+\t", - "+\t", - "+\t", - "+\t", - "+\t", - "+\t", - "+\t", - "+\t", - "+\t", - "+\t", - "+\t", - "+\t", - "+\t", - "+\t", - "+\t", - "+\t", - "+\t", - "+\t", - "+\t", - "+\t", - "+\t", - "+\t", - "+\t", - "+\t", - "+\t", - "+\t", - "+\t", + "Index: .classpath", + "===================================================================", + "--- .classpath", + "+++ .classpath", + "@@ -0,0 +1,48 @@", + "+", + "+", + "+\t", + "+\t", + "+\t", + "+\t", + "+\t", + "+\t", + "+\t", + "+\t", + "+\t", + "+\t", + "+\t", + "+\t", + "+\t", + "+\t", + "+\t", + "+\t", + "+\t", + "+\t", + "+\t", + "+\t", + "+\t", + "+\t", + "+\t", + "+\t", + "+\t", + "+\t", + "+\t", + "+\t", + "+\t", + "+\t", + "+\t", + "+\t", + "+\t", + "+\t", + "+\t", + "+\t", + "+\t", + "+\t", + "+\t", + "+\t", + "+\t", + "+\t", + "+\t", + "+\t", + "+\t", "+" ] - ], + ], [ - ".project", - ".project", + ".project", + ".project", [ - "Index: .project", - "===================================================================", - "--- .project", - "+++ .project", - "@@ -0,0 +1,23 @@", - "+", - "+", - "+\tplugin explorer", - "+\t", - "+\t", - "+\t", - "+\t", - "+\t\t", - "+\t\t\torg.eclipse.jdt.core.javabuilder", - "+\t\t\t", - "+\t\t\t", - "+\t\t", - "+\t\t", - "+\t\t\tcom.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder", - "+\t\t\t", - "+\t\t\t", - "+\t\t", - "+\t", - "+\t", - "+\t\torg.eclipse.jdt.core.javanature", - "+\t\tcom.atlassw.tools.eclipse.checkstyle.CheckstyleNature", - "+\t", + "Index: .project", + "===================================================================", + "--- .project", + "+++ .project", + "@@ -0,0 +1,23 @@", + "+", + "+", + "+\tplugin explorer", + "+\t", + "+\t", + "+\t", + "+\t", + "+\t\t", + "+\t\t\torg.eclipse.jdt.core.javabuilder", + "+\t\t\t", + "+\t\t\t", + "+\t\t", + "+\t\t", + "+\t\t\tcom.atlassw.tools.eclipse.checkstyle.CheckstyleBuilder", + "+\t\t\t", + "+\t\t\t", + "+\t\t", + "+\t", + "+\t", + "+\t\torg.eclipse.jdt.core.javanature", + "+\t\tcom.atlassw.tools.eclipse.checkstyle.CheckstyleNature", + "+\t", "+" ] - ], + ], [ - ".settings/org.eclipse.jdt.core.prefs", - ".settings/org.eclipse.jdt.core.prefs", + ".settings/org.eclipse.jdt.core.prefs", + ".settings/org.eclipse.jdt.core.prefs", [ - "Index: .settings/org.eclipse.jdt.core.prefs", - "===================================================================", - "--- .settings/org.eclipse.jdt.core.prefs", - "+++ .settings/org.eclipse.jdt.core.prefs", - "@@ -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", + "Index: .settings/org.eclipse.jdt.core.prefs", + "===================================================================", + "--- .settings/org.eclipse.jdt.core.prefs", + "+++ .settings/org.eclipse.jdt.core.prefs", + "@@ -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" ] - ], + ], [ - ".checkstyle", - ".checkstyle", + ".checkstyle", + ".checkstyle", [ - "Index: .checkstyle", - "===================================================================", - "--- .checkstyle", - "+++ .checkstyle", - "@@ -0,0 +1,9 @@", - "+", - "+", - "+ ", - "+ ", - "+ ", - "+ ", - "+ ", - "+ ", + "Index: .checkstyle", + "===================================================================", + "--- .checkstyle", + "+++ .checkstyle", + "@@ -0,0 +1,9 @@", + "+", + "+", + "+ ", + "+ ", + "+ ", + "+ ", + "+ ", + "+ ", "+" ] - ], + ], [ - "main/plugin-explorer/sitemap.xmap", - "main/plugin-explorer/sitemap.xmap", + "main/plugin-explorer/sitemap.xmap", + "main/plugin-explorer/sitemap.xmap", [ - "Index: main/plugin-explorer/sitemap.xmap", - "===================================================================", - "--- main/plugin-explorer/sitemap.xmap", - "+++ main/plugin-explorer/sitemap.xmap", - "@@ -19,6 +19,7 @@", - "", - "", - "", - "+\t\t\t", - "", - "", - "", - "@@ -91,6 +92,17 @@", - "", - "", - "", - "+\t\t\t", - "+\t\t\t\t", - "+\t\t\t\t\t", - "+\t\t\t\t\t\t", - "+\t\t\t\t\t\t", - "+\t\t\t\t\t\t", - "+\t\t\t\t\t", - "+\t\t\t\t\t", - "+\t\t\t\t", - "+\t\t\t", - "+", - "", - "", + "Index: main/plugin-explorer/sitemap.xmap", + "===================================================================", + "--- main/plugin-explorer/sitemap.xmap", + "+++ main/plugin-explorer/sitemap.xmap", + "@@ -19,6 +19,7 @@", + "", + "", + "", + "+\t\t\t", + "", + "", + "", + "@@ -91,6 +92,17 @@", + "", + "", + "", + "+\t\t\t", + "+\t\t\t\t", + "+\t\t\t\t\t", + "+\t\t\t\t\t\t", + "+\t\t\t\t\t\t", + "+\t\t\t\t\t\t", + "+\t\t\t\t\t", + "+\t\t\t\t\t", + "+\t\t\t\t", + "+\t\t\t", + "+", + "", + "", "" ] - ], + ], [ - "main/plugin-explorer/i18n/messages_fr.xml", - "main/plugin-explorer/i18n/messages_fr.xml", + "main/plugin-explorer/i18n/messages_fr.xml", + "main/plugin-explorer/i18n/messages_fr.xml", [ - "Index: main/plugin-explorer/i18n/messages_fr.xml", - "===================================================================", - "--- main/plugin-explorer/i18n/messages_fr.xml", - "+++ main/plugin-explorer/i18n/messages_fr.xml", - "@@ -92,6 +92,13 @@", - "Passe en mode de vue d\u00e9taill\u00e9e", - "", - "", - "+\tAjout des identifiants de connexion", - "+\tURL", - "+\tNom utilisateur", - "+\tMot de passe", - "+\tParam\u00e8tres manquants", - "+\tMerci de renseigner tous les champs.", - "+", - "Nouveau dossier", - "Nouveau dossier", + "Index: main/plugin-explorer/i18n/messages_fr.xml", + "===================================================================", + "--- main/plugin-explorer/i18n/messages_fr.xml", + "+++ main/plugin-explorer/i18n/messages_fr.xml", + "@@ -92,6 +92,13 @@", + "Passe en mode de vue d\u00e9taill\u00e9e", + "", + "", + "+\tAjout des identifiants de connexion", + "+\tURL", + "+\tNom utilisateur", + "+\tMot de passe", + "+\tParam\u00c3\u00a8tres manquants", + "+\tMerci de renseigner tous les champs.", + "+", + "Nouveau dossier", + "Nouveau dossier", "Nom" ] - ], + ], [ - "main/plugin-explorer/i18n/messages_en.xml", - "main/plugin-explorer/i18n/messages_en.xml", + "main/plugin-explorer/i18n/messages_en.xml", + "main/plugin-explorer/i18n/messages_en.xml", [ - "Index: main/plugin-explorer/i18n/messages_en.xml", - "===================================================================", - "--- main/plugin-explorer/i18n/messages_en.xml", - "+++ main/plugin-explorer/i18n/messages_en.xml", - "@@ -92,6 +92,14 @@", - "Switchs to detailed view", - "", - "", - "+\tAdd the connection IDs", - "+\tURL", - "+\tUser", - "+\tPassword", - "+\tMissing Parameters", - "+\tPlease fill in all fields", - "+", - "+", - "New folder", - "New folder", + "Index: main/plugin-explorer/i18n/messages_en.xml", + "===================================================================", + "--- main/plugin-explorer/i18n/messages_en.xml", + "+++ main/plugin-explorer/i18n/messages_en.xml", + "@@ -92,6 +92,14 @@", + "Switchs to detailed view", + "", + "", + "+\tAdd the connection IDs", + "+\tURL", + "+\tUser", + "+\tPassword", + "+\tMissing Parameters", + "+\tPlease fill in all fields", + "+", + "+", + "New folder", + "New folder", "Name" ] - ], + ], [ - "main/plugin-explorer/src/org/ametys/plugins/explorer/resources/generators/ResourcesExplorerGenerator.java", - "main/plugin-explorer/src/org/ametys/plugins/explorer/resources/generators/ResourcesExplorerGenerator.java", + "main/plugin-explorer/src/org/ametys/plugins/explorer/resources/generators/ResourcesExplorerGenerator.java", + "main/plugin-explorer/src/org/ametys/plugins/explorer/resources/generators/ResourcesExplorerGenerator.java", [ - "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", - "+++ main/plugin-explorer/src/org/ametys/plugins/explorer/resources/generators/ResourcesExplorerGenerator.java", - "@@ -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/generators/ResourcesExplorerGenerator.java", + "===================================================================", + "--- main/plugin-explorer/src/org/ametys/plugins/explorer/resources/generators/ResourcesExplorerGenerator.java", + "+++ main/plugin-explorer/src/org/ametys/plugins/explorer/resources/generators/ResourcesExplorerGenerator.java", + "@@ -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);", + "}", "}" ] - ], + ], [ - "main/plugin-explorer/src/org/ametys/plugins/explorer/resources/actions/AddCMISCollectionAction.java", - "main/plugin-explorer/src/org/ametys/plugins/explorer/resources/actions/AddCMISCollectionAction.java", + "main/plugin-explorer/src/org/ametys/plugins/explorer/resources/actions/AddCMISCollectionAction.java", + "main/plugin-explorer/src/org/ametys/plugins/explorer/resources/actions/AddCMISCollectionAction.java", [ - "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", - "+++ main/plugin-explorer/src/org/ametys/plugins/explorer/resources/actions/AddCMISCollectionAction.java", - "@@ -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/resources/actions/AddCMISCollectionAction.java", + "===================================================================", + "--- main/plugin-explorer/src/org/ametys/plugins/explorer/resources/actions/AddCMISCollectionAction.java", + "+++ main/plugin-explorer/src/org/ametys/plugins/explorer/resources/actions/AddCMISCollectionAction.java", + "@@ -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;", + "+ }", + "+", "+}" ] - ], + ], [ - "main/plugin-explorer/src/org/ametys/plugins/explorer/ExplorerNodeGenerator.java", - "main/plugin-explorer/src/org/ametys/plugins/explorer/ExplorerNodeGenerator.java", + "main/plugin-explorer/src/org/ametys/plugins/explorer/ExplorerNodeGenerator.java", + "main/plugin-explorer/src/org/ametys/plugins/explorer/ExplorerNodeGenerator.java", [ - "Index: main/plugin-explorer/src/org/ametys/plugins/explorer/ExplorerNodeGenerator.java", - "===================================================================", - "--- main/plugin-explorer/src/org/ametys/plugins/explorer/ExplorerNodeGenerator.java", - "+++ main/plugin-explorer/src/org/ametys/plugins/explorer/ExplorerNodeGenerator.java", - "@@ -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;", - "", + "Index: main/plugin-explorer/src/org/ametys/plugins/explorer/ExplorerNodeGenerator.java", + "===================================================================", + "--- main/plugin-explorer/src/org/ametys/plugins/explorer/ExplorerNodeGenerator.java", + "+++ main/plugin-explorer/src/org/ametys/plugins/explorer/ExplorerNodeGenerator.java", + "@@ -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())" ] - ], + ], [ - "main/plugin-explorer/plugin.xml", - "main/plugin-explorer/plugin.xml", + "main/plugin-explorer/plugin.xml", + "main/plugin-explorer/plugin.xml", [ - "Index: main/plugin-explorer/plugin.xml", - "===================================================================", - "--- main/plugin-explorer/plugin.xml", - "+++ main/plugin-explorer/plugin.xml", - "@@ -51,6 +51,15 @@", - "resource", - "ametys:resource", - "", - "+", - "+ ", - "+ cmis-root-collection", - "+ ametys:cmis-root-collection", - "+ resources_nodetypes.xml", - "+ ", - "+", - "", - "", + "Index: main/plugin-explorer/plugin.xml", + "===================================================================", + "--- main/plugin-explorer/plugin.xml", + "+++ main/plugin-explorer/plugin.xml", + "@@ -51,6 +51,15 @@", + "resource", + "ametys:resource", + "", + "+", + "+ ", + "+ cmis-root-collection", + "+ ametys:cmis-root-collection", + "+ resources_nodetypes.xml", + "+ ", + "+", + "", + "", "" ] - ], + ], [ - "main/plugin-explorer/resources/js/org/ametys/explorer/ResourcesExplorer.i18n.js", - "main/plugin-explorer/resources/js/org/ametys/explorer/ResourcesExplorer.i18n.js", + "main/plugin-explorer/resources/js/org/ametys/explorer/ResourcesExplorer.i18n.js", + "main/plugin-explorer/resources/js/org/ametys/explorer/ResourcesExplorer.i18n.js", [ - "Index: main/plugin-explorer/resources/js/org/ametys/explorer/ResourcesExplorer.i18n.js", - "===================================================================", - "--- main/plugin-explorer/resources/js/org/ametys/explorer/ResourcesExplorer.i18n.js", - "+++ main/plugin-explorer/resources/js/org/ametys/explorer/ResourcesExplorer.i18n.js", - "@@ -554,7 +554,7 @@", - "var appId = node.attributes.applicationId;", - "if (this._applications[appId])", - "{", - "-\t\t\tthis._applications[appId].execCommand ('updateToolbar', {'id': node.id});", - "+\t\t\tthis._applications[appId].execCommand ('updateToolbar', {'id': node.id, 'isModifiable': node.attributes['isModifiable']});", - "}", - "}", - "}", - "@@ -607,7 +607,7 @@", - "var appId = node.attributes.applicationId;", - "if (this._applications[appId])", - "{", - "-\t\t\tthis._applications[appId].execCommand ('updateToolbar', {'id': node.id, 'files': records});", - "+\t\t\tthis._applications[appId].execCommand ('updateToolbar', {'id': node.id, 'files': records, 'isModifiable': node.attributes['isModifiable']});", - "}", - "}", + "Index: main/plugin-explorer/resources/js/org/ametys/explorer/ResourcesExplorer.i18n.js", + "===================================================================", + "--- main/plugin-explorer/resources/js/org/ametys/explorer/ResourcesExplorer.i18n.js", + "+++ main/plugin-explorer/resources/js/org/ametys/explorer/ResourcesExplorer.i18n.js", + "@@ -554,7 +554,7 @@", + "var appId = node.attributes.applicationId;", + "if (this._applications[appId])", + "{", + "-\t\t\tthis._applications[appId].execCommand ('updateToolbar', {'id': node.id});", + "+\t\t\tthis._applications[appId].execCommand ('updateToolbar', {'id': node.id, 'isModifiable': node.attributes['isModifiable']});", + "}", + "}", + "}", + "@@ -607,7 +607,7 @@", + "var appId = node.attributes.applicationId;", + "if (this._applications[appId])", + "{", + "-\t\t\tthis._applications[appId].execCommand ('updateToolbar', {'id': node.id, 'files': records});", + "+\t\t\tthis._applications[appId].execCommand ('updateToolbar', {'id': node.id, 'files': records, 'isModifiable': node.attributes['isModifiable']});", + "}", + "}", "}" ] - ], + ], [ - "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", + "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", [ - "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", - "+++ main/plugin-explorer/resources/js/org/ametys/explorer/applications/resources/ResourcesActions.i18n.js", - "@@ -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)", - "+{", - "+\tif (org.ametys.servercomm.ServerComm.handleBadResponse(\"\", response, \"org.ametys.explorer.applications.resources.Folder.add\"))", - "+\t{", - "+\t\treturn;", - "+\t}", - "+", - "+\tvar id = response.selectSingleNode(\"ActionResult/id\")[org.ametys.servercomm.ServerComm.xmlTextContent];", - "+\tvar parentID = response.selectSingleNode(\"ActionResult/parentID\")[org.ametys.servercomm.ServerComm.xmlTextContent];", - "+\tvar 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", + "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", + "+++ main/plugin-explorer/resources/js/org/ametys/explorer/applications/resources/ResourcesActions.i18n.js", + "@@ -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)", + "+{", + "+\tif (org.ametys.servercomm.ServerComm.handleBadResponse(\"\", response, \"org.ametys.explorer.applications.resources.Folder.add\"))", + "+\t{", + "+\t\treturn;", + "+\t}", + "+", + "+\tvar id = response.selectSingleNode(\"ActionResult/id\")[org.ametys.servercomm.ServerComm.xmlTextContent];", + "+\tvar parentID = response.selectSingleNode(\"ActionResult/parentID\")[org.ametys.servercomm.ServerComm.xmlTextContent];", + "+\tvar 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" ] - ], + ], [ - "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", + "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", [ - "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", - "+++ main/plugin-explorer/resources/js/org/ametys/explorer/applications/resources/toolbar/ToolbarActions.i18n.js", - "@@ -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)", - "+{", - "+\t//DialogBox when adding nodes", - "+\taddCMIS = new org.ametys.DialogBox ({", - "+", - "+\t\ttitle : '',", - "+", - "+ 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", - "+ }]", - "+ });", - "+", - "+\tExt.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(\"\",", - "+ \t\t\"\");", - "+ }", - "+ 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)", - "+{", - "+\t// Rafraichi le noeud parent", - "+ application._explorer._refreshNode (parentID, application._explorer.renameNode, [id]);", - "+}", - "+", - "+/*------------------------------------------------------------------------*/", - "org.ametys.explorer.applications.resources.toolbar.Folder.add = function (application)", - "{", + "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", + "+++ main/plugin-explorer/resources/js/org/ametys/explorer/applications/resources/toolbar/ToolbarActions.i18n.js", + "@@ -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)", + "+{", + "+\t//DialogBox when adding nodes", + "+\taddCMIS = new org.ametys.DialogBox ({", + "+", + "+\t\ttitle : '',", + "+", + "+ 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", + "+ }]", + "+ });", + "+", + "+\tExt.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(\"\",", + "+ \t\t\"\");", + "+ }", + "+ 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)", + "+{", + "+\t// 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();" ] - ], + ], [ - "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", + "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", [ - "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", - "+++ main/plugin-explorer/resources/js/org/ametys/explorer/applications/resources/ResourcesApplication.i18n.js", - "@@ -107,6 +107,17 @@", - "this._toolbar = new Ext.Toolbar ({", - "region: 'north',", - "items : [{", - "+\t\t\t\t id: 'toolbar-btn-cmis-add',", - "+\t\t\t\t icon: getPluginResourcesUrl ('explorer') + '/img/resources/folder_new_32.png',", - "+\t\t\t\t tooltip : \"\",", - "+\t\t\t\t scale: 'large',", - "+\t\t\t\t application: this,", - "+\t\t\t\t handler: function () {", - "+\t\t\t\t org.ametys.explorer.applications.resources.toolbar.CMIS.add (this.application);", - "+\t\t\t\t },", - "+\t\t\t\t disabled: true", - "+\t\t\t\t },", - "+\t\t {", - "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;", - "", - "-\tthis._toolbar.get('toolbar-btn-folder-add').setDisabled (folder == null);", - "-\tthis._toolbar.get('toolbar-btn-folder-rename').setDisabled (isRoot || folder == null);", - "-\tthis._toolbar.get('toolbar-btn-folder-delete').setDisabled (isRoot || folder == null);", - "-\tthis._toolbar.get('toolbar-btn-file-add').setDisabled (folder == null);", - "-\tthis._toolbar.get('toolbar-btn-file-rename').setDisabled (files == null || files.length == 0);", - "-\tthis._toolbar.get('toolbar-btn-file-delete').setDisabled (files == null || files.length == 0);", - "+\tthis._toolbar.get('toolbar-btn-cmis-add').setDisabled (folder == null || isModifiable == 'false');", - "+\tthis._toolbar.get('toolbar-btn-folder-add').setDisabled (folder == null || isModifiable == 'false');", - "+\tthis._toolbar.get('toolbar-btn-folder-rename').setDisabled (isRoot || folder == null || isModifiable == 'false');", - "+\tthis._toolbar.get('toolbar-btn-folder-delete').setDisabled (isRoot || folder == null || isModifiable == 'false');", - "+\tthis._toolbar.get('toolbar-btn-file-add').setDisabled (folder == null || isModifiable == 'false');", - "+\tthis._toolbar.get('toolbar-btn-file-rename').setDisabled (files == null || files.length == 0 || isModifiable == 'false');", - "+\tthis._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);", - "-\tthis._toolbar.get('toolbar-btn-file-history').setDisabled (files == null || files.length == 0);", - "-\tthis._toolbar.get('toolbar-btn-file-cut').setDisabled (files == null || files.length == 0);", - "-\tthis._toolbar.get('toolbar-btn-file-paste').setDisabled (folder == null);", - "+\tthis._toolbar.get('toolbar-btn-file-history').setDisabled (files == null || files.length == 0 || isModifiable == 'false');", - "+\tthis._toolbar.get('toolbar-btn-file-cut').setDisabled (files == null || files.length == 0 || isModifiable == 'false');", - "+\tthis._toolbar.get('toolbar-btn-file-paste').setDisabled (folder == null || isModifiable == 'false');", - "", - "}", - "", - "@@ -331,7 +343,7 @@", - "break;", - "", - "case 'updateToolbar':", - "-\t\t\tthis._updateToolbar (params.id, params.files);", - "+\t\t\tthis._updateToolbar (params.id, params.files, params.isModifiable);", - "break;", - "default:", + "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", + "+++ main/plugin-explorer/resources/js/org/ametys/explorer/applications/resources/ResourcesApplication.i18n.js", + "@@ -107,6 +107,17 @@", + "this._toolbar = new Ext.Toolbar ({", + "region: 'north',", + "items : [{", + "+\t\t\t\t id: 'toolbar-btn-cmis-add',", + "+\t\t\t\t icon: getPluginResourcesUrl ('explorer') + '/img/resources/folder_new_32.png',", + "+\t\t\t\t tooltip : \"\",", + "+\t\t\t\t scale: 'large',", + "+\t\t\t\t application: this,", + "+\t\t\t\t handler: function () {", + "+\t\t\t\t org.ametys.explorer.applications.resources.toolbar.CMIS.add (this.application);", + "+\t\t\t\t },", + "+\t\t\t\t disabled: true", + "+\t\t\t\t },", + "+\t\t {", + "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;", + "", + "-\tthis._toolbar.get('toolbar-btn-folder-add').setDisabled (folder == null);", + "-\tthis._toolbar.get('toolbar-btn-folder-rename').setDisabled (isRoot || folder == null);", + "-\tthis._toolbar.get('toolbar-btn-folder-delete').setDisabled (isRoot || folder == null);", + "-\tthis._toolbar.get('toolbar-btn-file-add').setDisabled (folder == null);", + "-\tthis._toolbar.get('toolbar-btn-file-rename').setDisabled (files == null || files.length == 0);", + "-\tthis._toolbar.get('toolbar-btn-file-delete').setDisabled (files == null || files.length == 0);", + "+\tthis._toolbar.get('toolbar-btn-cmis-add').setDisabled (folder == null || isModifiable == 'false');", + "+\tthis._toolbar.get('toolbar-btn-folder-add').setDisabled (folder == null || isModifiable == 'false');", + "+\tthis._toolbar.get('toolbar-btn-folder-rename').setDisabled (isRoot || folder == null || isModifiable == 'false');", + "+\tthis._toolbar.get('toolbar-btn-folder-delete').setDisabled (isRoot || folder == null || isModifiable == 'false');", + "+\tthis._toolbar.get('toolbar-btn-file-add').setDisabled (folder == null || isModifiable == 'false');", + "+\tthis._toolbar.get('toolbar-btn-file-rename').setDisabled (files == null || files.length == 0 || isModifiable == 'false');", + "+\tthis._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);", + "-\tthis._toolbar.get('toolbar-btn-file-history').setDisabled (files == null || files.length == 0);", + "-\tthis._toolbar.get('toolbar-btn-file-cut').setDisabled (files == null || files.length == 0);", + "-\tthis._toolbar.get('toolbar-btn-file-paste').setDisabled (folder == null);", + "+\tthis._toolbar.get('toolbar-btn-file-history').setDisabled (files == null || files.length == 0 || isModifiable == 'false');", + "+\tthis._toolbar.get('toolbar-btn-file-cut').setDisabled (files == null || files.length == 0 || isModifiable == 'false');", + "+\tthis._toolbar.get('toolbar-btn-file-paste').setDisabled (folder == null || isModifiable == 'false');", + "", + "}", + "", + "@@ -331,7 +343,7 @@", + "break;", + "", + "case 'updateToolbar':", + "-\t\t\tthis._updateToolbar (params.id, params.files);", + "+\t\t\tthis._updateToolbar (params.id, params.files, params.isModifiable);", + "break;", + "default:", "throw \"The command '\" + cmd + \"' is unknown\";" ] - ], + ], [ - "main/plugin-explorer/resources/js/org/ametys/explorer/tree/ResourcesXmlLoader.js", - "main/plugin-explorer/resources/js/org/ametys/explorer/tree/ResourcesXmlLoader.js", + "main/plugin-explorer/resources/js/org/ametys/explorer/tree/ResourcesXmlLoader.js", + "main/plugin-explorer/resources/js/org/ametys/explorer/tree/ResourcesXmlLoader.js", [ - "Index: main/plugin-explorer/resources/js/org/ametys/explorer/tree/ResourcesXmlLoader.js", - "===================================================================", - "--- main/plugin-explorer/resources/js/org/ametys/explorer/tree/ResourcesXmlLoader.js", - "+++ main/plugin-explorer/resources/js/org/ametys/explorer/tree/ResourcesXmlLoader.js", - "@@ -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/js/org/ametys/explorer/tree/ResourcesXmlLoader.js", + "===================================================================", + "--- main/plugin-explorer/resources/js/org/ametys/explorer/tree/ResourcesXmlLoader.js", + "+++ main/plugin-explorer/resources/js/org/ametys/explorer/tree/ResourcesXmlLoader.js", + "@@ -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", "};" ] - ], + ], [ - "main/plugin-explorer/resources_nodetypes.xml", - "main/plugin-explorer/resources_nodetypes.xml", + "main/plugin-explorer/resources_nodetypes.xml", + "main/plugin-explorer/resources_nodetypes.xml", [ - "Index: main/plugin-explorer/resources_nodetypes.xml", - "===================================================================", - "--- main/plugin-explorer/resources_nodetypes.xml", - "+++ main/plugin-explorer/resources_nodetypes.xml", - "@@ -15,6 +15,15 @@", - "limitations under the License.", - "-->", - "", - "+ ", - "+ ", - "+ nt:folder", - "+ ametys:object", - "+ ", - "+ ", - "+ ", - "+ ", - "+ ", - "", - "", + "Index: main/plugin-explorer/resources_nodetypes.xml", + "===================================================================", + "--- main/plugin-explorer/resources_nodetypes.xml", + "+++ main/plugin-explorer/resources_nodetypes.xml", + "@@ -15,6 +15,15 @@", + "limitations under the License.", + "-->", + "", + "+ ", + "+ ", + "+ nt:folder", + "+ ametys:object", + "+ ", + "+ ", + "+ ", + "+ ", + "+ ", + "", + "", "nt:folder" ] ] diff --git a/tests/test_archive.py b/tests/test_archive.py index 64f17ce..bb14df0 100644 --- a/tests/test_archive.py +++ b/tests/test_archive.py @@ -12,22 +12,21 @@ from pathlib import Path import pytest - from commoncode import date as commoncode_date from commoncode import fileutils from commoncode.system import on_linux from commoncode.system import on_mac +from commoncode.system import on_macos_arm64 from commoncode.system import on_windows from commoncode.testcase import is_same - from extractcode_assert_utils import BaseArchiveTestCase from extractcode_assert_utils import check_files from extractcode_assert_utils import check_size from extractcode_assert_utils import to_posix import extractcode -from extractcode import archive from extractcode import ExtractErrorFailedToExtract +from extractcode import archive from extractcode import libarchive2 from extractcode import sevenzip @@ -291,9 +290,11 @@ def test_7zip_extract_can_extract_to_relative_paths(self): # The setup is a tad complex because we want to have a relative dir # to the base dir where we run tests from, i.e. the git checkout dir. # To use relative paths, we use our tmp dir at the root of the code tree - from os.path import join, abspath - import tempfile import shutil + import tempfile + from os.path import abspath + from os.path import join + from extractcode.sevenzip import extract test_file = self.get_test_loc('archive/relative_path/basic.zip', copy=True) @@ -1649,9 +1650,11 @@ def test_extract_twice_can_extract_to_relative_paths(self): # The setup is a tad complex because we want to have a relative dir # to the base dir where we run tests from, i.e. the git checkout dir # To use relative paths, we use our tmp dir at the root of the code tree - from os.path import join, abspath, exists import shutil import tempfile + from os.path import abspath + from os.path import exists + from os.path import join test_file = self.get_test_loc('archive/rpm/xz-compressed-cpio.rpm') # this will return an extractor that extracts twice @@ -1689,8 +1692,11 @@ def test_extract_rar_with_invalid_path(self): def test_extract_rar_with_trailing_data(self): test_file = self.get_test_loc('archive/rar/rar_trailing.rar') test_dir = self.get_temp_dir() - expected = Exception('Unknown error') - self.assertRaisesInstance(expected, archive.extract_rar, test_file, test_dir) + if on_macos_arm64: + archive.extract_rar(test_file, test_dir) + else: + expected = Exception('Unknown error') + self.assertRaisesInstance(expected, archive.extract_rar, test_file, test_dir) result = os.path.join(test_dir, 'd', 'b', 'a.txt') assert os.path.exists(result) diff --git a/tests/test_vmimage.py b/tests/test_vmimage.py index 6653cdd..44c0e80 100644 --- a/tests/test_vmimage.py +++ b/tests/test_vmimage.py @@ -13,6 +13,7 @@ import pytest from commoncode.system import on_linux +from commoncode.system import on_ubuntu_22 from extractcode_assert_utils import BaseArchiveTestCase from extractcode_assert_utils import check_files @@ -20,7 +21,7 @@ from extractcode import vmimage -@pytest.mark.skipif(not on_linux, reason='Only linux supports image extraction') +@pytest.mark.skipif((not on_linux) or on_ubuntu_22, reason='Only linux supports image extraction, kernel is unreadable on Ubuntu 22.04') class TestExtractVmImage(BaseArchiveTestCase): test_data_dir = os.path.join(os.path.dirname(__file__), 'data')