+++ /dev/null
-/*
- * Copyright (c) 2021 PANTHEON.tech, s.r.o. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * 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.restconf.common;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-import java.util.stream.Stream;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.MethodSource;
-import org.opendaylight.yangtools.yang.common.ErrorTag;
-
-public class ErrorTagsTest {
- @MethodSource("testStatusOfData")
- @ParameterizedTest(name = "{0} => {1}")
- void testStatusOf(final String tagName, final int status) {
- assertEquals(status, ErrorTags.statusOf(new ErrorTag(tagName)).getStatusCode());
- }
-
- static Stream<Object[]> testStatusOfData() {
- return Stream.of(new Object[][] {
- { "in-use", 409 },
- { "invalid-value", 400 },
- { "too-big", 413 },
- { "missing-attribute", 400 },
- { "bad-attribute", 400 },
- { "unknown-attribute", 400 },
- { "missing-element", 400 },
- { "bad-element", 400 },
- { "unknown-element", 400 },
- { "unknown-namespace", 400 },
- { "access-denied", 403 },
- { "lock-denied", 409 },
- { "resource-denied", 409 },
- { "rollback-failed", 500 },
- { "data-exists", 409 },
- { "data-missing", 409 },
- { "operation-not-supported", 501 },
- { "operation-failed", 500 },
- { "partial-operation", 500 },
- { "malformed-message", 400 },
- { "resource-denied-transport", 503 }
- });
- }
-
-}
import javax.ws.rs.core.Response.Status;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
-import org.opendaylight.restconf.common.ErrorTags;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.restconf.common.errors.RestconfError;
import org.opendaylight.restconf.nb.rfc8040.MediaTypes;
import org.opendaylight.restconf.nb.rfc8040.databind.DatabindProvider;
+import org.opendaylight.restconf.nb.rfc8040.legacy.ErrorTags;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.rev170126.errors.Errors;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.rev170126.errors.errors.Error;
import org.opendaylight.yangtools.yang.common.QName;
* 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.restconf.common;
+package org.opendaylight.restconf.nb.rfc8040.legacy;
import static java.util.Objects.requireNonNull;
-import com.google.common.annotations.Beta;
import com.google.common.collect.ImmutableMap;
import javax.ws.rs.core.Response.Status;
import org.eclipse.jdt.annotation.NonNullByDefault;
* <a href="https://www.rfc-editor.org/rfc/rfc8040#section-7">RFC8040 section 7</a>, we also define tags which
* map to useful {@link Status} codes.
*/
-@Beta
@NonNullByDefault
public final class ErrorTags {
/**
* @throws NullPointerException if {@code tag} is null
*/
public static Status statusOf(final ErrorTag tag) {
- final Status known = WELL_KNOWN_ERROR_TAGS.get(requireNonNull(tag));
+ final var known = WELL_KNOWN_ERROR_TAGS.get(requireNonNull(tag));
return known != null ? known : Status.INTERNAL_SERVER_ERROR;
}
// HTTP status 409 as specified by RFC8040 (and all previous drafts). See the discussion in:
// https://www.rfc-editor.org/errata/eid5565
// https://mailarchive.ietf.org/arch/msg/netconf/hkVDdHK4xA74NgvXzWP0zObMiyY/
- final String propName = "org.opendaylight.restconf.eid5565";
- final String propValue = System.getProperty(propName, "disabled");
+ final var propName = "org.opendaylight.restconf.eid5565";
+ final var propValue = System.getProperty(propName, "disabled");
switch (propValue) {
case "enabled":
// RFC7231 interpretation: 404 Not Found
import org.opendaylight.mdsal.dom.api.DOMMountPointService;
import org.opendaylight.mdsal.dom.api.DOMSchemaService;
import org.opendaylight.mdsal.dom.api.DOMYangTextSourceProvider;
-import org.opendaylight.restconf.common.ErrorTags;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
+import org.opendaylight.restconf.nb.rfc8040.legacy.ErrorTags;
import org.opendaylight.restconf.nb.rfc8040.legacy.InstanceIdentifierContext;
import org.opendaylight.restconf.nb.rfc8040.rests.services.api.SchemaExportContext;
import org.opendaylight.yangtools.yang.common.ErrorTag;
--- /dev/null
+/*
+ * Copyright (c) 2021 PANTHEON.tech, s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * 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.restconf.nb.rfc8040.legacy;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.util.List;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+import org.opendaylight.yangtools.yang.common.ErrorTag;
+
+class ErrorTagsTest {
+ @ParameterizedTest(name = "{0} => {1}")
+ @MethodSource
+ void testStatusOf(final String tagName, final int status) {
+ assertEquals(status, ErrorTags.statusOf(new ErrorTag(tagName)).getStatusCode());
+ }
+
+ static List<Arguments> testStatusOf() {
+ return List.of(
+ Arguments.of("in-use", 409),
+ Arguments.of("invalid-value", 400),
+ Arguments.of("too-big", 413),
+ Arguments.of("missing-attribute", 400),
+ Arguments.of("bad-attribute", 400),
+ Arguments.of("unknown-attribute", 400),
+ Arguments.of("missing-element", 400),
+ Arguments.of("bad-element", 400),
+ Arguments.of("unknown-element", 400),
+ Arguments.of("unknown-namespace", 400),
+ Arguments.of("access-denied", 403),
+ Arguments.of("lock-denied", 409),
+ Arguments.of("resource-denied", 409),
+ Arguments.of("rollback-failed", 500),
+ Arguments.of("data-exists", 409),
+ Arguments.of("data-missing", 409),
+ Arguments.of("operation-not-supported", 501),
+ Arguments.of("operation-failed", 500),
+ Arguments.of("partial-operation", 500),
+ Arguments.of("malformed-message", 400),
+ Arguments.of("resource-denied-transport", 503));
+ }
+}
import org.opendaylight.mdsal.dom.api.DOMYangTextSourceProvider;
import org.opendaylight.mdsal.dom.broker.DOMMountPointServiceImpl;
import org.opendaylight.mdsal.dom.spi.FixedDOMSchemaService;
-import org.opendaylight.restconf.common.ErrorTags;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
import org.opendaylight.restconf.common.errors.RestconfError;
+import org.opendaylight.restconf.nb.rfc8040.legacy.ErrorTags;
import org.opendaylight.restconf.nb.rfc8040.rests.services.api.SchemaExportContext;
import org.opendaylight.yangtools.yang.common.ErrorTag;
import org.opendaylight.yangtools.yang.common.ErrorType;