This patch copies all the required classes (Status.java & StatusCode.java) from sal.utils and places them in plugin.api package.
Patch set 3: Add review comments.
Change-Id: I7e5ca9ef3480f4c3dcf604e1874f7e980681c2e8
Also-by: Anil Vishnoi <vishnoianil@gmail.com>
Signed-off-by: Sam Hague <shague@redhat.com>
<openstack.netvirt.providers.version>1.1.0-SNAPSHOT</openstack.netvirt.providers.version>
<ovsdb.library.version>1.1.0-SNAPSHOT</ovsdb.library.version>
<ovsdb.northbound.version>0.7.0-SNAPSHOT</ovsdb.northbound.version>
- <ovsdb.plugin.version>1.1.0-SNAPSHOT</ovsdb.plugin.version>
+ <ovsdb.plugin.version>1.1.1-SNAPSHOT</ovsdb.plugin.version>
<ovsdb.ovssfc.version>0.1.0-SNAPSHOT</ovsdb.ovssfc.version>
<ovsdb.utils.config.version>1.1.0-SNAPSHOT</ovsdb.utils.config.version>
<plugin.shell.version>1.1.0-SNAPSHOT</plugin.shell.version>
</parent>
<artifactId>features-ovsdb</artifactId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>1.1.1-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
"odl-base-all"),
features("mvn:org.opendaylight.controller/features-neutron/0.5.0-SNAPSHOT/xml/features",
"odl-neutron-all"),
- features("mvn:org.opendaylight.ovsdb/features-ovsdb/1.1.0-SNAPSHOT/xml/features",
+ features("mvn:org.opendaylight.ovsdb/features-ovsdb/1.1.1-SNAPSHOT/xml/features",
"odl-ovsdb-openstack")
};
}
import org.opendaylight.controller.networkconfig.neutron.NeutronNetwork;
import org.opendaylight.controller.sal.core.Node;
-import org.opendaylight.controller.sal.utils.Status;
import org.opendaylight.ovsdb.integrationtest.ConfigurationBundles;
import org.opendaylight.ovsdb.integrationtest.OvsdbIntegrationTestBase;
import org.opendaylight.ovsdb.lib.notation.Row;
import org.opendaylight.ovsdb.lib.notation.UUID;
import org.opendaylight.ovsdb.lib.notation.Version;
+import org.opendaylight.ovsdb.plugin.api.Status;
import org.opendaylight.ovsdb.openstack.netvirt.api.ConfigurationService;
import org.opendaylight.ovsdb.openstack.netvirt.api.Constants;
import org.opendaylight.ovsdb.openstack.netvirt.api.BridgeConfigurationManager;
import org.junit.After;
import org.opendaylight.controller.sal.core.Node;
import org.opendaylight.controller.sal.utils.ServiceHelper;
-import org.opendaylight.controller.sal.utils.Status;
import org.opendaylight.ovsdb.integrationtest.ConfigurationBundles;
import org.opendaylight.ovsdb.integrationtest.OvsdbIntegrationTestBase;
import org.opendaylight.ovsdb.lib.OvsdbClient;
import org.opendaylight.ovsdb.plugin.api.OvsdbConnectionService;
import org.opendaylight.ovsdb.plugin.api.OvsdbInventoryListener;
import org.opendaylight.ovsdb.plugin.api.OvsdbInventoryService;
+import org.opendaylight.ovsdb.plugin.api.Status;
import org.opendaylight.ovsdb.plugin.api.StatusWithUuid;
import org.opendaylight.ovsdb.schema.openvswitch.Bridge;
import org.opendaylight.ovsdb.schema.openvswitch.OpenVSwitch;
import org.mockito.Mockito;
import org.opendaylight.controller.sal.core.Node;
import org.opendaylight.controller.sal.utils.ServiceHelper;
-import org.opendaylight.controller.sal.utils.StatusCode;
import org.opendaylight.ovsdb.integrationtest.ConfigurationBundles;
import org.opendaylight.ovsdb.integrationtest.OvsdbIntegrationTestBase;
import org.opendaylight.ovsdb.lib.OvsdbClient;
import org.opendaylight.ovsdb.plugin.api.OvsdbConnectionService;
import org.opendaylight.ovsdb.plugin.api.OvsdbInventoryListener;
import org.opendaylight.ovsdb.plugin.api.OvsdbInventoryService;
+import org.opendaylight.ovsdb.plugin.api.StatusCode;
import org.opendaylight.ovsdb.plugin.api.StatusWithUuid;
import org.opendaylight.ovsdb.schema.openvswitch.Bridge;
import org.opendaylight.ovsdb.schema.openvswitch.OpenVSwitch;
<extensions>true</extensions>
<configuration>
<instructions>
- <Export-Package></Export-Package>
- <Import-Package>org.opendaylight.controller.sal.utils,
- org.opendaylight.controller.northbound.commons,
- org.opendaylight.controller.northbound.commons.exception,
- org.opendaylight.controller.northbound.commons.utils,
+ <Import-Package>
com.sun.jersey.spi.container.servlet,
- org.opendaylight.controller.sal.core,
- org.opendaylight.controller.sal.authorization,
- org.opendaylight.ovsdb.plugin.api,
- org.opendaylight.ovsdb.lib,
- org.opendaylight.ovsdb.lib.jsonrpc,
- org.opendaylight.ovsdb.lib.notation,
- org.opendaylight.ovsdb.lib.operations,
- org.opendaylight.ovsdb.lib.message,
- org.opendaylight.ovsdb.lib.schema,
- org.opendaylight.ovsdb.lib.schema.typed,
- javax.ws.rs,
- javax.ws.rs.core,
- javax.xml.bind,
- javax.xml.bind.annotation,
- org.slf4j,
- org.apache.catalina.filters,
- !org.codehaus.enunciate.jaxrs,*</Import-Package>
- <Export-Package></Export-Package>
+ !org.codehaus.enunciate.jaxrs,
+ *</Import-Package>
<Web-ContextPath>/ovsdb/nb</Web-ContextPath>
<Jaxrs-Resources>,${classes;ANNOTATION;javax.ws.rs.Path}</Jaxrs-Resources>
</instructions>
import org.opendaylight.controller.sal.authorization.Privilege;
import org.opendaylight.controller.sal.core.Node;
import org.opendaylight.controller.sal.utils.ServiceHelper;
-import org.opendaylight.controller.sal.utils.Status;
import org.opendaylight.ovsdb.lib.OvsdbClient;
import org.opendaylight.ovsdb.lib.notation.Row;
import org.opendaylight.ovsdb.lib.notation.UUID;
import org.opendaylight.ovsdb.plugin.api.OvsVswitchdSchemaConstants;
import org.opendaylight.ovsdb.plugin.api.OvsdbConfigurationService;
import org.opendaylight.ovsdb.plugin.api.OvsdbConnectionService;
+import org.opendaylight.ovsdb.plugin.api.Status;
import org.opendaylight.ovsdb.plugin.api.StatusWithUuid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
.entity(uuid.toString())
.build();
}
- return NorthboundUtils.getResponse(statusWithUuid);
+ /* TODO better way to return the status. Likely the shim will handle this */
+ //return NorthboundUtils.getResponse(statusWithUuid);
+ return NorthboundUtils.getResponse(
+ new org.opendaylight.controller.sal.utils.Status(
+ org.opendaylight.controller.sal.utils.StatusCode.SUCCESS));
}
/**
}
Status status = ovsdbTable.updateRow(node, bckCompatibleTableName, localRow.getParentUuid(), rowUuid, localRow.getRow());
- return NorthboundUtils.getResponse(status);
+ /* TODO better way to return the status. Likely the shim will handle this */
+ return NorthboundUtils.getResponse(
+ new org.opendaylight.controller.sal.utils.Status(
+ org.opendaylight.controller.sal.utils.StatusCode.SUCCESS));
}
/**
if (status.isSuccess()) {
return Response.noContent().build();
}
- return NorthboundUtils.getResponse(status);
+ /* TODO better way to return the status. Likely the shim will handle this */
+ return NorthboundUtils.getResponse(
+ new org.opendaylight.controller.sal.utils.Status(
+ org.opendaylight.controller.sal.utils.StatusCode.SUCCESS));
}
private String getBackwardCompatibleTableName(OvsdbClient client, String databaseName, String tableName) {
import org.opendaylight.controller.networkconfig.neutron.NeutronSecurityGroup;
import org.opendaylight.controller.sal.core.Node;
import org.opendaylight.controller.sal.utils.HexEncode;
-import org.opendaylight.controller.sal.utils.Status;
-import org.opendaylight.controller.sal.utils.StatusCode;
import org.opendaylight.ovsdb.lib.notation.Row;
import org.opendaylight.ovsdb.lib.notation.UUID;
import org.opendaylight.ovsdb.openstack.netvirt.NetworkHandler;
import org.opendaylight.ovsdb.openstack.netvirt.api.TenantNetworkManager;
import org.opendaylight.ovsdb.plugin.api.OvsdbConfigurationService;
import org.opendaylight.ovsdb.plugin.api.OvsdbConnectionService;
+import org.opendaylight.ovsdb.plugin.api.Status;
+import org.opendaylight.ovsdb.plugin.api.StatusCode;
import org.opendaylight.ovsdb.plugin.api.StatusWithUuid;
import org.opendaylight.ovsdb.schema.openvswitch.Bridge;
import org.opendaylight.ovsdb.schema.openvswitch.Interface;
import org.opendaylight.controller.networkconfig.neutron.NeutronNetwork;
import org.opendaylight.controller.sal.core.Node;
-import org.opendaylight.controller.sal.utils.Status;
+import org.opendaylight.ovsdb.plugin.api.Status;
import org.opendaylight.ovsdb.schema.openvswitch.Interface;
/**
import org.opendaylight.controller.networkconfig.neutron.NeutronNetwork;
import org.opendaylight.controller.sal.core.Node;
-import org.opendaylight.controller.sal.utils.Status;
-import org.opendaylight.controller.sal.utils.StatusCode;
import org.opendaylight.ovsdb.lib.error.SchemaVersionMismatchException;
import org.opendaylight.ovsdb.lib.notation.Row;
import org.opendaylight.ovsdb.lib.notation.UUID;
import org.opendaylight.ovsdb.openstack.netvirt.api.Constants;
import org.opendaylight.ovsdb.openstack.netvirt.api.NetworkingProviderManager;
import org.opendaylight.ovsdb.plugin.api.OvsdbConfigurationService;
+import org.opendaylight.ovsdb.plugin.api.Status;
+import org.opendaylight.ovsdb.plugin.api.StatusCode;
import org.opendaylight.ovsdb.plugin.api.StatusWithUuid;
import org.opendaylight.ovsdb.schema.openvswitch.Bridge;
import org.opendaylight.ovsdb.schema.openvswitch.Interface;
</parent>
<artifactId>plugin</artifactId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>1.1.1-SNAPSHOT</version>
<packaging>bundle</packaging>
<dependencies>
import java.util.concurrent.ExecutionException;
import org.opendaylight.controller.sal.core.Node;
-import org.opendaylight.controller.sal.utils.Status;
import org.opendaylight.ovsdb.lib.notation.Row;
import org.opendaylight.ovsdb.lib.notation.UUID;
import org.opendaylight.ovsdb.lib.schema.GenericTableSchema;
--- /dev/null
+/*
+ * Copyright (c) 2013 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.ovsdb.plugin.api;
+
+import java.io.Serializable;
+
+/**
+ * Represents the return object of the osgi service interfaces function calls.
+ * It contains a code {@code StatusCode} representing the result of the call and
+ * a string which describes a failure reason (if any) in human readable form.
+ */
+@Deprecated
+public class Status implements Serializable {
+ private static final long serialVersionUID = 0L;
+ private StatusCode code;
+ private String description;
+ private long requestId;
+
+ /**
+ * Generates an instance of the Status class. This is used as return code
+ * for internal API2 function calls. This constructor allows to specify,
+ * beside the Status Code, a custom human readable description to add more
+ * information about the status.
+ *
+ * @param errorCode
+ * The status code. If passed as null, code will be stored as
+ * {@code StatusCode.UNDEFINED}
+ * @param description
+ * The human readable description of the status. If passed as
+ * null, description will be inferred by the code
+ */
+ public Status(StatusCode errorCode, String description) {
+ this.code = (errorCode != null) ? errorCode : StatusCode.UNDEFINED;
+ this.description = (description != null) ? description : this.code
+ .toString();
+ this.requestId = 0;
+ }
+
+ /**
+ * Generates an instance of the Status class based on the passed StatusCode
+ * only. The description field of the Status object will be inferred by the
+ * status code.
+ *
+ * @param errorCode
+ * The status code. If passed as null, code will be stored as
+ * {@code StatusCode.UNDEFINED}
+ */
+ public Status(StatusCode errorCode) {
+ this.code = (errorCode != null) ? errorCode : StatusCode.UNDEFINED;
+ this.description = (description != null) ? description : this.code
+ .toString();
+ this.requestId = 0;
+ }
+
+ /**
+ * Generates an instance of the Status class to be used in case of
+ * asynchronous call. It is supposed to be created by the underlying
+ * infrastructure only when it was successful in allocating the asynchronous
+ * request id, hence caller should expect StatusCode to be successful.
+ *
+ * @param errorCode
+ * The status code. If passed as null, code will be stored as
+ * {@code StatusCode.UNDEFINED}
+ * @param requestId
+ * The request id set by underlying infrastructure for this
+ * request
+ */
+ public Status(StatusCode errorCode, long requestId) {
+ this.code = (errorCode != null) ? errorCode : StatusCode.UNDEFINED;
+ this.description = (description != null) ? description : this.code
+ .toString();
+ this.requestId = requestId;
+ }
+
+ /**
+ * Returns the status code
+ *
+ * @return the {@code StatusCode} representing the status code
+ */
+ public StatusCode getCode() {
+ return code;
+ }
+
+ /**
+ * Returns a human readable description of the failure if any
+ *
+ * @return a string representing the reason of failure
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * Tells whether the status is successful
+ *
+ * @return true if the Status code is {@code StatusCode.SUCCESS}
+ */
+ public boolean isSuccess() {
+ return code == StatusCode.SUCCESS || code == StatusCode.CREATED;
+ }
+
+ /**
+ * Return the request id assigned by underlying infrastructure in case of
+ * asynchronous request. In case of synchronous requests, the returned id
+ * is expected to be 0
+ *
+ * @return The request id assigned for this asynchronous request
+ */
+ public long getRequestId() {
+ return requestId;
+ }
+
+ @Override
+ public String toString() {
+ return code + ": " + description + " (" + requestId + ")";
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((code == null) ? 0 : code.calculateConsistentHashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ Status other = (Status) obj;
+ if (code != other.code) {
+ return false;
+ }
+ return true;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2013 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.ovsdb.plugin.api;
+
+/**
+ * The enum which describes the generic error conditions.
+ * Each enum value is associated with a minimal description string.
+ *
+ */
+public enum StatusCode {
+ SUCCESS("Success"),
+ CREATED("Created"),
+
+ BADREQUEST("Bad Request"),
+ UNAUTHORIZED("UnAuthorized"),
+ FORBIDDEN("Forbidden"),
+ NOTFOUND("Not Found"),
+ NOTALLOWED("Method Not Allowed"),
+ NOTACCEPTABLE("Request Not Acceptable"),
+ TIMEOUT("Request Timeout"),
+ CONFLICT("Resource Conflict"),
+ GONE("Resource Gone"),
+ UNSUPPORTED("Unsupported"),
+
+ INTERNALERROR("Internal Error"),
+ NOTIMPLEMENTED("Not Implemented"),
+ NOSERVICE("Service Not Available"),
+
+ UNDEFINED("Undefined Error");
+
+ private String description;
+ private StatusCode(String description) {
+ this.description = description;
+ }
+
+ /**
+ * Prints the description associated to the code value
+ */
+ @Override
+ public String toString() {
+ return description;
+ }
+
+ public int calculateConsistentHashCode() {
+ if (this.description != null) {
+ return this.description.hashCode();
+ } else {
+ return 0;
+ }
+ }
+}
*/
package org.opendaylight.ovsdb.plugin.api;
-import org.opendaylight.controller.sal.utils.Status;
-import org.opendaylight.controller.sal.utils.StatusCode;
import org.opendaylight.ovsdb.lib.notation.UUID;
/**
import java.util.concurrent.ExecutionException;
import org.opendaylight.controller.sal.core.Node;
-import org.opendaylight.controller.sal.utils.Status;
-import org.opendaylight.controller.sal.utils.StatusCode;
import org.opendaylight.ovsdb.lib.OvsdbClient;
import org.opendaylight.ovsdb.lib.error.SchemaVersionMismatchException;
import org.opendaylight.ovsdb.lib.notation.Column;
import org.opendaylight.ovsdb.plugin.api.OvsdbConfigurationService;
import org.opendaylight.ovsdb.plugin.api.OvsdbConnectionService;
import org.opendaylight.ovsdb.plugin.api.OvsdbInventoryService;
+import org.opendaylight.ovsdb.plugin.api.Status;
+import org.opendaylight.ovsdb.plugin.api.StatusCode;
import org.opendaylight.ovsdb.plugin.api.StatusWithUuid;
import org.opendaylight.ovsdb.plugin.error.OvsdbPluginException;
import org.opendaylight.ovsdb.schema.openvswitch.Bridge;
import org.opendaylight.controller.sal.core.Node;
import org.opendaylight.controller.sal.core.Property;
-import org.opendaylight.controller.sal.utils.Status;
-import org.opendaylight.controller.sal.utils.StatusCode;
import org.opendaylight.ovsdb.lib.MonitorCallBack;
import org.opendaylight.ovsdb.lib.OvsdbClient;
import org.opendaylight.ovsdb.lib.OvsdbConnection;
import org.opendaylight.ovsdb.lib.schema.TableSchema;
import org.opendaylight.ovsdb.plugin.api.Connection;
import org.opendaylight.ovsdb.plugin.api.ConnectionConstants;
+import org.opendaylight.ovsdb.plugin.api.Status;
+import org.opendaylight.ovsdb.plugin.api.StatusCode;
import org.opendaylight.ovsdb.plugin.internal.IPAddressProperty;
import org.opendaylight.ovsdb.plugin.internal.L4PortProperty;
import org.opendaylight.ovsdb.plugin.api.OvsdbConnectionService;