当前位置: 首页>>代码示例>>Java>>正文


Java ExceptionClass.INVALID属性代码示例

本文整理汇总了Java中com.vangav.backend.exceptions.VangavException.ExceptionClass.INVALID属性的典型用法代码示例。如果您正苦于以下问题:Java ExceptionClass.INVALID属性的具体用法?Java ExceptionClass.INVALID怎么用?Java ExceptionClass.INVALID使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.vangav.backend.exceptions.VangavException.ExceptionClass的用法示例。


在下文中一共展示了ExceptionClass.INVALID属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: Period

/**
 * Constructor Period
 * @param value: number of units (e.g.: 5 seconds)
 * @param unit: e.g.: second, hour, week, etc ...
 * @return new Period Object
 * @throws Exception
 */
public Period (
  double value,
  TimeUnitType unit) {
  
  if (value < 0.0) {
    
    throw new CodeException(
      122,
      5,
      "Period value ["
      + value
      + "] can't be negative",
      ExceptionClass.INVALID);
  }
  
  this.value = value;
  this.unit = unit;
}
 
开发者ID:vangav,项目名称:vos_backend,代码行数:25,代码来源:Period.java

示例2: setValue

/**
 * setValue
 * @param value
 */
public void setValue (double value) {
  
  if (value < 0.0) {
    
    throw new CodeException(
      122,
      6,
      "Period value ["
      + value
      + "] can't be negative",
      ExceptionClass.INVALID);
  }
  
  this.value = value;
}
 
开发者ID:vangav,项目名称:vos_backend,代码行数:19,代码来源:Period.java

示例3: minus

/**
 * minus
 * @param value
 * @return a new Period Object with this Period's unit and
 *           new value = this value - param value
 * @throws Exception
 */
public Period minus (double value) throws Exception {
  
  if (value > this.value) {
    
    throw new CodeException(
      122,
      7,
      "Period minus operation will lead to a negative Period, that's an "
      + "invalid operation, minus value must be smaller than or equal to "
      + "current value. Current value ["
      + this.value
      + "] minus value ["
      + value
      + "].",
      ExceptionClass.INVALID);
  }
  
  return new Period(this.value - value, this.unit);
}
 
开发者ID:vangav,项目名称:vos_backend,代码行数:26,代码来源:Period.java

示例4: minus

/**
 * minus
 * @param value
 * @return a new Distance Object with this Distance's unit and
 *           new value = this value - param value
 * @throws Exception
 */
public Distance minus (double value) throws Exception {
  
  if (value > this.value) {
    
    throw new CodeException(
      122,
      1,
      "Distance minus operation will lead to a negative distance, that's an "
      + "invalid operation, minus value must be smaller than or equal to "
      + "current value. Current value ["
      + this.value
      + "] minus value ["
      + value
      + "].",
      ExceptionClass.INVALID);
  }
  
  return new Distance(this.value - value, this.unit);
}
 
开发者ID:vangav,项目名称:vos_backend,代码行数:26,代码来源:Distance.java

示例5: validate

@Override
@JsonIgnore
public void validate () throws Exception {

  this.validate(
    kClassPrefixName,
    this.class_prefix,
    ParamType.ALPHA_NUMERIC_DASH_UNDERSCORE,
    ParamOptionality.MANDATORY);
  this.validate(
    kActionIdName,
    this.action_id,
    ParamType.ALPHA_NUMERIC_DASH_UNDERSCORE,
    ParamOptionality.MANDATORY);

  // more validation
  if (ActionsManager.i().validateActionId(
        this.class_prefix,
        this.action_id) == false) {
    
    throw new BadRequestException(
      501,
      1,
      "Either or both of the class prefix ["
        + this.class_prefix
        + "] and the action id ["
        + this.action_id
        + "] are invalid",
      ExceptionClass.INVALID);
  }
}
 
开发者ID:vangav,项目名称:vos_vangav_analytics_writer,代码行数:31,代码来源:RequestRecordAction.java

示例6: UsersRank

/**
 * Constructor - UsersRank
 * @param initialCycle
 * @param copy - true if this is a copy construct and false otherwise
 * @return new UsersRank Object
 * @throws Exception
 */
