Remove DocumentedException.ErrorType
[netconf.git] / netconf / netconf-impl / src / main / java / org / opendaylight / netconf / impl / mapping / operations / DefaultCloseSession.java
index 5a5ae1cc43d837253c03637015975ac172f5f36b..b0092519d875f3d6580b02b58d76f7e910b534d6 100644 (file)
@@ -7,13 +7,16 @@
  */
 package org.opendaylight.netconf.impl.mapping.operations;
 
-import com.google.common.base.Preconditions;
-import java.util.Collections;
+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.opendaylight.yangtools.yang.common.ErrorType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
@@ -48,14 +51,12 @@ 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(), e, DocumentedException.ErrorType.APPLICATION,
-                    DocumentedException.ErrorTag.OPERATION_FAILED,
-                    DocumentedException.ErrorSeverity.ERROR, Collections.singletonMap(
-                    DocumentedException.ErrorSeverity.ERROR.toString(), e.getMessage()));
+            throw new DocumentedException("Unable to properly close session " + getNetconfSessionIdForReporting(), e,
+                    ErrorType.APPLICATION, DocumentedException.ErrorTag.OPERATION_FAILED, ErrorSeverity.ERROR,
+                    Map.of(ErrorSeverity.ERROR.toString(), e.getMessage()));
         }
         return document.createElement(XmlNetconfConstants.OK);
     }