mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUACAMOLE-926: Merge support for importing connections via CSV/JSON/YAML.
This commit is contained in:
@@ -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.
|
||||
*
|
||||
* <p>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.
|
||||
*
|
||||
* @param atomic
|
||||
* True if the provided directory is guaranteed to perform the operation
|
||||
* atomically within the context of this function.
|
||||
*
|
||||
* @param directory
|
||||
* A directory that will perform the operation atomically if the atomic
|
||||
* flag is set to true. If the flag is false, the directory may still
|
||||
* be used, though atomicity is not guaranteed.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If an issue occurs during the operation.
|
||||
*/
|
||||
void executeOperation(boolean atomic, Directory<ObjectType> directory)
|
||||
throws GuacamoleException;
|
||||
}
|
@@ -90,4 +90,10 @@ public class DelegatingDirectory<ObjectType extends Identifiable>
|
||||
directory.remove(identifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tryAtomically(AtomicDirectoryOperation<ObjectType> operation)
|
||||
throws GuacamoleException {
|
||||
directory.tryAtomically(operation);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -215,8 +215,29 @@ public interface Directory<ObjectType extends Identifiable> {
|
||||
* @param identifier The identifier of the object to remove.
|
||||
*
|
||||
* @throws GuacamoleException If an error occurs while removing the object,
|
||||
* or if removing object is not allowed.
|
||||
* or if removing the object is not allowed.
|
||||
*/
|
||||
void remove(String identifier) throws GuacamoleException;
|
||||
|
||||
/**
|
||||
* Attempt to perform the provided operation atomically if possible. If the
|
||||
* operation can be performed atomically, the atomic flag will be set to
|
||||
* true, and the directory passed to the provided operation callback will
|
||||
* peform directory operations atomically within the operation callback.
|
||||
*
|
||||
* @param operation
|
||||
* The directory operation that should be performed atomically.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If an error occurs during execution of the provided operation.
|
||||
*/
|
||||
default void tryAtomically(AtomicDirectoryOperation<ObjectType> operation)
|
||||
throws GuacamoleException {
|
||||
|
||||
// By default, perform the operation non-atomically. If atomic operation
|
||||
// is supported by an implementation, it must be implemented there.
|
||||
operation.executeOperation(false, this);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user