Examples of TranslatableJsonException


Examples of com.serotonin.m2m2.i18n.TranslatableJsonException

        String text = jsonObject.getString("outputScale");
        if (text != null) {
            outputScale = OUTPUT_SCALE_CODES.getId(text);
            if (outputScale == -1)
                throw new TranslatableJsonException("emport.error.invalid", "outputScale", text,
                        OUTPUT_SCALE_CODES.getCodeList());
        }
    }
View Full Code Here

Examples of com.serotonin.m2m2.i18n.TranslatableJsonException

    @Override
    public void jsonRead(JsonReader reader, JsonObject jsonObject) throws JsonException {
        String text = jsonObject.getString("attributeId");
        if (text == null)
            throw new TranslatableJsonException("emport.error.missing", "attributeId", ATTRIBUTE_CODES.getCodeList());
        attributeId = ATTRIBUTE_CODES.getId(text);
        if (!ATTRIBUTE_CODES.isValidId(attributeId))
            throw new TranslatableJsonException("emport.error.invalid", "attributeId", text,
                    ATTRIBUTE_CODES.getCodeList());
    }
View Full Code Here

Examples of com.serotonin.m2m2.i18n.TranslatableJsonException

    if (value != null)
      dataTypeId = value;

    JsonObject ctjson = jsonObject.getJsonObject("changeType");
    if (ctjson == null)
      throw new TranslatableJsonException("emport.error.missingObject",
          "changeType");

    String text = ctjson.getString("type");
    if (text == null)
      throw new TranslatableJsonException("emport.error.missing", "type",
          ChangeTypeVO.CHANGE_TYPE_CODES.getCodeList());

    changeTypeId = ChangeTypeVO.CHANGE_TYPE_CODES.getId(text);
    if (changeTypeId == -1)
      throw new TranslatableJsonException("emport.error.invalid",
          "changeType", text,
          ChangeTypeVO.CHANGE_TYPE_CODES.getCodeList());

    reader.readInto(getChangeType(), ctjson);
  }
View Full Code Here

Examples of com.serotonin.m2m2.i18n.TranslatableJsonException

    public void jsonRead(JsonReader reader, JsonObject jsonObject) throws JsonException {
        String text = jsonObject.getString("alarmLevel");
        if (text != null) {
            alarmLevel = AlarmLevels.CODES.getId(text);
            if (!AlarmLevels.CODES.isValidId(alarmLevel))
                throw new TranslatableJsonException("emport.error.scheduledEvent.invalid", "alarmLevel", text,
                        AlarmLevels.CODES.getCodeList());
        }

        text = jsonObject.getString("scheduleType");
        if (text != null) {
            scheduleType = TYPE_CODES.getId(text);
            if (!TYPE_CODES.isValidId(scheduleType))
                throw new TranslatableJsonException("emport.error.scheduledEvent.invalid", "scheduleType", text,
                        TYPE_CODES.getCodeList());
        }
    }
View Full Code Here

Examples of com.serotonin.m2m2.i18n.TranslatableJsonException

   
    String text = jsonObject.getString("includeEvents");
    if(text != null){
      includeEvents = EVENT_CODES.getId(text);
      if(includeEvents == -1)
        throw new TranslatableJsonException("emport.error.invalid",
            "includeEvents", text,
            EVENT_CODES.getCodeList());
    }
   
    text = jsonObject.getString("dateRangeType");
    if(text != null){
      dateRangeType = DATE_RANGE_TYPES.getId(text);
      if(dateRangeType == -1)
        throw new TranslatableJsonException("emport.error.invalid",
            "dateRangeType", text,
            DATE_RANGE_TYPES.getCodeList());
    }
   
    if(dateRangeType == DATE_RANGE_TYPE_RELATIVE){
      text = jsonObject.getString("relativeDateType");
      if(text != null){
        relativeDateType = DATE_RELATIVE_TYPES.getId(text);
        if(relativeDateType == -1)
          throw new TranslatableJsonException("emport.error.invalid",
              "relativeDateType", text,
              DATE_RELATIVE_TYPES.getCodeList());
      }
   
      if(relativeDateType == RELATIVE_DATE_TYPE_PREVIOUS ){
        text = jsonObject.getString("previousPeriodType");
        if(text != null){
          previousPeriodType = Common.TIME_PERIOD_CODES.getId(text);
          if(previousPeriodType == -1)
            throw new TranslatableJsonException("emport.error.invalid",
                "previousPeriodType", text,
                Common.TIME_PERIOD_CODES.getCodeList());
          previousPeriodCount = jsonObject.getInt("previousPeriods");
        }
      }else if(relativeDateType == RELATIVE_DATE_TYPE_PREVIOUS){
        text = jsonObject.getString("pastPeriodType");
        if(text != null){
          pastPeriodType = Common.TIME_PERIOD_CODES.getId(text);
          if(pastPeriodType == -1)
            throw new TranslatableJsonException("emport.error.invalid",
                "pastPeriodType", text,
                Common.TIME_PERIOD_CODES.getCodeList());
          pastPeriodCount = jsonObject.getInt("pastPeriods");
        }
      }
    }else if(dateRangeType == DATE_RANGE_TYPE_SPECIFIC){
      fromNone = jsonObject.getBoolean("fromInception");
      if(!fromNone){
        fromYear = jsonObject.getInt("fromYear");
        fromMonth = jsonObject.getInt("fromMonth");
        fromDay = jsonObject.getInt("fromDay");
        fromHour = jsonObject.getInt("fromHour");
        fromMinute = jsonObject.getInt("fromMinute");
       
      }
      toNone = jsonObject.getBoolean("toLatest");
      if(!toNone){
        toYear = jsonObject.getInt("toYear");
        toMonth = jsonObject.getInt("toMonth");
        toDay = jsonObject.getInt("toDay");
        toHour = jsonObject.getInt("toHour");
        toMinute = jsonObject.getInt("toMinute");
      }
    }
   
    schedule = jsonObject.getBoolean("schedule");
    if(schedule){
      text = jsonObject.getString("schedulePeriod");
      if(text != null){
        schedulePeriod = SCHEDULE_CODES.getId(text);
        if(schedulePeriod == -1)
          throw new TranslatableJsonException("emport.error.invalid",
              "schedulePeriod", text,
              SCHEDULE_CODES.getCodeList());
        if(schedulePeriod == SCHEDULE_CRON){
          scheduleCron = jsonObject.getString("scheduleCron");
          try {
                      new CronTimerTrigger(scheduleCron);
                  }catch (ParseException e) {
                    throw new TranslatableJsonException("emport.error.invalid",
                "scheduleCron", scheduleCron,
                "cron expressions");
                  }
        }
      }else{
        throw new TranslatableJsonException("emport.error.invalid",
            "schedulePeriod", "null",
            SCHEDULE_CODES.getCodeList());
      }
    }
   
    email = jsonObject.getBoolean("email");
    if(email){
     
      JsonArray recipientsArray = jsonObject.getJsonArray("recipients");
      boolean add = true;
      if(recipientsArray != null){
        for(JsonValue jv : recipientsArray){
          RecipientListEntryBean recipient = new RecipientListEntryBean();
          reader.readInto(recipient, jv);
          for(RecipientListEntryBean existing : recipients){
            if(existing.equals(recipient)){
              reader.readInto(existing, jv);
              add = false;
              break;
            }
          }
          if(add){
            recipients.add(recipient);
          }else{
            add = true;
          }
        }
      }else{
        throw new TranslatableJsonException("emport.error.invalid",
            "recipients", "null",
            "valid users, email addresses or mailing lists");
      }
     
      includeData = jsonObject.getBoolean("includeData");
View Full Code Here

Examples of com.serotonin.m2m2.i18n.TranslatableJsonException

        super.jsonRead(reader, jsonObject);
        String text = jsonObject.getString("attractionPointId");
        if (text != null) {
            DataPointVO dp = new DataPointDao().getDataPoint(text);
            if (dp == null)
                throw new TranslatableJsonException("virtual.error.attractor.missingPoint", "attractionPointId", text);
            attractionPointId = dp.getId();
        }
    }
