本文整理汇总了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);
}
示例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;
}
示例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"));
}
示例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"));
}
示例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"));
}
示例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"));
}
示例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"));
}
示例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"));
}
示例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"));
}
示例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"));
}
示例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()));
}
示例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"));
}
示例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);
}
示例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);
}
示例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);
}