/*
- * //******************************************************************
- * //
- * // Copyright 2015 Intel Corporation.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- * //
- * // Licensed under the Apache License, Version 2.0 (the "License");
- * // you may not use this file except in compliance with the License.
- * // You may obtain a copy of the License at
- * //
- * // http://www.apache.org/licenses/LICENSE-2.0
- * //
- * // Unless required by applicable law or agreed to in writing, software
- * // distributed under the License is distributed on an "AS IS" BASIS,
- * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * // See the License for the specific language governing permissions and
- * // limitations under the License.
- * //
- * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *******************************************************************
+ *
+ * Copyright 2015 Intel Corporation.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
*/
package org.iotivity.base;
public void get(Map<String, String> queryParamsMap,
OnGetListener onGetListener,
QualityOfService qualityOfService) throws OcException {
+
+ if (qualityOfService == null) {
+ throw new OcException(ErrorCode.INVALID_PARAM, "qualityOfService cannot be null");
+ }
+
this.get1(queryParamsMap, onGetListener, qualityOfService.getValue());
}
Map<String, String> queryParamsMap,
OnGetListener onGetListener,
QualityOfService qualityOfService) throws OcException {
+
+ if (qualityOfService == null) {
+ throw new OcException(ErrorCode.INVALID_PARAM, "qualityOfService cannot be null");
+ }
+
this.get3(
resourceType,
resourceInterface,
Map<String, String> queryParamsMap,
OnPutListener onPutListener,
QualityOfService qualityOfService) throws OcException {
+
+ if (qualityOfService == null) {
+ throw new OcException(ErrorCode.INVALID_PARAM, "qualityOfService cannot be null");
+ }
+
this.put1(
ocRepresentation,
queryParamsMap,
Map<String, String> queryParamsMap,
OnPutListener onPutListener,
QualityOfService qualityOfService) throws OcException {
+
+ if (qualityOfService == null) {
+ throw new OcException(ErrorCode.INVALID_PARAM, "qualityOfService cannot be null");
+ }
+
this.put3(
resourceType,
resourceInterface,
Map<String, String> queryParamsMap,
OnPostListener onPostListener,
QualityOfService qualityOfService) throws OcException {
+
+ if (qualityOfService == null) {
+ throw new OcException(ErrorCode.INVALID_PARAM, "qualityOfService cannot be null");
+ }
+
this.post1(
ocRepresentation,
queryParamsMap,
Map<String, String> queryParamsMap,
OnPostListener onPostListener,
QualityOfService qualityOfService) throws OcException {
+
+ if (qualityOfService == null) {
+ throw new OcException(ErrorCode.INVALID_PARAM, "qualityOfService cannot be null");
+ }
+
this.post3(
resourceType,
resourceInterface,
*/
public void deleteResource(OnDeleteListener onDeleteListener,
QualityOfService qualityOfService) throws OcException {
+
+ if (qualityOfService == null) {
+ throw new OcException(ErrorCode.INVALID_PARAM, "qualityOfService cannot be null");
+ }
+
this.deleteResource1(onDeleteListener,
qualityOfService.getValue());
}
public void observe(ObserveType observeType,
Map<String, String> queryParamsMap,
OnObserveListener onObserveListener) throws OcException {
+
+ if (observeType == null) {
+ throw new OcException(ErrorCode.INVALID_PARAM, "observeType cannot be null");
+ }
+
this.observe(
observeType.getValue(),
queryParamsMap,
Map<String, String> queryParamsMap,
OnObserveListener onObserveListener,
QualityOfService qualityOfService) throws OcException {
+
+ if (observeType == null) {
+ throw new OcException(ErrorCode.INVALID_PARAM, "observeType cannot be null");
+ }
+
+ if (qualityOfService == null) {
+ throw new OcException(ErrorCode.INVALID_PARAM, "qualityOfService cannot be null");
+ }
+
this.observe1(
observeType.getValue(),
queryParamsMap,
*
* @throws OcException
*/
- public native void cancelObserve() throws OcException;
+ public void cancelObserve() throws OcException{
+ this.cancelObserve(OcPlatform.getPlatformQualityOfService());
+ }
/**
* Method to cancel the observation on the resource
* @throws OcException
*/
public void cancelObserve(QualityOfService qualityOfService) throws OcException {
+
+ if (qualityOfService == null) {
+ throw new OcException(ErrorCode.INVALID_PARAM, "qualityOfService cannot be null");
+ }
+
this.cancelObserve1(qualityOfService.getValue());
}
*
* @param headerOptionList List<OcHeaderOption> where header information(header optionID and
* optionData is passed
+ * @throws OcException
*/
- public void setHeaderOptions(List<OcHeaderOption> headerOptionList) {
+ public void setHeaderOptions(List<OcHeaderOption> headerOptionList) throws OcException {
+
+ if (headerOptionList == null) {
+ throw new OcException(ErrorCode.INVALID_PARAM, "headerOptionList cannot be null");
+ }
+
this.setHeaderOptions(headerOptionList.toArray(
new OcHeaderOption[headerOptionList.size()])
);
public native String getServerId();
/**
+ * Method to get a string representation of the human friendly name defined by the vendor.
+ *
+ * @return human friendly name
+ */
+ public native String getDeviceName();
+
+ /**
* An OnGetListener can be registered via the resource get call.
* Event listeners are notified asynchronously
*/
private native void dispose();
private long mNativeHandle;
+
+ /**
+ * Method to discovery Topics
+ *
+ * @param queryParamsMap map which can have the query parameter name and value
+ * @param onTopicFoundListener event handler The handler method will be invoked with a map
+ * of attribute name and values.
+ * @param qualityOfService the quality of communication.
+ * @throws OcException
+ */
+ public void discoveryMQTopics(Map<String, String> queryParamsMap,
+ OnMQTopicFoundListener onTopicFoundListener,
+ QualityOfService qualityOfService) throws OcException {
+
+ if (qualityOfService == null) {
+ throw new OcException(ErrorCode.INVALID_PARAM, "qualityOfService cannot be null");
+ }
+
+ this.discoveryMQTopicsImpl(queryParamsMap, onTopicFoundListener,
+ qualityOfService.getValue());
+ }
+
+ private synchronized native void discoveryMQTopicsImpl(
+ Map<String, String> queryParamsMap,
+ OnMQTopicFoundListener onTopicFoundListener,
+ int qualityOfService) throws OcException;
+
+ /**
+ * Method to create Topic into MQ Brober.
+ *
+ * @param ocRepresentation representation of the MQ Broker.
+ * @param uri new MQ Topic uri which want to create.
+ * @param queryParamsMap map which can have the query parameter name and value.
+ * @param onTopicCreatedListener event handler The handler method will be invoked with a map
+ * of attribute name and values.
+ * @param qualityOfService the quality of communication.
+ * @throws OcException
+ */
+ public void createMQTopic(OcRepresentation ocRepresentation,
+ String uri,
+ Map<String, String> queryParamsMap,
+ OnMQTopicCreatedListener onTopicCreatedListener,
+ QualityOfService qualityOfService) throws OcException {
+
+ if (qualityOfService == null) {
+ throw new OcException(ErrorCode.INVALID_PARAM, "qualityOfService cannot be null");
+ }
+
+ this.createMQTopicImpl(ocRepresentation, uri, queryParamsMap,
+ onTopicCreatedListener, qualityOfService.getValue());
+ }
+
+ private synchronized native void createMQTopicImpl(
+ OcRepresentation ocRepresentation,
+ String uri,
+ Map<String, String> queryParamsMap,
+ OnMQTopicCreatedListener onTopicCreatedListener,
+ int qualityOfService) throws OcException;
+
+ /**
+ * Method to set subscribe on the Topic.
+ *
+ * @param queryParamsMap map which can have the query parameter name and value.
+ * @param onObserveListener event handler The handler method will be invoked with a map
+ * of attribute name and values.
+ * @param qualityOfService the quality of communication.
+ * @throws OcException
+ */
+ public void subscribeMQTopic(Map<String, String> queryParamsMap,
+ OnObserveListener onObserveListener,
+ QualityOfService qualityOfService) throws OcException {
+
+ if (qualityOfService == null) {
+ throw new OcException(ErrorCode.INVALID_PARAM, "qualityOfService cannot be null");
+ }
+
+ this.subscribeMQTopicImpl(queryParamsMap,
+ onObserveListener,
+ qualityOfService.getValue());
+ }
+
+ private synchronized native void subscribeMQTopicImpl(Map<String, String> queryParamsMap,
+ OnObserveListener onObserveListener,
+ int qualityOfService) throws OcException;
+
+ /**
+ * Method to cancel the observation on the Topic.
+ *
+ * @param qualityOfService the quality of communication.
+ * @throws OcException
+ */
+ public void unsubscribeMQTopic(QualityOfService qualityOfService) throws OcException{
+
+ if (qualityOfService == null) {
+ throw new OcException(ErrorCode.INVALID_PARAM, "qualityOfService cannot be null");
+ }
+
+ this.unsubscribeMQTopicImpl(qualityOfService.getValue());
+ }
+
+ private native void unsubscribeMQTopicImpl(
+ int qualityOfService) throws OcException;
+
+ /**
+ * Method to requestMQPublish on a Topic
+ *
+ * @param queryParamsMap Map which can have the query parameter name and value
+ * @param onPostListener event handler The event handler will be invoked with a map of
+ * attribute name and values.
+ * @param qualityOfService the quality of communication.
+ * @throws OcException
+ */
+ public void requestMQPublish(Map<String, String> queryParamsMap,
+ OnPostListener onPostListener,
+ QualityOfService qualityOfService) throws OcException {
+
+ if (qualityOfService == null) {
+ throw new OcException(ErrorCode.INVALID_PARAM, "qualityOfService cannot be null");
+ }
+
+ this.requestMQPublishImpl(queryParamsMap,
+ onPostListener,
+ qualityOfService.getValue());
+ }
+
+ private native void requestMQPublishImpl(Map<String, String> queryParamsMap,
+ OnPostListener onPostListener,
+ int qualityOfService) throws OcException;
+
+ /**
+ * Method to publishMQTopic on a Topic
+ *
+ * @param ocRepresentation representation of the resource
+ * @param queryParamsMap Map which can have the query parameter name and value
+ * @param onPostListener event handler The event handler will be invoked with a map of
+ * attribute name and values.
+ * @param qualityOfService the quality of communication.
+ * @throws OcException
+ */
+ public void publishMQTopic(OcRepresentation ocRepresentation,
+ Map<String, String> queryParamsMap,
+ OnPostListener onPostListener,
+ QualityOfService qualityOfService) throws OcException {
+
+ if (qualityOfService == null) {
+ throw new OcException(ErrorCode.INVALID_PARAM, "qualityOfService cannot be null");
+ }
+
+ this.publishMQTopicImpl(ocRepresentation,
+ queryParamsMap,
+ onPostListener,
+ qualityOfService.getValue());
+ }
+
+ private native void publishMQTopicImpl(OcRepresentation ocRepresentation,
+ Map<String, String> queryParamsMap,
+ OnPostListener onPostListener,
+ int qualityOfService) throws OcException;
+
+ /**
+ * An OnMQTopicFoundListener can be registered via the OcResource.discoveryMQTopics call.
+ * Event listeners are notified asynchronously
+ */
+ public interface OnMQTopicFoundListener {
+ public void onTopicDiscoveried(OcResource resource);
+ public void onDiscoveryTopicFailed(Throwable ex, String uri);
+ }
+
+ /**
+ * An OnMQTopicCreatedListener can be registered via the OcResource.createMQTopic call.
+ * Event listeners are notified asynchronously
+ */
+ public interface OnMQTopicCreatedListener {
+ public void onTopicResourceCreated(OcResource resource);
+ public void onCreateTopicFailed(Throwable ex, String uri);
+ }
+
+ /**
+ * An OnMQTopicSubscribeListener can be registered via the OcResource.subscribeMQTopic call.
+ * Event listeners are notified asynchronously
+ */
+ public interface OnMQTopicSubscribeListener {
+ /**
+ * To Subscriber.
+ */
+ public static final int SUBSCRIBER = 0;
+ /**
+ * To Unrubscriber.
+ */
+ public static final int UNSUBSCRIBER = 1;
+ /**
+ * Others.
+ */
+ public static final int NO_OPTION = 2;
+ public void onSubScribeCompleted(List<OcHeaderOption> headerOptionList,
+ OcRepresentation ocRepresentation,
+ int sequenceNumber);
+ public void onUnsubScribeCompleted(OcRepresentation ocRepresentation,
+ int sequenceNumber);
+ public void onSubScribeFailed(Throwable ex);
+ }
}