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


Java ErrorConstants类代码示例

本文整理汇总了Java中com.icthh.xm.commons.errors.ErrorConstants的典型用法代码示例。如果您正苦于以下问题:Java ErrorConstants类的具体用法?Java ErrorConstants怎么用?Java ErrorConstants使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: createXmEntity

import com.icthh.xm.commons.errors.ErrorConstants; //导入依赖的package包/类
/**
 * POST /xm-entities : Create a new xmEntity.
 * @param xmEntity the xmEntity to create
 * @return the ResponseEntity with status 201 (Created) and with body the new xmEntity, or with
 *         status 400 (Bad Request) if the xmEntity has already an ID
 * @throws URISyntaxException if the Location URI syntax is incorrect
 */
@PostMapping("/xm-entities")
@Timed
public ResponseEntity<XmEntity> createXmEntity(@Valid @RequestBody XmEntity xmEntity) throws URISyntaxException {
    log.debug("REST request to save XmEntity : {}", xmEntity);
    if (xmEntity.getId() != null) {
        throw new BusinessException(ErrorConstants.ERR_BUSINESS_IDEXISTS,
            "A new XmEntity cannot already have an ID");
    }
    if (Constants.TENANT_TYPE_KEY.equals(xmEntity.getTypeKey()) && xmEntity.getName().trim().contains(" ")) {
        throw new BusinessException(ErrorConstants.ERR_VALIDATION,
            "Entity name can not contain whitespaces");
    }
    XmEntity result = xmEntityService.save(xmEntity);
    return ResponseEntity.created(new URI("/api/xm-entities/" + result.getId()))
        .headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, String.valueOf(result.getId())))
        .body(result);
}
 
开发者ID:xm-online,项目名称:xm-ms-entity,代码行数:25,代码来源:XmEntityResource.java

示例2: resolveId

import com.icthh.xm.commons.errors.ErrorConstants; //导入依赖的package包/类
@Override
public Object resolveId(final ObjectIdGenerator.IdKey id) {
    Object entity = repository.findOne((Long) id.key);

    if (entity == null) {
        throw new BusinessException(ErrorConstants.ERR_NOTFOUND, "Can not resolve XmEntity by ID: " + id.key);
    }

    return entity;
}
 
开发者ID:xm-online,项目名称:xm-ms-entity,代码行数:11,代码来源:XmEntityObjectIdResolver.java

示例3: testMethodArgumentNotValid

import com.icthh.xm.commons.errors.ErrorConstants; //导入依赖的package包/类
@Test
public void testMethodArgumentNotValid() throws Exception {
     mockMvc.perform(post("/test/method-argument").content("{}").contentType(MediaType.APPLICATION_JSON))
         .andExpect(status().isBadRequest())
         .andExpect(jsonPath("$.error").value(ErrorConstants.ERR_VALIDATION))
         .andExpect(jsonPath("$.error_description").value("Input parameters error"))
         .andExpect(jsonPath("$.fieldErrors.[0].objectName").value("testDTO"))
         .andExpect(jsonPath("$.fieldErrors.[0].field").value("test"))
         .andExpect(jsonPath("$.fieldErrors.[0].message").value("NotNull"));
}
 
开发者ID:xm-online,项目名称:xm-uaa,代码行数:11,代码来源:ExceptionTranslatorIntTest.java

示例4: testParameterizedError

import com.icthh.xm.commons.errors.ErrorConstants; //导入依赖的package包/类
@Test
public void testParameterizedError() throws Exception {
    mockMvc.perform(get("/test/parameterized-error"))
        .andExpect(status().isBadRequest())
        .andExpect(jsonPath("$.error").value(ErrorConstants.ERR_BUSINESS))
        .andExpect(jsonPath("$.error_description").value("Business logic error occurred, please contact support"))
        .andExpect(jsonPath("$.params.param0").value("param0_value"))
        .andExpect(jsonPath("$.params.param1").value("param1_value"));
}
 
开发者ID:xm-online,项目名称:xm-uaa,代码行数:10,代码来源:ExceptionTranslatorIntTest.java

示例5: testParameterizedError2

import com.icthh.xm.commons.errors.ErrorConstants; //导入依赖的package包/类
@Test
public void testParameterizedError2() throws Exception {
    mockMvc.perform(get("/test/parameterized-error2"))
        .andExpect(status().isBadRequest())
        .andExpect(jsonPath("$.error").value(ErrorConstants.ERR_BUSINESS))
        .andExpect(jsonPath("$.error_description").value("Business logic error occurred, please contact support"))
        .andExpect(jsonPath("$.params.foo").value("foo_value"))
        .andExpect(jsonPath("$.params.bar").value("bar_value"));
}
 
