You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@guacamole.apache.org by "jmuehlner (via GitHub)" <gi...@apache.org> on 2023/03/14 19:02:55 UTC

[GitHub] [guacamole-client] jmuehlner opened a new pull request, #809: GUACAMOLE-926: Batch Connection Import

jmuehlner opened a new pull request, #809:
URL: https://github.com/apache/guacamole-client/pull/809

   There's still a bit of cleanup to be done here, but the functionality is essentially done, so if people want to have a look, I'd appreciate it.
   
   This PR implements a batch import UI for connections, allowing an admin to provide a CSV, YAML, or JSON file with a list of connections, which will be submitted to a modified PATCH implementation on the backend that now allows creation of bulk directory objects.
   
   <img width="866" alt="Screenshot 2023-03-14 112023" src="https://user-images.githubusercontent.com/4633119/225110249-1c72a3e2-c8aa-41b1-9630-49983321441a.png">
   <img width="866" alt="Screenshot 2023-03-14 111613" src="https://user-images.githubusercontent.com/4633119/225110258-ea4c59f4-7a93-434a-becc-2e5634674b94.png">
   <img width="868" alt="Screenshot 2023-03-14 111632" src="https://user-images.githubusercontent.com/4633119/225110261-d4e059d2-f803-4aee-9cff-f5d52486b99c.png">
   <img width="864" alt="Screenshot 2023-03-14 111658" src="https://user-images.githubusercontent.com/4633119/225110268-b4a5246a-09af-4ba7-afb5-23adb7424eb1.png">
   <img width="863" alt="Screenshot 2023-03-14 111743" src="https://user-images.githubusercontent.com/4633119/225110272-eac37d33-729a-4519-9eec-015459641e8f.png">
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: Guacamole REST API Documentation.

Posted by Nick Couchman <vn...@apache.org>.
On Mon, Mar 20, 2023 at 5:11 PM Aaron Meyer <am...@meyertech.net> wrote:
>
> Thank you, Nick.
>
> Follow-up question then... if I were to spelunk through the source any hints on what to look for?

There are a couple of things that will help you out in this. First,
the bulk of the REST API source code is located here:

https://github.com/apache/guacamole-client/tree/master/guacamole/src/main/java/org/apache/guacamole/rest

It may not be immediately obvious what each of the classes present in
terms of an endpoint, but it'll help. Probably the most useful thing
for me has been to use the full Guacamole Client in a browser with the
Developer Console/Tools open, and use the Network tab to see the HTTP
and WebSocket calls made by the client. The full Guacamole Client uses
the REST API to do all of its interaction and management, so you
should be able to look through those transactions and get an idea for
how things like user, group, and connection management are done.

And, of course, feel free to post back here.

-Nick

RE: Guacamole REST API Documentation.

Posted by Aaron Meyer <am...@meyertech.net>.
Thank you, Nick.

Follow-up question then... if I were to spelunk through the source any hints on what to look for?

In your service,
Aaron Meyer

-----Original Message-----
From: Nick Couchman <vn...@apache.org> 
Sent: Monday, March 20, 2023 2:42 PM
To: dev@guacamole.apache.org
Subject: Re: Guacamole REST API Documentation.

On Mon, Mar 20, 2023 at 3:36 PM Aaron Meyer <am...@meyertech.net> wrote:
>
> First time poster here. My apologies if I missed this being covered elsewhere in my research.
>
> I would like to automate configurations and interactions with guacamole. Both my not being a Java dev and interacting services require the use of REST API for this interaction.
>
> While I see a various guacamole API's documented on the projects website I only see Java integrations and haven't found anything specific to REST API methods. Is there an official source documenting this?

No, there is currently no official documentation for the REST API. We have had some interest in trying to automate the documentation, but have not found a good framework for it and no progress has been made on that front, to my knowledge.

-Nick


Re: Guacamole REST API Documentation.

Posted by Nick Couchman <vn...@apache.org>.
On Mon, Mar 20, 2023 at 3:36 PM Aaron Meyer <am...@meyertech.net> wrote:
>
> First time poster here. My apologies if I missed this being covered elsewhere in my research.
>
> I would like to automate configurations and interactions with guacamole. Both my not being a Java dev and interacting services require the use of REST API for this interaction.
>
> While I see a various guacamole API's documented on the projects website I only see Java integrations and haven't found anything specific to REST API methods. Is there an official source documenting this?

No, there is currently no official documentation for the REST API. We
have had some interest in trying to automate the documentation, but
have not found a good framework for it and no progress has been made
on that front, to my knowledge.

-Nick

Guacamole REST API Documentation.

Posted by Aaron Meyer <am...@meyertech.net>.
First time poster here. My apologies if I missed this being covered elsewhere in my research.

I would like to automate configurations and interactions with guacamole. Both my not being a Java dev and interacting services require the use of REST API for this interaction.

While I see a various guacamole API's documented on the projects website I only see Java integrations and haven't found anything specific to REST API methods. Is there an official source documenting this?

I have found this 2 year old GitHub and it has been helpful but is also a bit out of date: https://github.com/ridvanaltun/guacamole-rest-api-documentation

I have also found this GitHub for a Powershell module that needs some work, but seems serviceable - again it's out of date an missing some of the newer release features: https://github.com/UpperM/guacamole-powershell


Any guidance would be appreciated.


In your service,
Aaron Meyer



[GitHub] [guacamole-client] jmuehlner commented on a diff in pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "jmuehlner (via GitHub)" <gi...@apache.org>.
jmuehlner commented on code in PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#discussion_r1142526435


##########
guacamole/src/main/frontend/src/images/action-icons/guac-monitor-add-many.svg:
##########


Review Comment:
   Yeah ... that's how I started, but the monitors get to be really tiny if I squeeze them in there, small enough that it's really hard to tell what it's supposed to be at the resolution it's displayed at.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] jmuehlner commented on a diff in pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "jmuehlner (via GitHub)" <gi...@apache.org>.
jmuehlner commented on code in PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#discussion_r1159085167