View Full Code Here

Examples of com.serotonin.m2m2.i18n.TranslatableJsonException

  @Override
  public void jsonRead(JsonReader reader, JsonObject jsonObject) throws JsonException {
   
    String text = jsonObject.getString("pointXid");
    if(text == null){
      throw new TranslatableJsonException("reports.emport.point.missingAttr", "pointXid");
    }else{
      DataPointVO vo = DataPointDao.instance.getByXid(text);
      if(vo == null){
        throw new TranslatableJsonException("reports.emport.pointDNE", text);
      }
      this.pointId = vo.getId();
    }
   
  }
View Full Code Here

Examples of com.serotonin.m2m2.i18n.TranslatableJsonException

    protected void jsonReadDataPoint(JsonValue jsonXid, PointComponent comp) throws JsonException {
        if (jsonXid != null) {
            String xid = jsonXid.toString();
            DataPointVO dataPoint = new DataPointDao().getDataPoint(xid);
            if (dataPoint == null)
                throw new TranslatableJsonException("emport.error.missingPoint", xid);
            if (!comp.definition().supports(dataPoint.getPointLocator().getDataTypeId()))
                throw new TranslatableJsonException("emport.error.component.incompatibleDataType", xid, definition()
                        .getExportName());
            comp.tsetDataPoint(dataPoint);
        }
    }
View Full Code Here

Examples of com.serotonin.m2m2.i18n.TranslatableJsonException

        public Type resolve(JsonValue jsonValue) throws JsonException {
            JsonObject json = jsonValue.toJsonObject();

            String type = json.getString("type");
            if (type == null)
                throw new TranslatableJsonException("emport.error.component.missing", "type", getExportTypes());

            ImplDefinition def = ImplDefinition.findByExportName(getImplementations(), type);

            if (def == null)
                throw new TranslatableJsonException("emport.error.text.invalid", "type", type, getExportTypes());

            return resolveClass(def);
        }
View Full Code Here

Examples of com.serotonin.m2m2.i18n.TranslatableJsonException

    @Override
    public void jsonRead(JsonReader reader, JsonObject jsonObject) throws JsonException {
        if (isNew()) {
            String username = jsonObject.getString("user");
            if (StringUtils.isBlank(username))
                throw new TranslatableJsonException("emport.error.missingValue", "user");
            User user = new UserDao().getUser(username);
            if (user == null)
                throw new TranslatableJsonException("emport.error.missingUser", username);
            userId = user.getId();
        }

        JsonArray components = jsonObject.getJsonArray("viewComponents");
        if (components != null) {
            viewComponents.clear();
            for (JsonValue jv : components)
                addViewComponent(reader.read(ViewComponent.class, jv));
        }

        String text = jsonObject.getString("anonymousAccess");
        if (text != null) {
            anonymousAccess = ShareUser.ACCESS_CODES.getId(text);
            if (anonymousAccess == -1)
                throw new TranslatableJsonException("emport.error.invalid", "anonymousAccess", text,
                        ShareUser.ACCESS_CODES.getCodeList());
        }

        JsonArray jsonSharers = jsonObject.getJsonArray("sharingUsers");
        if (jsonSharers != null) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.