You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@guacamole.apache.org by GitBox <gi...@apache.org> on 2022/10/12 18:36:33 UTC

[GitHub] [guacamole-client] mike-jumper commented on a diff in pull request #768: GUACAMOLE-1224: Add global logging and event handling around object management.

mike-jumper commented on code in PR #768:
URL: https://github.com/apache/guacamole-client/pull/768#discussion_r993784471


##########
guacamole/src/main/java/org/apache/guacamole/event/AffectedObject.java:
##########
@@ -0,0 +1,129 @@
+/*
+ * 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.event;
+
+import org.apache.guacamole.net.auth.Nameable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.guacamole.net.event.IdentifiableObjectEvent;
+
+/**
+ * Loggable representation of the object affected by an operation.
+ */
+public class AffectedObject implements LoggableDetail {
+
+    /**
+     * Logger for this class.
+     */
+    private static final Logger logger = LoggerFactory.getLogger(AffectedObject.class);
+    
+    /**
+     * The event representing the requested operation.
+     */
+    private final IdentifiableObjectEvent<?> event;
+
+    /**
+     * Creates a new AffectedObject representing the object affected by the
+     * operation described by the given event.
+     *
+     * @param event
+     *     The event representing the operation.
+     */
+    public AffectedObject(IdentifiableObjectEvent<?> event) {
+        this.event = event;
+    }
+
+    @Override
+    public String toString() {
+
+        Object object = event.getObject();
+        String identifier = event.getObjectIdentifier();
+        String dataSource = event.getAuthenticationProvider().getIdentifier();
+
+        String objectType;
+        String name = null; // Not all objects have names
+
+        // Obtain name of object (if applicable and available)
+        if (object instanceof Nameable) {
+            try {
+                name = ((Nameable) object).getName();
+            }
+            catch (RuntimeException | Error e) {
+                logger.debug("Name of object \"{}\" could not be retrieved.", identifier, e);
+            }
+        }
+
+        /// Determine type of object

Review Comment:
   Yep, this is definitely a typo on my part.



-- 
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