Search in sources :

Example 1 with NotImplementedException

use of sun.reflect.generics.reflectiveObjects.NotImplementedException in project azure-iot-sdk-java by Azure.

the class DeviceTwin method updateDesiredProperties.

/**
     * This method updates desired properties for the specified device.
     *
     * @param device The device with a valid id for which desired properties is to be updated.
     * @throws IOException This exception is thrown if the IO operation failed
     * @throws IotHubException This exception is thrown if the response verification failed
     */
public void updateDesiredProperties(DeviceTwinDevice device) throws IotHubException, IOException {
    if (device == null || device.getDeviceId() == null || device.getDeviceId().length() == 0) {
        /*
            **Codes_SRS_DEVICETWIN_25_021: [** The function shall throw IllegalArgumentException if the input device is null or if deviceId is null or empty **]**
             */
        throw new IllegalArgumentException("Instantiate a device and set device id to be used");
    }
    if (device.getDesiredMap() == null) {
        throw new IllegalArgumentException("Set desired properties for the device to be updated with");
    }
    /*
        **Codes_SRS_DEVICETWIN_25_022: [** The function shall build the URL for this operation by calling getUrlTwinDesired **]**
         */
    URL url = this.iotHubConnectionString.getUrlTwinDesired(device.getDeviceId());
    /*
        **Codes_SRS_DEVICETWIN_25_023: [** The function shall serialize the desired properties map by calling updateDesiredProperty Api on the twin object for the device provided by the user**]**
         */
    String desiredJson = device.getTwinParser().updateDesiredProperty(device.getDesiredMap());
    if (desiredJson == null) {
        return;
    }
    // Currently this is not supported by service - Please use Update twin to update desired properties
    throw new NotImplementedException();
/*
        **Codes_SRS_DEVICETWIN_25_024: [** The function shall create a new SAS token **]**

        **Codes_SRS_DEVICETWIN_25_025: [** The function shall create a new HttpRequest with http method as Patch **]**

        **Codes_SRS_DEVICETWIN_25_026: [** The function shall set the following HTTP headers specified in the IotHub DeviceTwin doc.
                                                1. Key as authorization with value as sastoken
                                                2. Key as request id with a new string value for every request
                                                3. Key as User-Agent with value specified by the clientIdentifier and its version
                                                4. Key as Accept with value as application/json
                                                5. Key as Content-Type and value as application/json
                                                6. Key as charset and value as utf-8
                                                7. Key as If-Match and value as '*'  **]**

        **Codes_SRS_DEVICETWIN_25_027: [** The function shall send the created request and get the response **]**

        **Codes_SRS_DEVICETWIN_25_028: [** The function shall verify the response status and throw proper Exception **]**
         */
/*
        HttpResponse response = this.processHttpTwinRequest(url, HttpMethod.PATCH, desiredJson.getBytes(), String.valueOf(requestId++));
        */
}
Also used : NotImplementedException(sun.reflect.generics.reflectiveObjects.NotImplementedException) IotHubConnectionString(com.microsoft.azure.sdk.iot.service.IotHubConnectionString) URL(java.net.URL)

Example 2 with NotImplementedException

use of sun.reflect.generics.reflectiveObjects.NotImplementedException in project divide by HiddenStage.

the class ObjectifyDAO method query.

@Override
public List<TransientObject> query(Query query) throws DAOException {
    logger.info("query: " + query);
    LoadType<?> filter = ofy().load().type(OfyObject.class);
    com.googlecode.objectify.cmd.Query<?> oFilter = filter.filter(TransientObject.META_DATA + "." + TransientObject.OBJECT_TYPE_KEY.KEY + " =", query.getFrom());
    for (Clause c : query.getWhere().values()) {
        oFilter = oFilter.filter(c.getBefore() + " " + // replace CONTAINS with ==
        (c.getOperand().equals(OPERAND.CONTAINS.toString()) ? OPERAND.EQ.toString() : c.getOperand()), c.getAfter());
    }
    if (query.getOffset() != null) {
        oFilter = oFilter.offset(query.getOffset());
    }
    if (query.getLimit() != null) {
        oFilter = oFilter.limit(query.getLimit());
    }
    if (query.getRandom() != null) {
        int count = count(query.getFrom());
        if (count < 1)
            return new ArrayList<TransientObject>();
        int random = RANDOM.nextInt(count);
        oFilter = oFilter.offset(random);
        oFilter = oFilter.limit(query.getLimit());
    }
    List list = null;
    switch(query.getAction()) {
        case SELECT:
            {
                if (query.getSelect() == null) {
                    list = oFilter.list();
                    List<TransientObject> toReturn = new ArrayList<TransientObject>(list.size());
                    try {
                        for (OfyObject oo : (List<OfyObject>) list) {
                            logger.info("Got: " + oo);
                            toReturn.add(BackendToOfy.getBack(oo));
                        }
                    } catch (Exception e) {
                        throw new DAOException(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e);
                    }
                    list.clear();
                    list = toReturn;
                } else if (query.getSelect().equals(SelectOperation.COUNT)) {
                    int count = count(query.getFrom());
                    return Arrays.asList((TransientObject) new Count(count, query.getFrom()));
                }
            }
            break;
        case DELETE:
            {
                list = oFilter.keys().list();
                ofy().delete().keys(list);
                int count = list.size();
                list.clear();
                EmptyTO o = new EmptyTO();
                o.put("count", count);
                list.add(o);
            }
            break;
        case UPDATE:
            {
                throw new NotImplementedException();
            }
    }
    logger.info("Query Complete: " + list);
    return (List<TransientObject>) list;
}
Also used : NotImplementedException(sun.reflect.generics.reflectiveObjects.NotImplementedException) NotImplementedException(sun.reflect.generics.reflectiveObjects.NotImplementedException) TransientObject(io.divide.shared.transitory.TransientObject)

