X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=restconf%2Frestconf-nb-bierman02%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Frestconf%2Fjersey%2Fproviders%2FAbstractIdentifierAwareJaxRsProvider.java;fp=restconf%2Frestconf-nb-bierman02%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Frestconf%2Fjersey%2Fproviders%2FAbstractIdentifierAwareJaxRsProvider.java;h=0000000000000000000000000000000000000000;hb=7e47f4213d56d36fd83c0de1b1e317ee105a6048;hp=b313911df734fe4173fb423a304831397b51c968;hpb=352559891fbfd6cd3ae9cacbc788b1a821b2a49e;p=netconf.git diff --git a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/restconf/jersey/providers/AbstractIdentifierAwareJaxRsProvider.java b/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/restconf/jersey/providers/AbstractIdentifierAwareJaxRsProvider.java deleted file mode 100644 index b313911df7..0000000000 --- a/restconf/restconf-nb-bierman02/src/main/java/org/opendaylight/restconf/jersey/providers/AbstractIdentifierAwareJaxRsProvider.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. 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.jersey.providers; - -import com.google.common.base.Optional; -import java.io.IOException; -import java.io.InputStream; -import java.lang.annotation.Annotation; -import java.lang.reflect.Type; -import javax.ws.rs.HttpMethod; -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.Request; -import javax.ws.rs.core.UriInfo; -import javax.ws.rs.ext.MessageBodyReader; -import org.opendaylight.netconf.sal.rest.api.RestconfConstants; -import org.opendaylight.netconf.sal.restconf.impl.ControllerContext; -import org.opendaylight.restconf.RestConnectorProvider; -import org.opendaylight.restconf.common.context.InstanceIdentifierContext; -import org.opendaylight.restconf.utils.parser.ParserIdentifier; - -/** - * JaxRd identifier aware provider. - * - * @deprecated move to splitted module restconf-nb-rfc8040 - */ -@Deprecated -public abstract class AbstractIdentifierAwareJaxRsProvider implements MessageBodyReader { - - @Context - private UriInfo uriInfo; - - @Context - private Request request; - - @Override - public final boolean isReadable(final Class type, final Type genericType, final Annotation[] annotations, - final MediaType mediaType) { - return true; - } - - @Override - public final T readFrom(final Class type, final Type genericType, - final Annotation[] annotations, final MediaType mediaType, - final MultivaluedMap httpHeaders, final InputStream entityStream) throws IOException, - WebApplicationException { - final InstanceIdentifierContext path = getInstanceIdentifierContext(); - if (entityStream.available() < 1) { - return emptyBody(path); - } - - return readBody(path, entityStream); - } - - /** - * Create a type corresponding to an empty body. - * - * @param path Request path - * @return empty body type - */ - protected abstract T emptyBody(InstanceIdentifierContext path); - - protected abstract T readBody(InstanceIdentifierContext path, InputStream entityStream) - throws IOException, WebApplicationException; - - - private String getIdentifier() { - return this.uriInfo.getPathParameters(false).getFirst(RestconfConstants.IDENTIFIER); - } - - private InstanceIdentifierContext getInstanceIdentifierContext() { - return ParserIdentifier.toInstanceIdentifier( - getIdentifier(), - ControllerContext.getInstance().getGlobalSchema(), - Optional.of(RestConnectorProvider.getMountPointService())); - } - - protected UriInfo getUriInfo() { - return this.uriInfo; - } - - protected boolean isPost() { - return HttpMethod.POST.equals(this.request.getMethod()); - } - - void setUriInfo(final UriInfo uriInfo) { - this.uriInfo = uriInfo; - } - - void setRequest(final Request request) { - this.request = request; - } -}