Пример #1
0
  public void createResources() throws XBeeException {
    sensorResource = new SensorResource();
    periodicReportResource = new PeriodicReportResource();
    alarmResource = new AlarmResource();

    String targetId, content;
    targetId = sclId + "/applications";
    ResponseConfirm responseConfirm =
        core.doRequest(
            new RequestIndication("CREATE", targetId, reqEntity, new Application(appID, ipuId)));
    if (responseConfirm.getStatusCode().equals(StatusCode.STATUS_CREATED)) {
      targetId = sclId + "/applications/" + appID + "/containers";
      // create resources container
      core.doRequest(
          new RequestIndication(
              "CREATE", targetId, reqEntity, new Container("ReportDataContainer")));

      // create descriptors containter
      core.doRequest(
          new RequestIndication(
              "CREATE", targetId, reqEntity, new Container("ReportDataDescriptor")));

      // create resources container
      content = Mapper.getResourcesRep(sclId, appID, ipuId);
      targetId =
          sclId + "/applications/" + appID + "/containers/ReportDataDescriptor/contentInstances";
      core.doRequest(
          new RequestIndication(
              "CREATE", targetId, reqEntity, new ContentInstance(content.getBytes())));
    }

    targetId = sclId + "/applications";
    ResponseConfirm responseConfirm1 =
        core.doRequest(
            new RequestIndication("CREATE", targetId, reqEntity, new Application(appID2, ipuId)));
    if (responseConfirm1.getStatusCode().equals(StatusCode.STATUS_CREATED)) {
      targetId = sclId + "/applications/" + appID2 + "/containers";
      // create resources container
      core.doRequest(
          new RequestIndication(
              "CREATE", targetId, reqEntity, new Container("AlarmDataContainer")));

      // create descriptors containter
      core.doRequest(
          new RequestIndication(
              "CREATE", targetId, reqEntity, new Container("AlarmDataDescriptor")));

      targetId =
          sclId + "/applications/" + appID2 + "/containers/AlarmDataDescriptor/contentInstances";
      content = Mapper.getAlarmDataDescriptorRep(sclId, appID2, ipuId);
      core.doRequest(
          new RequestIndication(
              "CREATE", targetId, reqEntity, new ContentInstance(content.getBytes())));
    }
  }