Example 3 with NotImplementedException

use of sun.reflect.generics.reflectiveObjects.NotImplementedException in project blueprints by tinkerpop.

the class RexsterElementIterable method iterator.

public Iterator<T> iterator() {
    return new Iterator<T>() {

        private final Queue<T> queue = new LinkedList<T>();

        private int start = 0;

        private int end = graph.getBufferSize();

        public boolean hasNext() {
            if (!queue.isEmpty())
                return true;
            else {
                if (end > start) {
                    // last buffer if start == end
                    fillBuffer(queue, start, end);
                    this.update();
                }
                return !queue.isEmpty();
            }
        }

        public void remove() {
            throw new NotImplementedException();
        }

        public T next() {
            if (!queue.isEmpty()) {
                return queue.remove();
            } else {
                if (end > start) {
                    // last buffer if start == end
                    fillBuffer(queue, start, end);
                    this.update();
                }
                if (!queue.isEmpty()) {
                    return queue.remove();
                } else
                    throw new NoSuchElementException();
            }
        }

        private void update() {
            final int bufferSize = graph.getBufferSize();
            if (this.queue.size() == bufferSize) {
                // next buffer if full
                this.start = this.start + bufferSize;
                this.end = this.end + bufferSize;
            } else {
                // last buffer
                this.start = this.end;
            }
        }
    };
}
Also used : NotImplementedException(sun.reflect.generics.reflectiveObjects.NotImplementedException) Iterator(java.util.Iterator) Queue(java.util.Queue) NoSuchElementException(java.util.NoSuchElementException)

Example 4 with NotImplementedException

use of sun.reflect.generics.reflectiveObjects.NotImplementedException in project azure-iot-sdk-java by Azure.

the class DeviceTwin method replaceDesiredProperties.

/**
     * This method replaces desired properties for the specified device. desired properties can be input
     * via device's setDesiredProperties method.
     *
     * @param device The device with a valid id for which device twin is to be updated.
     * @throws IOException This exception is thrown if the IO operation failed
     * @throws IotHubException This exception is thrown if the response verification failed
     */
public void replaceDesiredProperties(DeviceTwinDevice device) throws IotHubException, IOException {
    if (device == null || device.getDeviceId() == null || device.getDeviceId().length() == 0) {
        /*
            **Codes_SRS_DEVICETWIN_25_029: [** The function shall throw IllegalArgumentException if the input device is null or if deviceId is null or empty **]**
             */
        throw new IllegalArgumentException("Instantiate a device and set device id to be used");
    }
    if (device.getDesiredMap() == null) {
        throw new IllegalArgumentException("Set desired properties fort he device to be replaced with");
    }
    /*
        **Codes_SRS_DEVICETWIN_25_030: [** The function shall build the URL for this operation by calling getUrlTwinDesired **]**
         */
    URL url = this.iotHubConnectionString.getUrlTwinDesired(device.getDeviceId());
    /*
        **Codes_SRS_DEVICETWIN_25_031: [** The function shall serialize the desired properties map by calling resetDesiredProperty Api on the twin object for the device provided by the user**]**
         */
    String tags = device.getTwinParser().resetDesiredProperty(device.getDesiredMap());
    if (tags == null || tags.length() == 0) {
        /*
             *Codes_SRS_DEVICETWIN_25_045: [** If resetDesiredProperty call returns null or empty string then this method shall throw IOException**]**
             */
        throw new IOException("Serializer cannot return null or empty string");
    }
    throw new NotImplementedException();
/*
        **Codes_SRS_DEVICETWIN_25_032: [** The function shall create a new SAS token **]**
        **Codes_SRS_DEVICETWIN_25_033: [** The function shall create a new HttpRequest with http method as PUT **]**

        **Codes_SRS_DEVICETWIN_25_034: [** The function shall set the following HTTP headers specified in the IotHub DeviceTwin doc.
                                                1. Key as authorization with value as sastoken
                                                2. Key as request id with a new string value for every request
                                                3. Key as User-Agent with value specified by the clientIdentifier and its version
                                                4. Key as Accept with value as application/json
                                                5. Key as Content-Type and value as application/json
                                                6. Key as charset and value as utf-8
                                                7. Key as If-Match and value as '*'  **]**

        **Codes_SRS_DEVICETWIN_25_035: [** The function shall send the created request and get the response **]**

        **Codes_SRS_DEVICETWIN_25_036: [** The function shall verify the response status and throw proper Exception **]**
         */
// Currently not implemented on service
// HttpResponse response = this.processHttpTwinRequest(url, HttpMethod.PUT, tags.getBytes(), String.valueOf(requestId++));
}
Also used : NotImplementedException(sun.reflect.generics.reflectiveObjects.NotImplementedException) IotHubConnectionString(com.microsoft.azure.sdk.iot.service.IotHubConnectionString) IOException(java.io.IOException) URL(java.net.URL)