开发者ID:xm-online,项目名称:xm-uaa,代码行数:10,代码来源:ExceptionTranslatorIntTest.java

示例6: testAccessDenied

import com.icthh.xm.commons.errors.ErrorConstants; //导入依赖的package包/类
@Test
public void testAccessDenied() throws Exception {
    mockMvc.perform(get("/test/access-denied"))
        .andExpect(status().isForbidden())
        .andExpect(jsonPath("$.error").value(ErrorConstants.ERR_ACCESS_DENIED))
        .andExpect(jsonPath("$.error_description").value("Access denied"));
}
 
开发者ID:xm-online,项目名称:xm-uaa,代码行数:8,代码来源:ExceptionTranslatorIntTest.java

示例7: testMethodNotSupported

import com.icthh.xm.commons.errors.ErrorConstants; //导入依赖的package包/类
@Test
public void testMethodNotSupported() throws Exception {
    mockMvc.perform(post("/test/access-denied"))
        .andExpect(status().isMethodNotAllowed())
        .andExpect(jsonPath("$.error").value(ErrorConstants.ERR_METHOD_NOT_SUPPORTED))
        .andExpect(jsonPath("$.error_description").value("Method not supported"));
}
 
开发者ID:xm-online,项目名称:xm-uaa,代码行数:8,代码来源:ExceptionTranslatorIntTest.java

示例8: testInternalServerError

import com.icthh.xm.commons.errors.ErrorConstants; //导入依赖的package包/类
@Test
public void testInternalServerError() throws Exception {
    mockMvc.perform(get("/test/internal-server-error"))
        .andExpect(status().isInternalServerError())
        .andExpect(jsonPath("$.error").value(ErrorConstants.ERR_INTERNAL_SERVER_ERROR))
        .andExpect(jsonPath("$.error_description").value("Internal server error, please try later"));
}
 
开发者ID:xm-online,项目名称:xm-uaa,代码行数:8,代码来源:ExceptionTranslatorIntTest.java

示例9: testMethodArgumentNotValid

import com.icthh.xm.commons.errors.ErrorConstants; //导入依赖的package包/类
@Test
public void testMethodArgumentNotValid() throws Exception {
    mockMvc.perform(post("/test/method-argument").content("{}").contentType(MediaType.APPLICATION_JSON))
        .andExpect(status().isBadRequest())
        .andExpect(jsonPath("$.error").value(ErrorConstants.ERR_VALIDATION))
        .andExpect(jsonPath("$.fieldErrors.[0].objectName").value("testDTO"))
        .andExpect(jsonPath("$.fieldErrors.[0].field").value("test"))
        .andExpect(jsonPath("$.fieldErrors.[0].message").value("NotNull"));
}
 
开发者ID:xm-online,项目名称:xm-ms-balance,代码行数:10,代码来源:ExceptionTranslatorIntTest.java

示例10: testMethodArgumentNotValid

import com.icthh.xm.commons.errors.ErrorConstants; //导入依赖的package包/类
@Test
public void testMethodArgumentNotValid() throws Exception {
    mockMvc.perform(post("/test/method-argument").content("{}").contentType(MediaType.APPLICATION_JSON))
        .andExpect(status().isBadRequest())
        .andExpect(jsonPath("$.error").value(ErrorConstants.ERR_VALIDATION))
        .andExpect(jsonPath("$.error_description").value("Input parameters error"))
        .andExpect(jsonPath("$.fieldErrors.[0].objectName").value("testDTO"))
        .andExpect(jsonPath("$.fieldErrors.[0].field").value("test"))
        .andExpect(jsonPath("$.fieldErrors.[0].message").value("NotNull"));
}
 
开发者ID:xm-online,项目名称:xm-ms-dashboard,代码行数:11,代码来源:ExceptionTranslatorIntTest.java

示例11: error

import com.icthh.xm.commons.errors.ErrorConstants; //导入依赖的package包/类
@RequestMapping(value = "${error.path:/error}")
public @ResponseBody
ResponseEntity error(HttpServletRequest request) {
    final int status = getErrorStatus(request);
    final String errorMessage = getErrorMessage(request);
    return ResponseEntity.status(status).body(new ErrorVM(ErrorConstants.ERR_BUSINESS,
        errorMessage != null ? errorMessage : HttpStatus.valueOf(status).getReasonPhrase()));
}
 