private UsersRank (
  long initialCycle,
  boolean copy) throws Exception {
  
  super (
    "users_rank_" + initialCycle,
    PeriodicJob.Type.ASYNC,
    RoundedOffCalendarInl.getRoundedCalendar(
      RoundingType.PAST,
      RoundingFactor.MONTH),
    new Period(
      1.0,
      TimeUnitType.WEEK),
    new CycleTickerBuilder()
      .initialCycle(initialCycle)
      .cycleStep(kCycleStep)
      .build() );
  
  if (copy == false) {
  
    this.initialCycle = initialCycle;
    currInitialCycle += 1;
    
    if (currInitialCycle > 5) {
      
      throw new CodeException(
        500,
        1,
        "UsersRank periodic job is designed to run 4 times in parallel only, "
          + "trying to run it for the ["
          + (currInitialCycle - 1)
          + "] is invalid.",
        ExceptionClass.INVALID);
    }
  }
}
 
开发者ID:vangav,项目名称:vos_instagram_jobs,代码行数:43,代码来源:UsersRank.java

示例7: PostsRank

/**
 * Constructor - PostsRank
 * @param initialCycle
 * @param copy - true if this is a copy construct and false otherwise
 * @return new PostsRank Object
 * @throws Exception
 */
private PostsRank (
  long initialCycle,
  boolean copy) throws Exception {
  
  super (
    "posts_rank_" + initialCycle,
    PeriodicJob.Type.ASYNC,
    RoundedOffCalendarInl.getRoundedCalendar(
      RoundingType.PAST,
      RoundingFactor.DAY_OF_MONTH),
    new Period(
      1.0,
      TimeUnitType.DAY),
    new CycleTickerBuilder()
      .initialCycle(initialCycle)
      .cycleStep(kCycleStep)
      .build() );
  
  if (copy == false) {
  
    this.initialCycle = initialCycle;
    currInitialCycle += 1;
    
    if (currInitialCycle > 5) {
      
      throw new CodeException(
        500,
        1,
        "PostsRank periodic job is designed to run 4 times in parallel only, "
          + "trying to run it for the ["
          + (currInitialCycle - 1)
          + "] is invalid.",
        ExceptionClass.INVALID);
    }
  }
}
 
开发者ID:vangav,项目名称:vos_instagram_jobs,代码行数:43,代码来源:PostsRank.java

示例8: processRequest

@Override
protected void processRequest (final Request request) throws Exception {

  // use the following request Object to process the request and set
  //   the response to be returned
  RequestGetPostPhotoId requestGetPostPhotoId =
    (RequestGetPostPhotoId)request.getRequestJsonBody();
  
  // set/check post_id
  
  UUID postId = UUID.fromString(requestGetPostPhotoId.post_id);
  
  if (CheckersInl.postExists(postId) == false) {
    
    throw new BadRequestException(
      413,
      1,
      "Post with post_id ["
        + requestGetPostPhotoId.post_id
        + "] doesn't exist, request issued by user_id ["
        + requestGetPostPhotoId.user_id
        + "] from device_token ["
        + requestGetPostPhotoId.device_token
        +"]",
      ExceptionClass.INVALID);
  }
  
  // select post's photo_id from the database
  
  ResultSet resultSet =
    Posts.i().executeSyncSelectPhotoId(postId);
  
  String photoId =
    resultSet.one().getUUID(Posts.kPhotoIdColumnName).toString();
  
  // set response
  ((ResponseGetPostPhotoId)request.getResponseBody() ).set(
    requestGetPostPhotoId.request_tracking_id,
    photoId);
}
 
开发者ID:vangav,项目名称:vos_instagram,代码行数:40,代码来源:HandlerGetPostPhotoId.java

示例9: throwInvalidParam

/**
 * throwInvalidParam
 * short helper method for throwing an invalid param exception
 * @param name
 * @throws Exception
 */
private static void throwInvalidParam (String name) throws Exception {

  throw new BadRequestException(
    151,
    7,
    "Invalid param ["
    + name
    + "]",
    ExceptionClass.INVALID);
}
 
开发者ID:vangav,项目名称:vos_backend,代码行数:16,代码来源:ParamValidatorInl.java

示例10: belongsToEnum

/**
 * belongsToEnum
 * throws an exception param value isn't one of param validValuesEnum
 * @param name
 * @param value
 * @param validValuesEnum
 * @throws Exception
 */
