Remove DocumentedException.ErrorSeverity
[netconf.git] / netconf / netconf-impl / src / main / java / org / opendaylight / netconf / impl / mapping / operations / DefaultCloseSession.java
index d98f07b069560c3eb4e1394e0d13613f268c9af8..ff08feb10f7f635c714425ffa6d113f85b551a8f 100644 (file)
@@ -5,18 +5,17 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.netconf.impl.mapping.operations;
 
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import java.util.Collections;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.config.util.xml.XmlElement;
-import org.opendaylight.controller.config.util.xml.XmlUtil;
+import static java.util.Objects.requireNonNull;
+
+import java.util.Map;
+import org.opendaylight.netconf.api.DocumentedException;
+import org.opendaylight.netconf.api.xml.XmlElement;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
 import org.opendaylight.netconf.impl.NetconfServerSession;
 import org.opendaylight.netconf.util.mapping.AbstractSingletonNetconfOperation;
+import org.opendaylight.yangtools.yang.common.ErrorSeverity;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
@@ -51,16 +50,15 @@ public class DefaultCloseSession extends AbstractSingletonNetconfOperation imple
             throws DocumentedException {
         try {
             sessionResources.close();
-            Preconditions.checkNotNull(session, "Session was not set").delayedClose();
+            requireNonNull(session, "Session was not set").delayedClose();
             LOG.info("Session {} closing", session.getSessionId());
         } catch (final Exception e) {
             throw new DocumentedException("Unable to properly close session "
-                    + getNetconfSessionIdForReporting(), DocumentedException.ErrorType.APPLICATION,
+                    + getNetconfSessionIdForReporting(), e, DocumentedException.ErrorType.APPLICATION,
                     DocumentedException.ErrorTag.OPERATION_FAILED,
-                    DocumentedException.ErrorSeverity.ERROR, Collections.singletonMap(
-                    DocumentedException.ErrorSeverity.ERROR.toString(), e.getMessage()));
+                    ErrorSeverity.ERROR, Map.of(ErrorSeverity.ERROR.toString(), e.getMessage()));
         }
-        return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.<String>absent());
+        return document.createElement(XmlNetconfConstants.OK);
     }
 
     @Override