开发者ID:xm-online,项目名称:xm-gate,代码行数:9,代码来源:GateErrorController.java

示例12: testMethodArgumentNotValid

import com.icthh.xm.commons.errors.ErrorConstants; //导入依赖的package包/类
@Test
public void testMethodArgumentNotValid() throws Exception {
     mockMvc.perform(post("/test/method-argument").content("{}").contentType(MediaType.APPLICATION_JSON))
         .andExpect(status().isBadRequest())
         .andExpect(jsonPath("$.error").value(ErrorConstants.ERR_VALIDATION))
         .andExpect(jsonPath("$.fieldErrors.[0].objectName").value("testDTO"))
         .andExpect(jsonPath("$.fieldErrors.[0].field").value("test"))
         .andExpect(jsonPath("$.fieldErrors.[0].message").value("NotNull"));
}
 
开发者ID:xm-online,项目名称:xm-gate,代码行数:10,代码来源:ExceptionTranslatorIntTest.java

示例13: createLocation

import com.icthh.xm.commons.errors.ErrorConstants; //导入依赖的package包/类
/**
 * POST  /locations : Create a new location.
 *
 * @param location the location to create
 * @return the ResponseEntity with status 201 (Created) and with body the new location, or with status 400 (Bad Request) if the location has already an ID
 * @throws URISyntaxException if the Location URI syntax is incorrect
 */
@PostMapping("/locations")
@Timed
public ResponseEntity<Location> createLocation(@Valid @RequestBody Location location) throws URISyntaxException {
    log.debug("REST request to save Location : {}", location);
    if (location.getId() != null) {
        throw new BusinessException(ErrorConstants.ERR_BUSINESS_IDEXISTS,
                                          "A new location cannot already have an ID");
    }
    Location result = locationRepository.save(location);
    locationSearchRepository.save(result);
    return ResponseEntity.created(new URI("/api/locations/" + result.getId()))
        .headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString()))
        .body(result);
}
 
开发者ID:xm-online,项目名称:xm-ms-entity,代码行数:22,代码来源:LocationResource.java

示例14: createRating

import com.icthh.xm.commons.errors.ErrorConstants; //导入依赖的package包/类
/**
 * POST  /ratings : Create a new rating.
 *
 * @param rating the rating to create
 * @return the ResponseEntity with status 201 (Created) and with body the new rating, or with status 400 (Bad Request) if the rating has already an ID
 * @throws URISyntaxException if the Location URI syntax is incorrect
 */
@PostMapping("/ratings")
@Timed
public ResponseEntity<Rating> createRating(@Valid @RequestBody Rating rating) throws URISyntaxException {
    log.debug("REST request to save Rating : {}", rating);
    if (rating.getId() != null) {
        throw new BusinessException(ErrorConstants.ERR_BUSINESS_IDEXISTS,
                                          "A new rating cannot already have an ID");
    }
    Rating result = ratingService.save(rating);
    return ResponseEntity.created(new URI("/api/ratings/" + result.getId()))
        .headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString()))
        .body(result);
}
 
开发者ID:xm-online,项目名称:xm-ms-entity,代码行数:21,代码来源:RatingResource.java

示例15: createTag

import com.icthh.xm.commons.errors.ErrorConstants; //导入依赖的package包/类
/**
 * POST  /tags : Create a new tag.
 *
 * @param tag the tag to create
 * @return the ResponseEntity with status 201 (Created) and with body the new tag, or with status 400 (Bad Request) if the tag has already an ID
 * @throws URISyntaxException if the Location URI syntax is incorrect
 */
@PostMapping("/tags")
@Timed
public ResponseEntity<Tag> createTag(@Valid @RequestBody Tag tag) throws URISyntaxException {
    log.debug("REST request to save Tag : {}", tag);
    if (tag.getId() != null) {
        throw new BusinessException(ErrorConstants.ERR_BUSINESS_IDEXISTS,
                                          "A new tag cannot already have an ID");
    }
    Tag result = tagRepository.save(tag);
    tagSearchRepository.save(result);
    return ResponseEntity.created(new URI("/api/tags/" + result.getId()))
        .headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString()))
        .body(result);
}
 
开发者ID:xm-online,项目名称:xm-ms-entity,代码行数:22,代码来源:TagResource.java


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