public static <E extends Enum<E> > void belongsToEnum (
  String name,
  String value,
  Class<E> validValuesEnum) throws Exception {

  ArgumentsInl.checkNotNull(
    "value of ["
    + name
    + "]",
    value,
    ExceptionType.CODE_EXCEPTION);
  ArgumentsInl.checkNotNull(
    "valid values enum",
    validValuesEnum,
    ExceptionType.CODE_EXCEPTION);
  
  for (Enum<E> validValue : validValuesEnum.getEnumConstants() ) {
    
    if (value.compareTo(validValue.name() ) == 0) {
      
      return;
    }
  }
  
  throw new CodeException(
    23,
    10,
    "Invalid ["
    + name
    + "] value ["
    + value
    + "] must be one of the valid values --> "
    + Arrays.toString(validValuesEnum.getEnumConstants() ),
    ExceptionClass.INVALID);
}
 
开发者ID:vangav,项目名称:vos_backend,代码行数:43,代码来源:StringVerifierInl.java

示例11: getProfilePictureAsync

/**
 * getProfilePictureAsync
 * BLOCKING method
 * gets a facebook user's profile picture from a previously issued async
 *   request
 * @param requestTrackingUuid
 * @return user's facebook profile picture in String format
 * @throws Exception
 */
public String getProfilePictureAsync (
  String requestTrackingUuid) throws Exception {
  
  if (this.futureDownloadResponses.containsKey(
        requestTrackingUuid) == false) {
    
    throw new CodeException(
      153,
      8,
      "Invalid request tracking id ["
      + requestTrackingUuid
      + "]",
      ExceptionClass.INVALID);
  }
  
  RestAsync restAsync =
    this.futureDownloadResponses.remove(requestTrackingUuid).get();
  
  if (restAsync.isResponseStatusSuccess() == true) {
    
    return restAsync.getRawResponseString();
  } else {
    
    throw new BadRequestException(
      153,
      9,
      "Couldn't get profile picture for user wit facebook user id ["
        + this.userId
        + "] and fb_access_token ["
        + this.accessToken
        + "], got http status code ["
        + restAsync.getResponseStatusCode()
        + "] and raw response ["
        + restAsync.getRawResponseString()
        + "]",
      ExceptionClass.COMMUNICATION);
  }
}
 
开发者ID:vangav,项目名称:vos_backend,代码行数:47,代码来源:FacebookGraph.java

示例12: getPicturesAsync

/**
 * getPicturesAsync
 * BLOCKING method
 * @param requestTrackingUuid
 * @return Map<String, Pair<Integer, String> >
 *          key is the picture_id
 *          pair-Integer is the response's http status code
 *            e.g.:
 *              200 - HTTP_OK
 *              400 - HTTP_BAD_REQUEST
 *              500 - HTTP_INTERNAL_SERVER_ERROR
 *              https://en.wikipedia.org/wiki/List_of_HTTP_status_codes
 *          pair-String for the raw response String (the picture in case of a
 *            success response)
 * @throws Exception
 */
public Map<String, Pair<Integer, String> > getPicturesAsync (
  String requestTrackingUuid) throws Exception {

  if (this.futureDownloadResponses.containsKey(
        requestTrackingUuid) == false) {

    throw new CodeException(
      153,
      12,
      "Invalid request tracking id ["
      + requestTrackingUuid
      + "]",
      ExceptionClass.INVALID);
  }
  
  Map<String, RestAsync> requests =
    this.futureDownloadResponses.remove(requestTrackingUuid).getAll();
  
  RestAsync currRestAsync;
  
  Map<String, Pair<Integer, String> > result =
    new HashMap<String, Pair<Integer, String> >();
  
  for (String pictureId : requests.keySet() ) {
    
    currRestAsync = requests.get(pictureId);
    
    result.put(
      pictureId,
      new Pair<Integer, String>(
        currRestAsync.getResponseStatusCode(),
        currRestAsync.getRawResponseString() ) );
  }
  
  return result;
}
 
开发者ID:vangav,项目名称:vos_backend,代码行数:52,代码来源:FacebookGraph.java

示例13: processRequest

@Override
protected void processRequest (final Request request) throws Exception {

  // use the following request Object to process the request and set
  //   the response to be returned
  RequestGetPhoto requestGetPhoto =
    (RequestGetPhoto)request.getRequestJsonBody();
  
  // select photo from database
  
  ResultSet resultSet =
    PhotosBlobs.i().executeSyncSelect(
      UUID.fromString(requestGetPhoto.photo_id) );
  
  if (resultSet.isExhausted() == true) {
    
    throw new BadRequestException(
      408,
      1,
      "Photo with photo_id ["
        + requestGetPhoto.photo_id
        + "] doesn't exist, request issued by user_id ["
        + requestGetPhoto.user_id
        + "] from device_token ["
        + requestGetPhoto.device_token
        + "]",
      ExceptionClass.INVALID);
  }
  
  // Extract photo
  ByteBuffer photoByteBuffer =
    resultSet.one().getBytes(PhotosBlobs.kPhotoColumnName);
  
  // decode photo
  String photoString =
    EncodingInl.decodeStringFromByteBuffer(photoByteBuffer);

  // set response
  ((ResponseGetPhoto)request.getResponseBody() ).set(
    requestGetPhoto.request_tracking_id,
    photoString);
}
 