##########
guacamole/src/main/frontend/src/app/import/types/DisplayErrorList.js:
##########
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Service which defines the DisplayErrorList class.
+ */
+angular.module('import').factory('DisplayErrorList', [
+        function defineDisplayErrorList() {
+
+    /**
+     * A list of human-readable error messages, intended to be usable in a
+     * sortable / filterable table.
+     *
+     * @constructor
+     * @param {String[]} messages
+     *     The error messages that should be prepared for display.
+     */
+    const DisplayErrorList = function DisplayErrorList(messages) {
+
+        // Use empty message list by default
+        this.messages = messages || [];
+
+        // The single String message composed of all messages concatenated
+        // together. This will be used for filtering / sorting, and should only
+        // be calculated once.
+        this.cachedMessage = null;

Review Comment:
   Oops, that's supposed to be `concatenatedMessage`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] jmuehlner commented on a diff in pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "jmuehlner (via GitHub)" <gi...@apache.org>.
jmuehlner commented on code in PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#discussion_r1159076524


##########
guacamole/src/main/frontend/src/app/rest/services/connectionService.js:
##########
@@ -24,9 +24,11 @@ angular.module('rest').factory('connectionService', ['$injector',
         function connectionService($injector) {
 
     // Required services
-    var requestService        = $injector.get('requestService');
     var authenticationService = $injector.get('authenticationService');
     var cacheService          = $injector.get('cacheService');
+
+    // Required types
+    const Error = $injector.get('Error');

Review Comment:
   Nope. I'll get rid of it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] jmuehlner commented on a diff in pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "jmuehlner (via GitHub)" <gi...@apache.org>.
jmuehlner commented on code in PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#discussion_r1158813797


##########
guacamole/src/main/java/org/apache/guacamole/rest/jsonpatch/APIPatchError.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.guacamole.rest.jsonpatch;
+
+import org.apache.guacamole.rest.jsonpatch.APIPatch.Operation;
+
+/**
+ * A failure outcome associated with a particular patch within a JSON Patch
+ * request. This status indicates that a particular patch failed to apply,
+ * and includes the error describing the failure, along with the operation and
+ * path from the original patch, and the identifier of the object
+ * referenced by the original patch.
+ */
+public class APIPatchError extends APIPatchOutcome {
+
+    /**
+     * The error associated with the submitted patch.
+     */
+    private final String error;
+
+    /**
+     * Create a failure status associated with a submitted patch from a JSON
+     * patch API request.
+     *
+     * @param op
+     *     The operation requested by the failed patch.
+     *
+     * @param identifier
+     *     The identifier of the object associated with the failed patch. If
+     *     the patch failed to create a new object, this will be null.
+     *
+     * @param path
+     *     The patch from the failed patch.
+     *
+     * @param error
+     *     The error message associated with the failure that prevented the
+     *     patch from applying.
+     */
+    public APIPatchError(
+            Operation op, String identifier, String path, String error) {
+        super(op, identifier, path);
+        this.error = error;
+    }
+
+    /**
+     * Return the error associated with the patch failure.
+     *
+     * @return
+     *     The error associated with the patch failure.
+     */
+    public String getError() {
+        return error;
+    }

Review Comment:
   Yeah, probably actually. 
   
   I can't guarantee that the caught errors will actually be translateable, but I can at least check if it implements `Translatable` and handle appropriately if so.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] jmuehlner commented on pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "jmuehlner (via GitHub)" <gi...@apache.org>.
jmuehlner commented on PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#issuecomment-1500714976

   Converting to draft while it give it one more once-over.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] jmuehlner commented on a diff in pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "jmuehlner (via GitHub)" <gi...@apache.org>.
jmuehlner commented on code in PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#discussion_r1160044403


##########
guacamole/src/main/java/org/apache/guacamole/rest/jsonpatch/APIPatchError.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.guacamole.rest.jsonpatch;
+
+import org.apache.guacamole.rest.jsonpatch.APIPatch.Operation;
+
+/**
+ * A failure outcome associated with a particular patch within a JSON Patch
+ * request. This status indicates that a particular patch failed to apply,
+ * and includes the error describing the failure, along with the operation and
+ * path from the original patch, and the identifier of the object
+ * referenced by the original patch.
+ */
+public class APIPatchError extends APIPatchOutcome {
+
+    /**
+     * The error associated with the submitted patch.
+     */
+    private final String error;
+
+    /**
+     * Create a failure status associated with a submitted patch from a JSON
+     * patch API request.
+     *
+     * @param op
+     *     The operation requested by the failed patch.
+     *
+     * @param identifier
+     *     The identifier of the object associated with the failed patch. If
+     *     the patch failed to create a new object, this will be null.
+     *
+     * @param path
+     *     The patch from the failed patch.
+     *
+     * @param error
+     *     The error message associated with the failure that prevented the
+     *     patch from applying.
+     */
+    public APIPatchError(
+            Operation op, String identifier, String path, String error) {
+        super(op, identifier, path);
+        this.error = error;
+    }
+
+    /**
+     * Return the error associated with the patch failure.
+     *
+     * @return
+     *     The error associated with the patch failure.
+     */
+    public String getError() {
+        return error;
+    }

Review Comment:
   Or wait, I already did this.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] mike-jumper merged pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "mike-jumper (via GitHub)" <gi...@apache.org>.
mike-jumper merged PR #809:
URL: https://github.com/apache/guacamole-client/pull/809


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] jmuehlner commented on a diff in pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "jmuehlner (via GitHub)" <gi...@apache.org>.
jmuehlner commented on code in PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#discussion_r1142484324


##########
guacamole/src/main/frontend/src/app/import/directives/connectionImportErrors.js:
##########
@@ -0,0 +1,234 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* global _ */

Review Comment:
   This is a [JSLint ](https://www.jslint.com/help.html) directive indicating that the `_` variable is a global defined outside this file. This makes Netbeans happy, among other possible benefits.
   
   There's a prior example here: https://github.com/apache/guacamole-client/blob/master/guacamole/src/main/frontend/src/app/client/types/ManagedClient.js#L20



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] jmuehlner commented on a diff in pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "jmuehlner (via GitHub)" <gi...@apache.org>.
jmuehlner commented on code in PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#discussion_r1142515589


##########
guacamole/src/main/java/org/apache/guacamole/rest/directory/DirectoryResource.java:
##########
@@ -386,46 +417,210 @@ public Map<String, ExternalType> getObjects(
 
     /**
      * Applies the given object patches, updating the underlying directory
-     * accordingly. This operation currently only supports deletion of objects
-     * through the "remove" patch operation. The path of each patch operation is
-     * of the form "/ID" where ID is the identifier of the object being
-     * modified.
+     * accordingly. This operation supports addition and removal of objects
+     * through the "add" and "remove" patch operation. The path of each patch
+     * operation is of the form "/ID" where ID is the identifier of the object
+     * being modified. In the case of object creation, the identifier is
+     * ignored, as the identifier will be automatically provided. This operation
+     * is atomic.
      *
      * @param patches
      *     The patches to apply for this request.
      *
      * @throws GuacamoleException
-     *     If an error occurs while deleting the objects.
+     *     If an error occurs while adding, updating, or removing objects.
+     *
+     * @return
+     *     A response describing the outcome of each patch. Only the identifier
+     *     of each patched object will be included in the response, not the
+     *     full object.
      */
     @PATCH
-    public void patchObjects(List<APIPatch<String>> patches)
+    public APIPatchResponse patchObjects(List<APIPatch<ExternalType>> patches)
             throws GuacamoleException {
 
-        // Apply each operation specified within the patch
-        for (APIPatch<String> patch : patches) {
+        // An outcome for each patch included in the request. This list
+        // may include both success and failure responses, though the
+        // presense of any failure would indicated that the entire
+        // request has failed and no changes have been made.
+        List<APIPatchOutcome> patchOutcomes = new ArrayList<>();
 
-            // Only remove is supported
-            if (patch.getOp() != APIPatch.Operation.remove)
-                throw new GuacamoleUnsupportedException("Only the \"remove\" "
-                        + "operation is supported.");
+        // Perform all requested operations atomically
+        directory.tryAtomically(new AtomicDirectoryOperation<InternalType>() {
 
-            // Retrieve and validate path
-            String path = patch.getPath();
-            if (!path.startsWith("/"))
-                throw new GuacamoleClientException("Patch paths must start with \"/\".");
+            @Override
+            public void executeOperation(boolean atomic, Directory<InternalType> directory)
+                    throws GuacamoleException {
+
+                // If the underlying directory implentation does not support
+                // atomic operations, abort the patch operation. This REST
+                // endpoint requires that operations be performed atomically.
+                if (!atomic)
+                    throw new GuacamoleUnsupportedException(
+                            "Atomic operations are not supported. " +
+                            "The patch cannot be executed.");
+
+                // Keep a list of all objects that have been successfully
+                // added or removed
+                Collection<InternalType> addedObjects = new ArrayList<>();
+                Collection<String> removedIdentifiers = new ArrayList<>();
+
+                // A list of all responses associated with the successful
+                // creation of new objects
+                List<APIPatchOutcome> creationSuccesses = new ArrayList<>();
+
+                // True if any operation in the patch failed. Any failure will
+                // fail the request, though won't result in immediate stoppage
+                // since more errors may yet be uncovered.
+                boolean failed = false;
+
+                // Apply each operation specified within the patch
+                for (APIPatch<ExternalType> patch : patches) {
+
+                    // Retrieve and validate path
+                    String path = patch.getPath();
+                    if (!path.startsWith("/"))
+                        throw new GuacamoleClientException("Patch paths must start with \"/\".");
+
+                    if(patch.getOp() == APIPatch.Operation.add) {

Review Comment:
   I would expect the cost of calling `getOp()` to be negligible considering that it doesn't do any calculation and just returns a value. There wouldn't be any harm in creating a copy of the variable in the local scope either though. 
   
   I suspect that the JDK or JVM might optimize away the cost of the extra stack frame for the `getOp()` call, but I'm not 100% sure about that. I'll change it over to a local variable and then we don't have to worry about it.
   
   As for the switch statement - I mostly just wanted to avoid another layer of indentation, since an `if` adds one level, and 
   ```
   switch(op) {
       case add:
            ... stuff ...
   ```
   adds two.
   
   I'll admit that a switch statement is probably the "right way to do it" though. If people have strong preferences here, I'm happy to change it over.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] necouchman commented on a diff in pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "necouchman (via GitHub)" <gi...@apache.org>.
necouchman commented on code in PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#discussion_r1139288588


##########
guacamole/src/main/frontend/src/app/import/controllers/importConnectionsController.js:
##########
@@ -0,0 +1,760 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* global _ */

Review Comment:
   Something new, different, extra?



##########
guacamole/src/main/frontend/src/app/import/directives/connectionImportErrors.js:
##########
@@ -0,0 +1,234 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* global _ */

Review Comment:
   ?



##########
guacamole/src/main/java/org/apache/guacamole/rest/jsonpatch/APIPatchOutcome.java:
##########
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.guacamole.rest.jsonpatch;
+
+import org.apache.guacamole.rest.jsonpatch.APIPatch.Operation;
+
+/**
+ * A successful outcome associated with a particular patch within a JSON Patch
+ * request. The outcome contains the operation requested by the original patch,
+ * the path from the original patch, and the identifier of the object corresponding
+ * to the value from the original patch.
+ *
+ * The purpose of this class is to present a relatively lightweight outcome for
+ * the user who submitted the Patch request. Rather than including the full
+ * contents of the value, only the identifier is included, allowing the user to
+ * determine the identifier of any newly-created objects as part of the request.
+ *
+ */
+public class APIPatchOutcome {
+
+    /**
+     * The requested operation for the patch corresponding to this outcome.
+     */
+    private final Operation op;
+
+    /**
+     * The identifier for the value in patch corresponding to this outcome.
+     * If the value in the patch was null, this identifier should also be null.
+     */
+    private String identifier;
+
+    /**
+     * The path for the patch corresponding to this outcome.
+     */
+    private final String path;
+
+    /**
+     * Create an outcome associated with a submitted patch, as part of a JSON
+     * patch API request.
+     *
+     * @param op
+     * @param identifier
+     * @param path

Review Comment:
   Looks like these parameters are missing documentation?



##########
guacamole/src/main/frontend/src/translations/en.json:
##########
@@ -5,7 +5,7 @@
     "APP" : {
 
         "NAME"    : "Apache Guacamole",
-        "VERSION" : "${project.version}",
+        "VERSION" : "1.5.0",

Review Comment:
   Any reason this is being set statically, here?



##########
guacamole/src/main/frontend/src/translations/en.json:
##########
@@ -183,6 +183,79 @@
 
     },
 
+    "IMPORT": {
+        
+        "ACTION_ACKNOWLEDGE"          : "@:APP.ACTION_ACKNOWLEDGE",
+
+        "BUTTON_CANCEL": "Cancel",
+        "BUTTON_CLEAR": "Clear",
+        "BUTTON_IMPORT": "Import Connections",
+
+        "CONNECTIONS_IMPORTED_SUCCESS": "{NUMBER} connections imported successfully.",
+
+        "DIALOG_HEADER_ERROR" : "@:APP.DIALOG_HEADER_ERROR",
+        "DIALOG_HEADER_SUCCESS": "Success",
+
+        "FIELD_PLACEHOLDER_FILTER" : "@:APP.FIELD_PLACEHOLDER_FILTER",
+
+        "HEADER": "Connection Import",
+
+        "HELP_HEADER": "Connection Import File Format",
+
+        "HELP_FILE_TYPE_HEADER": "File Types",
+        "HELP_FILE_TYPE_DESCRIPTION" : "Three file types are supported for connection import: CSV, JSON, and YAML. The same data may be specified by each file type. This must include the connection name and protocol. Optionally, a connection group location, a list of users and/or user groups to grant access, connection parameters, or connection protocols may also be specified. Any users or user groups that do not exist in the current data source will be automatically created.",
+
+        "HELP_CSV_HEADER": "CSV Format",
+        "HELP_CSV_DESCRIPTION": "A connection import CSV file has one connection record per row. Each column will specify a connection field. At minimum the connection name and protocol must be specified.",
+        "HELP_CSV_MORE_DETAILS": "The CSV header for each row specifies the connection field. The connection group ID that the connection should be imported into may be directly specified with \"parentIdentifier\", or the path to the parent group may be specified using \"group\" as shown below. In most cases, there should be no conflict between fields, but if needed, an \" (attribute)\" or \" (parameter)\" suffix may be added to disambiguate. Lists of user or user group identifiers must be semicolon-seperated.¹",
+
+        "HELP_JSON_HEADER": "JSON Format",
+        "HELP_JSON_DESCRIPTION": "A connection import JSON file is a list of connection objects. At minimum the connection name and protocol must be specified in each connection object.",
+        "HELP_JSON_MORE_DETAILS": "The connection group ID that the connection should be imported into may be directly specified with a \"parentIdentifier\" field, or the path to the parent group may be specified using a \"group\" field as shown below. An array of user and user group identifiers to grant access to may be specified per connection.",
+
+        "HELP_YAML_HEADER": "YAML Format",
+        "HELP_YAML_DESCRIPTION": "A connection import YAML file is a list of connection objects with exactly the same structure as the JSON format.",
+        
+        "HELP_SEMICOLON_FOOTNOTE": "If present, semicolons can be escaped with a backslash, e.g. \"first\\\\;last\"",
+
+        "ERROR_AMBIGUOUS_CSV_HEADER": 
+            "Ambiguous CSV Header \"{HEADER}\" could be either a connection attribute or parameter",
+        "ERROR_ARRAY_REQUIRED": 
+            "The provided file must contain a list of connections",
+        "ERROR_DUPLICATE_CSV_HEADER": 
+            "Duplicate CSV Header: {HEADER}",
+        "ERROR_EMPTY_FILE": "The provided file is empty",
+        "ERROR_INVALID_CSV_HEADER": 
+            "Invalid CSV Header \"{HEADER}\" is neither an attribute or parameter",
+        "ERROR_INVALID_GROUP": "No group matching \"{GROUP}\" found",
+        "ERROR_INVALID_FILE_TYPE": 
+            "Unsupported file type: \"{TYPE}\"",
+        "ERROR_INVALID_USER_IDENTIFIERS":
+            "Users not found: {IDENTIFIER_LIST}",
+        "ERROR_INVALID_USER_GROUP_IDENTIFIERS":
+            "User Groups not found: {IDENTIFIER_LIST}",
+        "ERROR_NO_FILE_SUPPLIED": "Please select a file to import",
+        "ERROR_AMBIGUOUS_PARENT_GROUP":
+            "Both group and parentIdentifier may be not specified at the same time",
+        "ERROR_REQUIRED_PROTOCOL": 
+            "No connection protocol found in the provided file",
+        "ERROR_REQUIRED_NAME": 
+            "No connection name found in the provided file",
+
+        "ERROR_FILE_SINGLE_ONLY": "Please upload only a single file at a time",
+
+        "TABLE_HEADER_NAME" : "Name",
+        "TABLE_HEADER_PROTOCOL" : "Protocol",
+        "TABLE_HEADER_ERRORS" : "Errors",
+        "TABLE_HEADER_ROW_NUMBER": "Row #",
+
+        "UPLOAD_FILE_TYPES": "CSV, JSON, or YAML",
+        "UPLOAD_HELP_LINK": "View Format Tips",
+        "UPLOAD_DROP_TITLE": "Drop a File Here",
+        "UPLOAD_BROWSE_LINK": "Browse for File"
+        
+    },

Review Comment:
   Seems like the style, here, doesn't match the other sections, in a couple of ways:
   * Generally things are organized alphabetically, and so `ERROR_` should be between `DIALOG_` and `FIELD_`.
   * There are several line breaks here between the key and value pairs.



##########
guacamole/src/main/java/org/apache/guacamole/rest/directory/DirectoryResource.java:
##########
@@ -386,46 +417,210 @@ public Map<String, ExternalType> getObjects(
 
     /**
      * Applies the given object patches, updating the underlying directory
-     * accordingly. This operation currently only supports deletion of objects
-     * through the "remove" patch operation. The path of each patch operation is
-     * of the form "/ID" where ID is the identifier of the object being
-     * modified.
+     * accordingly. This operation supports addition and removal of objects
+     * through the "add" and "remove" patch operation. The path of each patch
+     * operation is of the form "/ID" where ID is the identifier of the object
+     * being modified. In the case of object creation, the identifier is
+     * ignored, as the identifier will be automatically provided. This operation
+     * is atomic.
      *
      * @param patches
      *     The patches to apply for this request.
      *
      * @throws GuacamoleException
-     *     If an error occurs while deleting the objects.
+     *     If an error occurs while adding, updating, or removing objects.
+     *
+     * @return
+     *     A response describing the outcome of each patch. Only the identifier
+     *     of each patched object will be included in the response, not the
+     *     full object.
      */
     @PATCH
-    public void patchObjects(List<APIPatch<String>> patches)
+    public APIPatchResponse patchObjects(List<APIPatch<ExternalType>> patches)
             throws GuacamoleException {
 
-        // Apply each operation specified within the patch
-        for (APIPatch<String> patch : patches) {
+        // An outcome for each patch included in the request. This list
+        // may include both success and failure responses, though the
+        // presense of any failure would indicated that the entire
+        // request has failed and no changes have been made.
+        List<APIPatchOutcome> patchOutcomes = new ArrayList<>();
 
-            // Only remove is supported
-            if (patch.getOp() != APIPatch.Operation.remove)
-                throw new GuacamoleUnsupportedException("Only the \"remove\" "
-                        + "operation is supported.");
+        // Perform all requested operations atomically
+        directory.tryAtomically(new AtomicDirectoryOperation<InternalType>() {
 
-            // Retrieve and validate path
-            String path = patch.getPath();
-            if (!path.startsWith("/"))
-                throw new GuacamoleClientException("Patch paths must start with \"/\".");
+            @Override
+            public void executeOperation(boolean atomic, Directory<InternalType> directory)
+                    throws GuacamoleException {
+
+                // If the underlying directory implentation does not support
+                // atomic operations, abort the patch operation. This REST
+                // endpoint requires that operations be performed atomically.
+                if (!atomic)
+                    throw new GuacamoleUnsupportedException(
+                            "Atomic operations are not supported. " +
+                            "The patch cannot be executed.");
+
+                // Keep a list of all objects that have been successfully
+                // added or removed
+                Collection<InternalType> addedObjects = new ArrayList<>();
+                Collection<String> removedIdentifiers = new ArrayList<>();
+
+                // A list of all responses associated with the successful
+                // creation of new objects
+                List<APIPatchOutcome> creationSuccesses = new ArrayList<>();
+
+                // True if any operation in the patch failed. Any failure will
+                // fail the request, though won't result in immediate stoppage
+                // since more errors may yet be uncovered.
+                boolean failed = false;
+
+                // Apply each operation specified within the patch
+                for (APIPatch<ExternalType> patch : patches) {
+
+                    // Retrieve and validate path
+                    String path = patch.getPath();
+                    if (!path.startsWith("/"))
+                        throw new GuacamoleClientException("Patch paths must start with \"/\".");
+
+                    if(patch.getOp() == APIPatch.Operation.add) {

Review Comment:
   I hesitate to question this at all, because I know you know what you're doing, but i"ll throw a couple of things out there - feel free to ignore them if you've already considered and have reasons for doing this the way you have it written, here...
   * Throughout this section, there are multiple calls to `patch.getOp()`. I don't know what the cost is in terms of doing that versus assigning the value to a variable and checking throughout this section? Maybe it's negligible, and doesn't matter, and it makes sense to keep it this way? Or maybe it occupies more memory than it's worth and the cost of doing it this way is less than going the variable route?
   * I know there are only two operations here (three if you count the catch-all at the end), but any reason to go `if/else` rather than a `switch()` statement?



##########
extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/base/JDBCDirectory.java:
##########
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.guacamole.auth.jdbc.base;
+
+import org.apache.guacamole.GuacamoleException;
+import org.apache.guacamole.net.auth.AtomicDirectoryOperation;
+import org.apache.guacamole.net.auth.Directory;
+import org.apache.guacamole.net.auth.Identifiable;
+import org.mybatis.guice.transactional.Transactional;
+
+/**
+ * An implementation of Directory that uses database transactions to guarantee
+ * atomicity for any operations supplied to tryAtomically().
+ */

Review Comment:
   Does this implementation, coupled with the fact that it is used elsewhere, mean that all JDBC operations will be attempted atomically? And does that have any potential adverse impacts from a performance perspective, particularly when you have multiple people accessing the Guacamole UI, starting and stopping connections, which will involve DB reads to retrieve connection data and DB writes for history entries, etc.
   
   Sorry if that's a stupid or obvious question...



##########
guacamole/src/main/java/org/apache/guacamole/rest/directory/DirectoryResource.java:
##########
@@ -386,46 +417,210 @@ public Map<String, ExternalType> getObjects(
 
     /**
      * Applies the given object patches, updating the underlying directory
-     * accordingly. This operation currently only supports deletion of objects
-     * through the "remove" patch operation. The path of each patch operation is
-     * of the form "/ID" where ID is the identifier of the object being
-     * modified.
+     * accordingly. This operation supports addition and removal of objects
+     * through the "add" and "remove" patch operation. The path of each patch
+     * operation is of the form "/ID" where ID is the identifier of the object
+     * being modified. In the case of object creation, the identifier is
+     * ignored, as the identifier will be automatically provided. This operation
+     * is atomic.
      *
      * @param patches
      *     The patches to apply for this request.
      *
      * @throws GuacamoleException
-     *     If an error occurs while deleting the objects.
+     *     If an error occurs while adding, updating, or removing objects.
+     *
+     * @return
+     *     A response describing the outcome of each patch. Only the identifier
+     *     of each patched object will be included in the response, not the
+     *     full object.
      */
     @PATCH
-    public void patchObjects(List<APIPatch<String>> patches)
+    public APIPatchResponse patchObjects(List<APIPatch<ExternalType>> patches)
             throws GuacamoleException {
 
-        // Apply each operation specified within the patch
-        for (APIPatch<String> patch : patches) {
+        // An outcome for each patch included in the request. This list
+        // may include both success and failure responses, though the
+        // presense of any failure would indicated that the entire

Review Comment:
   presense -> presence
   
   ?



##########
guacamole/src/main/java/org/apache/guacamole/rest/APIError.java:
##########
@@ -21,6 +21,8 @@
 
 import java.util.Collection;
 import java.util.Collections;
+import java.util.List;
+

Review Comment:
   Extra line.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] jmuehlner commented on a diff in pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "jmuehlner (via GitHub)" <gi...@apache.org>.
jmuehlner commented on code in PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#discussion_r1140546140


##########
doc/licenses/csv-6.2.5/README:
##########
@@ -0,0 +1,7 @@
+node-csv (https://github.com/adaltas/node-csv)
+---------------------------------------------
+
+    Version: 6.2.5
+    From: 'adaltas' (https://github.com/adaltas)

Review Comment:
   > Initial review of just the additional bundled dependency licenses:
   > 
   > * Some of the names of the copyright holders (`From: ...`) need to be corrected to align with the copyright holders declared by the license.
   > * Some of the references to `.../LICENSE` need to be corrected to the name of the bundled license file (`.../LICENSE.md`, `.../license.md`, etc.).
   
   Oof, sorry about all the mistakes. These should all be fixed now.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] jmuehlner commented on a diff in pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "jmuehlner (via GitHub)" <gi...@apache.org>.
jmuehlner commented on code in PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#discussion_r1142494496


##########
extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/base/JDBCDirectory.java:
##########
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.guacamole.auth.jdbc.base;
+
+import org.apache.guacamole.GuacamoleException;
+import org.apache.guacamole.net.auth.AtomicDirectoryOperation;
+import org.apache.guacamole.net.auth.Directory;
+import org.apache.guacamole.net.auth.Identifiable;
+import org.mybatis.guice.transactional.Transactional;
+
+/**
+ * An implementation of Directory that uses database transactions to guarantee
+ * atomicity for any operations supplied to tryAtomically().
+ */

Review Comment:
   The only place this is used is in the [Directory PATCH endpoint](https://github.com/jmuehlner/guacamole-client/blob/GUACAMOLE-926-batch-connection-import/guacamole/src/main/java/org/apache/guacamole/rest/directory/DirectoryResource.java#L449), so it should have no effects on performance or anything else for any other JDBC call. 
   
   So no, not all JDBC operations will be attempted atomically.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] necouchman commented on a diff in pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "necouchman (via GitHub)" <gi...@apache.org>.
necouchman commented on code in PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#discussion_r1142488395


##########
guacamole/src/main/frontend/src/app/import/directives/connectionImportErrors.js:
##########
@@ -0,0 +1,234 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* global _ */

Review Comment:
   Okay, I've no problem keeping them if they are helpful and/or needed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] jmuehlner commented on a diff in pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "jmuehlner (via GitHub)" <gi...@apache.org>.
jmuehlner commented on code in PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#discussion_r1142525771


##########
guacamole/src/main/frontend/src/translations/en.json:
##########
@@ -183,6 +183,79 @@
 
     },
 
+    "IMPORT": {
+        
+        "ACTION_ACKNOWLEDGE"          : "@:APP.ACTION_ACKNOWLEDGE",
+
+        "BUTTON_CANCEL": "Cancel",
+        "BUTTON_CLEAR": "Clear",
+        "BUTTON_IMPORT": "Import Connections",
+
+        "CONNECTIONS_IMPORTED_SUCCESS": "{NUMBER} connections imported successfully.",
+
+        "DIALOG_HEADER_ERROR" : "@:APP.DIALOG_HEADER_ERROR",
+        "DIALOG_HEADER_SUCCESS": "Success",
+
+        "FIELD_PLACEHOLDER_FILTER" : "@:APP.FIELD_PLACEHOLDER_FILTER",
+
+        "HEADER": "Connection Import",
+
+        "HELP_HEADER": "Connection Import File Format",
+
+        "HELP_FILE_TYPE_HEADER": "File Types",
+        "HELP_FILE_TYPE_DESCRIPTION" : "Three file types are supported for connection import: CSV, JSON, and YAML. The same data may be specified by each file type. This must include the connection name and protocol. Optionally, a connection group location, a list of users and/or user groups to grant access, connection parameters, or connection protocols may also be specified. Any users or user groups that do not exist in the current data source will be automatically created.",
+
+        "HELP_CSV_HEADER": "CSV Format",
+        "HELP_CSV_DESCRIPTION": "A connection import CSV file has one connection record per row. Each column will specify a connection field. At minimum the connection name and protocol must be specified.",
+        "HELP_CSV_MORE_DETAILS": "The CSV header for each row specifies the connection field. The connection group ID that the connection should be imported into may be directly specified with \"parentIdentifier\", or the path to the parent group may be specified using \"group\" as shown below. In most cases, there should be no conflict between fields, but if needed, an \" (attribute)\" or \" (parameter)\" suffix may be added to disambiguate. Lists of user or user group identifiers must be semicolon-seperated.¹",

Review Comment:
   Yes.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] mike-jumper commented on a diff in pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "mike-jumper (via GitHub)" <gi...@apache.org>.
mike-jumper commented on code in PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#discussion_r1142458229


##########
guacamole/src/main/frontend/src/translations/en.json:
##########
@@ -183,6 +183,79 @@
 
     },
 
+    "IMPORT": {
+        
+        "ACTION_ACKNOWLEDGE"          : "@:APP.ACTION_ACKNOWLEDGE",
+
+        "BUTTON_CANCEL": "Cancel",
+        "BUTTON_CLEAR": "Clear",
+        "BUTTON_IMPORT": "Import Connections",
+
+        "CONNECTIONS_IMPORTED_SUCCESS": "{NUMBER} connections imported successfully.",

Review Comment:
   You'll need to use pluralization here so that "connection" vs. "connections" is chosen appropriately based on the value of `NUMBER`.



##########
guacamole/src/main/frontend/src/translations/en.json:
##########
@@ -183,6 +183,79 @@
 
     },
 
+    "IMPORT": {
+        
+        "ACTION_ACKNOWLEDGE"          : "@:APP.ACTION_ACKNOWLEDGE",
+
+        "BUTTON_CANCEL": "Cancel",
+        "BUTTON_CLEAR": "Clear",
+        "BUTTON_IMPORT": "Import Connections",

Review Comment:
   The prefix for actions that may be taken, button or not, is `ACTION_`. Here, for generic actions like "Cancel" and "Clear", they should be defined at the `APP` level and then referenced.



##########
guacamole/src/main/frontend/src/translations/en.json:
##########
@@ -183,6 +183,79 @@
 
     },
 
+    "IMPORT": {
+        
+        "ACTION_ACKNOWLEDGE"          : "@:APP.ACTION_ACKNOWLEDGE",
+
+        "BUTTON_CANCEL": "Cancel",
+        "BUTTON_CLEAR": "Clear",
+        "BUTTON_IMPORT": "Import Connections",
+
+        "CONNECTIONS_IMPORTED_SUCCESS": "{NUMBER} connections imported successfully.",
+
+        "DIALOG_HEADER_ERROR" : "@:APP.DIALOG_HEADER_ERROR",
+        "DIALOG_HEADER_SUCCESS": "Success",
+
+        "FIELD_PLACEHOLDER_FILTER" : "@:APP.FIELD_PLACEHOLDER_FILTER",
+
+        "HEADER": "Connection Import",
+
+        "HELP_HEADER": "Connection Import File Format",
+
+        "HELP_FILE_TYPE_HEADER": "File Types",
+        "HELP_FILE_TYPE_DESCRIPTION" : "Three file types are supported for connection import: CSV, JSON, and YAML. The same data may be specified by each file type. This must include the connection name and protocol. Optionally, a connection group location, a list of users and/or user groups to grant access, connection parameters, or connection protocols may also be specified. Any users or user groups that do not exist in the current data source will be automatically created.",
+
+        "HELP_CSV_HEADER": "CSV Format",
+        "HELP_CSV_DESCRIPTION": "A connection import CSV file has one connection record per row. Each column will specify a connection field. At minimum the connection name and protocol must be specified.",
+        "HELP_CSV_MORE_DETAILS": "The CSV header for each row specifies the connection field. The connection group ID that the connection should be imported into may be directly specified with \"parentIdentifier\", or the path to the parent group may be specified using \"group\" as shown below. In most cases, there should be no conflict between fields, but if needed, an \" (attribute)\" or \" (parameter)\" suffix may be added to disambiguate. Lists of user or user group identifiers must be semicolon-seperated.¹",
+
+        "HELP_JSON_HEADER": "JSON Format",
+        "HELP_JSON_DESCRIPTION": "A connection import JSON file is a list of connection objects. At minimum the connection name and protocol must be specified in each connection object.",
+        "HELP_JSON_MORE_DETAILS": "The connection group ID that the connection should be imported into may be directly specified with a \"parentIdentifier\" field, or the path to the parent group may be specified using a \"group\" field as shown below. An array of user and user group identifiers to grant access to may be specified per connection.",
+
+        "HELP_YAML_HEADER": "YAML Format",
+        "HELP_YAML_DESCRIPTION": "A connection import YAML file is a list of connection objects with exactly the same structure as the JSON format.",
+        
+        "HELP_SEMICOLON_FOOTNOTE": "If present, semicolons can be escaped with a backslash, e.g. \"first\\\\;last\"",
+
+        "ERROR_AMBIGUOUS_CSV_HEADER": 
+            "Ambiguous CSV Header \"{HEADER}\" could be either a connection attribute or parameter",
+        "ERROR_ARRAY_REQUIRED": 
+            "The provided file must contain a list of connections",
+        "ERROR_DUPLICATE_CSV_HEADER": 
+            "Duplicate CSV Header: {HEADER}",
+        "ERROR_EMPTY_FILE": "The provided file is empty",
+        "ERROR_INVALID_CSV_HEADER": 
+            "Invalid CSV Header \"{HEADER}\" is neither an attribute or parameter",
+        "ERROR_INVALID_GROUP": "No group matching \"{GROUP}\" found",
+        "ERROR_INVALID_FILE_TYPE": 
+            "Unsupported file type: \"{TYPE}\"",
+        "ERROR_INVALID_USER_IDENTIFIERS":
+            "Users not found: {IDENTIFIER_LIST}",
+        "ERROR_INVALID_USER_GROUP_IDENTIFIERS":
+            "User Groups not found: {IDENTIFIER_LIST}",
+        "ERROR_NO_FILE_SUPPLIED": "Please select a file to import",
+        "ERROR_AMBIGUOUS_PARENT_GROUP":
+            "Both group and parentIdentifier may be not specified at the same time",
+        "ERROR_REQUIRED_PROTOCOL": 
+            "No connection protocol found in the provided file",
+        "ERROR_REQUIRED_NAME": 
+            "No connection name found in the provided file",
+
+        "ERROR_FILE_SINGLE_ONLY": "Please upload only a single file at a time",
+
+        "TABLE_HEADER_NAME" : "Name",
+        "TABLE_HEADER_PROTOCOL" : "Protocol",
+        "TABLE_HEADER_ERRORS" : "Errors",
+        "TABLE_HEADER_ROW_NUMBER": "Row #",
+
+        "UPLOAD_FILE_TYPES": "CSV, JSON, or YAML",
+        "UPLOAD_HELP_LINK": "View Format Tips",
+        "UPLOAD_DROP_TITLE": "Drop a File Here",

Review Comment:
   This is probably a `HELP_`.



##########
guacamole/src/main/frontend/src/translations/en.json:
##########
@@ -183,6 +183,79 @@
 
     },
 
+    "IMPORT": {
+        
+        "ACTION_ACKNOWLEDGE"          : "@:APP.ACTION_ACKNOWLEDGE",
+
+        "BUTTON_CANCEL": "Cancel",
+        "BUTTON_CLEAR": "Clear",
+        "BUTTON_IMPORT": "Import Connections",
+
+        "CONNECTIONS_IMPORTED_SUCCESS": "{NUMBER} connections imported successfully.",
+
+        "DIALOG_HEADER_ERROR" : "@:APP.DIALOG_HEADER_ERROR",
+        "DIALOG_HEADER_SUCCESS": "Success",
+
+        "FIELD_PLACEHOLDER_FILTER" : "@:APP.FIELD_PLACEHOLDER_FILTER",
+
+        "HEADER": "Connection Import",
+
+        "HELP_HEADER": "Connection Import File Format",
+
+        "HELP_FILE_TYPE_HEADER": "File Types",
+        "HELP_FILE_TYPE_DESCRIPTION" : "Three file types are supported for connection import: CSV, JSON, and YAML. The same data may be specified by each file type. This must include the connection name and protocol. Optionally, a connection group location, a list of users and/or user groups to grant access, connection parameters, or connection protocols may also be specified. Any users or user groups that do not exist in the current data source will be automatically created.",
+
+        "HELP_CSV_HEADER": "CSV Format",
+        "HELP_CSV_DESCRIPTION": "A connection import CSV file has one connection record per row. Each column will specify a connection field. At minimum the connection name and protocol must be specified.",
+        "HELP_CSV_MORE_DETAILS": "The CSV header for each row specifies the connection field. The connection group ID that the connection should be imported into may be directly specified with \"parentIdentifier\", or the path to the parent group may be specified using \"group\" as shown below. In most cases, there should be no conflict between fields, but if needed, an \" (attribute)\" or \" (parameter)\" suffix may be added to disambiguate. Lists of user or user group identifiers must be semicolon-seperated.¹",
+
+        "HELP_JSON_HEADER": "JSON Format",
+        "HELP_JSON_DESCRIPTION": "A connection import JSON file is a list of connection objects. At minimum the connection name and protocol must be specified in each connection object.",
+        "HELP_JSON_MORE_DETAILS": "The connection group ID that the connection should be imported into may be directly specified with a \"parentIdentifier\" field, or the path to the parent group may be specified using a \"group\" field as shown below. An array of user and user group identifiers to grant access to may be specified per connection.",
+
+        "HELP_YAML_HEADER": "YAML Format",
+        "HELP_YAML_DESCRIPTION": "A connection import YAML file is a list of connection objects with exactly the same structure as the JSON format.",
+        
+        "HELP_SEMICOLON_FOOTNOTE": "If present, semicolons can be escaped with a backslash, e.g. \"first\\\\;last\"",
+
+        "ERROR_AMBIGUOUS_CSV_HEADER": 
+            "Ambiguous CSV Header \"{HEADER}\" could be either a connection attribute or parameter",
+        "ERROR_ARRAY_REQUIRED": 
+            "The provided file must contain a list of connections",
+        "ERROR_DUPLICATE_CSV_HEADER": 
+            "Duplicate CSV Header: {HEADER}",
+        "ERROR_EMPTY_FILE": "The provided file is empty",
+        "ERROR_INVALID_CSV_HEADER": 
+            "Invalid CSV Header \"{HEADER}\" is neither an attribute or parameter",
+        "ERROR_INVALID_GROUP": "No group matching \"{GROUP}\" found",
+        "ERROR_INVALID_FILE_TYPE": 
+            "Unsupported file type: \"{TYPE}\"",
+        "ERROR_INVALID_USER_IDENTIFIERS":
+            "Users not found: {IDENTIFIER_LIST}",
+        "ERROR_INVALID_USER_GROUP_IDENTIFIERS":
+            "User Groups not found: {IDENTIFIER_LIST}",
+        "ERROR_NO_FILE_SUPPLIED": "Please select a file to import",
+        "ERROR_AMBIGUOUS_PARENT_GROUP":
+            "Both group and parentIdentifier may be not specified at the same time",
+        "ERROR_REQUIRED_PROTOCOL": 
+            "No connection protocol found in the provided file",
+        "ERROR_REQUIRED_NAME": 
+            "No connection name found in the provided file",
+
+        "ERROR_FILE_SINGLE_ONLY": "Please upload only a single file at a time",
+
+        "TABLE_HEADER_NAME" : "Name",
+        "TABLE_HEADER_PROTOCOL" : "Protocol",
+        "TABLE_HEADER_ERRORS" : "Errors",
+        "TABLE_HEADER_ROW_NUMBER": "Row #",
+
+        "UPLOAD_FILE_TYPES": "CSV, JSON, or YAML",
+        "UPLOAD_HELP_LINK": "View Format Tips",

Review Comment:
   `ACTION_...`?



##########
guacamole/src/main/frontend/src/translations/en.json:
##########
@@ -905,6 +978,7 @@
     "SETTINGS_CONNECTIONS" : {
 
         "ACTION_ACKNOWLEDGE"          : "@:APP.ACTION_ACKNOWLEDGE",
+        "ACTION_IMPORT_CONNECTIONS"   : "Import",

Review Comment:
   This should probably be declared generically as `ACTION_IMPORT` at the `APP` level, and then referenced here.



##########
guacamole/src/main/frontend/src/translations/en.json:
##########
@@ -183,6 +183,79 @@
 
     },
 
+    "IMPORT": {
+        
+        "ACTION_ACKNOWLEDGE"          : "@:APP.ACTION_ACKNOWLEDGE",
+
+        "BUTTON_CANCEL": "Cancel",
+        "BUTTON_CLEAR": "Clear",
+        "BUTTON_IMPORT": "Import Connections",
+
+        "CONNECTIONS_IMPORTED_SUCCESS": "{NUMBER} connections imported successfully.",
+
+        "DIALOG_HEADER_ERROR" : "@:APP.DIALOG_HEADER_ERROR",
+        "DIALOG_HEADER_SUCCESS": "Success",
+
+        "FIELD_PLACEHOLDER_FILTER" : "@:APP.FIELD_PLACEHOLDER_FILTER",
+
+        "HEADER": "Connection Import",
+
+        "HELP_HEADER": "Connection Import File Format",
+
+        "HELP_FILE_TYPE_HEADER": "File Types",
+        "HELP_FILE_TYPE_DESCRIPTION" : "Three file types are supported for connection import: CSV, JSON, and YAML. The same data may be specified by each file type. This must include the connection name and protocol. Optionally, a connection group location, a list of users and/or user groups to grant access, connection parameters, or connection protocols may also be specified. Any users or user groups that do not exist in the current data source will be automatically created.",
+
+        "HELP_CSV_HEADER": "CSV Format",
+        "HELP_CSV_DESCRIPTION": "A connection import CSV file has one connection record per row. Each column will specify a connection field. At minimum the connection name and protocol must be specified.",
+        "HELP_CSV_MORE_DETAILS": "The CSV header for each row specifies the connection field. The connection group ID that the connection should be imported into may be directly specified with \"parentIdentifier\", or the path to the parent group may be specified using \"group\" as shown below. In most cases, there should be no conflict between fields, but if needed, an \" (attribute)\" or \" (parameter)\" suffix may be added to disambiguate. Lists of user or user group identifiers must be semicolon-seperated.¹",
+
+        "HELP_JSON_HEADER": "JSON Format",
+        "HELP_JSON_DESCRIPTION": "A connection import JSON file is a list of connection objects. At minimum the connection name and protocol must be specified in each connection object.",
+        "HELP_JSON_MORE_DETAILS": "The connection group ID that the connection should be imported into may be directly specified with a \"parentIdentifier\" field, or the path to the parent group may be specified using a \"group\" field as shown below. An array of user and user group identifiers to grant access to may be specified per connection.",
+
+        "HELP_YAML_HEADER": "YAML Format",
+        "HELP_YAML_DESCRIPTION": "A connection import YAML file is a list of connection objects with exactly the same structure as the JSON format.",
+        
+        "HELP_SEMICOLON_FOOTNOTE": "If present, semicolons can be escaped with a backslash, e.g. \"first\\\\;last\"",
+
+        "ERROR_AMBIGUOUS_CSV_HEADER": 
+            "Ambiguous CSV Header \"{HEADER}\" could be either a connection attribute or parameter",
+        "ERROR_ARRAY_REQUIRED": 
+            "The provided file must contain a list of connections",
+        "ERROR_DUPLICATE_CSV_HEADER": 
+            "Duplicate CSV Header: {HEADER}",
+        "ERROR_EMPTY_FILE": "The provided file is empty",
+        "ERROR_INVALID_CSV_HEADER": 
+            "Invalid CSV Header \"{HEADER}\" is neither an attribute or parameter",
+        "ERROR_INVALID_GROUP": "No group matching \"{GROUP}\" found",
+        "ERROR_INVALID_FILE_TYPE": 
+            "Unsupported file type: \"{TYPE}\"",
+        "ERROR_INVALID_USER_IDENTIFIERS":
+            "Users not found: {IDENTIFIER_LIST}",
+        "ERROR_INVALID_USER_GROUP_IDENTIFIERS":
+            "User Groups not found: {IDENTIFIER_LIST}",
+        "ERROR_NO_FILE_SUPPLIED": "Please select a file to import",
+        "ERROR_AMBIGUOUS_PARENT_GROUP":
+            "Both group and parentIdentifier may be not specified at the same time",
+        "ERROR_REQUIRED_PROTOCOL": 
+            "No connection protocol found in the provided file",
+        "ERROR_REQUIRED_NAME": 
+            "No connection name found in the provided file",
+
+        "ERROR_FILE_SINGLE_ONLY": "Please upload only a single file at a time",
+
+        "TABLE_HEADER_NAME" : "Name",
+        "TABLE_HEADER_PROTOCOL" : "Protocol",
+        "TABLE_HEADER_ERRORS" : "Errors",
+        "TABLE_HEADER_ROW_NUMBER": "Row #",
+
+        "UPLOAD_FILE_TYPES": "CSV, JSON, or YAML",
+        "UPLOAD_HELP_LINK": "View Format Tips",
+        "UPLOAD_DROP_TITLE": "Drop a File Here",
+        "UPLOAD_BROWSE_LINK": "Browse for File"

Review Comment:
   This is probably an `ACTION_`.



##########
guacamole/src/main/frontend/src/translations/en.json:
##########
@@ -183,6 +183,79 @@
 
     },
 
+    "IMPORT": {
+        
+        "ACTION_ACKNOWLEDGE"          : "@:APP.ACTION_ACKNOWLEDGE",
+
+        "BUTTON_CANCEL": "Cancel",
+        "BUTTON_CLEAR": "Clear",
+        "BUTTON_IMPORT": "Import Connections",
+
+        "CONNECTIONS_IMPORTED_SUCCESS": "{NUMBER} connections imported successfully.",
+
+        "DIALOG_HEADER_ERROR" : "@:APP.DIALOG_HEADER_ERROR",
+        "DIALOG_HEADER_SUCCESS": "Success",
+
+        "FIELD_PLACEHOLDER_FILTER" : "@:APP.FIELD_PLACEHOLDER_FILTER",
+
+        "HEADER": "Connection Import",
+
+        "HELP_HEADER": "Connection Import File Format",
+
+        "HELP_FILE_TYPE_HEADER": "File Types",

Review Comment:
   `SECTION_HEADER_...`?



##########
guacamole/src/main/frontend/src/translations/en.json:
##########
@@ -183,6 +183,79 @@
 
     },
 
+    "IMPORT": {
+        
+        "ACTION_ACKNOWLEDGE"          : "@:APP.ACTION_ACKNOWLEDGE",
+
+        "BUTTON_CANCEL": "Cancel",
+        "BUTTON_CLEAR": "Clear",
+        "BUTTON_IMPORT": "Import Connections",
+
+        "CONNECTIONS_IMPORTED_SUCCESS": "{NUMBER} connections imported successfully.",
+
+        "DIALOG_HEADER_ERROR" : "@:APP.DIALOG_HEADER_ERROR",
+        "DIALOG_HEADER_SUCCESS": "Success",
+
+        "FIELD_PLACEHOLDER_FILTER" : "@:APP.FIELD_PLACEHOLDER_FILTER",
+
+        "HEADER": "Connection Import",
+
+        "HELP_HEADER": "Connection Import File Format",
+
+        "HELP_FILE_TYPE_HEADER": "File Types",
+        "HELP_FILE_TYPE_DESCRIPTION" : "Three file types are supported for connection import: CSV, JSON, and YAML. The same data may be specified by each file type. This must include the connection name and protocol. Optionally, a connection group location, a list of users and/or user groups to grant access, connection parameters, or connection protocols may also be specified. Any users or user groups that do not exist in the current data source will be automatically created.",
+
+        "HELP_CSV_HEADER": "CSV Format",
+        "HELP_CSV_DESCRIPTION": "A connection import CSV file has one connection record per row. Each column will specify a connection field. At minimum the connection name and protocol must be specified.",
+        "HELP_CSV_MORE_DETAILS": "The CSV header for each row specifies the connection field. The connection group ID that the connection should be imported into may be directly specified with \"parentIdentifier\", or the path to the parent group may be specified using \"group\" as shown below. In most cases, there should be no conflict between fields, but if needed, an \" (attribute)\" or \" (parameter)\" suffix may be added to disambiguate. Lists of user or user group identifiers must be semicolon-seperated.¹",
+
+        "HELP_JSON_HEADER": "JSON Format",
+        "HELP_JSON_DESCRIPTION": "A connection import JSON file is a list of connection objects. At minimum the connection name and protocol must be specified in each connection object.",
+        "HELP_JSON_MORE_DETAILS": "The connection group ID that the connection should be imported into may be directly specified with a \"parentIdentifier\" field, or the path to the parent group may be specified using a \"group\" field as shown below. An array of user and user group identifiers to grant access to may be specified per connection.",
+
+        "HELP_YAML_HEADER": "YAML Format",
+        "HELP_YAML_DESCRIPTION": "A connection import YAML file is a list of connection objects with exactly the same structure as the JSON format.",
+        
+        "HELP_SEMICOLON_FOOTNOTE": "If present, semicolons can be escaped with a backslash, e.g. \"first\\\\;last\"",
+
+        "ERROR_AMBIGUOUS_CSV_HEADER": 
+            "Ambiguous CSV Header \"{HEADER}\" could be either a connection attribute or parameter",
+        "ERROR_ARRAY_REQUIRED": 
+            "The provided file must contain a list of connections",
+        "ERROR_DUPLICATE_CSV_HEADER": 
+            "Duplicate CSV Header: {HEADER}",
+        "ERROR_EMPTY_FILE": "The provided file is empty",
+        "ERROR_INVALID_CSV_HEADER": 
+            "Invalid CSV Header \"{HEADER}\" is neither an attribute or parameter",
+        "ERROR_INVALID_GROUP": "No group matching \"{GROUP}\" found",
+        "ERROR_INVALID_FILE_TYPE": 
+            "Unsupported file type: \"{TYPE}\"",
+        "ERROR_INVALID_USER_IDENTIFIERS":
+            "Users not found: {IDENTIFIER_LIST}",
+        "ERROR_INVALID_USER_GROUP_IDENTIFIERS":
+            "User Groups not found: {IDENTIFIER_LIST}",
+        "ERROR_NO_FILE_SUPPLIED": "Please select a file to import",
+        "ERROR_AMBIGUOUS_PARENT_GROUP":
+            "Both group and parentIdentifier may be not specified at the same time",
+        "ERROR_REQUIRED_PROTOCOL": 
+            "No connection protocol found in the provided file",
+        "ERROR_REQUIRED_NAME": 
+            "No connection name found in the provided file",
+
+        "ERROR_FILE_SINGLE_ONLY": "Please upload only a single file at a time",
+
+        "TABLE_HEADER_NAME" : "Name",
+        "TABLE_HEADER_PROTOCOL" : "Protocol",
+        "TABLE_HEADER_ERRORS" : "Errors",
+        "TABLE_HEADER_ROW_NUMBER": "Row #",
+
+        "UPLOAD_FILE_TYPES": "CSV, JSON, or YAML",

Review Comment:
   `INFO_...`? Or `HELP_...`?



##########
guacamole/src/main/frontend/src/images/action-icons/guac-monitor-add-many.svg:
##########


Review Comment:
   I think it would make more sense for this icon to show multiple monitors than multiple plus signs.



##########
guacamole/src/main/frontend/src/translations/en.json:
##########
@@ -183,6 +183,79 @@
 
     },
 
+    "IMPORT": {
+        
+        "ACTION_ACKNOWLEDGE"          : "@:APP.ACTION_ACKNOWLEDGE",
+
+        "BUTTON_CANCEL": "Cancel",
+        "BUTTON_CLEAR": "Clear",
+        "BUTTON_IMPORT": "Import Connections",
+
+        "CONNECTIONS_IMPORTED_SUCCESS": "{NUMBER} connections imported successfully.",
+
+        "DIALOG_HEADER_ERROR" : "@:APP.DIALOG_HEADER_ERROR",
+        "DIALOG_HEADER_SUCCESS": "Success",
+
+        "FIELD_PLACEHOLDER_FILTER" : "@:APP.FIELD_PLACEHOLDER_FILTER",
+
+        "HEADER": "Connection Import",
+
+        "HELP_HEADER": "Connection Import File Format",

Review Comment:
   Same here - this needs to be more specific to the meaning of the string and use the established translation key prefixes.



##########
guacamole/src/main/frontend/src/translations/en.json:
##########
@@ -183,6 +183,79 @@
 
     },
 
+    "IMPORT": {
+        
+        "ACTION_ACKNOWLEDGE"          : "@:APP.ACTION_ACKNOWLEDGE",
+
+        "BUTTON_CANCEL": "Cancel",
+        "BUTTON_CLEAR": "Clear",
+        "BUTTON_IMPORT": "Import Connections",
+
+        "CONNECTIONS_IMPORTED_SUCCESS": "{NUMBER} connections imported successfully.",

Review Comment:
   This needs a prefix - presumably `INFO_`?



##########
guacamole/src/main/frontend/src/translations/en.json:
##########
@@ -183,6 +183,79 @@
 
     },
 
+    "IMPORT": {
+        
+        "ACTION_ACKNOWLEDGE"          : "@:APP.ACTION_ACKNOWLEDGE",
+
+        "BUTTON_CANCEL": "Cancel",
+        "BUTTON_CLEAR": "Clear",
+        "BUTTON_IMPORT": "Import Connections",
+
+        "CONNECTIONS_IMPORTED_SUCCESS": "{NUMBER} connections imported successfully.",
+
+        "DIALOG_HEADER_ERROR" : "@:APP.DIALOG_HEADER_ERROR",
+        "DIALOG_HEADER_SUCCESS": "Success",
+
+        "FIELD_PLACEHOLDER_FILTER" : "@:APP.FIELD_PLACEHOLDER_FILTER",
+
+        "HEADER": "Connection Import",

Review Comment:
   The name of this key needs to be more specific to the meaning of the string, not just `HEADER`. Assuming this is for a section of a page, the prefix should also be `SECTION_HEADER_`.



##########
guacamole/src/main/frontend/src/translations/en.json:
##########
@@ -183,6 +183,79 @@
 
     },
 
+    "IMPORT": {
+        
+        "ACTION_ACKNOWLEDGE"          : "@:APP.ACTION_ACKNOWLEDGE",
+
+        "BUTTON_CANCEL": "Cancel",
+        "BUTTON_CLEAR": "Clear",
+        "BUTTON_IMPORT": "Import Connections",
+
+        "CONNECTIONS_IMPORTED_SUCCESS": "{NUMBER} connections imported successfully.",
+
+        "DIALOG_HEADER_ERROR" : "@:APP.DIALOG_HEADER_ERROR",
+        "DIALOG_HEADER_SUCCESS": "Success",
+
+        "FIELD_PLACEHOLDER_FILTER" : "@:APP.FIELD_PLACEHOLDER_FILTER",
+
+        "HEADER": "Connection Import",
+
+        "HELP_HEADER": "Connection Import File Format",
+
+        "HELP_FILE_TYPE_HEADER": "File Types",
+        "HELP_FILE_TYPE_DESCRIPTION" : "Three file types are supported for connection import: CSV, JSON, and YAML. The same data may be specified by each file type. This must include the connection name and protocol. Optionally, a connection group location, a list of users and/or user groups to grant access, connection parameters, or connection protocols may also be specified. Any users or user groups that do not exist in the current data source will be automatically created.",
+
+        "HELP_CSV_HEADER": "CSV Format",
+        "HELP_CSV_DESCRIPTION": "A connection import CSV file has one connection record per row. Each column will specify a connection field. At minimum the connection name and protocol must be specified.",
+        "HELP_CSV_MORE_DETAILS": "The CSV header for each row specifies the connection field. The connection group ID that the connection should be imported into may be directly specified with \"parentIdentifier\", or the path to the parent group may be specified using \"group\" as shown below. In most cases, there should be no conflict between fields, but if needed, an \" (attribute)\" or \" (parameter)\" suffix may be added to disambiguate. Lists of user or user group identifiers must be semicolon-seperated.¹",

Review Comment:
   Is that `¹` at the end intentional?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] jmuehlner commented on a diff in pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "jmuehlner (via GitHub)" <gi...@apache.org>.
jmuehlner commented on code in PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#discussion_r1159079815


##########
guacamole/src/main/frontend/src/app/import/controllers/importConnectionsController.js:
##########
@@ -0,0 +1,760 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* global _ */
+
+/**
+ * The controller for the connection import page.
+ */
+angular.module('import').controller('importConnectionsController', ['$scope', '$injector',
+        function importConnectionsController($scope, $injector) {
+
+    // The file types supported for connection import
+    const LEGAL_FILE_TYPES = ['csv', 'json', 'yaml'];
+
+    // Required services
+    const $document              = $injector.get('$document');
+    const $location              = $injector.get('$location');
+    const $q                     = $injector.get('$q');
+    const $routeParams           = $injector.get('$routeParams');
+    const $timeout               = $injector.get('$timeout');
+    const connectionParseService = $injector.get('connectionParseService');
+    const connectionService      = $injector.get('connectionService');
+    const guacNotification       = $injector.get('guacNotification');
+    const permissionService      = $injector.get('permissionService');
+    const userService            = $injector.get('userService');
+    const userGroupService       = $injector.get('userGroupService');
+
+    // Required types
+    const DirectoryPatch      = $injector.get('DirectoryPatch');
+    const Error               = $injector.get('Error');
+    const ParseError          = $injector.get('ParseError');
+    const PermissionSet       = $injector.get('PermissionSet');
+    const User                = $injector.get('User');
+    const UserGroup           = $injector.get('UserGroup');
+
+    /**
+     * The result of parsing the current upload, if successful.
+     *
+     * @type {ParseResult}
+     */
+    $scope.parseResult = null;
+
+    /**
+     * The failure associated with the current attempt to create connections
+     * through the API, if any.
+     *
+     * @type {Error}
+     */
+    $scope.patchFailure = null;;
+
+    /**
+     * True if the file is fully uploaded and ready to be processed, or false
+     * otherwise.
+     *
+     * @type {Boolean}
+     */
+    $scope.dataReady = false;
+
+    /**
+     * True if the file upload has been aborted mid-upload, or false otherwise.
+     */
+    $scope.aborted = false;
+
+    /**
+     * True if fully-uploaded data is being processed, or false otherwise.
+     */
+    $scope.processing = false;
+
+    /**
+     * The MIME type of the uploaded file, if any.
+     *
+     * @type {String}
+     */
+    $scope.mimeType = null;
+
+    /**
+     * The raw string contents of the uploaded file, if any.
+     *
+     * @type {String}
+     */
+    $scope.fileData = null;
+
+    /**
+     * The file reader currently being used to upload the file, if any. If
+     * null, no file upload is currently in progress.
+     *
+     * @type {FileReader}
+     */
+    $scope.fileReader = null;
+
+    /**
+     * Clear all file upload state.
+     */
+    function resetUploadState() {
+
+        $scope.aborted = false;
+        $scope.dataReady = false;
+        $scope.processing = false;
+        $scope.fileData = null;
+        $scope.mimeType = null;
+        $scope.fileReader = null;
+        $scope.parseResult = null;
+        $scope.patchFailure = null;
+        $scope.fileName = null;
+
+    }
+
+    // Indicate that data is currently being loaded / processed if the the file
+    // has been provided but not yet fully uploaded, or if the the file is
+    // fully loaded and is currently being processed.
+    $scope.isLoading = () => (
+            ($scope.fileName && !$scope.dataReady && !$scope.patchFailure)
+            || $scope.processing);
+
+    /**
+     * Create all users and user groups mentioned in the import file that don't
+     * already exist in the current data source. If either creation fails, any
+     * already-created entities will be cleaned up, and the returned promise
+     * will be rejected.
+     *
+     * @param {ParseResult} parseResult
+     *     The result of parsing the user-supplied import file.
+     *
+     * @return {Promise.<Object>}
+     *     A promise resolving to an object containing the results of the calls
+     *     to create the users and groups.
+     */
+    function createUsersAndGroups(parseResult) {
+
+        const dataSource = $routeParams.dataSource;
+
+        return $q.all({
+            existingUsers : userService.getUsers(dataSource),
+            existingGroups : userGroupService.getUserGroups(dataSource)
+        }).then(({existingUsers, existingGroups}) => {
+
+            const userPatches = Object.keys(parseResult.users)
+
+                // Filter out any existing users
+                .filter(identifier => !existingUsers[identifier])
+
+                // A patch to create each new user
+                .map(username => new DirectoryPatch({
+                    op: 'add',
+                    path: '/',
+                    value: new User({ username })
+                }));
+
+            const groupPatches = Object.keys(parseResult.groups)
+
+                // Filter out any existing groups
+                .filter(identifier => !existingGroups[identifier])
+
+                // A patch to create each new user group
+                .map(identifier => new DirectoryPatch({
+                    op: 'add',
+                    path: '/',
+                    value: new UserGroup({ identifier })
+                }));
+
+            // First, create any required users and groups, automatically cleaning
+            // up any created already-created entities if a call fails.
+            // NOTE: Generally we'd want to do these calls in parallel, using
+            // `$q.all()`. However, `$q.all()` rejects immediately if any of the
+            // wrapped promises reject, so the users may not be ready for cleanup
+            // at the time that the group promise rejects, or vice versa. While
+            // it would be possible to juggle promises and still do these calls
+            // in parallel, the code gets pretty complex, so for readability and
+            // simplicity, they are executed serially. The performance cost of
+            // doing so should be low.
+            return userService.patchUsers(dataSource, userPatches).then(userResponse => {
+
+                // Then, if that succeeds, create any required groups
+                return userGroupService.patchUserGroups(dataSource, groupPatches).then(
+
+                    // If user group creation succeeds, resolve the returned promise
+                    userGroupResponse => ({ userResponse, userGroupResponse}))
+
+                // If the group creation request fails, clean up any created users
+                .catch(groupFailure => {
+                    cleanUpUsers(userResponse);
+                    return groupFailure;
+                });
+
+            });
+
+        });
+
+    }
+
+    /**
+     * Grant read permissions for each user and group in the supplied parse
+     * result to each connection in their connection list. Note that there will
+     * be a seperate request for each user and group.
+     *
+     * @param {ParseResult} parseResult
+     *     The result of successfully parsing a user-supplied import file.
+     *
+     * @param {Object} response
+     *     The response from the PATCH API request.
+     *
+     * @returns {Promise.<Object>}
+     *     A promise that will resolve with the result of every permission
+     *     granting request.
+     */
+    function grantConnectionPermissions(parseResult, response) {
+
+        const dataSource = $routeParams.dataSource;
+
+        // All connection grant requests, one per user/group
+        const userRequests = {};
+        const groupRequests = {};
+
+        // Create a PermissionSet granting access to all connections at
+        // the provided indices within the provided parse result
+        const createPermissionSet = indices =>
+            new PermissionSet({ connectionPermissions: indices.reduce(
+                    (permissions, index) => {
+                const connectionId = response.patches[index].identifier;
+                permissions[connectionId] = [
+                        PermissionSet.ObjectPermissionType.READ];
+                return permissions;
+            }, {}) });
+
+        // Now that we've created all the users, grant access to each
+        _.forEach(parseResult.users, (connectionIndices, identifier) =>
+
+            // Grant the permissions - note the group flag is `false`
+            userRequests[identifier] = permissionService.patchPermissions(
+                dataSource, identifier,
+
+                // Create the permissions to these connections for this user
+                createPermissionSet(connectionIndices),
+
+                // Do not remove any permissions
+                new PermissionSet(),
+
+                // This call is not for a group
+                false));
+
+        // Now that we've created all the groups, grant access to each
+        _.forEach(parseResult.groups, (connectionIndices, identifier) =>
+
+            // Grant the permissions - note the group flag is `true`
+            groupRequests[identifier] = permissionService.patchPermissions(
+                dataSource, identifier,
+
+                // Create the permissions to these connections for this user
+                createPermissionSet(connectionIndices),
+
+                // Do not remove any permissions
+                new PermissionSet(),
+
+                // This call is for a group
+                true));
+
+        // Return the result from all the permission granting calls
+        return $q.all({ ...userRequests, ...groupRequests });
+    }
+
+    // Given a PATCH API response, create an array of patches to delete every
+    // entity created in the original request that generated this response
+    const createDeletionPatches = creationResponse =>
+        creationResponse.patches.map(patch =>
+
+            // Add one deletion patch per original creation patch
+            new DirectoryPatch({
+                op: 'remove',
+                path: '/' + patch.identifier
+            }));
+
+    /**
+     * Given a successful response to a connection PATCH request, make another
+     * request to delete every created connection in the provided request, i.e.
+     * clean up every connection that was created.
+     *
+     * @param {DirectoryPatchResponse} creationResponse
+     *     The response to the connection PATCH request.
+     *
+     * @returns {DirectoryPatchResponse}
+     *     The response to the PATCH deletion request.
+     */
+    function cleanUpConnections(creationResponse) {
+
+        return connectionService.patchConnections(
+            $routeParams.dataSource, createDeletionPatches(creationResponse));
+
+    }
+
+    /**
+     * Given a successful response to a user PATCH request, make another
+     * request to delete every created user in the provided request.
+     *
+     * @param {DirectoryPatchResponse} creationResponse
+     *     The response to the user PATCH request.
+     *
+     * @returns {DirectoryPatchResponse}
+     *     The response to the PATCH deletion request.
+     */
+    function cleanUpUsers(creationResponse) {
+
+        return userService.patchUsers(
+            $routeParams.dataSource, createDeletionPatches(creationResponse));
+
+    }
+
+    /**
+     * Process a successfully parsed import file, creating any specified
+     * connections, creating and granting permissions to any specified users
+     * and user groups. If successful, the user will be shown a success message.
+     * If not, any errors will be displayed and any already-created entities
+     * will be rolled back.
+     *
+     * @param {ParseResult} parseResult
+     *     The result of parsing the user-supplied import file.
+     */
+    function handleParseSuccess(parseResult) {
+
+        $scope.parseResult = parseResult;
+
+        // If errors were encounted during file parsing, abort further
+        // processing - the user will have a chance to fix the errors and try
+        // again
+        if (parseResult.hasErrors)
+            return;
+
+        const dataSource = $routeParams.dataSource;
+
+        // First, attempt to create the connections
+        connectionService.patchConnections(dataSource, parseResult.patches)
+                .then(connectionResponse =>
+
+            // If connection creation is successful, create users and groups
+            createUsersAndGroups(parseResult).then(() =>
+
+                grantConnectionPermissions(parseResult, connectionResponse)
+                        .then(() => {
+
+                    $scope.processing = false;
+
+                    // Display a success message if everything worked
+                    guacNotification.showStatus({
+                        className  : 'success',
+                        title      : 'IMPORT.DIALOG_HEADER_SUCCESS',
+                        text       : {
+                            key: 'IMPORT.INFO_CONNECTIONS_IMPORTED_SUCCESS',
+                            variables: { NUMBER: parseResult.patches.length }
+                        },
+
+                        // Add a button to acknowledge and redirect to
+                        // the connection listing page
+                        actions    : [{
+                            name      : 'IMPORT.ACTION_ACKNOWLEDGE',
+                            callback  : () => {
+
+                                // Close the notification
+                                guacNotification.showStatus(false);
+
+                                // Redirect to connection list page
+                                $location.url('/settings/' + dataSource + '/connections');
+                            }
+                        }]
+                    });
+                }))
+
+            // If an error occurs while trying to users or groups, or while trying
+            // to assign permissions to users or groups, clean up the already-created
+            // connections, displaying an error to the user along with a blank slate
+            // so they can fix their problems and try again.
+            .catch(error => {
+                cleanUpConnections(connectionResponse);
+                handleError(error);
+            }))
+
+        // If an error occured when the call to create the connections was made,
+        // skip any further processing - the user will have a chance to fix the
+        // problems and try again
+        .catch(patchFailure => {
+            $scope.processing = false;
+            $scope.patchFailure = patchFailure;
+        });
+    }
+
+    /**
+     * Display the provided error to the user in a dismissable dialog.
+     *
+     * @argument {ParseError|Error} error
+     *     The error to display.
+     */
+    const handleError = error => {
+
+        // Any error indicates that processing of the file has failed, so clear
+        // all upload state to allow for a fresh retry
+        resetUploadState();
+
+        let text;
+
+        // If it's a import file parsing error
+        if (error instanceof ParseError)
+            text = {
+
+                // Use the translation key if available
+                key: error.key || error.message,
+                variables: error.variables
+            };
+
+        // If it's a generic REST error
+        else if (error instanceof Error)
+            text = error.translatableMessage;
+
+        // If it's an unknown type, just use the message directly
+        else
+            text = { key: error };
+
+        guacNotification.showStatus({
+            className  : 'error',
+            title      : 'IMPORT.DIALOG_HEADER_ERROR',
+            text,
+
+            // Add a button to hide the error
+            actions    : [{
+                name      : 'IMPORT.ACTION_ACKNOWLEDGE',
+                callback  : () => guacNotification.showStatus(false)
+            }]
+        })
+
+    };
+
+    /**
+     * Process the uploaded import file, importing the connections, granting
+     * connection permissions, or displaying errors to the user if there are
+     * problems with the provided file.
+     *
+     * @param {String} mimeType
+     *     The MIME type of the uploaded data file.
+     *
+     * @param {String} data
+     *     The raw string contents of the import file.
+     */
+    function processData(mimeType, data) {
+
+        // Data processing has begun
+        $scope.processing = true;
+
+        // The function that will process all the raw data and return a list of
+        // patches to be submitted to the API
+        let processDataCallback;
+
+        // Choose the appropriate parse function based on the mimetype
+        if (mimeType.endsWith("json"))
+            processDataCallback = connectionParseService.parseJSON;
+
+        else if (mimeType.endsWith("csv"))
+            processDataCallback = connectionParseService.parseCSV;
+
+        else if (mimeType.endsWith("yaml"))
+            processDataCallback = connectionParseService.parseYAML;
+
+        // The file type was validated before being uploaded - this should
+        // never happen
+        else
+            processDataCallback = () => {
+                throw new ParseError({
+                    message: "Unexpected invalid file type: " + mimeType
+                });
+            };
+
+        // Make the call to process the data into a series of patches
+        processDataCallback(data)
+
+            // Send the data off to be imported if parsing is successful
+            .then(handleParseSuccess)
+
+            // Display any error found while parsing the file
+            .catch(handleError);
+    }
+
+    /**
+     * Process the uploaded import data. Only usuable if the upload is fully
+     * complete.
+     */
+    $scope.import = () => processData($scope.mimeType, $scope.fileData);
+
+    /**
+     * @return {Boolean}
+     *     True if import should be disabled, or false if import should be
+     *     allowed.
+     */
+    $scope.importDisabled = () =>
+
+        // Disable import if no data is ready
+        !$scope.dataReady ||
+
+        // Disable import if the file is currently being processed
+        $scope.processing;
+
+    /**
+     * Cancel any in-progress upload, or clear any uploaded-but-errored-out
+     * batch.
+     */
+    $scope.cancel = function() {
+
+        // If the upload is in progress, stop it now; the FileReader will
+        // reset the upload state when it stops
+        if ($scope.fileReader) {
+            $scope.aborted = true;
+            $scope.fileReader.abort();
+        }
+
+        // Clear any upload state - there's no FileReader handler to do it
+        else
+            resetUploadState();
+
+    };
+
+    /**
+     * Returns true if cancellation should be disabled, or false if
+     * cancellation should be allowed.
+     *
+     * @return {Boolean}
+     *     True if cancellation should be disabled, or false if cancellation
+     *     should be allowed.
+     */
+    $scope.cancelDisabled = () =>
+
+        // Disable cancellation if the import has already been cancelled
+        $scope.aborted ||
+
+        // Disable cancellation if the file is currently being processed
+        $scope.processing ||
+
+        // Disable cancellation if no data is ready or being uploaded
+        !($scope.fileReader || $scope.dataReady);
+
+    /**
+     * Handle a provided File upload, reading all data onto the scope for
+     * import processing, should the user request an import.
+     *
+     * @argument {File} file
+     *     The file to upload onto the scope for further processing.
+     */
+    const handleFile = file => {
+
+        // The MIME type of the provided file
+        const mimeType = file.type;
+
+        // Check if the mimetype ends with one of the supported types,
+        // e.g. "application/json" or "text/csv"
+        if (_.every(LEGAL_FILE_TYPES.map(
+                type => !mimeType.endsWith(type)))) {
+
+            // If the provided file is not one of the supported types,
+            // display an error and abort processing
+            handleError(new ParseError({
+                message: "Invalid file type: " + mimeType,
+                key: 'IMPORT.ERROR_INVALID_FILE_TYPE',
+                variables: { TYPE: mimeType }
+            }));
+            return;
+        }
+
+        $scope.fileName = file.name;
+
+        // Initialize upload state
+        $scope.aborted = false;
+        $scope.dataReady = false;
+        $scope.processing = false;
+        $scope.uploadStarted = true;
+
+        // Save the MIME type to the scope
+        $scope.mimeType = file.type;
+
+        // Save the file to the scope when ready
+        $scope.fileReader = new FileReader();
+        $scope.fileReader.onloadend = (e => {
+
+            // If the upload was explicitly aborted, clear any upload state and
+            // do not process the data
+            if ($scope.aborted)
+                resetUploadState();
+
+            else {
+
+                // Save the uploaded data
+                $scope.fileData = e.target.result;
+
+                // Mark the data as ready
+                $scope.dataReady = true;
+
+                // Clear the file reader from the scope now that this file is
+                // fully uploaded
+                $scope.fileReader = null;
+
+            }
+        });
+
+        // Read all the data into memory
+        $scope.fileReader.readAsBinaryString(file);
+    };
+
+    /**
+     * Whether a drag/drop operation is currently in progress (the user has
+     * dragged a file over the Guacamole connection but has not yet
+     * dropped it).
+     *
+     * @type boolean
+     */
+    $scope.dropPending = false;
+
+    /**
+     * The name of the file that's currently being uploaded, or has yet to
+     * be imported, if any.
+     */
+    $scope.fileName = null;
+
+    /**
+     * The container for the file upload UI.
+     *
+     * @type Element
+     *
+     */
+    const uploadContainer = angular.element(
+            $document.find('.file-upload-container'));
+
+    /**
+     * The location where files can be dragged-and-dropped to.
+     *
+     * @type Element
+     */
+    const dropTarget = uploadContainer.find('.drop-target');

Review Comment:
   That's the way I originally had it, but the directive and controller got so intertangled that it ended up being cleaner to merge them.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] mike-jumper commented on a diff in pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "mike-jumper (via GitHub)" <gi...@apache.org>.
mike-jumper commented on code in PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#discussion_r1147775560


##########
guacamole/src/main/frontend/src/images/action-icons/guac-monitor-add-many.svg:
##########


Review Comment:
   What do you think of:
   
   ![Multiple monitors, overlapping](https://user-images.githubusercontent.com/4632905/227575314-4d30ad3b-cd0b-4fdf-9a47-959f71cd574b.svg)
   
   (https://user-images.githubusercontent.com/4632905/227575314-4d30ad3b-cd0b-4fdf-9a47-959f71cd574b.svg)
   
   or:
   
   ![Multiple smaller monitors, overlapping](https://user-images.githubusercontent.com/4632905/227575411-ae8c60df-61f9-41e0-944e-a9c99ad4cb26.svg)
   
   (https://user-images.githubusercontent.com/4632905/227575411-ae8c60df-61f9-41e0-944e-a9c99ad4cb26.svg)
   
   ?
   
   (GitHub doesn't seem to provide a way to set the background color of a comment, paragraph, section, etc., so the above may be invisible...)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] mike-jumper commented on a diff in pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "mike-jumper (via GitHub)" <gi...@apache.org>.
mike-jumper commented on code in PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#discussion_r1158789600


##########
guacamole/src/main/frontend/src/app/rest/services/connectionService.js:
##########
@@ -24,9 +24,11 @@ angular.module('rest').factory('connectionService', ['$injector',
         function connectionService($injector) {
 
     // Required services
-    var requestService        = $injector.get('requestService');
     var authenticationService = $injector.get('authenticationService');
     var cacheService          = $injector.get('cacheService');
+
+    // Required types
+    const Error = $injector.get('Error');

Review Comment:
   Is this used? I don't see any usages in the relevant part of the diff.



##########
guacamole/src/main/frontend/src/app/import/types/ParseError.js:
##########
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Service which defines the ParseError class.
+ */
+angular.module('import').factory('ParseError', [function defineParseError() {
+
+    /**
+     * An error representing a parsing failure when attempting to convert
+     * user-provided data into a list of Connection objects.
+     *
+     * @constructor
+     * @param {ParseError|Object} [template={}]
+     *     The object whose properties should be copied within the new
+     *     ParseError.
+     */
+    const ParseError = function ParseError(template) {
+
+        // Use empty object by default
+        template = template || {};
+
+        /**
+         * A human-readable message describing the error that occurred.
+         *
+         * @type String
+         */
+        this.message = template.message;
+
+        /**
+         * The key associated with the translation string that used when
+         * displaying this message.
+         *
+         * @type String
+         */
+        this.key = template.key;
+
+        /**
+         * The object which should be passed through to the translation service
+         * for the sake of variable substitution. Each property of the provided
+         * object will be substituted for the variable of the same name within
+         * the translation string.
+         *
+         * @type Object
+         */
+        this.variables = template.variables;

Review Comment:
   Should this extend or otherwise leverage `TranslatableMessage`?



##########
guacamole/src/main/frontend/src/app/import/types/DisplayErrorList.js:
##########
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Service which defines the DisplayErrorList class.
+ */
+angular.module('import').factory('DisplayErrorList', [
+        function defineDisplayErrorList() {
+
+    /**
+     * A list of human-readable error messages, intended to be usable in a
+     * sortable / filterable table.
+     *
+     * @constructor
+     * @param {String[]} messages
+     *     The error messages that should be prepared for display.
+     */
+    const DisplayErrorList = function DisplayErrorList(messages) {
+
+        // Use empty message list by default
+        this.messages = messages || [];
+
+        // The single String message composed of all messages concatenated
+        // together. This will be used for filtering / sorting, and should only
+        // be calculated once.
+        this.cachedMessage = null;

Review Comment:
   Please document object properties using JSDoc.



##########
guacamole/src/main/frontend/src/app/import/types/DisplayErrorList.js:
##########
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Service which defines the DisplayErrorList class.
+ */
+angular.module('import').factory('DisplayErrorList', [
+        function defineDisplayErrorList() {
+
+    /**
+     * A list of human-readable error messages, intended to be usable in a
+     * sortable / filterable table.
+     *
+     * @constructor
+     * @param {String[]} messages
+     *     The error messages that should be prepared for display.
+     */
+    const DisplayErrorList = function DisplayErrorList(messages) {
+
+        // Use empty message list by default
+        this.messages = messages || [];
+
+        // The single String message composed of all messages concatenated
+        // together. This will be used for filtering / sorting, and should only
+        // be calculated once.
+        this.cachedMessage = null;

Review Comment:
   This doesn't appear to be used, though there is a reference to `concatenatedMessage`.



##########
guacamole/src/main/frontend/src/app/import/controllers/importConnectionsController.js:
##########
@@ -0,0 +1,760 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* global _ */
+
+/**
+ * The controller for the connection import page.
+ */
+angular.module('import').controller('importConnectionsController', ['$scope', '$injector',
+        function importConnectionsController($scope, $injector) {
+
+    // The file types supported for connection import
+    const LEGAL_FILE_TYPES = ['csv', 'json', 'yaml'];
+
+    // Required services
+    const $document              = $injector.get('$document');
+    const $location              = $injector.get('$location');
+    const $q                     = $injector.get('$q');
+    const $routeParams           = $injector.get('$routeParams');
+    const $timeout               = $injector.get('$timeout');
+    const connectionParseService = $injector.get('connectionParseService');
+    const connectionService      = $injector.get('connectionService');
+    const guacNotification       = $injector.get('guacNotification');
+    const permissionService      = $injector.get('permissionService');
+    const userService            = $injector.get('userService');
+    const userGroupService       = $injector.get('userGroupService');
+
+    // Required types
+    const DirectoryPatch      = $injector.get('DirectoryPatch');
+    const Error               = $injector.get('Error');
+    const ParseError          = $injector.get('ParseError');
+    const PermissionSet       = $injector.get('PermissionSet');
+    const User                = $injector.get('User');
+    const UserGroup           = $injector.get('UserGroup');
+
+    /**
+     * The result of parsing the current upload, if successful.
+     *
+     * @type {ParseResult}
+     */
+    $scope.parseResult = null;
+
+    /**
+     * The failure associated with the current attempt to create connections
+     * through the API, if any.
+     *
+     * @type {Error}
+     */
+    $scope.patchFailure = null;;
+
+    /**
+     * True if the file is fully uploaded and ready to be processed, or false
+     * otherwise.
+     *
+     * @type {Boolean}
+     */
+    $scope.dataReady = false;
+
+    /**
+     * True if the file upload has been aborted mid-upload, or false otherwise.
+     */
+    $scope.aborted = false;
+
+    /**
+     * True if fully-uploaded data is being processed, or false otherwise.
+     */
+    $scope.processing = false;
+
+    /**
+     * The MIME type of the uploaded file, if any.
+     *
+     * @type {String}
+     */
+    $scope.mimeType = null;
+
+    /**
+     * The raw string contents of the uploaded file, if any.
+     *
+     * @type {String}
+     */
+    $scope.fileData = null;
+
+    /**
+     * The file reader currently being used to upload the file, if any. If
+     * null, no file upload is currently in progress.
+     *
+     * @type {FileReader}
+     */
+    $scope.fileReader = null;
+
+    /**
+     * Clear all file upload state.
+     */
+    function resetUploadState() {
+
+        $scope.aborted = false;
+        $scope.dataReady = false;
+        $scope.processing = false;
+        $scope.fileData = null;
+        $scope.mimeType = null;
+        $scope.fileReader = null;
+        $scope.parseResult = null;
+        $scope.patchFailure = null;
+        $scope.fileName = null;
+
+    }
+
+    // Indicate that data is currently being loaded / processed if the the file
+    // has been provided but not yet fully uploaded, or if the the file is
+    // fully loaded and is currently being processed.
+    $scope.isLoading = () => (
+            ($scope.fileName && !$scope.dataReady && !$scope.patchFailure)
+            || $scope.processing);
+
+    /**
+     * Create all users and user groups mentioned in the import file that don't
+     * already exist in the current data source. If either creation fails, any
+     * already-created entities will be cleaned up, and the returned promise
+     * will be rejected.
+     *
+     * @param {ParseResult} parseResult
+     *     The result of parsing the user-supplied import file.
+     *
+     * @return {Promise.<Object>}
+     *     A promise resolving to an object containing the results of the calls
+     *     to create the users and groups.
+     */
+    function createUsersAndGroups(parseResult) {
+
+        const dataSource = $routeParams.dataSource;
+
+        return $q.all({
+            existingUsers : userService.getUsers(dataSource),
+            existingGroups : userGroupService.getUserGroups(dataSource)
+        }).then(({existingUsers, existingGroups}) => {
+
+            const userPatches = Object.keys(parseResult.users)
+
+                // Filter out any existing users
+                .filter(identifier => !existingUsers[identifier])
+
+                // A patch to create each new user
+                .map(username => new DirectoryPatch({
+                    op: 'add',
+                    path: '/',
+                    value: new User({ username })
+                }));
+
+            const groupPatches = Object.keys(parseResult.groups)
+
+                // Filter out any existing groups
+                .filter(identifier => !existingGroups[identifier])
+
+                // A patch to create each new user group
+                .map(identifier => new DirectoryPatch({
+                    op: 'add',
+                    path: '/',
+                    value: new UserGroup({ identifier })
+                }));
+
+            // First, create any required users and groups, automatically cleaning
+            // up any created already-created entities if a call fails.
+            // NOTE: Generally we'd want to do these calls in parallel, using
+            // `$q.all()`. However, `$q.all()` rejects immediately if any of the
+            // wrapped promises reject, so the users may not be ready for cleanup
+            // at the time that the group promise rejects, or vice versa. While
+            // it would be possible to juggle promises and still do these calls
+            // in parallel, the code gets pretty complex, so for readability and
+            // simplicity, they are executed serially. The performance cost of
+            // doing so should be low.
+            return userService.patchUsers(dataSource, userPatches).then(userResponse => {
+
+                // Then, if that succeeds, create any required groups
+                return userGroupService.patchUserGroups(dataSource, groupPatches).then(
+
+                    // If user group creation succeeds, resolve the returned promise
+                    userGroupResponse => ({ userResponse, userGroupResponse}))
+
+                // If the group creation request fails, clean up any created users
+                .catch(groupFailure => {
+                    cleanUpUsers(userResponse);
+                    return groupFailure;
+                });
+
+            });
+
+        });
+
+    }
+
+    /**
+     * Grant read permissions for each user and group in the supplied parse
+     * result to each connection in their connection list. Note that there will
+     * be a seperate request for each user and group.
+     *
+     * @param {ParseResult} parseResult
+     *     The result of successfully parsing a user-supplied import file.
+     *
+     * @param {Object} response
+     *     The response from the PATCH API request.
+     *
+     * @returns {Promise.<Object>}
+     *     A promise that will resolve with the result of every permission
+     *     granting request.
+     */
+    function grantConnectionPermissions(parseResult, response) {
+
+        const dataSource = $routeParams.dataSource;
+
+        // All connection grant requests, one per user/group
+        const userRequests = {};
+        const groupRequests = {};
+
+        // Create a PermissionSet granting access to all connections at
+        // the provided indices within the provided parse result
+        const createPermissionSet = indices =>
+            new PermissionSet({ connectionPermissions: indices.reduce(
+                    (permissions, index) => {
+                const connectionId = response.patches[index].identifier;
+                permissions[connectionId] = [
+                        PermissionSet.ObjectPermissionType.READ];
+                return permissions;
+            }, {}) });
+
+        // Now that we've created all the users, grant access to each
+        _.forEach(parseResult.users, (connectionIndices, identifier) =>
+
+            // Grant the permissions - note the group flag is `false`
+            userRequests[identifier] = permissionService.patchPermissions(
+                dataSource, identifier,
+
+                // Create the permissions to these connections for this user
+                createPermissionSet(connectionIndices),
+
+                // Do not remove any permissions
+                new PermissionSet(),
+
+                // This call is not for a group
+                false));
+
+        // Now that we've created all the groups, grant access to each
+        _.forEach(parseResult.groups, (connectionIndices, identifier) =>
+
+            // Grant the permissions - note the group flag is `true`
+            groupRequests[identifier] = permissionService.patchPermissions(
+                dataSource, identifier,
+
+                // Create the permissions to these connections for this user
+                createPermissionSet(connectionIndices),
+
+                // Do not remove any permissions
+                new PermissionSet(),
+
+                // This call is for a group
+                true));
+
+        // Return the result from all the permission granting calls
+        return $q.all({ ...userRequests, ...groupRequests });
+    }
+
+    // Given a PATCH API response, create an array of patches to delete every
+    // entity created in the original request that generated this response
+    const createDeletionPatches = creationResponse =>
+        creationResponse.patches.map(patch =>
+
+            // Add one deletion patch per original creation patch
+            new DirectoryPatch({
+                op: 'remove',
+                path: '/' + patch.identifier
+            }));
+
+    /**
+     * Given a successful response to a connection PATCH request, make another
+     * request to delete every created connection in the provided request, i.e.
+     * clean up every connection that was created.
+     *
+     * @param {DirectoryPatchResponse} creationResponse
+     *     The response to the connection PATCH request.
+     *
+     * @returns {DirectoryPatchResponse}
+     *     The response to the PATCH deletion request.
+     */
+    function cleanUpConnections(creationResponse) {
+
+        return connectionService.patchConnections(
+            $routeParams.dataSource, createDeletionPatches(creationResponse));
+
+    }
+
+    /**
+     * Given a successful response to a user PATCH request, make another
+     * request to delete every created user in the provided request.
+     *
+     * @param {DirectoryPatchResponse} creationResponse
+     *     The response to the user PATCH request.
+     *
+     * @returns {DirectoryPatchResponse}
+     *     The response to the PATCH deletion request.
+     */
+    function cleanUpUsers(creationResponse) {
+
+        return userService.patchUsers(
+            $routeParams.dataSource, createDeletionPatches(creationResponse));
+
+    }
+
+    /**
+     * Process a successfully parsed import file, creating any specified
+     * connections, creating and granting permissions to any specified users
+     * and user groups. If successful, the user will be shown a success message.
+     * If not, any errors will be displayed and any already-created entities
+     * will be rolled back.
+     *
+     * @param {ParseResult} parseResult
+     *     The result of parsing the user-supplied import file.
+     */
+    function handleParseSuccess(parseResult) {
+
+        $scope.parseResult = parseResult;
+
+        // If errors were encounted during file parsing, abort further
+        // processing - the user will have a chance to fix the errors and try
+        // again
+        if (parseResult.hasErrors)
+            return;
+
+        const dataSource = $routeParams.dataSource;
+
+        // First, attempt to create the connections
+        connectionService.patchConnections(dataSource, parseResult.patches)
+                .then(connectionResponse =>
+
+            // If connection creation is successful, create users and groups
+            createUsersAndGroups(parseResult).then(() =>
+
+                grantConnectionPermissions(parseResult, connectionResponse)
+                        .then(() => {
+
+                    $scope.processing = false;
+
+                    // Display a success message if everything worked
+                    guacNotification.showStatus({
+                        className  : 'success',
+                        title      : 'IMPORT.DIALOG_HEADER_SUCCESS',
+                        text       : {
+                            key: 'IMPORT.INFO_CONNECTIONS_IMPORTED_SUCCESS',
+                            variables: { NUMBER: parseResult.patches.length }
+                        },
+
+                        // Add a button to acknowledge and redirect to
+                        // the connection listing page
+                        actions    : [{
+                            name      : 'IMPORT.ACTION_ACKNOWLEDGE',
+                            callback  : () => {
+
+                                // Close the notification
+                                guacNotification.showStatus(false);
+
+                                // Redirect to connection list page
+                                $location.url('/settings/' + dataSource + '/connections');
+                            }
+                        }]
+                    });
+                }))
+
+            // If an error occurs while trying to users or groups, or while trying
+            // to assign permissions to users or groups, clean up the already-created
+            // connections, displaying an error to the user along with a blank slate
+            // so they can fix their problems and try again.
+            .catch(error => {
+                cleanUpConnections(connectionResponse);
+                handleError(error);
+            }))
+
+        // If an error occured when the call to create the connections was made,
+        // skip any further processing - the user will have a chance to fix the
+        // problems and try again
+        .catch(patchFailure => {
+            $scope.processing = false;
+            $scope.patchFailure = patchFailure;
+        });
+    }
+
+    /**
+     * Display the provided error to the user in a dismissable dialog.
+     *
+     * @argument {ParseError|Error} error
+     *     The error to display.
+     */
+    const handleError = error => {
+
+        // Any error indicates that processing of the file has failed, so clear
+        // all upload state to allow for a fresh retry
+        resetUploadState();
+
+        let text;
+
+        // If it's a import file parsing error
+        if (error instanceof ParseError)
+            text = {
+
+                // Use the translation key if available
+                key: error.key || error.message,
+                variables: error.variables
+            };
+
+        // If it's a generic REST error
+        else if (error instanceof Error)
+            text = error.translatableMessage;
+
+        // If it's an unknown type, just use the message directly
+        else
+            text = { key: error };
+
+        guacNotification.showStatus({
+            className  : 'error',
+            title      : 'IMPORT.DIALOG_HEADER_ERROR',
+            text,
+
+            // Add a button to hide the error
+            actions    : [{
+                name      : 'IMPORT.ACTION_ACKNOWLEDGE',
+                callback  : () => guacNotification.showStatus(false)
+            }]
+        })
+
+    };
+
+    /**
+     * Process the uploaded import file, importing the connections, granting
+     * connection permissions, or displaying errors to the user if there are
+     * problems with the provided file.
+     *
+     * @param {String} mimeType
+     *     The MIME type of the uploaded data file.
+     *
+     * @param {String} data
+     *     The raw string contents of the import file.
+     */
+    function processData(mimeType, data) {
+
+        // Data processing has begun
+        $scope.processing = true;
+
+        // The function that will process all the raw data and return a list of
+        // patches to be submitted to the API
+        let processDataCallback;
+
+        // Choose the appropriate parse function based on the mimetype
+        if (mimeType.endsWith("json"))
+            processDataCallback = connectionParseService.parseJSON;
+
+        else if (mimeType.endsWith("csv"))
+            processDataCallback = connectionParseService.parseCSV;
+
+        else if (mimeType.endsWith("yaml"))
+            processDataCallback = connectionParseService.parseYAML;
+
+        // The file type was validated before being uploaded - this should
+        // never happen
+        else
+            processDataCallback = () => {
+                throw new ParseError({
+                    message: "Unexpected invalid file type: " + mimeType
+                });
+            };
+
+        // Make the call to process the data into a series of patches
+        processDataCallback(data)
+
+            // Send the data off to be imported if parsing is successful
+            .then(handleParseSuccess)
+
+            // Display any error found while parsing the file
+            .catch(handleError);
+    }
+
+    /**
+     * Process the uploaded import data. Only usuable if the upload is fully
+     * complete.
+     */
+    $scope.import = () => processData($scope.mimeType, $scope.fileData);
+
+    /**
+     * @return {Boolean}
+     *     True if import should be disabled, or false if import should be
+     *     allowed.
+     */
+    $scope.importDisabled = () =>

Review Comment:
   Overall description missing from this JSDoc.



##########
guacamole/src/main/frontend/src/app/import/controllers/importConnectionsController.js:
##########
@@ -0,0 +1,760 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* global _ */
+
+/**
+ * The controller for the connection import page.
+ */
+angular.module('import').controller('importConnectionsController', ['$scope', '$injector',
+        function importConnectionsController($scope, $injector) {
+
+    // The file types supported for connection import
+    const LEGAL_FILE_TYPES = ['csv', 'json', 'yaml'];
+
+    // Required services
+    const $document              = $injector.get('$document');
+    const $location              = $injector.get('$location');
+    const $q                     = $injector.get('$q');
+    const $routeParams           = $injector.get('$routeParams');
+    const $timeout               = $injector.get('$timeout');
+    const connectionParseService = $injector.get('connectionParseService');
+    const connectionService      = $injector.get('connectionService');
+    const guacNotification       = $injector.get('guacNotification');
+    const permissionService      = $injector.get('permissionService');
+    const userService            = $injector.get('userService');
+    const userGroupService       = $injector.get('userGroupService');
+
+    // Required types
+    const DirectoryPatch      = $injector.get('DirectoryPatch');
+    const Error               = $injector.get('Error');
+    const ParseError          = $injector.get('ParseError');
+    const PermissionSet       = $injector.get('PermissionSet');
+    const User                = $injector.get('User');
+    const UserGroup           = $injector.get('UserGroup');
+
+    /**
+     * The result of parsing the current upload, if successful.
+     *
+     * @type {ParseResult}
+     */
+    $scope.parseResult = null;
+
+    /**
+     * The failure associated with the current attempt to create connections
+     * through the API, if any.
+     *
+     * @type {Error}
+     */
+    $scope.patchFailure = null;;
+
+    /**
+     * True if the file is fully uploaded and ready to be processed, or false
+     * otherwise.
+     *
+     * @type {Boolean}
+     */
+    $scope.dataReady = false;
+
+    /**
+     * True if the file upload has been aborted mid-upload, or false otherwise.
+     */
+    $scope.aborted = false;
+
+    /**
+     * True if fully-uploaded data is being processed, or false otherwise.
+     */
+    $scope.processing = false;
+
+    /**
+     * The MIME type of the uploaded file, if any.
+     *
+     * @type {String}
+     */
+    $scope.mimeType = null;
+
+    /**
+     * The raw string contents of the uploaded file, if any.
+     *
+     * @type {String}
+     */
+    $scope.fileData = null;
+
+    /**
+     * The file reader currently being used to upload the file, if any. If
+     * null, no file upload is currently in progress.
+     *
+     * @type {FileReader}
+     */
+    $scope.fileReader = null;
+
+    /**
+     * Clear all file upload state.
+     */
+    function resetUploadState() {
+
+        $scope.aborted = false;
+        $scope.dataReady = false;
+        $scope.processing = false;
+        $scope.fileData = null;
+        $scope.mimeType = null;
+        $scope.fileReader = null;
+        $scope.parseResult = null;
+        $scope.patchFailure = null;
+        $scope.fileName = null;
+
+    }
+
+    // Indicate that data is currently being loaded / processed if the the file
+    // has been provided but not yet fully uploaded, or if the the file is
+    // fully loaded and is currently being processed.
+    $scope.isLoading = () => (
+            ($scope.fileName && !$scope.dataReady && !$scope.patchFailure)
+            || $scope.processing);
+
+    /**
+     * Create all users and user groups mentioned in the import file that don't
+     * already exist in the current data source. If either creation fails, any
+     * already-created entities will be cleaned up, and the returned promise
+     * will be rejected.
+     *
+     * @param {ParseResult} parseResult
+     *     The result of parsing the user-supplied import file.
+     *
+     * @return {Promise.<Object>}
+     *     A promise resolving to an object containing the results of the calls
+     *     to create the users and groups.
+     */
+    function createUsersAndGroups(parseResult) {
+
+        const dataSource = $routeParams.dataSource;
+
+        return $q.all({
+            existingUsers : userService.getUsers(dataSource),
+            existingGroups : userGroupService.getUserGroups(dataSource)
+        }).then(({existingUsers, existingGroups}) => {
+
+            const userPatches = Object.keys(parseResult.users)
+
+                // Filter out any existing users
+                .filter(identifier => !existingUsers[identifier])
+
+                // A patch to create each new user
+                .map(username => new DirectoryPatch({
+                    op: 'add',
+                    path: '/',
+                    value: new User({ username })
+                }));
+
+            const groupPatches = Object.keys(parseResult.groups)
+
+                // Filter out any existing groups
+                .filter(identifier => !existingGroups[identifier])
+
+                // A patch to create each new user group
+                .map(identifier => new DirectoryPatch({
+                    op: 'add',
+                    path: '/',
+                    value: new UserGroup({ identifier })
+                }));
+
+            // First, create any required users and groups, automatically cleaning
+            // up any created already-created entities if a call fails.
+            // NOTE: Generally we'd want to do these calls in parallel, using
+            // `$q.all()`. However, `$q.all()` rejects immediately if any of the
+            // wrapped promises reject, so the users may not be ready for cleanup
+            // at the time that the group promise rejects, or vice versa. While
+            // it would be possible to juggle promises and still do these calls
+            // in parallel, the code gets pretty complex, so for readability and
+            // simplicity, they are executed serially. The performance cost of
+            // doing so should be low.
+            return userService.patchUsers(dataSource, userPatches).then(userResponse => {
+
+                // Then, if that succeeds, create any required groups
+                return userGroupService.patchUserGroups(dataSource, groupPatches).then(
+
+                    // If user group creation succeeds, resolve the returned promise
+                    userGroupResponse => ({ userResponse, userGroupResponse}))
+
+                // If the group creation request fails, clean up any created users
+                .catch(groupFailure => {
+                    cleanUpUsers(userResponse);
+                    return groupFailure;
+                });
+
+            });
+
+        });
+
+    }
+
+    /**
+     * Grant read permissions for each user and group in the supplied parse
+     * result to each connection in their connection list. Note that there will
+     * be a seperate request for each user and group.
+     *
+     * @param {ParseResult} parseResult
+     *     The result of successfully parsing a user-supplied import file.
+     *
+     * @param {Object} response
+     *     The response from the PATCH API request.
+     *
+     * @returns {Promise.<Object>}
+     *     A promise that will resolve with the result of every permission
+     *     granting request.
+     */
+    function grantConnectionPermissions(parseResult, response) {
+
+        const dataSource = $routeParams.dataSource;
+
+        // All connection grant requests, one per user/group
+        const userRequests = {};
+        const groupRequests = {};
+
+        // Create a PermissionSet granting access to all connections at
+        // the provided indices within the provided parse result
+        const createPermissionSet = indices =>
+            new PermissionSet({ connectionPermissions: indices.reduce(
+                    (permissions, index) => {
+                const connectionId = response.patches[index].identifier;
+                permissions[connectionId] = [
+                        PermissionSet.ObjectPermissionType.READ];
+                return permissions;
+            }, {}) });
+
+        // Now that we've created all the users, grant access to each
+        _.forEach(parseResult.users, (connectionIndices, identifier) =>
+
+            // Grant the permissions - note the group flag is `false`
+            userRequests[identifier] = permissionService.patchPermissions(
+                dataSource, identifier,
+
+                // Create the permissions to these connections for this user
+                createPermissionSet(connectionIndices),
+
+                // Do not remove any permissions
+                new PermissionSet(),
+
+                // This call is not for a group
+                false));
+
+        // Now that we've created all the groups, grant access to each
+        _.forEach(parseResult.groups, (connectionIndices, identifier) =>
+
+            // Grant the permissions - note the group flag is `true`
+            groupRequests[identifier] = permissionService.patchPermissions(
+                dataSource, identifier,
+
+                // Create the permissions to these connections for this user
+                createPermissionSet(connectionIndices),
+
+                // Do not remove any permissions
+                new PermissionSet(),
+
+                // This call is for a group
+                true));
+
+        // Return the result from all the permission granting calls
+        return $q.all({ ...userRequests, ...groupRequests });
+    }
+
+    // Given a PATCH API response, create an array of patches to delete every
+    // entity created in the original request that generated this response
+    const createDeletionPatches = creationResponse =>
+        creationResponse.patches.map(patch =>
+
+            // Add one deletion patch per original creation patch
+            new DirectoryPatch({
+                op: 'remove',
+                path: '/' + patch.identifier
+            }));
+
+    /**
+     * Given a successful response to a connection PATCH request, make another
+     * request to delete every created connection in the provided request, i.e.
+     * clean up every connection that was created.
+     *
+     * @param {DirectoryPatchResponse} creationResponse
+     *     The response to the connection PATCH request.
+     *
+     * @returns {DirectoryPatchResponse}
+     *     The response to the PATCH deletion request.
+     */
+    function cleanUpConnections(creationResponse) {
+
+        return connectionService.patchConnections(
+            $routeParams.dataSource, createDeletionPatches(creationResponse));
+
+    }
+
+    /**
+     * Given a successful response to a user PATCH request, make another
+     * request to delete every created user in the provided request.
+     *
+     * @param {DirectoryPatchResponse} creationResponse
+     *     The response to the user PATCH request.
+     *
+     * @returns {DirectoryPatchResponse}
+     *     The response to the PATCH deletion request.
+     */
+    function cleanUpUsers(creationResponse) {
+
+        return userService.patchUsers(
+            $routeParams.dataSource, createDeletionPatches(creationResponse));
+
+    }
+
+    /**
+     * Process a successfully parsed import file, creating any specified
+     * connections, creating and granting permissions to any specified users
+     * and user groups. If successful, the user will be shown a success message.
+     * If not, any errors will be displayed and any already-created entities
+     * will be rolled back.
+     *
+     * @param {ParseResult} parseResult
+     *     The result of parsing the user-supplied import file.
+     */
+    function handleParseSuccess(parseResult) {
+
+        $scope.parseResult = parseResult;
+
+        // If errors were encounted during file parsing, abort further
+        // processing - the user will have a chance to fix the errors and try
+        // again
+        if (parseResult.hasErrors)
+            return;
+
+        const dataSource = $routeParams.dataSource;
+
+        // First, attempt to create the connections
+        connectionService.patchConnections(dataSource, parseResult.patches)
+                .then(connectionResponse =>
+
+            // If connection creation is successful, create users and groups
+            createUsersAndGroups(parseResult).then(() =>
+
+                grantConnectionPermissions(parseResult, connectionResponse)
+                        .then(() => {
+
+                    $scope.processing = false;
+
+                    // Display a success message if everything worked
+                    guacNotification.showStatus({
+                        className  : 'success',
+                        title      : 'IMPORT.DIALOG_HEADER_SUCCESS',
+                        text       : {
+                            key: 'IMPORT.INFO_CONNECTIONS_IMPORTED_SUCCESS',
+                            variables: { NUMBER: parseResult.patches.length }
+                        },
+
+                        // Add a button to acknowledge and redirect to
+                        // the connection listing page
+                        actions    : [{
+                            name      : 'IMPORT.ACTION_ACKNOWLEDGE',
+                            callback  : () => {
+
+                                // Close the notification
+                                guacNotification.showStatus(false);
+
+                                // Redirect to connection list page
+                                $location.url('/settings/' + dataSource + '/connections');
+                            }
+                        }]
+                    });
+                }))
+
+            // If an error occurs while trying to users or groups, or while trying
+            // to assign permissions to users or groups, clean up the already-created
+            // connections, displaying an error to the user along with a blank slate
+            // so they can fix their problems and try again.
+            .catch(error => {
+                cleanUpConnections(connectionResponse);
+                handleError(error);
+            }))
+
+        // If an error occured when the call to create the connections was made,
+        // skip any further processing - the user will have a chance to fix the
+        // problems and try again
+        .catch(patchFailure => {
+            $scope.processing = false;
+            $scope.patchFailure = patchFailure;
+        });
+    }
+
+    /**
+     * Display the provided error to the user in a dismissable dialog.
+     *
+     * @argument {ParseError|Error} error
+     *     The error to display.
+     */
+    const handleError = error => {
+
+        // Any error indicates that processing of the file has failed, so clear
+        // all upload state to allow for a fresh retry
+        resetUploadState();
+
+        let text;
+
+        // If it's a import file parsing error
+        if (error instanceof ParseError)
+            text = {
+
+                // Use the translation key if available
+                key: error.key || error.message,
+                variables: error.variables
+            };
+
+        // If it's a generic REST error
+        else if (error instanceof Error)
+            text = error.translatableMessage;
+
+        // If it's an unknown type, just use the message directly
+        else
+            text = { key: error };
+
+        guacNotification.showStatus({
+            className  : 'error',
+            title      : 'IMPORT.DIALOG_HEADER_ERROR',
+            text,
+
+            // Add a button to hide the error
+            actions    : [{
+                name      : 'IMPORT.ACTION_ACKNOWLEDGE',
+                callback  : () => guacNotification.showStatus(false)
+            }]
+        })
+
+    };
+
+    /**
+     * Process the uploaded import file, importing the connections, granting
+     * connection permissions, or displaying errors to the user if there are
+     * problems with the provided file.
+     *
+     * @param {String} mimeType
+     *     The MIME type of the uploaded data file.
+     *
+     * @param {String} data
+     *     The raw string contents of the import file.
+     */
+    function processData(mimeType, data) {
+
+        // Data processing has begun
+        $scope.processing = true;
+
+        // The function that will process all the raw data and return a list of
+        // patches to be submitted to the API
+        let processDataCallback;
+
+        // Choose the appropriate parse function based on the mimetype
+        if (mimeType.endsWith("json"))
+            processDataCallback = connectionParseService.parseJSON;
+
+        else if (mimeType.endsWith("csv"))
+            processDataCallback = connectionParseService.parseCSV;
+
+        else if (mimeType.endsWith("yaml"))
+            processDataCallback = connectionParseService.parseYAML;
+
+        // The file type was validated before being uploaded - this should
+        // never happen
+        else
+            processDataCallback = () => {
+                throw new ParseError({
+                    message: "Unexpected invalid file type: " + mimeType
+                });
+            };
+
+        // Make the call to process the data into a series of patches
+        processDataCallback(data)
+
+            // Send the data off to be imported if parsing is successful
+            .then(handleParseSuccess)
+
+            // Display any error found while parsing the file
+            .catch(handleError);
+    }
+
+    /**
+     * Process the uploaded import data. Only usuable if the upload is fully
+     * complete.
+     */
+    $scope.import = () => processData($scope.mimeType, $scope.fileData);
+
+    /**
+     * @return {Boolean}
+     *     True if import should be disabled, or false if import should be
+     *     allowed.
+     */
+    $scope.importDisabled = () =>
+
+        // Disable import if no data is ready
+        !$scope.dataReady ||
+
+        // Disable import if the file is currently being processed
+        $scope.processing;
+
+    /**
+     * Cancel any in-progress upload, or clear any uploaded-but-errored-out
+     * batch.
+     */
+    $scope.cancel = function() {
+
+        // If the upload is in progress, stop it now; the FileReader will
+        // reset the upload state when it stops
+        if ($scope.fileReader) {
+            $scope.aborted = true;
+            $scope.fileReader.abort();
+        }
+
+        // Clear any upload state - there's no FileReader handler to do it
+        else
+            resetUploadState();
+
+    };
+
+    /**
+     * Returns true if cancellation should be disabled, or false if
+     * cancellation should be allowed.
+     *
+     * @return {Boolean}
+     *     True if cancellation should be disabled, or false if cancellation
+     *     should be allowed.
+     */
+    $scope.cancelDisabled = () =>
+
+        // Disable cancellation if the import has already been cancelled
+        $scope.aborted ||
+
+        // Disable cancellation if the file is currently being processed
+        $scope.processing ||
+
+        // Disable cancellation if no data is ready or being uploaded
+        !($scope.fileReader || $scope.dataReady);
+
+    /**
+     * Handle a provided File upload, reading all data onto the scope for
+     * import processing, should the user request an import.
+     *
+     * @argument {File} file
+     *     The file to upload onto the scope for further processing.
+     */
+    const handleFile = file => {
+
+        // The MIME type of the provided file
+        const mimeType = file.type;
+
+        // Check if the mimetype ends with one of the supported types,
+        // e.g. "application/json" or "text/csv"
+        if (_.every(LEGAL_FILE_TYPES.map(
+                type => !mimeType.endsWith(type)))) {
+
+            // If the provided file is not one of the supported types,
+            // display an error and abort processing
+            handleError(new ParseError({
+                message: "Invalid file type: " + mimeType,
+                key: 'IMPORT.ERROR_INVALID_FILE_TYPE',
+                variables: { TYPE: mimeType }
+            }));
+            return;
+        }
+
+        $scope.fileName = file.name;
+
+        // Initialize upload state
+        $scope.aborted = false;
+        $scope.dataReady = false;
+        $scope.processing = false;
+        $scope.uploadStarted = true;
+
+        // Save the MIME type to the scope
+        $scope.mimeType = file.type;
+
+        // Save the file to the scope when ready
+        $scope.fileReader = new FileReader();
+        $scope.fileReader.onloadend = (e => {
+
+            // If the upload was explicitly aborted, clear any upload state and
+            // do not process the data
+            if ($scope.aborted)
+                resetUploadState();
+
+            else {
+
+                // Save the uploaded data
+                $scope.fileData = e.target.result;
+
+                // Mark the data as ready
+                $scope.dataReady = true;
+
+                // Clear the file reader from the scope now that this file is
+                // fully uploaded
+                $scope.fileReader = null;
+
+            }
+        });
+
+        // Read all the data into memory
+        $scope.fileReader.readAsBinaryString(file);
+    };
+
+    /**
+     * Whether a drag/drop operation is currently in progress (the user has
+     * dragged a file over the Guacamole connection but has not yet
+     * dropped it).
+     *
+     * @type boolean
+     */
+    $scope.dropPending = false;
+
+    /**
+     * The name of the file that's currently being uploaded, or has yet to
+     * be imported, if any.
+     */
+    $scope.fileName = null;
+
+    /**
+     * The container for the file upload UI.
+     *
+     * @type Element
+     *
+     */
+    const uploadContainer = angular.element(
+            $document.find('.file-upload-container'));
+
+    /**
+     * The location where files can be dragged-and-dropped to.
+     *
+     * @type Element
+     */
+    const dropTarget = uploadContainer.find('.drop-target');

Review Comment:
   Should this be moved to a directive such that the controller for this page does not directly manipulate the DOM?



##########
guacamole/src/main/frontend/src/app/import/services/connectionCSVService.js:
##########
@@ -0,0 +1,430 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * 'License'); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* global _ */
+
+// A suffix that indicates that a particular header refers to a parameter
+const PARAMETER_SUFFIX = ' (parameter)';
+
+// A suffix that indicates that a particular header refers to an attribute
+const ATTRIBUTE_SUFFIX = ' (attribute)';
+
+/**
+ * A service for parsing user-provided CSV connection data for bulk import.
+ */
+angular.module('import').factory('connectionCSVService',
+        ['$injector', function connectionCSVService($injector) {
+
+    // Required types
+    const ParseError          = $injector.get('ParseError');
+    const ImportConnection    = $injector.get('ImportConnection');
+    const TranslatableMessage = $injector.get('TranslatableMessage');
+
+    // Required services
+    const $q            = $injector.get('$q');
+    const $routeParams  = $injector.get('$routeParams');
+    const schemaService = $injector.get('schemaService');
+
+    const service = {};
+
+    /**
+     * Returns a promise that resolves to a object detailing the connection
+     * attributes for the current data source, as well as the connection
+     * paremeters for every protocol, for the current data source.
+     *
+     * The object that the promise will contain an "attributes" key that maps to
+     * a set of attribute names, and a "protocolParameters" key that maps to an
+     * object mapping protocol names to sets of parameter names for that protocol.
+     *
+     * The intended use case for this object is to determine if there is a
+     * connection parameter or attribute with a given name, by e.g. checking the
+     * path `.protocolParameters[protocolName]` to see if a protocol exists,
+     * checking the path `.protocolParameters[protocolName][fieldName]` to see
+     * if a parameter exists for a given protocol, or checking the path
+     * `.attributes[fieldName]` to check if a connection attribute exists.
+     *
+     * @returns {Promise.<Object>}

Review Comment:
   Missing JSDoc description for return value.



##########
guacamole/src/main/frontend/src/app/import/services/connectionParseService.js:
##########
@@ -0,0 +1,393 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * 'License'); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* global _ */
+
+import { parse as parseCSVData } from 'csv-parse/lib/sync'
+import { parse as parseYAMLData } from 'yaml'
+
+/**
+ * A service for parsing user-provided JSON, YAML, or JSON connection data into
+ * an appropriate format for bulk uploading using the PATCH REST endpoint.
+ */
+angular.module('import').factory('connectionParseService',
+        ['$injector', function connectionParseService($injector) {
+
+    // Required types
+    const Connection          = $injector.get('Connection');
+    const DirectoryPatch      = $injector.get('DirectoryPatch');
+    const ParseError          = $injector.get('ParseError');
+    const ParseResult         = $injector.get('ParseResult');
+    const TranslatableMessage = $injector.get('TranslatableMessage');
+
+    // Required services
+    const $q                     = $injector.get('$q');
+    const $routeParams           = $injector.get('$routeParams');
+    const schemaService          = $injector.get('schemaService');
+    const connectionCSVService   = $injector.get('connectionCSVService');
+    const connectionGroupService = $injector.get('connectionGroupService');
+
+    const service = {};
+
+    /**
+     * Perform basic checks, common to all file types - namely that the parsed
+     * data is an array, and contains at least one connection entry. Returns an
+     * error if any of these basic checks fails.
+     *
+     * returns {ParseError}
+     *     An error describing the parsing failure, if one of the basic checks
+     *     fails.
+     */
+    function performBasicChecks(parsedData) {
+
+        // Make sure that the file data parses to an array (connection list)
+        if (!(parsedData instanceof Array))
+            return new ParseError({
+                message: 'Import data must be a list of connections',
+                key: 'IMPORT.ERROR_ARRAY_REQUIRED'
+            });
+
+        // Make sure that the connection list is not empty - contains at least
+        // one connection
+        if (!parsedData.length)
+            return new ParseError({
+                message: 'The provided file is empty',
+                key: 'IMPORT.ERROR_EMPTY_FILE'
+            });
+    }
+
+
+    /**
+     * Returns a promise that resolves to an object mapping potential groups
+     * that might be encountered in an imported connection to group identifiers.
+     *
+     * The idea is that a user-provided import file might directly specify a
+     * parentIdentifier, or it might specify a named group path like "ROOT",
+     * "ROOT/parent", or "ROOT/parent/child". This object resolved by the
+     * promise returned from this function will map all of the above to the
+     * identifier of the appropriate group, if defined.
+     *
+     * @returns {Promise.<Object>}

Review Comment:
   Please document the return value.



##########
guacamole/src/main/frontend/src/app/index/config/indexRouteConfig.js:
##########
@@ -126,6 +126,23 @@ angular.module('index').config(['$routeProvider', '$locationProvider',
             resolve       : { routeToUserHomePage: routeToUserHomePage }
         })
 
+        // Connection import page
+        .when('/import/:dataSource/connection', {
+            title         : 'APP.NAME',
+            bodyClassName : 'settings',
+            templateUrl   : 'app/import/templates/connectionImport.html',
+            controller    : 'importConnectionsController',
+            resolve       : { updateCurrentToken: updateCurrentToken }
+        })
+
+        // Connection import page

Review Comment:
   Copypasta?



##########
guacamole/src/main/java/org/apache/guacamole/rest/directory/DirectoryResource.java:
##########
@@ -386,46 +417,211 @@ public Map<String, ExternalType> getObjects(
 
     /**
      * Applies the given object patches, updating the underlying directory
-     * accordingly. This operation currently only supports deletion of objects
-     * through the "remove" patch operation. The path of each patch operation is
-     * of the form "/ID" where ID is the identifier of the object being
-     * modified.
+     * accordingly. This operation supports addition and removal of objects
+     * through the "add" and "remove" patch operation. The path of each patch
+     * operation is of the form "/ID" where ID is the identifier of the object
+     * being modified. In the case of object creation, the identifier is
+     * ignored, as the identifier will be automatically provided. This operation
+     * is atomic.
      *
      * @param patches
      *     The patches to apply for this request.
      *
      * @throws GuacamoleException
-     *     If an error occurs while deleting the objects.
+     *     If an error occurs while adding, updating, or removing objects.
+     *
+     * @return
+     *     A response describing the outcome of each patch. Only the identifier
+     *     of each patched object will be included in the response, not the
+     *     full object.
      */
     @PATCH
-    public void patchObjects(List<APIPatch<String>> patches)
+    public APIPatchResponse patchObjects(List<APIPatch<ExternalType>> patches)
             throws GuacamoleException {
 
-        // Apply each operation specified within the patch
-        for (APIPatch<String> patch : patches) {
+        // An outcome for each patch included in the request. This list
+        // may include both success and failure responses, though the
+        // presence of any failure would indicated that the entire
+        // request has failed and no changes have been made.
+        List<APIPatchOutcome> patchOutcomes = new ArrayList<>();
 
-            // Only remove is supported
-            if (patch.getOp() != APIPatch.Operation.remove)
-                throw new GuacamoleUnsupportedException("Only the \"remove\" "
-                        + "operation is supported.");
+        // Perform all requested operations atomically
+        directory.tryAtomically(new AtomicDirectoryOperation<InternalType>() {
 
-            // Retrieve and validate path
-            String path = patch.getPath();
-            if (!path.startsWith("/"))
-                throw new GuacamoleClientException("Patch paths must start with \"/\".");
+            @Override
+            public void executeOperation(boolean atomic, Directory<InternalType> directory)
+                    throws GuacamoleException {
+
+                // If the underlying directory implentation does not support
+                // atomic operations, abort the patch operation. This REST
+                // endpoint requires that operations be performed atomically.
+                if (!atomic)
+                    throw new GuacamoleUnsupportedException(
+                            "Atomic operations are not supported. " +
+                            "The patch cannot be executed.");

Review Comment:
   Recommend rephrasing this such that the message will indicate to the administrator the nature of the failure. "Atomic operations are not supported" sounds like Guacamole overall does not support the operation, whereas the issue is that an extension does not support atomic operations and therefore can't reliably perform patching.



##########
guacamole/src/main/frontend/src/app/import/directives/connectionImportErrors.js:
##########
@@ -0,0 +1,234 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* global _ */
+
+/**
+ * A directive that displays errors that occured during parsing of a connection

Review Comment:
   occurred*



##########
guacamole/src/main/frontend/src/app/import/types/ParseResult.js:
##########
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Service which defines the ParseResult class.
+ */
+angular.module('import').factory('ParseResult', [function defineParseResult() {
+
+    /**
+     * The result of parsing a connection import file - containing a list of
+     * API patches ready to be submitted to the PATCH REST API for batch
+     * connection creation, a set of users and user groups to grant access to
+     * each connection, and any errors that may have occured while parsing

Review Comment:
   occurred*



##########
guacamole/src/main/frontend/src/app/import/controllers/importConnectionsController.js:
##########
@@ -0,0 +1,760 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* global _ */
+
+/**
+ * The controller for the connection import page.
+ */
+angular.module('import').controller('importConnectionsController', ['$scope', '$injector',
+        function importConnectionsController($scope, $injector) {
+
+    // The file types supported for connection import
+    const LEGAL_FILE_TYPES = ['csv', 'json', 'yaml'];
+
+    // Required services
+    const $document              = $injector.get('$document');
+    const $location              = $injector.get('$location');
+    const $q                     = $injector.get('$q');
+    const $routeParams           = $injector.get('$routeParams');
+    const $timeout               = $injector.get('$timeout');
+    const connectionParseService = $injector.get('connectionParseService');
+    const connectionService      = $injector.get('connectionService');
+    const guacNotification       = $injector.get('guacNotification');
+    const permissionService      = $injector.get('permissionService');
+    const userService            = $injector.get('userService');
+    const userGroupService       = $injector.get('userGroupService');
+
+    // Required types
+    const DirectoryPatch      = $injector.get('DirectoryPatch');
+    const Error               = $injector.get('Error');
+    const ParseError          = $injector.get('ParseError');
+    const PermissionSet       = $injector.get('PermissionSet');
+    const User                = $injector.get('User');
+    const UserGroup           = $injector.get('UserGroup');
+
+    /**
+     * The result of parsing the current upload, if successful.
+     *
+     * @type {ParseResult}
+     */
+    $scope.parseResult = null;
+
+    /**
+     * The failure associated with the current attempt to create connections
+     * through the API, if any.
+     *
+     * @type {Error}
+     */
+    $scope.patchFailure = null;;
+
+    /**
+     * True if the file is fully uploaded and ready to be processed, or false
+     * otherwise.
+     *
+     * @type {Boolean}
+     */
+    $scope.dataReady = false;
+
+    /**
+     * True if the file upload has been aborted mid-upload, or false otherwise.
+     */
+    $scope.aborted = false;
+
+    /**
+     * True if fully-uploaded data is being processed, or false otherwise.
+     */
+    $scope.processing = false;
+
+    /**
+     * The MIME type of the uploaded file, if any.
+     *
+     * @type {String}
+     */
+    $scope.mimeType = null;
+
+    /**
+     * The raw string contents of the uploaded file, if any.
+     *
+     * @type {String}
+     */
+    $scope.fileData = null;
+
+    /**
+     * The file reader currently being used to upload the file, if any. If
+     * null, no file upload is currently in progress.
+     *
+     * @type {FileReader}
+     */
+    $scope.fileReader = null;
+
+    /**
+     * Clear all file upload state.
+     */
+    function resetUploadState() {
+
+        $scope.aborted = false;
+        $scope.dataReady = false;
+        $scope.processing = false;
+        $scope.fileData = null;
+        $scope.mimeType = null;
+        $scope.fileReader = null;
+        $scope.parseResult = null;
+        $scope.patchFailure = null;
+        $scope.fileName = null;
+
+    }
+
+    // Indicate that data is currently being loaded / processed if the the file
+    // has been provided but not yet fully uploaded, or if the the file is
+    // fully loaded and is currently being processed.
+    $scope.isLoading = () => (
+            ($scope.fileName && !$scope.dataReady && !$scope.patchFailure)
+            || $scope.processing);
+
+    /**
+     * Create all users and user groups mentioned in the import file that don't
+     * already exist in the current data source. If either creation fails, any
+     * already-created entities will be cleaned up, and the returned promise
+     * will be rejected.
+     *
+     * @param {ParseResult} parseResult
+     *     The result of parsing the user-supplied import file.
+     *
+     * @return {Promise.<Object>}
+     *     A promise resolving to an object containing the results of the calls
+     *     to create the users and groups.
+     */
+    function createUsersAndGroups(parseResult) {
+
+        const dataSource = $routeParams.dataSource;
+
+        return $q.all({
+            existingUsers : userService.getUsers(dataSource),
+            existingGroups : userGroupService.getUserGroups(dataSource)
+        }).then(({existingUsers, existingGroups}) => {
+
+            const userPatches = Object.keys(parseResult.users)
+
+                // Filter out any existing users
+                .filter(identifier => !existingUsers[identifier])
+
+                // A patch to create each new user
+                .map(username => new DirectoryPatch({
+                    op: 'add',
+                    path: '/',
+                    value: new User({ username })
+                }));
+
+            const groupPatches = Object.keys(parseResult.groups)
+
+                // Filter out any existing groups
+                .filter(identifier => !existingGroups[identifier])
+
+                // A patch to create each new user group
+                .map(identifier => new DirectoryPatch({
+                    op: 'add',
+                    path: '/',
+                    value: new UserGroup({ identifier })
+                }));
+
+            // First, create any required users and groups, automatically cleaning
+            // up any created already-created entities if a call fails.
+            // NOTE: Generally we'd want to do these calls in parallel, using
+            // `$q.all()`. However, `$q.all()` rejects immediately if any of the
+            // wrapped promises reject, so the users may not be ready for cleanup
+            // at the time that the group promise rejects, or vice versa. While
+            // it would be possible to juggle promises and still do these calls
+            // in parallel, the code gets pretty complex, so for readability and
+            // simplicity, they are executed serially. The performance cost of
+            // doing so should be low.
+            return userService.patchUsers(dataSource, userPatches).then(userResponse => {
+
+                // Then, if that succeeds, create any required groups
+                return userGroupService.patchUserGroups(dataSource, groupPatches).then(
+
+                    // If user group creation succeeds, resolve the returned promise
+                    userGroupResponse => ({ userResponse, userGroupResponse}))
+
+                // If the group creation request fails, clean up any created users
+                .catch(groupFailure => {
+                    cleanUpUsers(userResponse);
+                    return groupFailure;
+                });
+
+            });
+
+        });
+
+    }
+
+    /**
+     * Grant read permissions for each user and group in the supplied parse
+     * result to each connection in their connection list. Note that there will
+     * be a seperate request for each user and group.
+     *
+     * @param {ParseResult} parseResult
+     *     The result of successfully parsing a user-supplied import file.
+     *
+     * @param {Object} response
+     *     The response from the PATCH API request.
+     *
+     * @returns {Promise.<Object>}
+     *     A promise that will resolve with the result of every permission
+     *     granting request.
+     */
+    function grantConnectionPermissions(parseResult, response) {
+
+        const dataSource = $routeParams.dataSource;
+
+        // All connection grant requests, one per user/group
+        const userRequests = {};
+        const groupRequests = {};
+
+        // Create a PermissionSet granting access to all connections at
+        // the provided indices within the provided parse result
+        const createPermissionSet = indices =>
+            new PermissionSet({ connectionPermissions: indices.reduce(
+                    (permissions, index) => {
+                const connectionId = response.patches[index].identifier;
+                permissions[connectionId] = [
+                        PermissionSet.ObjectPermissionType.READ];
+                return permissions;
+            }, {}) });
+
+        // Now that we've created all the users, grant access to each
+        _.forEach(parseResult.users, (connectionIndices, identifier) =>
+
+            // Grant the permissions - note the group flag is `false`
+            userRequests[identifier] = permissionService.patchPermissions(
+                dataSource, identifier,
+
+                // Create the permissions to these connections for this user
+                createPermissionSet(connectionIndices),
+
+                // Do not remove any permissions
+                new PermissionSet(),
+
+                // This call is not for a group
+                false));
+
+        // Now that we've created all the groups, grant access to each
+        _.forEach(parseResult.groups, (connectionIndices, identifier) =>
+
+            // Grant the permissions - note the group flag is `true`
+            groupRequests[identifier] = permissionService.patchPermissions(
+                dataSource, identifier,
+
+                // Create the permissions to these connections for this user
+                createPermissionSet(connectionIndices),
+
+                // Do not remove any permissions
+                new PermissionSet(),
+
+                // This call is for a group
+                true));
+
+        // Return the result from all the permission granting calls
+        return $q.all({ ...userRequests, ...groupRequests });
+    }
+
+    // Given a PATCH API response, create an array of patches to delete every
+    // entity created in the original request that generated this response
+    const createDeletionPatches = creationResponse =>
+        creationResponse.patches.map(patch =>
+
+            // Add one deletion patch per original creation patch
+            new DirectoryPatch({
+                op: 'remove',
+                path: '/' + patch.identifier
+            }));
+
+    /**
+     * Given a successful response to a connection PATCH request, make another
+     * request to delete every created connection in the provided request, i.e.
+     * clean up every connection that was created.
+     *
+     * @param {DirectoryPatchResponse} creationResponse
+     *     The response to the connection PATCH request.
+     *
+     * @returns {DirectoryPatchResponse}
+     *     The response to the PATCH deletion request.
+     */
+    function cleanUpConnections(creationResponse) {
+
+        return connectionService.patchConnections(
+            $routeParams.dataSource, createDeletionPatches(creationResponse));
+
+    }
+
+    /**
+     * Given a successful response to a user PATCH request, make another
+     * request to delete every created user in the provided request.
+     *
+     * @param {DirectoryPatchResponse} creationResponse
+     *     The response to the user PATCH request.
+     *
+     * @returns {DirectoryPatchResponse}
+     *     The response to the PATCH deletion request.
+     */
+    function cleanUpUsers(creationResponse) {
+
+        return userService.patchUsers(
+            $routeParams.dataSource, createDeletionPatches(creationResponse));
+
+    }
+
+    /**
+     * Process a successfully parsed import file, creating any specified
+     * connections, creating and granting permissions to any specified users
+     * and user groups. If successful, the user will be shown a success message.
+     * If not, any errors will be displayed and any already-created entities
+     * will be rolled back.
+     *
+     * @param {ParseResult} parseResult
+     *     The result of parsing the user-supplied import file.
+     */
+    function handleParseSuccess(parseResult) {
+
+        $scope.parseResult = parseResult;
+
+        // If errors were encounted during file parsing, abort further
+        // processing - the user will have a chance to fix the errors and try
+        // again
+        if (parseResult.hasErrors)
+            return;
+
+        const dataSource = $routeParams.dataSource;
+
+        // First, attempt to create the connections
+        connectionService.patchConnections(dataSource, parseResult.patches)
+                .then(connectionResponse =>
+
+            // If connection creation is successful, create users and groups
+            createUsersAndGroups(parseResult).then(() =>
+
+                grantConnectionPermissions(parseResult, connectionResponse)
+                        .then(() => {
+
+                    $scope.processing = false;
+
+                    // Display a success message if everything worked
+                    guacNotification.showStatus({
+                        className  : 'success',
+                        title      : 'IMPORT.DIALOG_HEADER_SUCCESS',
+                        text       : {
+                            key: 'IMPORT.INFO_CONNECTIONS_IMPORTED_SUCCESS',
+                            variables: { NUMBER: parseResult.patches.length }
+                        },
+
+                        // Add a button to acknowledge and redirect to
+                        // the connection listing page
+                        actions    : [{
+                            name      : 'IMPORT.ACTION_ACKNOWLEDGE',
+                            callback  : () => {
+
+                                // Close the notification
+                                guacNotification.showStatus(false);
+
+                                // Redirect to connection list page
+                                $location.url('/settings/' + dataSource + '/connections');
+                            }
+                        }]
+                    });
+                }))
+
+            // If an error occurs while trying to users or groups, or while trying
+            // to assign permissions to users or groups, clean up the already-created
+            // connections, displaying an error to the user along with a blank slate
+            // so they can fix their problems and try again.
+            .catch(error => {
+                cleanUpConnections(connectionResponse);
+                handleError(error);
+            }))
+
+        // If an error occured when the call to create the connections was made,
+        // skip any further processing - the user will have a chance to fix the
+        // problems and try again
+        .catch(patchFailure => {
+            $scope.processing = false;
+            $scope.patchFailure = patchFailure;
+        });
+    }
+
+    /**
+     * Display the provided error to the user in a dismissable dialog.
+     *
+     * @argument {ParseError|Error} error
+     *     The error to display.
+     */
+    const handleError = error => {
+
+        // Any error indicates that processing of the file has failed, so clear
+        // all upload state to allow for a fresh retry
+        resetUploadState();
+
+        let text;
+
+        // If it's a import file parsing error
+        if (error instanceof ParseError)
+            text = {
+
+                // Use the translation key if available
+                key: error.key || error.message,
+                variables: error.variables
+            };
+
+        // If it's a generic REST error
+        else if (error instanceof Error)
+            text = error.translatableMessage;
+
+        // If it's an unknown type, just use the message directly
+        else
+            text = { key: error };
+
+        guacNotification.showStatus({
+            className  : 'error',
+            title      : 'IMPORT.DIALOG_HEADER_ERROR',
+            text,
+
+            // Add a button to hide the error
+            actions    : [{
+                name      : 'IMPORT.ACTION_ACKNOWLEDGE',
+                callback  : () => guacNotification.showStatus(false)
+            }]
+        })
+
+    };
+
+    /**
+     * Process the uploaded import file, importing the connections, granting
+     * connection permissions, or displaying errors to the user if there are
+     * problems with the provided file.
+     *
+     * @param {String} mimeType
+     *     The MIME type of the uploaded data file.
+     *
+     * @param {String} data
+     *     The raw string contents of the import file.
+     */
+    function processData(mimeType, data) {
+
+        // Data processing has begun
+        $scope.processing = true;
+
+        // The function that will process all the raw data and return a list of
+        // patches to be submitted to the API
+        let processDataCallback;
+
+        // Choose the appropriate parse function based on the mimetype
+        if (mimeType.endsWith("json"))
+            processDataCallback = connectionParseService.parseJSON;
+
+        else if (mimeType.endsWith("csv"))
+            processDataCallback = connectionParseService.parseCSV;
+
+        else if (mimeType.endsWith("yaml"))
+            processDataCallback = connectionParseService.parseYAML;

Review Comment:
   I think we should map the specific, known mimetypes (`application/json`, `text/csv`, etc.) to their corresponding handlers rather than forgivingly accepting anything that ends with specific substrings.



##########
guacamole/src/main/frontend/src/app/import/services/connectionCSVService.js:
##########
@@ -0,0 +1,430 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * 'License'); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* global _ */
+
+// A suffix that indicates that a particular header refers to a parameter
+const PARAMETER_SUFFIX = ' (parameter)';
+
+// A suffix that indicates that a particular header refers to an attribute
+const ATTRIBUTE_SUFFIX = ' (attribute)';

Review Comment:
   Please document with JSDoc.



##########
guacamole/src/main/frontend/src/app/import/types/ParseResult.js:
##########
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Service which defines the ParseResult class.
+ */
+angular.module('import').factory('ParseResult', [function defineParseResult() {
+
+    /**
+     * The result of parsing a connection import file - containing a list of
+     * API patches ready to be submitted to the PATCH REST API for batch
+     * connection creation, a set of users and user groups to grant access to
+     * each connection, and any errors that may have occured while parsing
+     * each connection.
+     *
+     * @constructor
+     * @param {ParseResult|Object} [template={}]
+     *     The object whose properties should be copied within the new
+     *     ParseResult.
+     */
+    const ParseResult = function ParseResult(template) {
+
+        // Use empty object by default
+        template = template || {};
+
+        /**
+         * An array of patches, ready to be submitted to the PATCH REST API for
+         * batch connection creation.
+         *
+         * @type {DirectoryPatch[]}
+         */
+        this.patches = template.patches || [];
+
+        /**
+         * An object whose keys are the user identifiers of users specified
+         * in the batch import. and the keys are an array of indices of
+         * connections to which those users should be granted access.
+         *
+         * @type {Object.<String, Integer[]>}
+         */
+        this.users = template.users || {};
+
+        /**
+         * An object whose keys are the user group identifiers of every user
+         * group specified in the batch import. i.e. a set of all user group
+         * identifiers.
+         *
+         * @type {Object.<String, Boolean>}
+         */
+        this.groups = template.users || {};
+
+        /**
+         * An array of errors encountered while parsing the corresponding
+         * connection (at the same array index). Each connection should have a
+         * an array of errors. If empty, no errors occured for this connection.

Review Comment:
   occurred*



##########
guacamole/src/main/frontend/src/app/import/services/connectionParseService.js:
##########
@@ -0,0 +1,393 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * 'License'); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* global _ */
+
+import { parse as parseCSVData } from 'csv-parse/lib/sync'
+import { parse as parseYAMLData } from 'yaml'
+
+/**
+ * A service for parsing user-provided JSON, YAML, or JSON connection data into
+ * an appropriate format for bulk uploading using the PATCH REST endpoint.
+ */
+angular.module('import').factory('connectionParseService',
+        ['$injector', function connectionParseService($injector) {
+
+    // Required types
+    const Connection          = $injector.get('Connection');
+    const DirectoryPatch      = $injector.get('DirectoryPatch');
+    const ParseError          = $injector.get('ParseError');
+    const ParseResult         = $injector.get('ParseResult');
+    const TranslatableMessage = $injector.get('TranslatableMessage');
+
+    // Required services
+    const $q                     = $injector.get('$q');
+    const $routeParams           = $injector.get('$routeParams');
+    const schemaService          = $injector.get('schemaService');
+    const connectionCSVService   = $injector.get('connectionCSVService');
+    const connectionGroupService = $injector.get('connectionGroupService');
+
+    const service = {};
+
+    /**
+     * Perform basic checks, common to all file types - namely that the parsed
+     * data is an array, and contains at least one connection entry. Returns an
+     * error if any of these basic checks fails.
+     *
+     * returns {ParseError}

Review Comment:
   `@returns`*



##########
guacamole/src/main/frontend/src/app/import/controllers/importConnectionsController.js:
##########
@@ -0,0 +1,760 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* global _ */
+
+/**
+ * The controller for the connection import page.
+ */
+angular.module('import').controller('importConnectionsController', ['$scope', '$injector',
+        function importConnectionsController($scope, $injector) {
+
+    // The file types supported for connection import
+    const LEGAL_FILE_TYPES = ['csv', 'json', 'yaml'];
+
+    // Required services
+    const $document              = $injector.get('$document');
+    const $location              = $injector.get('$location');
+    const $q                     = $injector.get('$q');
+    const $routeParams           = $injector.get('$routeParams');
+    const $timeout               = $injector.get('$timeout');
+    const connectionParseService = $injector.get('connectionParseService');
+    const connectionService      = $injector.get('connectionService');
+    const guacNotification       = $injector.get('guacNotification');
+    const permissionService      = $injector.get('permissionService');
+    const userService            = $injector.get('userService');
+    const userGroupService       = $injector.get('userGroupService');
+
+    // Required types
+    const DirectoryPatch      = $injector.get('DirectoryPatch');
+    const Error               = $injector.get('Error');
+    const ParseError          = $injector.get('ParseError');
+    const PermissionSet       = $injector.get('PermissionSet');
+    const User                = $injector.get('User');
+    const UserGroup           = $injector.get('UserGroup');
+
+    /**
+     * The result of parsing the current upload, if successful.
+     *
+     * @type {ParseResult}
+     */
+    $scope.parseResult = null;
+
+    /**
+     * The failure associated with the current attempt to create connections
+     * through the API, if any.
+     *
+     * @type {Error}
+     */
+    $scope.patchFailure = null;;
+
+    /**
+     * True if the file is fully uploaded and ready to be processed, or false
+     * otherwise.
+     *
+     * @type {Boolean}
+     */
+    $scope.dataReady = false;
+
+    /**
+     * True if the file upload has been aborted mid-upload, or false otherwise.
+     */
+    $scope.aborted = false;
+
+    /**
+     * True if fully-uploaded data is being processed, or false otherwise.
+     */
+    $scope.processing = false;
+
+    /**
+     * The MIME type of the uploaded file, if any.
+     *
+     * @type {String}
+     */
+    $scope.mimeType = null;
+
+    /**
+     * The raw string contents of the uploaded file, if any.
+     *
+     * @type {String}
+     */
+    $scope.fileData = null;
+
+    /**
+     * The file reader currently being used to upload the file, if any. If
+     * null, no file upload is currently in progress.
+     *
+     * @type {FileReader}
+     */
+    $scope.fileReader = null;
+
+    /**
+     * Clear all file upload state.
+     */
+    function resetUploadState() {
+
+        $scope.aborted = false;
+        $scope.dataReady = false;
+        $scope.processing = false;
+        $scope.fileData = null;
+        $scope.mimeType = null;
+        $scope.fileReader = null;
+        $scope.parseResult = null;
+        $scope.patchFailure = null;
+        $scope.fileName = null;
+
+    }
+
+    // Indicate that data is currently being loaded / processed if the the file
+    // has been provided but not yet fully uploaded, or if the the file is
+    // fully loaded and is currently being processed.
+    $scope.isLoading = () => (
+            ($scope.fileName && !$scope.dataReady && !$scope.patchFailure)
+            || $scope.processing);
+
+    /**
+     * Create all users and user groups mentioned in the import file that don't
+     * already exist in the current data source. If either creation fails, any
+     * already-created entities will be cleaned up, and the returned promise
+     * will be rejected.
+     *
+     * @param {ParseResult} parseResult
+     *     The result of parsing the user-supplied import file.
+     *
+     * @return {Promise.<Object>}
+     *     A promise resolving to an object containing the results of the calls
+     *     to create the users and groups.
+     */
+    function createUsersAndGroups(parseResult) {
+
+        const dataSource = $routeParams.dataSource;
+
+        return $q.all({
+            existingUsers : userService.getUsers(dataSource),
+            existingGroups : userGroupService.getUserGroups(dataSource)
+        }).then(({existingUsers, existingGroups}) => {
+
+            const userPatches = Object.keys(parseResult.users)
+
+                // Filter out any existing users
+                .filter(identifier => !existingUsers[identifier])
+
+                // A patch to create each new user
+                .map(username => new DirectoryPatch({
+                    op: 'add',
+                    path: '/',
+                    value: new User({ username })
+                }));
+
+            const groupPatches = Object.keys(parseResult.groups)
+
+                // Filter out any existing groups
+                .filter(identifier => !existingGroups[identifier])
+
+                // A patch to create each new user group
+                .map(identifier => new DirectoryPatch({
+                    op: 'add',
+                    path: '/',
+                    value: new UserGroup({ identifier })
+                }));
+
+            // First, create any required users and groups, automatically cleaning
+            // up any created already-created entities if a call fails.
+            // NOTE: Generally we'd want to do these calls in parallel, using
+            // `$q.all()`. However, `$q.all()` rejects immediately if any of the
+            // wrapped promises reject, so the users may not be ready for cleanup
+            // at the time that the group promise rejects, or vice versa. While
+            // it would be possible to juggle promises and still do these calls
+            // in parallel, the code gets pretty complex, so for readability and
+            // simplicity, they are executed serially. The performance cost of
+            // doing so should be low.
+            return userService.patchUsers(dataSource, userPatches).then(userResponse => {
+
+                // Then, if that succeeds, create any required groups
+                return userGroupService.patchUserGroups(dataSource, groupPatches).then(
+
+                    // If user group creation succeeds, resolve the returned promise
+                    userGroupResponse => ({ userResponse, userGroupResponse}))
+
+                // If the group creation request fails, clean up any created users
+                .catch(groupFailure => {
+                    cleanUpUsers(userResponse);
+                    return groupFailure;
+                });
+
+            });
+
+        });
+
+    }
+
+    /**
+     * Grant read permissions for each user and group in the supplied parse
+     * result to each connection in their connection list. Note that there will
+     * be a seperate request for each user and group.
+     *
+     * @param {ParseResult} parseResult
+     *     The result of successfully parsing a user-supplied import file.
+     *
+     * @param {Object} response
+     *     The response from the PATCH API request.
+     *
+     * @returns {Promise.<Object>}
+     *     A promise that will resolve with the result of every permission
+     *     granting request.
+     */
+    function grantConnectionPermissions(parseResult, response) {
+
+        const dataSource = $routeParams.dataSource;
+
+        // All connection grant requests, one per user/group
+        const userRequests = {};
+        const groupRequests = {};
+
+        // Create a PermissionSet granting access to all connections at
+        // the provided indices within the provided parse result
+        const createPermissionSet = indices =>
+            new PermissionSet({ connectionPermissions: indices.reduce(
+                    (permissions, index) => {
+                const connectionId = response.patches[index].identifier;
+                permissions[connectionId] = [
+                        PermissionSet.ObjectPermissionType.READ];
+                return permissions;
+            }, {}) });
+
+        // Now that we've created all the users, grant access to each
+        _.forEach(parseResult.users, (connectionIndices, identifier) =>
+
+            // Grant the permissions - note the group flag is `false`
+            userRequests[identifier] = permissionService.patchPermissions(
+                dataSource, identifier,
+
+                // Create the permissions to these connections for this user
+                createPermissionSet(connectionIndices),
+
+                // Do not remove any permissions
+                new PermissionSet(),
+
+                // This call is not for a group
+                false));
+
+        // Now that we've created all the groups, grant access to each
+        _.forEach(parseResult.groups, (connectionIndices, identifier) =>
+
+            // Grant the permissions - note the group flag is `true`
+            groupRequests[identifier] = permissionService.patchPermissions(
+                dataSource, identifier,
+
+                // Create the permissions to these connections for this user
+                createPermissionSet(connectionIndices),
+
+                // Do not remove any permissions
+                new PermissionSet(),
+
+                // This call is for a group
+                true));
+
+        // Return the result from all the permission granting calls
+        return $q.all({ ...userRequests, ...groupRequests });
+    }
+
+    // Given a PATCH API response, create an array of patches to delete every
+    // entity created in the original request that generated this response
+    const createDeletionPatches = creationResponse =>
+        creationResponse.patches.map(patch =>
+
+            // Add one deletion patch per original creation patch
+            new DirectoryPatch({
+                op: 'remove',
+                path: '/' + patch.identifier
+            }));
+
+    /**
+     * Given a successful response to a connection PATCH request, make another
+     * request to delete every created connection in the provided request, i.e.
+     * clean up every connection that was created.
+     *
+     * @param {DirectoryPatchResponse} creationResponse
+     *     The response to the connection PATCH request.
+     *
+     * @returns {DirectoryPatchResponse}
+     *     The response to the PATCH deletion request.
+     */
+    function cleanUpConnections(creationResponse) {
+
+        return connectionService.patchConnections(
+            $routeParams.dataSource, createDeletionPatches(creationResponse));
+
+    }
+
+    /**
+     * Given a successful response to a user PATCH request, make another
+     * request to delete every created user in the provided request.
+     *
+     * @param {DirectoryPatchResponse} creationResponse
+     *     The response to the user PATCH request.
+     *
+     * @returns {DirectoryPatchResponse}
+     *     The response to the PATCH deletion request.
+     */
+    function cleanUpUsers(creationResponse) {
+
+        return userService.patchUsers(
+            $routeParams.dataSource, createDeletionPatches(creationResponse));
+
+    }
+
+    /**
+     * Process a successfully parsed import file, creating any specified
+     * connections, creating and granting permissions to any specified users
+     * and user groups. If successful, the user will be shown a success message.
+     * If not, any errors will be displayed and any already-created entities
+     * will be rolled back.
+     *
+     * @param {ParseResult} parseResult
+     *     The result of parsing the user-supplied import file.
+     */
+    function handleParseSuccess(parseResult) {
+
+        $scope.parseResult = parseResult;
+
+        // If errors were encounted during file parsing, abort further
+        // processing - the user will have a chance to fix the errors and try
+        // again
+        if (parseResult.hasErrors)
+            return;
+
+        const dataSource = $routeParams.dataSource;
+
+        // First, attempt to create the connections
+        connectionService.patchConnections(dataSource, parseResult.patches)
+                .then(connectionResponse =>
+
+            // If connection creation is successful, create users and groups
+            createUsersAndGroups(parseResult).then(() =>
+
+                grantConnectionPermissions(parseResult, connectionResponse)
+                        .then(() => {
+
+                    $scope.processing = false;
+
+                    // Display a success message if everything worked
+                    guacNotification.showStatus({
+                        className  : 'success',
+                        title      : 'IMPORT.DIALOG_HEADER_SUCCESS',
+                        text       : {
+                            key: 'IMPORT.INFO_CONNECTIONS_IMPORTED_SUCCESS',
+                            variables: { NUMBER: parseResult.patches.length }
+                        },
+
+                        // Add a button to acknowledge and redirect to
+                        // the connection listing page
+                        actions    : [{
+                            name      : 'IMPORT.ACTION_ACKNOWLEDGE',
+                            callback  : () => {
+
+                                // Close the notification
+                                guacNotification.showStatus(false);
+
+                                // Redirect to connection list page
+                                $location.url('/settings/' + dataSource + '/connections');
+                            }
+                        }]
+                    });
+                }))
+
+            // If an error occurs while trying to users or groups, or while trying
+            // to assign permissions to users or groups, clean up the already-created
+            // connections, displaying an error to the user along with a blank slate
+            // so they can fix their problems and try again.
+            .catch(error => {
+                cleanUpConnections(connectionResponse);
+                handleError(error);
+            }))
+
+        // If an error occured when the call to create the connections was made,

Review Comment:
   occurred*



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] jmuehlner commented on pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "jmuehlner (via GitHub)" <gi...@apache.org>.
jmuehlner commented on PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#issuecomment-1499729083

   Updated the connection icon to something a bit more distinct. (thanks to @mike-jumper for this one)
   <img width="697" alt="image" src="https://user-images.githubusercontent.com/4633119/230508971-8a07dcf3-c5a4-4d79-8b3f-b6fb77d98345.png">
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] mike-jumper commented on a diff in pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "mike-jumper (via GitHub)" <gi...@apache.org>.
mike-jumper commented on code in PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#discussion_r1158829771


##########
guacamole-ext/src/main/java/org/apache/guacamole/net/auth/AtomicDirectoryOperation.java:
##########
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.guacamole.net.auth;
+
+import org.apache.guacamole.GuacamoleException;
+
+/**
+ * An operation that should be attempted atomically when passed to
+ * {@link Directory#tryAtomically}, if atomic operations are supported by
+ * the Directory.
+ */
+public interface AtomicDirectoryOperation<ObjectType extends Identifiable>  {
+
+    /**
+     * Attempt the operation atomically. If the Directory does not support
+     * atomic operations, the atomic flag will be set to false. If the atomic
+     * flag is set to true, the provided directory is guaranteed to perform
+     * the operations within this function atomically. Atomicity of the
+     * provided directory outside this function, or of the directory invoking

Review Comment:
   Never mind - I misread this. There's no typo here.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] jmuehlner commented on a diff in pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "jmuehlner (via GitHub)" <gi...@apache.org>.
jmuehlner commented on code in PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#discussion_r1158866149


##########
guacamole/src/main/frontend/src/app/import/templates/connectionImportFileHelp.html:
##########
@@ -0,0 +1,93 @@
+<div class="import help">
+
+    <div class="header">
+        <h2>{{'IMPORT.SECTION_HEADER_HELP_CONNECTION_IMPORT_FILE' | translate}}</h2>
+        <guac-user-menu></guac-user-menu>
+    </div>
+
+    <h2>{{'IMPORT.HELP_FILE_TYPE_HEADER' | translate}}</h2>
+    <p>{{'IMPORT.HELP_FILE_TYPE_DESCRIPTION' | translate}}</p>
+
+    <h2>{{'IMPORT.HELP_CSV_HEADER' | translate}}</h2>
+    <p>{{'IMPORT.HELP_CSV_DESCRIPTION' | translate}}</p>
+    <p>{{'IMPORT.HELP_CSV_MORE_DETAILS' | translate}}</p>
+    <pre>name,protocol,hostname,group,users,groups,guacd-encryption (attribute)
+conn1,vnc,conn1.web.com,ROOT,guac user 1;guac user 2,Connection 1 Users,none
+conn2,rdp,conn2.web.com,ROOT/Parent Group,guac user 1,,ssl
+conn3,ssh,conn3.web.com,ROOT/Parent Group/Child Group,guac user 2;guac user 3,,
+conn4,kubernetes,,,,,</pre>

Review Comment:
   Adding `\n`s into the translation value in the JSON _does_ work! I'll switch all these over.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] mike-jumper commented on pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "mike-jumper (via GitHub)" <gi...@apache.org>.
mike-jumper commented on PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#issuecomment-1468698099

   How is the "Row #" heading intended to be interpreted when importing from JSON or YAML?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] jmuehlner commented on a diff in pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "jmuehlner (via GitHub)" <gi...@apache.org>.
jmuehlner commented on code in PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#discussion_r1142486908


##########
guacamole/src/main/java/org/apache/guacamole/rest/jsonpatch/APIPatchOutcome.java:
##########
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.guacamole.rest.jsonpatch;
+
+import org.apache.guacamole.rest.jsonpatch.APIPatch.Operation;
+
+/**
+ * A successful outcome associated with a particular patch within a JSON Patch
+ * request. The outcome contains the operation requested by the original patch,
+ * the path from the original patch, and the identifier of the object corresponding
+ * to the value from the original patch.
+ *
+ * The purpose of this class is to present a relatively lightweight outcome for
+ * the user who submitted the Patch request. Rather than including the full
+ * contents of the value, only the identifier is included, allowing the user to
+ * determine the identifier of any newly-created objects as part of the request.
+ *
+ */
+public class APIPatchOutcome {
+
+    /**
+     * The requested operation for the patch corresponding to this outcome.
+     */
+    private final Operation op;
+
+    /**
+     * The identifier for the value in patch corresponding to this outcome.
+     * If the value in the patch was null, this identifier should also be null.
+     */
+    private String identifier;
+
+    /**
+     * The path for the patch corresponding to this outcome.
+     */
+    private final String path;
+
+    /**
+     * Create an outcome associated with a submitted patch, as part of a JSON
+     * patch API request.
+     *
+     * @param op
+     * @param identifier
+     * @param path

Review Comment:
   They sure are! Will fix.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] jmuehlner commented on a diff in pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "jmuehlner (via GitHub)" <gi...@apache.org>.
jmuehlner commented on code in PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#discussion_r1142487155


##########
guacamole/src/main/java/org/apache/guacamole/rest/directory/DirectoryResource.java:
##########
@@ -386,46 +417,210 @@ public Map<String, ExternalType> getObjects(
 
     /**
      * Applies the given object patches, updating the underlying directory
-     * accordingly. This operation currently only supports deletion of objects
-     * through the "remove" patch operation. The path of each patch operation is
-     * of the form "/ID" where ID is the identifier of the object being
-     * modified.
+     * accordingly. This operation supports addition and removal of objects
+     * through the "add" and "remove" patch operation. The path of each patch
+     * operation is of the form "/ID" where ID is the identifier of the object
+     * being modified. In the case of object creation, the identifier is
+     * ignored, as the identifier will be automatically provided. This operation
+     * is atomic.
      *
      * @param patches
      *     The patches to apply for this request.
      *
      * @throws GuacamoleException
-     *     If an error occurs while deleting the objects.
+     *     If an error occurs while adding, updating, or removing objects.
+     *
+     * @return
+     *     A response describing the outcome of each patch. Only the identifier
+     *     of each patched object will be included in the response, not the
+     *     full object.
      */
     @PATCH
-    public void patchObjects(List<APIPatch<String>> patches)
+    public APIPatchResponse patchObjects(List<APIPatch<ExternalType>> patches)
             throws GuacamoleException {
 
-        // Apply each operation specified within the patch
-        for (APIPatch<String> patch : patches) {
+        // An outcome for each patch included in the request. This list
+        // may include both success and failure responses, though the
+        // presense of any failure would indicated that the entire

Review Comment:
   Oops yes. Will fix.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] jmuehlner commented on a diff in pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "jmuehlner (via GitHub)" <gi...@apache.org>.
jmuehlner commented on code in PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#discussion_r1160017591


##########
guacamole/src/main/java/org/apache/guacamole/rest/jsonpatch/APIPatchError.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.guacamole.rest.jsonpatch;
+
+import org.apache.guacamole.rest.jsonpatch.APIPatch.Operation;
+
+/**
+ * A failure outcome associated with a particular patch within a JSON Patch
+ * request. This status indicates that a particular patch failed to apply,
+ * and includes the error describing the failure, along with the operation and
+ * path from the original patch, and the identifier of the object
+ * referenced by the original patch.
+ */
+public class APIPatchError extends APIPatchOutcome {
+
+    /**
+     * The error associated with the submitted patch.
+     */
+    private final String error;
+
+    /**
+     * Create a failure status associated with a submitted patch from a JSON
+     * patch API request.
+     *
+     * @param op
+     *     The operation requested by the failed patch.
+     *
+     * @param identifier
+     *     The identifier of the object associated with the failed patch. If
+     *     the patch failed to create a new object, this will be null.
+     *
+     * @param path
+     *     The patch from the failed patch.
+     *
+     * @param error
+     *     The error message associated with the failure that prevented the
+     *     patch from applying.
+     */
+    public APIPatchError(
+            Operation op, String identifier, String path, String error) {
+        super(op, identifier, path);
+        this.error = error;
+    }
+
+    /**
+     * Return the error associated with the patch failure.
+     *
+     * @return
+     *     The error associated with the patch failure.
+     */
+    public String getError() {
+        return error;
+    }

Review Comment:
   Yes good call I will do that.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] jmuehlner commented on a diff in pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "jmuehlner (via GitHub)" <gi...@apache.org>.
jmuehlner commented on code in PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#discussion_r1142489866


##########
guacamole/src/main/frontend/src/app/import/directives/connectionImportErrors.js:
##########
@@ -0,0 +1,234 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* global _ */

Review Comment:
   Definitely not needed per se - it builds and runs fine, but helpful yes. 😃 



##########
guacamole/src/main/frontend/src/app/import/directives/connectionImportErrors.js:
##########
@@ -0,0 +1,234 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* global _ */

Review Comment:
   Definitely not needed per se - it builds and runs fine without them, but helpful yes. 😃 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] jmuehlner commented on a diff in pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "jmuehlner (via GitHub)" <gi...@apache.org>.
jmuehlner commented on code in PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#discussion_r1147909614


##########
guacamole/src/main/frontend/src/app/import/templates/connectionImportFileHelp.html:
##########
@@ -0,0 +1,93 @@
+<div class="import help">
+
+    <div class="header">
+        <h2>{{'IMPORT.SECTION_HEADER_HELP_CONNECTION_IMPORT_FILE' | translate}}</h2>
+        <guac-user-menu></guac-user-menu>
+    </div>
+
+    <h2>{{'IMPORT.HELP_FILE_TYPE_HEADER' | translate}}</h2>
+    <p>{{'IMPORT.HELP_FILE_TYPE_DESCRIPTION' | translate}}</p>
+
+    <h2>{{'IMPORT.HELP_CSV_HEADER' | translate}}</h2>
+    <p>{{'IMPORT.HELP_CSV_DESCRIPTION' | translate}}</p>
+    <p>{{'IMPORT.HELP_CSV_MORE_DETAILS' | translate}}</p>
+    <pre>name,protocol,hostname,group,users,groups,guacd-encryption (attribute)
+conn1,vnc,conn1.web.com,ROOT,guac user 1;guac user 2,Connection 1 Users,none
+conn2,rdp,conn2.web.com,ROOT/Parent Group,guac user 1,,ssl
+conn3,ssh,conn3.web.com,ROOT/Parent Group/Child Group,guac user 2;guac user 3,,
+conn4,kubernetes,,,,,</pre>

Review Comment:
   Should it? I had assumed that this sort of example file content usually isn't. Plus doing all this formatting within the translation system seems like it'd be a pain - probably having to split this apart line by line.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] mike-jumper commented on a diff in pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "mike-jumper (via GitHub)" <gi...@apache.org>.
mike-jumper commented on code in PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#discussion_r1147775560


##########
guacamole/src/main/frontend/src/images/action-icons/guac-monitor-add-many.svg:
##########


Review Comment:
   What do you think of:
   
   ![Multiple monitors, overlapping](https://user-images.githubusercontent.com/4632905/227575314-4d30ad3b-cd0b-4fdf-9a47-959f71cd574b.svg)
   
   or:
   
   ![Multiple smaller monitors, overlapping](https://user-images.githubusercontent.com/4632905/227575411-ae8c60df-61f9-41e0-944e-a9c99ad4cb26.svg)
   
   ?
   
   (GitHub doesn't seem to provide a way to set the background color of a comment, paragraph, section, etc., so the above may be invisible...)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] mike-jumper commented on a diff in pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "mike-jumper (via GitHub)" <gi...@apache.org>.
mike-jumper commented on code in PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#discussion_r1158728924


##########
extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/base/JDBCDirectory.java:
##########
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.guacamole.auth.jdbc.base;
+
+import org.apache.guacamole.GuacamoleException;
+import org.apache.guacamole.net.auth.AtomicDirectoryOperation;
+import org.apache.guacamole.net.auth.Directory;
+import org.apache.guacamole.net.auth.Identifiable;
+import org.mybatis.guice.transactional.Transactional;
+
+/**
+ * An implementation of Directory that uses database transactions to guarantee
+ * atomicity for any operations supplied to tryAtomically().
+ */
+public abstract class JDBCDirectory<ObjectType extends Identifiable>
+        extends RestrictedObject implements Directory<ObjectType>  {
+
+    @Transactional
+    public void tryAtomically(AtomicDirectoryOperation<ObjectType> operation)

Review Comment:
   If this is inherited from `Directory` it should be annotated with `@Overrides`.



##########
guacamole-ext/src/main/java/org/apache/guacamole/net/auth/AtomicDirectoryOperation.java:
##########
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.guacamole.net.auth;
+
+import org.apache.guacamole.GuacamoleException;
+
+/**
+ * An operation that should be attempted atomically when passed to
+ * {@link Directory#tryAtomically}, if atomic operations are supported by
+ * the Directory.
+ */
+public interface AtomicDirectoryOperation<ObjectType extends Identifiable>  {
+
+    /**
+     * Attempt the operation atomically. If the Directory does not support
+     * atomic operations, the atomic flag will be set to false. If the atomic
+     * flag is set to true, the provided directory is guaranteed to perform
+     * the operations within this function atomically. Atomicity of the
+     * provided directory outside this function, or of the directory invoking
+     * this function are not guaranteed.
+     *
+     * NOTE: If atomicity is required for this operation, a GuacamoleException
+     * may be thrown by this function before any changes are made, ensuring the
+     * operation will only ever be performed atomically.

Review Comment:
   I think you may need an explicit `<p>` for JavaDoc to know that you intend a second paragraph.



##########
guacamole/src/main/java/org/apache/guacamole/rest/jsonpatch/APIPatchFailureException.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.guacamole.rest.jsonpatch;
+
+import java.util.List;
+
+import org.apache.guacamole.GuacamoleClientException;
+
+/**
+ * An exception describing a failure to apply the patches from a JSON Patch
+ * request. A list of outcomes is included, one for each patch in the request.
+ */
+public class APIPatchFailureException extends GuacamoleClientException {

Review Comment:
   Recommend instead extending `TranslatableGuacamoleClientException` so that failures may be translated.



##########
guacamole-ext/src/main/java/org/apache/guacamole/net/auth/AtomicDirectoryOperation.java:
##########
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.guacamole.net.auth;
+
+import org.apache.guacamole.GuacamoleException;
+
+/**
+ * An operation that should be attempted atomically when passed to
+ * {@link Directory#tryAtomically}, if atomic operations are supported by
+ * the Directory.
+ */
+public interface AtomicDirectoryOperation<ObjectType extends Identifiable>  {
+
+    /**
+     * Attempt the operation atomically. If the Directory does not support
+     * atomic operations, the atomic flag will be set to false. If the atomic
+     * flag is set to true, the provided directory is guaranteed to perform
+     * the operations within this function atomically. Atomicity of the
+     * provided directory outside this function, or of the directory invoking

Review Comment:
   if*



##########
guacamole/src/main/frontend/src/app/rest/services/userService.js:
##########
@@ -235,6 +235,39 @@ angular.module('rest').factory('userService', ['$injector',
         });
 
     };
+
+    /**
+     * Makes a request to the REST API to apply a supplied list of user patches,
+     * returning a promise that can be used for processing the results of the
+     * call.
+     *
+     * This operation is atomic - if any errors are encountered during the
+     * connection patching process, the entire request will fail, and no
+     * changes will be persisted.
+     *
+     * @param {DirectoryPatch.<User>[]} patches
+     *     An array of patches to apply.
+     *
+     * @returns {Promise}
+     *     A promise for the HTTP call which will succeed if and only if the
+     *     patch operation is successful.
+     */
+    service.patchUsers = function patchUsers(dataSource, patches) {
+
+        // Make the PATCH request
+        return authenticationService.request({
+            method  : 'PATCH',
+            url     : 'api/session/data/' + encodeURIComponent(dataSource) + '/users',
+            data    : patches
+        })
+
+        // Clear the cache
+        .then(function usersPatched(patchResponse){
+            cacheService.users.removeAll();
+            return patchResponse;
+        });
+
+    }

Review Comment:
   Missing semicolon here.



##########
guacamole/src/main/frontend/src/app/rest/types/DirectoryPatchOutcome.js:
##########
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Service which defines the DirectoryPatchOutcome class.
+ */
+angular.module('rest').factory('DirectoryPatchOutcome', [
+        function defineDirectoryPatchOutcome() {
+            
+    /**
+     * An object returned by a PATCH request to a directory REST API, 
+     * representing the outcome associated with a particular patch in the
+     * request. This object can indicate either a successful or unsuccessful 
+     * response. The error field is only meaningful for unsuccessful patches.
+     * @constructor
+     * 
+     * @param {DirectoryPatchOutcome|Object} [template={}]
+     *     The object whose properties should be copied within the new
+     *     DirectoryPatchOutcome.
+     */
+    const DirectoryPatchOutcome = function DirectoryPatchOutcome(template) {
+
+        // Use empty object by default
+        template = template || {};
+
+        /**
+         * The operation to apply to the objects indicated by the path. Valid
+         * operation values are defined within DirectoryPatch.Operation.
+         *
+         * @type {String}
+         */
+        this.op = template.op;
+
+        /**
+         * The path of the object operated on by the corresponding patch in the
+         * request.
+         *
+         * @type {String}
+         */
+        this.path = template.path;
+
+        /**
+         * The identifier of the object operated on by the corresponding patch
+         * in the request. If the object was newly created and the PATCH request
+         * did not fail, this will be the identifier of the newly created object.
+         *
+         * @type {String}
+         */
+        this.identifier = template.identifier;
+
+        /**
+         * The error message associated with the failure, if the patch failed to
+         * apply.
+         *
+         * @type {String}
+         */
+        this.error = template.error;

Review Comment:
   I suspect this should be a `TranslatableMessage`.



##########
guacamole/src/main/frontend/src/app/rest/services/connectionService.js:
##########
@@ -154,6 +156,45 @@ angular.module('rest').factory('connectionService', ['$injector',
         }
 
     };
+
+    /**
+     * Makes a request to the REST API to apply a supplied list of connection
+     * patches, returning a promise that can be used for processing the results 
+     * of the call. 
+     * 
+     * This operation is atomic - if any errors are encountered during the 
+     * connection patching process, the entire request will fail, and no 
+     * changes will be persisted.
+     *
+     * @param {DirectoryPatch.<Connection>[]} patches 
+     *     An array of patches to apply.
+     *
+     * @returns {Promise}
+     *     A promise for the HTTP call which will succeed if and only if the
+     *     patch operation is successful.
+     */
+    service.patchConnections = function patchConnections(dataSource, patches) {

Review Comment:
   Please document the `dataSource` parameter.



##########
guacamole/src/main/frontend/src/app/rest/services/connectionService.js:
##########
@@ -154,6 +156,45 @@ angular.module('rest').factory('connectionService', ['$injector',
         }
 
     };
+
+    /**
+     * Makes a request to the REST API to apply a supplied list of connection
+     * patches, returning a promise that can be used for processing the results 
+     * of the call. 
+     * 
+     * This operation is atomic - if any errors are encountered during the 
+     * connection patching process, the entire request will fail, and no 
+     * changes will be persisted.
+     *
+     * @param {DirectoryPatch.<Connection>[]} patches 
+     *     An array of patches to apply.
+     *
+     * @returns {Promise}
+     *     A promise for the HTTP call which will succeed if and only if the
+     *     patch operation is successful.
+     */
+    service.patchConnections = function patchConnections(dataSource, patches) {

Review Comment:
   Please document the `dataSource` parameter.



##########
guacamole/src/main/frontend/src/app/rest/types/DirectoryPatch.js:
##########
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Service which defines the DirectoryPatch class.
+ */
+angular.module('rest').factory('DirectoryPatch', [function defineDirectoryPatch() {
+            
+    /**
+     * The object consumed by REST API calls when representing changes to an
+     * arbitrary set of directory-based objects.
+     * @constructor
+     * 
+     * @template DirectoryObject
+     *     The directory-based object type that this DirectoryPatch will 
+     *     operate on.
+     * 
+     * @param {DirectoryObject|Object} [template={}]
+     *     The object whose properties should be copied within the new
+     *     DirectoryPatch.
+     */
+    var DirectoryPatch = function DirectoryPatch(template) {
+
+        // Use empty object by default
+        template = template || {};
+
+        /**
+         * The operation to apply to the objects indicated by the path. Valid
+         * operation values are defined within DirectoryPatch.Operation.
+         *
+         * @type {String}
+         */
+        this.op = template.op;
+
+        /**
+         * The path of the objects to modify. For creation of new objects, this
+         * should be "/". Otherwise, it should be "/{identifier}", specifying
+         * the identifier of the existing object being modified.
+         *
+         * @type {String}
+         * @default '/'
+         */
+        this.path = template.path || '/';
+
+        /**
+         * The object being added, or undefined if deleting.
+         *
+         * @type {DirectoryObject}
+         */
+        this.value = template.value;
+
+    };
+
+    /**
+     * All valid patch operations for directory-based objects.
+     */
+    DirectoryPatch.Operation = {
+
+        /**
+         * Adds the specified object to the relation.
+         */
+        ADD : "add",
+
+        /**
+         * Removes the specified object from the relation.
+         */
+        REMOVE : "remove"

Review Comment:
   Please use `'` for JS strings: https://guacamole.apache.org/guac-style/#naming



##########
guacamole/src/main/java/org/apache/guacamole/rest/jsonpatch/APIPatchError.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.guacamole.rest.jsonpatch;
+
+import org.apache.guacamole.rest.jsonpatch.APIPatch.Operation;
+
+/**
+ * A failure outcome associated with a particular patch within a JSON Patch
+ * request. This status indicates that a particular patch failed to apply,
+ * and includes the error describing the failure, along with the operation and
+ * path from the original patch, and the identifier of the object
+ * referenced by the original patch.
+ */
+public class APIPatchError extends APIPatchOutcome {
+
+    /**
+     * The error associated with the submitted patch.
+     */
+    private final String error;
+
+    /**
+     * Create a failure status associated with a submitted patch from a JSON
+     * patch API request.
+     *
+     * @param op
+     *     The operation requested by the failed patch.
+     *
+     * @param identifier
+     *     The identifier of the object associated with the failed patch. If
+     *     the patch failed to create a new object, this will be null.
+     *
+     * @param path
+     *     The patch from the failed patch.
+     *
+     * @param error
+     *     The error message associated with the failure that prevented the
+     *     patch from applying.
+     */
+    public APIPatchError(
+            Operation op, String identifier, String path, String error) {
+        super(op, identifier, path);
+        this.error = error;
+    }
+
+    /**
+     * Return the error associated with the patch failure.
+     *
+     * @return
+     *     The error associated with the patch failure.
+     */
+    public String getError() {
+        return error;
+    }

Review Comment:
   Should this instead be a `TranslatableMessage`?



##########
guacamole/src/main/frontend/src/app/rest/services/userGroupService.js:
##########
@@ -190,6 +190,39 @@ angular.module('rest').factory('userGroupService', ['$injector',
 
     };
 
+    /**
+     * Makes a request to the REST API to apply a supplied list of user group
+     * patches, returning a promise that can be used for processing the results
+     * of the call.
+     *
+     * This operation is atomic - if any errors are encountered during the
+     * connection patching process, the entire request will fail, and no
+     * changes will be persisted.
+     *
+     * @param {DirectoryPatch.<UserGroup>[]} patches
+     *     An array of patches to apply.
+     *
+     * @returns {Promise}
+     *     A promise for the HTTP call which will succeed if and only if the
+     *     patch operation is successful.
+     */
+    service.patchUserGroups = function patchUserGroups(dataSource, patches) {
+
+        // Make the PATCH request
+        return authenticationService.request({
+            method  : 'PATCH',
+            url     : 'api/session/data/' + encodeURIComponent(dataSource) + '/userGroups',
+            data    : patches
+        })
+
+        // Clear the cache
+        .then(function userGroupsPatched(patchResponse){
+            cacheService.users.removeAll();
+            return patchResponse;
+        });
+
+    }

Review Comment:
   Missing semicolon here.



##########
guacamole/src/main/frontend/src/app/rest/services/userGroupService.js:
##########
@@ -190,6 +190,39 @@ angular.module('rest').factory('userGroupService', ['$injector',
 
     };
 
+    /**
+     * Makes a request to the REST API to apply a supplied list of user group
+     * patches, returning a promise that can be used for processing the results
+     * of the call.
+     *
+     * This operation is atomic - if any errors are encountered during the
+     * connection patching process, the entire request will fail, and no
+     * changes will be persisted.
+     *
+     * @param {DirectoryPatch.<UserGroup>[]} patches
+     *     An array of patches to apply.
+     *
+     * @returns {Promise}
+     *     A promise for the HTTP call which will succeed if and only if the
+     *     patch operation is successful.
+     */
+    service.patchUserGroups = function patchUserGroups(dataSource, patches) {

Review Comment:
   Please document the `dataSource` parameter.



##########
guacamole/src/main/frontend/src/app/rest/services/userService.js:
##########
@@ -235,6 +235,39 @@ angular.module('rest').factory('userService', ['$injector',
         });
 
     };
+
+    /**
+     * Makes a request to the REST API to apply a supplied list of user patches,
+     * returning a promise that can be used for processing the results of the
+     * call.
+     *
+     * This operation is atomic - if any errors are encountered during the
+     * connection patching process, the entire request will fail, and no
+     * changes will be persisted.
+     *
+     * @param {DirectoryPatch.<User>[]} patches
+     *     An array of patches to apply.
+     *
+     * @returns {Promise}
+     *     A promise for the HTTP call which will succeed if and only if the
+     *     patch operation is successful.
+     */
+    service.patchUsers = function patchUsers(dataSource, patches) {

Review Comment:
   Please document the `dataSource` parameter.



##########
guacamole/src/main/frontend/src/app/rest/services/connectionService.js:
##########
@@ -154,6 +156,45 @@ angular.module('rest').factory('connectionService', ['$injector',
         }
 
     };
+
+    /**
+     * Makes a request to the REST API to apply a supplied list of connection
+     * patches, returning a promise that can be used for processing the results 
+     * of the call. 
+     * 
+     * This operation is atomic - if any errors are encountered during the 
+     * connection patching process, the entire request will fail, and no 
+     * changes will be persisted.
+     *
+     * @param {DirectoryPatch.<Connection>[]} patches 
+     *     An array of patches to apply.
+     *
+     * @returns {Promise}
+     *     A promise for the HTTP call which will succeed if and only if the
+     *     patch operation is successful.
+     */
+    service.patchConnections = function patchConnections(dataSource, patches) {
+
+        // Make the PATCH request
+        return authenticationService.request({
+            method  : 'PATCH',
+            url     : 'api/session/data/' + encodeURIComponent(dataSource) + '/connections',
+            data    : patches
+        })
+
+        // Clear the cache
+        .then(function connectionsPatched(patchResponse){
+            cacheService.connections.removeAll();
+
+            // Clear users cache to force reload of permissions for any
+            // newly created or replaced connections
+            cacheService.users.removeAll();
+
+            return patchResponse;
+            
+        });
+
+    }

Review Comment:
   Same here - missing semicolon.



##########
guacamole/src/main/frontend/src/app/import/templates/connectionImportFileHelp.html:
##########
@@ -0,0 +1,93 @@
+<div class="import help">
+
+    <div class="header">
+        <h2>{{'IMPORT.SECTION_HEADER_HELP_CONNECTION_IMPORT_FILE' | translate}}</h2>
+        <guac-user-menu></guac-user-menu>
+    </div>
+
+    <h2>{{'IMPORT.HELP_FILE_TYPE_HEADER' | translate}}</h2>
+    <p>{{'IMPORT.HELP_FILE_TYPE_DESCRIPTION' | translate}}</p>
+
+    <h2>{{'IMPORT.HELP_CSV_HEADER' | translate}}</h2>
+    <p>{{'IMPORT.HELP_CSV_DESCRIPTION' | translate}}</p>
+    <p>{{'IMPORT.HELP_CSV_MORE_DETAILS' | translate}}</p>
+    <pre>name,protocol,hostname,group,users,groups,guacd-encryption (attribute)
+conn1,vnc,conn1.web.com,ROOT,guac user 1;guac user 2,Connection 1 Users,none
+conn2,rdp,conn2.web.com,ROOT/Parent Group,guac user 1,,ssl
+conn3,ssh,conn3.web.com,ROOT/Parent Group/Child Group,guac user 2;guac user 3,,
+conn4,kubernetes,,,,,</pre>

Review Comment:
   Since the example CSV itself contains English that's meant to be human-readable, I think it should be (if possible). Does angular-translate strip newlines from the translated text? If not, I'd think we could have something like:
   
       "IMPORT" : {
           "INFO_EXAMPLE_CSV" : "a,b,c\n1,2,3\n4,5,6"
       },
   
   and:
   
       <pre>{{ 'IMPORT.INFO_EXAMPLE_CSV' | translate }}</pre>



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] jmuehlner commented on a diff in pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "jmuehlner (via GitHub)" <gi...@apache.org>.
jmuehlner commented on code in PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#discussion_r1158802338


##########
guacamole-ext/src/main/java/org/apache/guacamole/net/auth/AtomicDirectoryOperation.java:
##########
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.guacamole.net.auth;
+
+import org.apache.guacamole.GuacamoleException;
+
+/**
+ * An operation that should be attempted atomically when passed to
+ * {@link Directory#tryAtomically}, if atomic operations are supported by
+ * the Directory.
+ */
+public interface AtomicDirectoryOperation<ObjectType extends Identifiable>  {
+
+    /**
+     * Attempt the operation atomically. If the Directory does not support
+     * atomic operations, the atomic flag will be set to false. If the atomic
+     * flag is set to true, the provided directory is guaranteed to perform
+     * the operations within this function atomically. Atomicity of the
+     * provided directory outside this function, or of the directory invoking

Review Comment:
   if?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] jmuehlner commented on pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "jmuehlner (via GitHub)" <gi...@apache.org>.
jmuehlner commented on PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#issuecomment-1498343924

   I'm seeing this error on CI (though not locally)
   ```
   Error:  Failed to execute goal com.github.searls:jasmine-maven-plugin:3.0-beta-02:test (default) on project guacamole-common-js: The jasmine-maven-plugin encountered an exception:: session not created: This version of ChromeDriver only supports Chrome version 112
   Error:  Current browser version is 111.0.5563.110 with binary path /usr/bin/chromium
   Error:  Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
   Error:  System info: host: 'a24ad6ba7e99', ip: '172.17.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.0-1034-azure', java.version: '1.8.0_342'
   Error:  Driver info: driver.version: ChromeDriver
   ```
   
   Hopefully it goes away by itself soon...


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] jmuehlner commented on pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "jmuehlner (via GitHub)" <gi...@apache.org>.
jmuehlner commented on PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#issuecomment-1470538335

   Ok, I think this is now cleaned up enough to be ready for review. Looking forward to hearing people's thoughts, nitpicks, etc.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] necouchman commented on pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "necouchman (via GitHub)" <gi...@apache.org>.
necouchman commented on PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#issuecomment-1507288610

   Sorry, didn't get around to looking at it before the merge, but I think most of my remaining concerns were around style/organization of the translation file, and those seem to have been cleaned up. Looks great, @jmuehlner !


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] mike-jumper commented on a diff in pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "mike-jumper (via GitHub)" <gi...@apache.org>.
mike-jumper commented on code in PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#discussion_r1140426543


##########
doc/licenses/csv-6.2.5/dep-coordinates.txt:
##########
@@ -0,0 +1,2 @@
+csv:6.2.5
+csv-parse:5.3.3

Review Comment:
   csv-parse v5.3.3 is part of csv v6.2.5?



##########
doc/licenses/core-util-is-1.0.3/README:
##########
@@ -0,0 +1,7 @@
+core-util-is (https://github.com/isaacs/core-util-is)
+---------------------------------------------
+
+    Version: 1.0.3
+    From: 'isaacs' (https://github.com/isaacs)

Review Comment:
   According to the license, this should be "Node.js contributors".



##########
doc/licenses/ieee754-1.2.1/README:
##########
@@ -0,0 +1,7 @@
+ieee754 (https://github.com/feross/ieee754)
+---------------------------------------------
+
+    Version: 1.2.1
+    From: 'Feross Aboukhadijeh' (https://github.com/feross)

Review Comment:
   According to the license, copyright on this is from "Fair Oaks Labs, Inc.".



##########
doc/licenses/readable-stream-2.3.7/README:
##########
@@ -0,0 +1,8 @@
+readable-stream (https://github.com/nodejs/readable-stream)
+---------------------------------------------
+
+    Version: 2.3.7
+    From: 'Node.js' (https://github.com/nodejs)

Review Comment:
   According to the license, this should be "Node.js contributors, Joyent, Inc., and other Node contributors".



##########
doc/licenses/stream-browserify-2.0.2/README:
##########
@@ -0,0 +1,8 @@
+stream-browserify (https://github.com/browserify/stream-browserify)
+---------------------------------------------
+
+    Version: 2.0.2
+    From: 'browserify' (https://github.com/browserify)

Review Comment:
   From the license, this should be "James Halliday".



##########
doc/licenses/setimmediate-1.0.5/README:
##########
@@ -0,0 +1,8 @@
+setImmediate.js (https://github.com/YuzuJS/setImmediate)
+---------------------------------------------
+
+    Version: 1.0.5
+    From: 'Yuzu (by Barnes & Noble Education)' (https://github.com/YuzuJS)
+    License(s):
+        MIT (bundled/setimmediate-1.0.5/LICENSE)

Review Comment:
   The bundled file is actually `LICENSE.txt`.



##########
doc/licenses/timers-browserify-2.0.12/README:
##########
@@ -0,0 +1,8 @@
+timers-browserify (https://github.com/browserify/timers-browserify)
+---------------------------------------------
+
+    Version: 2.0.12
+    From: 'browserify' (https://github.com/browserify)

Review Comment:
   According to the license, this should be "J. Ryan Stinnett".



##########
doc/licenses/csv-6.2.5/README:
##########
@@ -0,0 +1,7 @@
+node-csv (https://github.com/adaltas/node-csv)
+---------------------------------------------
+
+    Version: 6.2.5
+    From: 'adaltas' (https://github.com/adaltas)

Review Comment:
   This should be "Adaltas", apparently the name of a company.



##########
doc/licenses/timers-browserify-2.0.12/README:
##########
@@ -0,0 +1,8 @@
+timers-browserify (https://github.com/browserify/timers-browserify)
+---------------------------------------------
+
+    Version: 2.0.12
+    From: 'browserify' (https://github.com/browserify)
+    License(s):
+        MIT (bundled/timers-browserify-2.0.12/LICENSE)

Review Comment:
   The bundled file is actually `LICENSE.md`.



##########
doc/licenses/events-3.3.0/README:
##########
@@ -0,0 +1,7 @@
+events (https://github.com/browserify/events)
+---------------------------------------------
+
+    Version: 3.3.0
+    From: 'browserify' (https://github.com/browserify)

Review Comment:
   According to the license, this should be "Joyent, Inc. and other Node contributors."



##########
doc/licenses/process-nextick-args-2.0.1/README:
##########
@@ -0,0 +1,8 @@
+process-nextick-args (https://github.com/calvinmetcalf/process-nextick-args)
+---------------------------------------------
+
+    Version: 2.0.1
+    From: 'Calvin Metcalf' (https://github.com/calvinmetcalf)
+    License(s):
+        MIT (bundled/process-nextick-args-2.0.1/LICENSE)

Review Comment:
   The bundled file is actually `license.md`.



##########
doc/licenses/string_decoder-1.1.1/README:
##########
@@ -0,0 +1,8 @@
+string_decoder (https://github.com/nodejs/string_decoder)
+---------------------------------------------
+
+    Version: 1.1.1
+    From: 'Node.js' (https://github.com/nodejs)

Review Comment:
   According to the license, this should be "Node.js contributors, Joyent, Inc., and other Node contributors".



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] necouchman commented on pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "necouchman (via GitHub)" <gi...@apache.org>.
necouchman commented on PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#issuecomment-1470598722

   I've always got some good nits to pick.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] necouchman commented on a diff in pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "necouchman (via GitHub)" <gi...@apache.org>.
necouchman commented on code in PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#discussion_r1157095270


##########
guacamole/src/main/java/org/apache/guacamole/rest/directory/DirectoryResource.java:
##########
@@ -386,46 +417,210 @@ public Map<String, ExternalType> getObjects(
 
     /**
      * Applies the given object patches, updating the underlying directory
-     * accordingly. This operation currently only supports deletion of objects
-     * through the "remove" patch operation. The path of each patch operation is
-     * of the form "/ID" where ID is the identifier of the object being
-     * modified.
+     * accordingly. This operation supports addition and removal of objects
+     * through the "add" and "remove" patch operation. The path of each patch
+     * operation is of the form "/ID" where ID is the identifier of the object
+     * being modified. In the case of object creation, the identifier is
+     * ignored, as the identifier will be automatically provided. This operation
+     * is atomic.
      *
      * @param patches
      *     The patches to apply for this request.
      *
      * @throws GuacamoleException
-     *     If an error occurs while deleting the objects.
+     *     If an error occurs while adding, updating, or removing objects.
+     *
+     * @return
+     *     A response describing the outcome of each patch. Only the identifier
+     *     of each patched object will be included in the response, not the
+     *     full object.
      */
     @PATCH
-    public void patchObjects(List<APIPatch<String>> patches)
+    public APIPatchResponse patchObjects(List<APIPatch<ExternalType>> patches)
             throws GuacamoleException {
 
-        // Apply each operation specified within the patch
-        for (APIPatch<String> patch : patches) {
+        // An outcome for each patch included in the request. This list
+        // may include both success and failure responses, though the
+        // presense of any failure would indicated that the entire
+        // request has failed and no changes have been made.
+        List<APIPatchOutcome> patchOutcomes = new ArrayList<>();
 
-            // Only remove is supported
-            if (patch.getOp() != APIPatch.Operation.remove)
-                throw new GuacamoleUnsupportedException("Only the \"remove\" "
-                        + "operation is supported.");
+        // Perform all requested operations atomically
+        directory.tryAtomically(new AtomicDirectoryOperation<InternalType>() {
 
-            // Retrieve and validate path
-            String path = patch.getPath();
-            if (!path.startsWith("/"))
-                throw new GuacamoleClientException("Patch paths must start with \"/\".");
+            @Override
+            public void executeOperation(boolean atomic, Directory<InternalType> directory)
+                    throws GuacamoleException {
+
+                // If the underlying directory implentation does not support
+                // atomic operations, abort the patch operation. This REST
+                // endpoint requires that operations be performed atomically.
+                if (!atomic)
+                    throw new GuacamoleUnsupportedException(
+                            "Atomic operations are not supported. " +
+                            "The patch cannot be executed.");
+
+                // Keep a list of all objects that have been successfully
+                // added or removed
+                Collection<InternalType> addedObjects = new ArrayList<>();
+                Collection<String> removedIdentifiers = new ArrayList<>();
+
+                // A list of all responses associated with the successful
+                // creation of new objects
+                List<APIPatchOutcome> creationSuccesses = new ArrayList<>();
+
+                // True if any operation in the patch failed. Any failure will
+                // fail the request, though won't result in immediate stoppage
+                // since more errors may yet be uncovered.
+                boolean failed = false;
+
+                // Apply each operation specified within the patch
+                for (APIPatch<ExternalType> patch : patches) {
+
+                    // Retrieve and validate path
+                    String path = patch.getPath();
+                    if (!path.startsWith("/"))
+                        throw new GuacamoleClientException("Patch paths must start with \"/\".");
+
+                    if(patch.getOp() == APIPatch.Operation.add) {

Review Comment:
   No strong preference, just curious.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] jmuehlner commented on a diff in pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "jmuehlner (via GitHub)" <gi...@apache.org>.
jmuehlner commented on code in PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#discussion_r1159089459


##########
guacamole/src/main/java/org/apache/guacamole/rest/directory/DirectoryResource.java:
##########
@@ -386,46 +417,211 @@ public Map<String, ExternalType> getObjects(
 
     /**
      * Applies the given object patches, updating the underlying directory
-     * accordingly. This operation currently only supports deletion of objects
-     * through the "remove" patch operation. The path of each patch operation is
-     * of the form "/ID" where ID is the identifier of the object being
-     * modified.
+     * accordingly. This operation supports addition and removal of objects
+     * through the "add" and "remove" patch operation. The path of each patch
+     * operation is of the form "/ID" where ID is the identifier of the object
+     * being modified. In the case of object creation, the identifier is
+     * ignored, as the identifier will be automatically provided. This operation
+     * is atomic.
      *
      * @param patches
      *     The patches to apply for this request.
      *
      * @throws GuacamoleException
-     *     If an error occurs while deleting the objects.
+     *     If an error occurs while adding, updating, or removing objects.
+     *
+     * @return
+     *     A response describing the outcome of each patch. Only the identifier
+     *     of each patched object will be included in the response, not the
+     *     full object.
      */
     @PATCH
-    public void patchObjects(List<APIPatch<String>> patches)
+    public APIPatchResponse patchObjects(List<APIPatch<ExternalType>> patches)
             throws GuacamoleException {
 
-        // Apply each operation specified within the patch
-        for (APIPatch<String> patch : patches) {
+        // An outcome for each patch included in the request. This list
+        // may include both success and failure responses, though the
+        // presence of any failure would indicated that the entire
+        // request has failed and no changes have been made.
+        List<APIPatchOutcome> patchOutcomes = new ArrayList<>();
 
-            // Only remove is supported
-            if (patch.getOp() != APIPatch.Operation.remove)
-                throw new GuacamoleUnsupportedException("Only the \"remove\" "
-                        + "operation is supported.");
+        // Perform all requested operations atomically
+        directory.tryAtomically(new AtomicDirectoryOperation<InternalType>() {
 
-            // Retrieve and validate path
-            String path = patch.getPath();
-            if (!path.startsWith("/"))
-                throw new GuacamoleClientException("Patch paths must start with \"/\".");
+            @Override
+            public void executeOperation(boolean atomic, Directory<InternalType> directory)
+                    throws GuacamoleException {
+
+                // If the underlying directory implentation does not support
+                // atomic operations, abort the patch operation. This REST
+                // endpoint requires that operations be performed atomically.
+                if (!atomic)
+                    throw new GuacamoleUnsupportedException(
+                            "Atomic operations are not supported. " +
+                            "The patch cannot be executed.");

Review Comment:
   How does this look?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] jmuehlner commented on a diff in pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "jmuehlner (via GitHub)" <gi...@apache.org>.
jmuehlner commented on code in PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#discussion_r1158814257


##########
guacamole/src/main/frontend/src/app/rest/types/DirectoryPatch.js:
##########
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Service which defines the DirectoryPatch class.
+ */
+angular.module('rest').factory('DirectoryPatch', [function defineDirectoryPatch() {
+            
+    /**
+     * The object consumed by REST API calls when representing changes to an
+     * arbitrary set of directory-based objects.
+     * @constructor
+     * 
+     * @template DirectoryObject
+     *     The directory-based object type that this DirectoryPatch will 
+     *     operate on.
+     * 
+     * @param {DirectoryObject|Object} [template={}]
+     *     The object whose properties should be copied within the new
+     *     DirectoryPatch.
+     */
+    var DirectoryPatch = function DirectoryPatch(template) {
+
+        // Use empty object by default
+        template = template || {};
+
+        /**
+         * The operation to apply to the objects indicated by the path. Valid
+         * operation values are defined within DirectoryPatch.Operation.
+         *
+         * @type {String}
+         */
+        this.op = template.op;
+
+        /**
+         * The path of the objects to modify. For creation of new objects, this
+         * should be "/". Otherwise, it should be "/{identifier}", specifying
+         * the identifier of the existing object being modified.
+         *
+         * @type {String}
+         * @default '/'
+         */
+        this.path = template.path || '/';
+
+        /**
+         * The object being added, or undefined if deleting.
+         *
+         * @type {DirectoryObject}
+         */
+        this.value = template.value;
+
+    };
+
+    /**
+     * All valid patch operations for directory-based objects.
+     */
+    DirectoryPatch.Operation = {
+
+        /**
+         * Adds the specified object to the relation.
+         */
+        ADD : "add",
+
+        /**
+         * Removes the specified object from the relation.
+         */
+        REMOVE : "remove"

Review Comment:
   Oops!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] jmuehlner commented on a diff in pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "jmuehlner (via GitHub)" <gi...@apache.org>.
jmuehlner commented on code in PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#discussion_r1158844093


##########
guacamole/src/main/frontend/src/app/import/types/ParseError.js:
##########
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Service which defines the ParseError class.
+ */
+angular.module('import').factory('ParseError', [function defineParseError() {
+
+    /**
+     * An error representing a parsing failure when attempting to convert
+     * user-provided data into a list of Connection objects.
+     *
+     * @constructor
+     * @param {ParseError|Object} [template={}]
+     *     The object whose properties should be copied within the new
+     *     ParseError.
+     */
+    const ParseError = function ParseError(template) {
+
+        // Use empty object by default
+        template = template || {};
+
+        /**
+         * A human-readable message describing the error that occurred.
+         *
+         * @type String
+         */
+        this.message = template.message;
+
+        /**
+         * The key associated with the translation string that used when
+         * displaying this message.
+         *
+         * @type String
+         */
+        this.key = template.key;
+
+        /**
+         * The object which should be passed through to the translation service
+         * for the sake of variable substitution. Each property of the provided
+         * object will be substituted for the variable of the same name within
+         * the translation string.
+         *
+         * @type Object
+         */
+        this.variables = template.variables;

Review Comment:
   Hmm, I considered it, but `TranslatableMessage` seemed very REST-specific, and I wasn't sure if it was a good idea to use it here. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] jmuehlner commented on a diff in pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "jmuehlner (via GitHub)" <gi...@apache.org>.
jmuehlner commented on code in PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#discussion_r1147917617


##########
guacamole/src/main/frontend/src/images/action-icons/guac-monitor-add-many.svg:
##########


Review Comment:
   I do like the look of those better than the current icon, but unfortunately they don't render well in actual use on the button. The first one looks pretty similar to the current button, with a bit more hair on top.
   <img width="320" alt="image" src="https://user-images.githubusercontent.com/4633119/227606540-588cf08e-884a-4ee5-8e26-64708145fe5d.png">
   
   And the bottom one just looks like a blur to me.
   <img width="323" alt="image" src="https://user-images.githubusercontent.com/4633119/227605833-2a20ef6c-48b9-42d3-a48b-d5ded360cd4a.png">
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] jmuehlner commented on a diff in pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "jmuehlner (via GitHub)" <gi...@apache.org>.
jmuehlner commented on code in PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#discussion_r1147920287


##########
guacamole/src/main/frontend/src/translations/en.json:
##########
@@ -183,6 +185,61 @@
 
     },
 
+    "IMPORT": {
+
+	"ACTION_ACKNOWLEDGE": "@:APP.ACTION_ACKNOWLEDGE",
+	"ACTION_BROWSE_LINK": "Browse for File",
+	"ACTION_CANCEL": "@:APP.ACTION_CANCEL",
+	"ACTION_CLEAR": "@:APP.ACTION_CLEAR",
+	"ACTION_CONNECTION_FILE_HELP_LINK": "View Format Tips",
+        "ACTION_IMPORT": "@:APP.ACTION_IMPORT",
+	"ACTION_IMPORT_CONNECTIONS": "Import Connections",

Review Comment:
   Oh no! 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] jmuehlner commented on a diff in pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "jmuehlner (via GitHub)" <gi...@apache.org>.
jmuehlner commented on code in PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#discussion_r1159102823


##########
guacamole/src/main/frontend/src/app/import/controllers/importConnectionsController.js:
##########
@@ -0,0 +1,760 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* global _ */
+
+/**
+ * The controller for the connection import page.
+ */
+angular.module('import').controller('importConnectionsController', ['$scope', '$injector',
+        function importConnectionsController($scope, $injector) {
+
+    // The file types supported for connection import
+    const LEGAL_FILE_TYPES = ['csv', 'json', 'yaml'];
+
+    // Required services
+    const $document              = $injector.get('$document');
+    const $location              = $injector.get('$location');
+    const $q                     = $injector.get('$q');
+    const $routeParams           = $injector.get('$routeParams');
+    const $timeout               = $injector.get('$timeout');
+    const connectionParseService = $injector.get('connectionParseService');
+    const connectionService      = $injector.get('connectionService');
+    const guacNotification       = $injector.get('guacNotification');
+    const permissionService      = $injector.get('permissionService');
+    const userService            = $injector.get('userService');
+    const userGroupService       = $injector.get('userGroupService');
+
+    // Required types
+    const DirectoryPatch      = $injector.get('DirectoryPatch');
+    const Error               = $injector.get('Error');
+    const ParseError          = $injector.get('ParseError');
+    const PermissionSet       = $injector.get('PermissionSet');
+    const User                = $injector.get('User');
+    const UserGroup           = $injector.get('UserGroup');
+
+    /**
+     * The result of parsing the current upload, if successful.
+     *
+     * @type {ParseResult}
+     */
+    $scope.parseResult = null;
+
+    /**
+     * The failure associated with the current attempt to create connections
+     * through the API, if any.
+     *
+     * @type {Error}
+     */
+    $scope.patchFailure = null;;
+
+    /**
+     * True if the file is fully uploaded and ready to be processed, or false
+     * otherwise.
+     *
+     * @type {Boolean}
+     */
+    $scope.dataReady = false;
+
+    /**
+     * True if the file upload has been aborted mid-upload, or false otherwise.
+     */
+    $scope.aborted = false;
+
+    /**
+     * True if fully-uploaded data is being processed, or false otherwise.
+     */
+    $scope.processing = false;
+
+    /**
+     * The MIME type of the uploaded file, if any.
+     *
+     * @type {String}
+     */
+    $scope.mimeType = null;
+
+    /**
+     * The raw string contents of the uploaded file, if any.
+     *
+     * @type {String}
+     */
+    $scope.fileData = null;
+
+    /**
+     * The file reader currently being used to upload the file, if any. If
+     * null, no file upload is currently in progress.
+     *
+     * @type {FileReader}
+     */
+    $scope.fileReader = null;
+
+    /**
+     * Clear all file upload state.
+     */
+    function resetUploadState() {
+
+        $scope.aborted = false;
+        $scope.dataReady = false;
+        $scope.processing = false;
+        $scope.fileData = null;
+        $scope.mimeType = null;
+        $scope.fileReader = null;
+        $scope.parseResult = null;
+        $scope.patchFailure = null;
+        $scope.fileName = null;
+
+    }
+
+    // Indicate that data is currently being loaded / processed if the the file
+    // has been provided but not yet fully uploaded, or if the the file is
+    // fully loaded and is currently being processed.
+    $scope.isLoading = () => (
+            ($scope.fileName && !$scope.dataReady && !$scope.patchFailure)
+            || $scope.processing);
+
+    /**
+     * Create all users and user groups mentioned in the import file that don't
+     * already exist in the current data source. If either creation fails, any
+     * already-created entities will be cleaned up, and the returned promise
+     * will be rejected.
+     *
+     * @param {ParseResult} parseResult
+     *     The result of parsing the user-supplied import file.
+     *
+     * @return {Promise.<Object>}
+     *     A promise resolving to an object containing the results of the calls
+     *     to create the users and groups.
+     */
+    function createUsersAndGroups(parseResult) {
+
+        const dataSource = $routeParams.dataSource;
+
+        return $q.all({
+            existingUsers : userService.getUsers(dataSource),
+            existingGroups : userGroupService.getUserGroups(dataSource)
+        }).then(({existingUsers, existingGroups}) => {
+
+            const userPatches = Object.keys(parseResult.users)
+
+                // Filter out any existing users
+                .filter(identifier => !existingUsers[identifier])
+
+                // A patch to create each new user
+                .map(username => new DirectoryPatch({
+                    op: 'add',
+                    path: '/',
+                    value: new User({ username })
+                }));
+
+            const groupPatches = Object.keys(parseResult.groups)
+
+                // Filter out any existing groups
+                .filter(identifier => !existingGroups[identifier])
+
+                // A patch to create each new user group
+                .map(identifier => new DirectoryPatch({
+                    op: 'add',
+                    path: '/',
+                    value: new UserGroup({ identifier })
+                }));
+
+            // First, create any required users and groups, automatically cleaning
+            // up any created already-created entities if a call fails.
+            // NOTE: Generally we'd want to do these calls in parallel, using
+            // `$q.all()`. However, `$q.all()` rejects immediately if any of the
+            // wrapped promises reject, so the users may not be ready for cleanup
+            // at the time that the group promise rejects, or vice versa. While
+            // it would be possible to juggle promises and still do these calls
+            // in parallel, the code gets pretty complex, so for readability and
+            // simplicity, they are executed serially. The performance cost of
+            // doing so should be low.
+            return userService.patchUsers(dataSource, userPatches).then(userResponse => {
+
+                // Then, if that succeeds, create any required groups
+                return userGroupService.patchUserGroups(dataSource, groupPatches).then(
+
+                    // If user group creation succeeds, resolve the returned promise
+                    userGroupResponse => ({ userResponse, userGroupResponse}))
+
+                // If the group creation request fails, clean up any created users
+                .catch(groupFailure => {
+                    cleanUpUsers(userResponse);
+                    return groupFailure;
+                });
+
+            });
+
+        });
+
+    }
+
+    /**
+     * Grant read permissions for each user and group in the supplied parse
+     * result to each connection in their connection list. Note that there will
+     * be a seperate request for each user and group.
+     *
+     * @param {ParseResult} parseResult
+     *     The result of successfully parsing a user-supplied import file.
+     *
+     * @param {Object} response
+     *     The response from the PATCH API request.
+     *
+     * @returns {Promise.<Object>}
+     *     A promise that will resolve with the result of every permission
+     *     granting request.
+     */
+    function grantConnectionPermissions(parseResult, response) {
+
+        const dataSource = $routeParams.dataSource;
+
+        // All connection grant requests, one per user/group
+        const userRequests = {};
+        const groupRequests = {};
+
+        // Create a PermissionSet granting access to all connections at
+        // the provided indices within the provided parse result
+        const createPermissionSet = indices =>
+            new PermissionSet({ connectionPermissions: indices.reduce(
+                    (permissions, index) => {
+                const connectionId = response.patches[index].identifier;
+                permissions[connectionId] = [
+                        PermissionSet.ObjectPermissionType.READ];
+                return permissions;
+            }, {}) });
+
+        // Now that we've created all the users, grant access to each
+        _.forEach(parseResult.users, (connectionIndices, identifier) =>
+
+            // Grant the permissions - note the group flag is `false`
+            userRequests[identifier] = permissionService.patchPermissions(
+                dataSource, identifier,
+
+                // Create the permissions to these connections for this user
+                createPermissionSet(connectionIndices),
+
+                // Do not remove any permissions
+                new PermissionSet(),
+
+                // This call is not for a group
+                false));
+
+        // Now that we've created all the groups, grant access to each
+        _.forEach(parseResult.groups, (connectionIndices, identifier) =>
+
+            // Grant the permissions - note the group flag is `true`
+            groupRequests[identifier] = permissionService.patchPermissions(
+                dataSource, identifier,
+
+                // Create the permissions to these connections for this user
+                createPermissionSet(connectionIndices),
+
+                // Do not remove any permissions
+                new PermissionSet(),
+
+                // This call is for a group
+                true));
+
+        // Return the result from all the permission granting calls
+        return $q.all({ ...userRequests, ...groupRequests });
+    }
+
+    // Given a PATCH API response, create an array of patches to delete every
+    // entity created in the original request that generated this response
+    const createDeletionPatches = creationResponse =>
+        creationResponse.patches.map(patch =>
+
+            // Add one deletion patch per original creation patch
+            new DirectoryPatch({
+                op: 'remove',
+                path: '/' + patch.identifier
+            }));
+
+    /**
+     * Given a successful response to a connection PATCH request, make another
+     * request to delete every created connection in the provided request, i.e.
+     * clean up every connection that was created.
+     *
+     * @param {DirectoryPatchResponse} creationResponse
+     *     The response to the connection PATCH request.
+     *
+     * @returns {DirectoryPatchResponse}
+     *     The response to the PATCH deletion request.
+     */
+    function cleanUpConnections(creationResponse) {
+
+        return connectionService.patchConnections(
+            $routeParams.dataSource, createDeletionPatches(creationResponse));
+
+    }
+
+    /**
+     * Given a successful response to a user PATCH request, make another
+     * request to delete every created user in the provided request.
+     *
+     * @param {DirectoryPatchResponse} creationResponse
+     *     The response to the user PATCH request.
+     *
+     * @returns {DirectoryPatchResponse}
+     *     The response to the PATCH deletion request.
+     */
+    function cleanUpUsers(creationResponse) {
+
+        return userService.patchUsers(
+            $routeParams.dataSource, createDeletionPatches(creationResponse));
+
+    }
+
+    /**
+     * Process a successfully parsed import file, creating any specified
+     * connections, creating and granting permissions to any specified users
+     * and user groups. If successful, the user will be shown a success message.
+     * If not, any errors will be displayed and any already-created entities
+     * will be rolled back.
+     *
+     * @param {ParseResult} parseResult
+     *     The result of parsing the user-supplied import file.
+     */
+    function handleParseSuccess(parseResult) {
+
+        $scope.parseResult = parseResult;
+
+        // If errors were encounted during file parsing, abort further
+        // processing - the user will have a chance to fix the errors and try
+        // again
+        if (parseResult.hasErrors)
+            return;
+
+        const dataSource = $routeParams.dataSource;
+
+        // First, attempt to create the connections
+        connectionService.patchConnections(dataSource, parseResult.patches)
+                .then(connectionResponse =>
+
+            // If connection creation is successful, create users and groups
+            createUsersAndGroups(parseResult).then(() =>
+
+                grantConnectionPermissions(parseResult, connectionResponse)
+                        .then(() => {
+
+                    $scope.processing = false;
+
+                    // Display a success message if everything worked
+                    guacNotification.showStatus({
+                        className  : 'success',
+                        title      : 'IMPORT.DIALOG_HEADER_SUCCESS',
+                        text       : {
+                            key: 'IMPORT.INFO_CONNECTIONS_IMPORTED_SUCCESS',
+                            variables: { NUMBER: parseResult.patches.length }
+                        },
+
+                        // Add a button to acknowledge and redirect to
+                        // the connection listing page
+                        actions    : [{
+                            name      : 'IMPORT.ACTION_ACKNOWLEDGE',
+                            callback  : () => {
+
+                                // Close the notification
+                                guacNotification.showStatus(false);
+
+                                // Redirect to connection list page
+                                $location.url('/settings/' + dataSource + '/connections');
+                            }
+                        }]
+                    });
+                }))
+
+            // If an error occurs while trying to users or groups, or while trying
+            // to assign permissions to users or groups, clean up the already-created
+            // connections, displaying an error to the user along with a blank slate
+            // so they can fix their problems and try again.
+            .catch(error => {
+                cleanUpConnections(connectionResponse);
+                handleError(error);
+            }))
+
+        // If an error occured when the call to create the connections was made,
+        // skip any further processing - the user will have a chance to fix the
+        // problems and try again
+        .catch(patchFailure => {
+            $scope.processing = false;
+            $scope.patchFailure = patchFailure;
+        });
+    }
+
+    /**
+     * Display the provided error to the user in a dismissable dialog.
+     *
+     * @argument {ParseError|Error} error
+     *     The error to display.
+     */
+    const handleError = error => {
+
+        // Any error indicates that processing of the file has failed, so clear
+        // all upload state to allow for a fresh retry
+        resetUploadState();
+
+        let text;
+
+        // If it's a import file parsing error
+        if (error instanceof ParseError)
+            text = {
+
+                // Use the translation key if available
+                key: error.key || error.message,
+                variables: error.variables
+            };
+
+        // If it's a generic REST error
+        else if (error instanceof Error)
+            text = error.translatableMessage;
+
+        // If it's an unknown type, just use the message directly
+        else
+            text = { key: error };
+
+        guacNotification.showStatus({
+            className  : 'error',
+            title      : 'IMPORT.DIALOG_HEADER_ERROR',
+            text,
+
+            // Add a button to hide the error
+            actions    : [{
+                name      : 'IMPORT.ACTION_ACKNOWLEDGE',
+                callback  : () => guacNotification.showStatus(false)
+            }]
+        })
+
+    };
+
+    /**
+     * Process the uploaded import file, importing the connections, granting
+     * connection permissions, or displaying errors to the user if there are
+     * problems with the provided file.
+     *
+     * @param {String} mimeType
+     *     The MIME type of the uploaded data file.
+     *
+     * @param {String} data
+     *     The raw string contents of the import file.
+     */
+    function processData(mimeType, data) {
+
+        // Data processing has begun
+        $scope.processing = true;
+
+        // The function that will process all the raw data and return a list of
+        // patches to be submitted to the API
+        let processDataCallback;
+
+        // Choose the appropriate parse function based on the mimetype
+        if (mimeType.endsWith("json"))
+            processDataCallback = connectionParseService.parseJSON;
+
+        else if (mimeType.endsWith("csv"))
+            processDataCallback = connectionParseService.parseCSV;
+
+        else if (mimeType.endsWith("yaml"))
+            processDataCallback = connectionParseService.parseYAML;

Review Comment:
   Sure, seems fair.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] jmuehlner commented on a diff in pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "jmuehlner (via GitHub)" <gi...@apache.org>.
jmuehlner commented on code in PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#discussion_r1159160094


##########
guacamole/src/main/java/org/apache/guacamole/rest/jsonpatch/APIPatchFailureException.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.guacamole.rest.jsonpatch;
+
+import java.util.List;
+
+import org.apache.guacamole.GuacamoleClientException;
+
+/**
+ * An exception describing a failure to apply the patches from a JSON Patch
+ * request. A list of outcomes is included, one for each patch in the request.
+ */
+public class APIPatchFailureException extends GuacamoleClientException {

Review Comment:
   The `message` here is never displayed to the user, so I'm not sure how much this matters? 
   
   The only things that seem like they really need translation are the the errors in the `patches` list.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] mike-jumper commented on a diff in pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "mike-jumper (via GitHub)" <gi...@apache.org>.
mike-jumper commented on code in PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#discussion_r1160016729


##########
guacamole/src/main/java/org/apache/guacamole/rest/jsonpatch/APIPatchError.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.guacamole.rest.jsonpatch;
+
+import org.apache.guacamole.rest.jsonpatch.APIPatch.Operation;
+
+/**
+ * A failure outcome associated with a particular patch within a JSON Patch
+ * request. This status indicates that a particular patch failed to apply,
+ * and includes the error describing the failure, along with the operation and
+ * path from the original patch, and the identifier of the object
+ * referenced by the original patch.
+ */
+public class APIPatchError extends APIPatchOutcome {
+
+    /**
+     * The error associated with the submitted patch.
+     */
+    private final String error;
+
+    /**
+     * Create a failure status associated with a submitted patch from a JSON
+     * patch API request.
+     *
+     * @param op
+     *     The operation requested by the failed patch.
+     *
+     * @param identifier
+     *     The identifier of the object associated with the failed patch. If
+     *     the patch failed to create a new object, this will be null.
+     *
+     * @param path
+     *     The patch from the failed patch.
+     *
+     * @param error
+     *     The error message associated with the failure that prevented the
+     *     patch from applying.
+     */
+    public APIPatchError(
+            Operation op, String identifier, String path, String error) {
+        super(op, identifier, path);
+        this.error = error;
+    }
+
+    /**
+     * Return the error associated with the patch failure.
+     *
+     * @return
+     *     The error associated with the patch failure.
+     */
+    public String getError() {
+        return error;
+    }

Review Comment:
   Can also leverage `APP.TEXT_UNTRANSLATED` to turn any untranslated string into a translated string:
   
   https://github.com/apache/guacamole-client/blob/165bd413c0ab9c55b0c0e3614fcb829ef5f8ca95/guacamole/src/main/java/org/apache/guacamole/rest/APIError.java#L41-L52
   
   https://github.com/apache/guacamole-client/blob/165bd413c0ab9c55b0c0e3614fcb829ef5f8ca95/guacamole/src/main/java/org/apache/guacamole/rest/APIError.java#L205-L208



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] mike-jumper commented on pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "mike-jumper (via GitHub)" <gi...@apache.org>.
mike-jumper commented on PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#issuecomment-1505612387

   Looks good to me! Any further comments @necouchman?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] jmuehlner commented on a diff in pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "jmuehlner (via GitHub)" <gi...@apache.org>.
jmuehlner commented on code in PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#discussion_r1140528202


##########
doc/licenses/csv-6.2.5/dep-coordinates.txt:
##########
@@ -0,0 +1,2 @@
+csv:6.2.5
+csv-parse:5.3.3

Review Comment:
   Yep



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] jmuehlner commented on pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "jmuehlner (via GitHub)" <gi...@apache.org>.
jmuehlner commented on PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#issuecomment-1468700648

   > How is the "Row #" heading intended to be interpreted when importing from JSON or YAML?
   
   It's the index (+1) within the array of connection objects in the file. If you have a different suggestion for the header I'm down to change it.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] mike-jumper commented on a diff in pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "mike-jumper (via GitHub)" <gi...@apache.org>.
mike-jumper commented on code in PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#discussion_r1143682127


##########
guacamole/src/main/frontend/src/translations/en.json:
##########
@@ -183,6 +185,61 @@
 
     },
 
+    "IMPORT": {
+
+	"ACTION_ACKNOWLEDGE": "@:APP.ACTION_ACKNOWLEDGE",
+	"ACTION_BROWSE_LINK": "Browse for File",
+	"ACTION_CANCEL": "@:APP.ACTION_CANCEL",
+	"ACTION_CLEAR": "@:APP.ACTION_CLEAR",
+	"ACTION_CONNECTION_FILE_HELP_LINK": "View Format Tips",
+        "ACTION_IMPORT": "@:APP.ACTION_IMPORT",
+	"ACTION_IMPORT_CONNECTIONS": "Import Connections",

Review Comment:
   Looks like the indentation in this `"IMPORT" : { ... }` section got tab-ified.



##########
guacamole/src/main/frontend/src/app/import/templates/connectionImportFileHelp.html:
##########
@@ -0,0 +1,93 @@
+<div class="import help">
+
+    <div class="header">
+        <h2>{{'IMPORT.SECTION_HEADER_HELP_CONNECTION_IMPORT_FILE' | translate}}</h2>
+        <guac-user-menu></guac-user-menu>
+    </div>
+
+    <h2>{{'IMPORT.HELP_FILE_TYPE_HEADER' | translate}}</h2>
+    <p>{{'IMPORT.HELP_FILE_TYPE_DESCRIPTION' | translate}}</p>
+
+    <h2>{{'IMPORT.HELP_CSV_HEADER' | translate}}</h2>
+    <p>{{'IMPORT.HELP_CSV_DESCRIPTION' | translate}}</p>
+    <p>{{'IMPORT.HELP_CSV_MORE_DETAILS' | translate}}</p>
+    <pre>name,protocol,hostname,group,users,groups,guacd-encryption (attribute)
+conn1,vnc,conn1.web.com,ROOT,guac user 1;guac user 2,Connection 1 Users,none
+conn2,rdp,conn2.web.com,ROOT/Parent Group,guac user 1,,ssl
+conn3,ssh,conn3.web.com,ROOT/Parent Group/Child Group,guac user 2;guac user 3,,
+conn4,kubernetes,,,,,</pre>

Review Comment:
   Should this also be translated?



##########
guacamole/src/main/frontend/src/translations/en.json:
##########
@@ -183,6 +185,61 @@
 
     },
 
+    "IMPORT": {
+
+	"ACTION_ACKNOWLEDGE": "@:APP.ACTION_ACKNOWLEDGE",
+	"ACTION_BROWSE_LINK": "Browse for File",
+	"ACTION_CANCEL": "@:APP.ACTION_CANCEL",
+	"ACTION_CLEAR": "@:APP.ACTION_CLEAR",
+	"ACTION_CONNECTION_FILE_HELP_LINK": "View Format Tips",
+        "ACTION_IMPORT": "@:APP.ACTION_IMPORT",
+	"ACTION_IMPORT_CONNECTIONS": "Import Connections",
+
+	"DIALOG_HEADER_ERROR": "@:APP.DIALOG_HEADER_ERROR",
+	"DIALOG_HEADER_SUCCESS": "Success",
+
+	"ERROR_AMBIGUOUS_CSV_HEADER": "Ambiguous CSV Header \"{HEADER}\" could be either a connection attribute or parameter",
+	"ERROR_AMBIGUOUS_PARENT_GROUP": "Both group and parentIdentifier may be not specified at the same time",
+	"ERROR_ARRAY_REQUIRED": "The provided file must contain a list of connections",
+	"ERROR_DUPLICATE_CSV_HEADER": "Duplicate CSV Header: {HEADER}",
+	"ERROR_EMPTY_FILE": "The provided file is empty",
+	"ERROR_FILE_SINGLE_ONLY": "Please upload only a single file at a time",
+	"ERROR_INVALID_CSV_HEADER": "Invalid CSV Header \"{HEADER}\" is neither an attribute or parameter",
+	"ERROR_INVALID_FILE_TYPE": "Unsupported file type: \"{TYPE}\"",
+	"ERROR_INVALID_GROUP": "No group matching \"{GROUP}\" found",
+	"ERROR_INVALID_USER_GROUP_IDENTIFIERS": "User Groups not found: {IDENTIFIER_LIST}",
+	"ERROR_INVALID_USER_IDENTIFIERS": "Users not found: {IDENTIFIER_LIST}",
+	"ERROR_NO_FILE_SUPPLIED": "Please select a file to import",
+	"ERROR_REQUIRED_NAME": "No connection name found in the provided file",
+	"ERROR_REQUIRED_PROTOCOL": "No connection protocol found in the provided file",
+
+	"FIELD_PLACEHOLDER_FILTER": "@:APP.FIELD_PLACEHOLDER_FILTER",
+
+	"HELP_CSV_DESCRIPTION": "A connection import CSV file has one connection record per row. Each column will specify a connection field. At minimum the connection name and protocol must be specified.",
+	"HELP_CSV_HEADER": "CSV Format",

Review Comment:
   The `HELP_` prefix is used for descriptive text that assists the user in doing something. If this is just a header, I suspect this should be `SECTION_HEADER_`.



##########
guacamole/src/main/frontend/src/translations/en.json:
##########
@@ -183,6 +185,61 @@
 
     },
 
+    "IMPORT": {
+
+	"ACTION_ACKNOWLEDGE": "@:APP.ACTION_ACKNOWLEDGE",
+	"ACTION_BROWSE_LINK": "Browse for File",
+	"ACTION_CANCEL": "@:APP.ACTION_CANCEL",
+	"ACTION_CLEAR": "@:APP.ACTION_CLEAR",
+	"ACTION_CONNECTION_FILE_HELP_LINK": "View Format Tips",

Review Comment:
   This should be named semantically based on the action that the user will be taking, not based on how the relevant control is rendered (a link) or where it's located (file help). My recommendation would be `ACTION_VIEW_FORMAT_HELP` or similar.



##########
guacamole/src/main/frontend/src/translations/en.json:
##########
@@ -183,6 +185,61 @@
 
     },
 
+    "IMPORT": {
+
+	"ACTION_ACKNOWLEDGE": "@:APP.ACTION_ACKNOWLEDGE",
+	"ACTION_BROWSE_LINK": "Browse for File",

Review Comment:
   This should be `ACTION_BROWSE`, not `ACTION_BROWSE_LINK` (the user will be browsing for the file, not browse-linking for it).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] jmuehlner commented on pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "jmuehlner (via GitHub)" <gi...@apache.org>.
jmuehlner commented on PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#issuecomment-1477040992

   > 
   
   Ok, I think these should all be resolved now...


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [guacamole-client] jmuehlner commented on a diff in pull request #809: GUACAMOLE-926: Batch Connection Import

Posted by "jmuehlner (via GitHub)" <gi...@apache.org>.
jmuehlner commented on code in PR #809:
URL: https://github.com/apache/guacamole-client/pull/809#discussion_r1142494902


##########
guacamole/src/main/frontend/src/translations/en.json:
##########
@@ -5,7 +5,7 @@
     "APP" : {
 
         "NAME"    : "Apache Guacamole",
-        "VERSION" : "${project.version}",
+        "VERSION" : "1.5.0",

Review Comment:
   Err, no. Not sure how that happened. Will fix.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@guacamole.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org