Package com.cumulocity.me.sdk

Examples of com.cumulocity.me.sdk.SDKException


            String tenantId = System.getProperty(CUMULOCITY_TENANT);
            String user = System.getProperty(CUMULOCITY_USER);
            String password = System.getProperty(CUMULOCITY_PASSWORD);
            String applicationKey = System.getProperty(CUMOLOCITY_APPLICATION_KEY);
            if (host == null || tenantId == null || user == null || password == null) {
                throw new SDKException("Cannot Create Platform as Mandatory Param are not set");
            }
            if (System.getProperty(CUMULOCITY_PAGE_SIZE) != null) {
                int pageSize = Integer.parseInt(System.getProperty(CUMULOCITY_PAGE_SIZE));
                platform = new PlatformImpl(host, port, tenantId, user, password, applicationKey, pageSize);
            } else {
                platform = new PlatformImpl(host, port, tenantId, user, password, applicationKey);
            }
            String proxyHost = System.getProperty(CUMOLOCITY_PROXY_HOST);
            int proxyPort = -1;
            if (System.getProperty(CUMULOCITY_PROXY_PORT) != null) {
                proxyPort = Integer.parseInt(System.getProperty(CUMULOCITY_PROXY_PORT));
            }
            String proxyUser = System.getProperty(CUMULOCITY_PROXY_USER);
            String proxyPassword = System.getProperty(CUMULOCITY_PROXY_PASSWORD);

            if (proxyHost != null && proxyPort > 0) {
                platform.setProxyHost(proxyHost);
                platform.setProxyPort(proxyPort);
            }

            if (proxyUser != null && proxyPassword != null) {
                platform.setProxyUserId(proxyUser);
                platform.setProxyPassword(proxyPassword);
            }
        } catch (NumberFormatException e) {
            throw new SDKException("Invalid Number :" + e.getMessage());
        }

        return platform;
    }
View Full Code Here


        identityRepresentation = platformApiRepresentation.getIdentity();
    }

    public ExternalIDRepresentation getExternalId(ID extId) throws SDKException {
        if (extId == null || extId.getValue() == null || extId.getType() == null) {
            throw new SDKException("XtId without value/type or null");
        }

        Map filter = new HashMap();
        filter.put(TYPE, extId.getType());
        filter.put(EXTERNAL_ID, extId.getValue());
View Full Code Here

        restConnector.delete(extIdUrl);
    }

    public PagedCollectionResource getExternalIdsOfGlobalId(GId gid) throws SDKException {
        if (gid == null || gid.getValue() == null) {
            throw new SDKException("Cannot determine global id value");
        }

        Map filter = new HashMap();
        filter.put(GLOBAL_ID, gid.getValue());
        String uri = templateUrlParser.replacePlaceholdersWithParams(getIdentityRepresentation().getExternalIdsOfGlobalId(), filter);
View Full Code Here

        return new ExternalIDCollectionImpl(restConnector, uri, pageSize);
    }

    public ExternalIDRepresentation create(ExternalIDRepresentation representation) throws SDKException {
        if (representation == null || representation.getManagedObject() == null || representation.getManagedObject().getId() == null) {
            throw new SDKException("Cannot determine global id value");
        }

        Map filter = new HashMap();
        filter.put(GLOBAL_ID, representation.getManagedObject().getId().getValue());
        String path = templateUrlParser.replacePlaceholdersWithParams(getIdentityRepresentation().getExternalIdsOfGlobalId(), filter);
View Full Code Here

            return null;
        }
        try {
            return new String(data, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            throw new SDKException("UTF-8 is unpuspported!", e);
        }
    }
View Full Code Here

                }
            } while (true);

            return data;
        } catch (IOException e) {
            throw new SDKException("I/O error!", e);
        } catch (InterruptedException e) {
            throw new SDKException("Interrupted!", e);
        } finally {
            if (bytesCount < inputLength) {
                throw new SDKException("Received only " + bytesCount + " of " + inputLength + " expected bytes!");
            }
        }
    }
View Full Code Here

            return;
        }
        try {
            output.write(input);
        } catch (IOException e) {
            throw new SDKException("I/O error!", e);
        }
    }
View Full Code Here

  }

  private String createChildDevicePath(ManagedObjectRepresentation managedObjectRepresentation) {
    if (managedObjectRepresentation == null || managedObjectRepresentation.getChildDevices() == null) {
      throw new SDKException("Unable to get the child device URL");
    }

    return managedObjectRepresentation.getChildDevices().getSelf();

  }
View Full Code Here

        InventoryMediaType.MANAGED_OBJECT_REFERENCE, refrenceReprsentation);
  }

  private String createChildAssetPath(ManagedObjectRepresentation managedObjectRepresentation) {
    if (managedObjectRepresentation == null || managedObjectRepresentation.getChildAssets() == null) {
      throw new SDKException("Unable to get the child device URL");
    }
    return managedObjectRepresentation.getChildAssets().getSelf();
  }
View Full Code Here

        return (ManagedObjectRepresentation) restConnector.post(getSelfUri(), InventoryMediaType.MANAGED_OBJECT, representation);
    }

    public ManagedObject getManagedObject(GId globalId) {
        if ((globalId == null) || (globalId.getValue() == null)) {
            throw new SDKException("Cannot determine the Global ID Value");
        }
        String url = StringUtils.ensureTail(getSelfUri(), "/") + globalId.getValue();
        return new ManagedObjectImpl(restConnector, url, pageSize);
    }
View Full Code Here

TOP

Related Classes of com.cumulocity.me.sdk.SDKException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.