Example 5 with NotImplementedException

use of sun.reflect.generics.reflectiveObjects.NotImplementedException in project azure-iot-sdk-java by Azure.

the class DeviceTwin method replaceTags.

/**
     * This method replaces tags for the specified device. Tags can be input
     * via device's setTags method.
     *
     * @param device The device with a valid id for which device twin is to be updated.
     * @throws IOException This exception is thrown if the IO operation failed
     * @throws IotHubException This exception is thrown if the response verification failed
     */
public void replaceTags(DeviceTwinDevice device) throws IotHubException, IOException {
    if (device == null || device.getDeviceId() == null || device.getDeviceId().length() == 0) {
        /*
             * Codes_SRS_DEVICETWIN_25_037: [** The function shall throw IllegalArgumentException if the input device is null or if deviceId is null or empty **]**
             */
        throw new IllegalArgumentException("Instantiate a device and set device id to be used");
    }
    if (device.getTagsMap() == null) {
        throw new IllegalArgumentException("Set tags to be replaced with");
    }
    /*
        **Codes_SRS_DEVICETWIN_25_038: [** The function shall build the URL for this operation by calling getUrlTwinTags **]**
         */
    URL url = this.iotHubConnectionString.getUrlTwinTags(device.getDeviceId());
    /*
        **Codes_SRS_DEVICETWIN_25_039: [** The function shall serialize the tags map by calling resetTags Api on the twin object for the device provided by the user**]**
         */
    String tags = device.getTwinParser().resetTags(device.getTagsMap());
    if (tags == null || tags.length() == 0) {
        /*
             **Codes_SRS_DEVICETWIN_25_046: [** If resetTags call returns null or empty string then this method shall throw IOException**]**
             */
        throw new IOException("Serializer cannot return null or empty");
    }
    /*
        **Codes_SRS_DEVICETWIN_25_040: [** The function shall create a new SAS token **]**

        **Codes_SRS_DEVICETWIN_25_041: [** The function shall create a new HttpRequest with http method as PUT **]**

        **Codes_SRS_DEVICETWIN_25_042: [** The function shall set the following HTTP headers specified in the IotHub DeviceTwin doc.
                                                1. Key as authorization with value as sastoken
                                                2. Key as request id with a new string value for every request
                                                3. Key as User-Agent with value specified by the clientIdentifier and its version
                                                4. Key as Accept with value as application/json
                                                5. Key as Content-Type and value as application/json
                                                6. Key as charset and value as utf-8
                                                7. Key as If-Match and value as '*'  **]**

        **Codes_SRS_DEVICETWIN_25_043: [** The function shall send the created request and get the response **]**

        **Codes_SRS_DEVICETWIN_25_044: [** The function shall verify the response status and throw proper Exception **]**

         */
    throw new NotImplementedException();
// Currently not implemented on service
// HttpResponse response = this.processHttpTwinRequest(url, HttpMethod.PUT, tags.getBytes(), String.valueOf(requestId++));
}
Also used : NotImplementedException(sun.reflect.generics.reflectiveObjects.NotImplementedException) IotHubConnectionString(com.microsoft.azure.sdk.iot.service.IotHubConnectionString) IOException(java.io.IOException) URL(java.net.URL)

Aggregations

NotImplementedException (sun.reflect.generics.reflectiveObjects.NotImplementedException)6 IotHubConnectionString (com.microsoft.azure.sdk.iot.service.IotHubConnectionString)3 URL (java.net.URL)3 IOException (java.io.IOException)2 Array (com.badlogic.gdx.utils.Array)1 TransientObject (io.divide.shared.transitory.TransientObject)1 Field (java.lang.reflect.Field)1 Iterator (java.util.Iterator)1 NoSuchElementException (java.util.NoSuchElementException)1 Queue (java.util.Queue)1