guacamole-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmuehl...@apache.org
Subject [2/3] incubator-guacamole-client git commit: GUACAMOLE-5: All REST resources MUST be non-generic. Type parameters of generic classes will otherwise be handled as Object by Jersey due to type erasure, resulting in class cast exceptions due to JSON being d
Date Thu, 14 Jul 2016 21:46:21 GMT
GUACAMOLE-5: All REST resources MUST be non-generic. Type parameters of generic classes will
otherwise be handled as Object by Jersey due to type erasure, resulting in class cast exceptions
due to JSON being deserialized as a Map instead of the intended type.

Project: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/commit/cdd71411
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/cdd71411
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/cdd71411

Branch: refs/heads/master
Commit: cdd71411fb8f8e40109ca51f3136145ccd42136a
Parents: bd8c37c
Author: Michael Jumper <mjumper@apache.org>
Authored: Thu Jul 14 14:37:33 2016 -0700
Committer: Michael Jumper <mjumper@apache.org>
Committed: Thu Jul 14 14:37:33 2016 -0700

----------------------------------------------------------------------
 .../ActiveConnectionDirectoryResource.java      | 72 ++++++++++++++++++++
 .../ActiveConnectionModule.java                 |  5 ++
 .../connection/ConnectionDirectoryResource.java | 71 +++++++++++++++++++
 .../rest/connection/ConnectionModule.java       |  5 ++
 .../rest/directory/DirectoryObjectResource.java |  8 +--
 .../rest/directory/DirectoryResource.java       |  8 +--
 6 files changed, 157 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/cdd71411/guacamole/src/main/java/org/apache/guacamole/rest/activeconnection/ActiveConnectionDirectoryResource.java