开发者ID:vangav,项目名称:vos_instagram,代码行数:42,代码来源:HandlerGetPhoto.java

示例14: checkRequest

/**
 * checkRequest
 * validates the request before processing it
 * @param request
 * @throws Exception
 */
private void checkRequest (final Request request) throws Exception {
  
  // get request's body
  RequestUnlikePost requestUnlikePost =
    (RequestUnlikePost)request.getRequestJsonBody();
  
  // set/check post_id
  UUID postId = UUID.fromString(requestUnlikePost.post_id);
  
  if (CheckersInl.postExists(postId) == false) {
    
    throw new BadRequestException(
      429,
      1,
      "Can't unlike a post that doesn't exist, post_id ["
        + requestUnlikePost.post_id
        + "]. Request issued by user_id ["
        + requestUnlikePost.user_id
        + "] from device_token ["
        + requestUnlikePost.device_token
        + "]",
      ExceptionClass.INVALID);
  }
  
  // check if user didn't like this post before
  if (CheckersInl.userLikedPost(
        postId,
        requestUnlikePost.getUserId() ) == false) {
    
    throw new BadRequestException(
      429,
      2,
      "Post with post_id ["
        + requestUnlikePost.post_id
        + "] hasn't been liked by user_id ["
        + requestUnlikePost.user_id
        + "], request issued from device_token ["
        + requestUnlikePost.device_token
        + "]",
      ExceptionClass.INVALID);
  }
}
 
开发者ID:vangav,项目名称:vos_instagram,代码行数:48,代码来源:HandlerUnlikePost.java

示例15: processRequest

@Override
protected void processRequest (final Request request) throws Exception {

  // use the following request Object to process the request and set
  //   the response to be returned
  RequestGetProfilePicture requestGetProfilePicture =
    (RequestGetProfilePicture)request.getRequestJsonBody();
  
  // set/check get_profile_picture_user_id
  
  UUID getProfilePictureUserId =
    UUID.fromString(requestGetProfilePicture.get_profile_picture_user_id);
  
  if (requestGetProfilePicture.get_profile_picture_user_id.compareTo(
        requestGetProfilePicture.user_id) != 0) {
  
    if (CheckersInl.userIdExists(getProfilePictureUserId) == false) {
      
      throw new BadRequestException(
        414,
        1,
        "User with user_id ["
          + requestGetProfilePicture.get_profile_picture_user_id
          + "] doesn't exist, request issued by user_id ["
          + requestGetProfilePicture.user_id
          + "] from device_token ["
          + requestGetProfilePicture.device_token
          + "]",
        ExceptionClass.INVALID);
    }
  }
  
  // get user's profile_picture_id
  ResultSet resultSet =
    UsersInfo.i().executeSyncSelectProfilePictureId(getProfilePictureUserId);
  
  // no profile picture for this user?
  if (resultSet.isExhausted() == true) {
    
    // set empty response
    ((ResponseGetProfilePicture)request.getResponseBody() ).set(
      requestGetProfilePicture.request_tracking_id,
      "");
    
    return;
  }
  
  // extract profile_picture_id from result
  UUID profilePictureId =
    resultSet.one().getUUID(UsersInfo.kProfilePictureIdColumnName);
  
  // get profile picture
  resultSet =
    ProfilePicturesBlobs.i().executeSyncSelect(profilePictureId);
  
  // extract profile picture
  ByteBuffer profilePictureByteBuffer =
    resultSet.one().getBytes(ProfilePicturesBlobs.kPictureColumnName);
  
  // decode profile picture
  String profilePictureString =
    EncodingInl.decodeStringFromByteBuffer(profilePictureByteBuffer);
  
  // set response
  ((ResponseGetProfilePicture)request.getResponseBody() ).set(
    requestGetProfilePicture.request_tracking_id,
    profilePictureString);
}
 
开发者ID:vangav,项目名称:vos_instagram,代码行数:68,代码来源:HandlerGetProfilePicture.java


注:本文中的com.vangav.backend.exceptions.VangavException.ExceptionClass.INVALID属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。