----------------------------------------------------------------------
diff --git a/guacamole/src/main/java/org/apache/guacamole/rest/activeconnection/ActiveConnectionDirectoryResource.java
b/guacamole/src/main/java/org/apache/guacamole/rest/activeconnection/ActiveConnectionDirectoryResource.java
new file mode 100644
index 0000000..a19b5dc
--- /dev/null
+++ b/guacamole/src/main/java/org/apache/guacamole/rest/activeconnection/ActiveConnectionDirectoryResource.java
@@ -0,0 +1,72 @@
+/*
+ * 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.activeconnection;
+
+import com.google.inject.assistedinject.Assisted;
+import com.google.inject.assistedinject.AssistedInject;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import org.apache.guacamole.net.auth.ActiveConnection;
+import org.apache.guacamole.net.auth.Directory;
+import org.apache.guacamole.net.auth.UserContext;
+import org.apache.guacamole.rest.directory.DirectoryObjectResourceFactory;
+import org.apache.guacamole.rest.directory.DirectoryObjectTranslator;
+import org.apache.guacamole.rest.directory.DirectoryResource;
+
+/**
+ * A REST resource which abstracts the operations available on a Directory of
+ * ActiveConnections.
+ *
+ * @author Michael Jumper
+ */
+@Produces(MediaType.APPLICATION_JSON)
+@Consumes(MediaType.APPLICATION_JSON)
+public class ActiveConnectionDirectoryResource
+        extends DirectoryResource<ActiveConnection, APIActiveConnection> {
+
+    /**
+     * Creates a new ActiveConnectionDirectoryResource which exposes the
+     * operations and subresources available for the given ActiveConnection
+     * Directory.
+     *
+     * @param userContext
+     *     The UserContext associated with the given Directory.
+     *
+     * @param directory
+     *     The Directory being exposed.
+     *
+     * @param translator
+     *     A DirectoryObjectTranslator implementation which handles
+     *     ActiveConnections.
+     *
+     * @param resourceFactory
+     *     A factory which can be used to create instances of resources
+     *     representing ActiveConnections.
+     */
+    @AssistedInject
+    public ActiveConnectionDirectoryResource(@Assisted UserContext userContext,
+            @Assisted Directory<ActiveConnection> directory,
+            DirectoryObjectTranslator<ActiveConnection, APIActiveConnection> translator,
+            DirectoryObjectResourceFactory<ActiveConnection, APIActiveConnection> resourceFactory)
{
+        super(userContext, directory, translator, resourceFactory);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/cdd71411/guacamole/src/main/java/org/apache/guacamole/rest/activeconnection/ActiveConnectionModule.java
----------------------------------------------------------------------
diff --git a/guacamole/src/main/java/org/apache/guacamole/rest/activeconnection/ActiveConnectionModule.java
b/guacamole/src/main/java/org/apache/guacamole/rest/activeconnection/ActiveConnectionModule.java
index efecdde..c5418c2 100644
--- a/guacamole/src/main/java/org/apache/guacamole/rest/activeconnection/ActiveConnectionModule.java
+++ b/guacamole/src/main/java/org/apache/guacamole/rest/activeconnection/ActiveConnectionModule.java
@@ -27,6 +27,7 @@ import com.google.inject.assistedinject.FactoryModuleBuilder;
 import org.apache.guacamole.net.auth.ActiveConnection;
 import org.apache.guacamole.rest.directory.DirectoryObjectResource;
 import org.apache.guacamole.rest.directory.DirectoryObjectTranslator;
+import org.apache.guacamole.rest.directory.DirectoryResource;
 
 /**
  * Guice Module which configures injections required for handling
@@ -41,6 +42,10 @@ public class ActiveConnectionModule extends AbstractModule {
 
         // Create the required DirectoryResourceFactory implementation
         install(new FactoryModuleBuilder()
+                .implement(
+                    new TypeLiteral<DirectoryResource<ActiveConnection, APIActiveConnection>>()
{},
+                    ActiveConnectionDirectoryResource.class
+                )
                 .build(new TypeLiteral<DirectoryResourceFactory<ActiveConnection, APIActiveConnection>>()
{}));
 
         // Create the required DirectoryObjectResourceFactory implementation

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/cdd71411/guacamole/src/main/java/org/apache/guacamole/rest/connection/ConnectionDirectoryResource.java
----------------------------------------------------------------------
diff --git a/guacamole/src/main/java/org/apache/guacamole/rest/connection/ConnectionDirectoryResource.java
b/guacamole/src/main/java/org/apache/guacamole/rest/connection/ConnectionDirectoryResource.java
new file mode 100644
index 0000000..63bc879
--- /dev/null
+++ b/guacamole/src/main/java/org/apache/guacamole/rest/connection/ConnectionDirectoryResource.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.connection;
+
+import com.google.inject.assistedinject.Assisted;
+import com.google.inject.assistedinject.AssistedInject;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import org.apache.guacamole.net.auth.Connection;
+import org.apache.guacamole.net.auth.Directory;
+import org.apache.guacamole.net.auth.UserContext;
+import org.apache.guacamole.rest.directory.DirectoryObjectResourceFactory;
+import org.apache.guacamole.rest.directory.DirectoryObjectTranslator;
+import org.apache.guacamole.rest.directory.DirectoryResource;
+
+/**
+ * A REST resource which abstracts the operations available on a Directory of
+ * Connections.
+ *
+ * @author Michael Jumper
+ */
+@Produces(MediaType.APPLICATION_JSON)
+@Consumes(MediaType.APPLICATION_JSON)
+public class ConnectionDirectoryResource
+        extends DirectoryResource<Connection, APIConnection> {
+
+    /**
+     * Creates a new ConnectionDirectoryResource which exposes the operations
+     * and subresources available for the given Connection Directory.
+     *
+     * @param userContext
+     *     The UserContext associated with the given Directory.
+     *
+     * @param directory
+     *     The Directory being exposed.
+     *
+     * @param translator
+     *     A DirectoryObjectTranslator implementation which handles
+     *     Connections.
+     *
+     * @param resourceFactory
+     *     A factory which can be used to create instances of resources
+     *     representing Connections.
+     */
+    @AssistedInject
+    public ConnectionDirectoryResource(@Assisted UserContext userContext,
+            @Assisted Directory<Connection> directory,
+            DirectoryObjectTranslator<Connection, APIConnection> translator,
+            DirectoryObjectResourceFactory<Connection, APIConnection> resourceFactory)
{
+        super(userContext, directory, translator, resourceFactory);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/cdd71411/guacamole/src/main/java/org/apache/guacamole/rest/connection/ConnectionModule.java
----------------------------------------------------------------------
diff --git a/guacamole/src/main/java/org/apache/guacamole/rest/connection/ConnectionModule.java
b/guacamole/src/main/java/org/apache/guacamole/rest/connection/ConnectionModule.java
index 9f71671..228e53c 100644
--- a/guacamole/src/main/java/org/apache/guacamole/rest/connection/ConnectionModule.java
+++ b/guacamole/src/main/java/org/apache/guacamole/rest/connection/ConnectionModule.java
@@ -27,6 +27,7 @@ import com.google.inject.TypeLiteral;
 import com.google.inject.assistedinject.FactoryModuleBuilder;
 import org.apache.guacamole.net.auth.Connection;
 import org.apache.guacamole.rest.directory.DirectoryObjectTranslator;
+import org.apache.guacamole.rest.directory.DirectoryResource;
 
 /**
  * Guice Module which configures injections required for handling Connection
@@ -41,6 +42,10 @@ public class ConnectionModule extends AbstractModule {
 
         // Create the required DirectoryResourceFactory implementation
         install(new FactoryModuleBuilder()
+                .implement(
+                    new TypeLiteral<DirectoryResource<Connection, APIConnection>>()
{},
+                    ConnectionDirectoryResource.class
+                )
                 .build(new TypeLiteral<DirectoryResourceFactory<Connection, APIConnection>>()
{}));
 
         // Create the required DirectoryObjectResourceFactory implementation

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/cdd71411/guacamole/src/main/java/org/apache/guacamole/rest/directory/DirectoryObjectResource.java
----------------------------------------------------------------------
diff --git a/guacamole/src/main/java/org/apache/guacamole/rest/directory/DirectoryObjectResource.java
b/guacamole/src/main/java/org/apache/guacamole/rest/directory/DirectoryObjectResource.java
index 7e45b2b..463a1a0 100644
--- a/guacamole/src/main/java/org/apache/guacamole/rest/directory/DirectoryObjectResource.java
+++ b/guacamole/src/main/java/org/apache/guacamole/rest/directory/DirectoryObjectResource.java
@@ -19,8 +19,6 @@
 
 package org.apache.guacamole.rest.directory;
 
-import com.google.inject.assistedinject.Assisted;
-import com.google.inject.assistedinject.AssistedInject;
 import javax.ws.rs.Consumes;
 import javax.ws.rs.DELETE;
 import javax.ws.rs.GET;
@@ -51,7 +49,7 @@ import org.apache.guacamole.net.auth.Identifiable;
  */
 @Produces(MediaType.APPLICATION_JSON)
 @Consumes(MediaType.APPLICATION_JSON)
-public class DirectoryObjectResource<InternalType extends Identifiable, ExternalType>
{
+public abstract class DirectoryObjectResource<InternalType extends Identifiable, ExternalType>
{
 
     /**
      * The Directory which contains the object represented by this
@@ -84,9 +82,7 @@ public class DirectoryObjectResource<InternalType extends Identifiable,
External
      *     A DirectoryObjectTranslator implementation which handles the type of
      *     object given.
      */
-    @AssistedInject
-    public DirectoryObjectResource(@Assisted Directory<InternalType> directory,
-            @Assisted InternalType object,
+    public DirectoryObjectResource(Directory<InternalType> directory, InternalType
object,
             DirectoryObjectTranslator<InternalType, ExternalType> translator) {
         this.directory = directory;
         this.object = object;

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/cdd71411/guacamole/src/main/java/org/apache/guacamole/rest/directory/DirectoryResource.java
----------------------------------------------------------------------
diff --git a/guacamole/src/main/java/org/apache/guacamole/rest/directory/DirectoryResource.java
b/guacamole/src/main/java/org/apache/guacamole/rest/directory/DirectoryResource.java
index 2dbf7f1..5f1e950 100644
--- a/guacamole/src/main/java/org/apache/guacamole/rest/directory/DirectoryResource.java
+++ b/guacamole/src/main/java/org/apache/guacamole/rest/directory/DirectoryResource.java
@@ -19,8 +19,6 @@
 
 package org.apache.guacamole.rest.directory;
 
-import com.google.inject.assistedinject.Assisted;
-import com.google.inject.assistedinject.AssistedInject;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
@@ -69,7 +67,7 @@ import org.apache.guacamole.rest.PATCH;
  */
 @Produces(MediaType.APPLICATION_JSON)
 @Consumes(MediaType.APPLICATION_JSON)
-public class DirectoryResource<InternalType extends Identifiable, ExternalType> {
+public abstract class DirectoryResource<InternalType extends Identifiable, ExternalType>
{
 
     /**
      * The UserContext associated with the Directory being exposed by this
@@ -113,9 +111,7 @@ public class DirectoryResource<InternalType extends Identifiable, ExternalType>
      *     A factory which can be used to create instances of resources
      *     representing individual objects contained within the given Directory.
      */
-    @AssistedInject
-    public DirectoryResource(@Assisted UserContext userContext,
-            @Assisted Directory<InternalType> directory,
+    public DirectoryResource(UserContext userContext, Directory<InternalType> directory,
             DirectoryObjectTranslator<InternalType, ExternalType> translator,
             DirectoryObjectResourceFactory<InternalType, ExternalType> resourceFactory)
{
         this.userContext = userContext;


Mime
View raw message