本文整理汇总了Java中com.icthh.xm.commons.errors.ErrorConstants类的典型用法代码示例。如果您正苦于以下问题:Java ErrorConstants类的具体用法?Java ErrorConstants怎么用?Java ErrorConstants使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ErrorConstants类属于com.icthh.xm.commons.errors包,在下文中一共展示了ErrorConstants类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: createComment
import com.icthh.xm.commons.errors.ErrorConstants; //导入依赖的package包/类
/**
* POST /comments : Create a new comment.
*
* @param comment the comment to create
* @return the ResponseEntity with status 201 (Created) and with body the new comment, or with status 400 (Bad Request) if the comment has already an ID
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/comments")
@Timed
public ResponseEntity<Comment> createComment(@Valid @RequestBody Comment comment) throws URISyntaxException {
log.debug("REST request to save Comment : {}", comment);
if (comment.getId() != null) {
throw new BusinessException(ErrorConstants.ERR_BUSINESS_IDEXISTS,
"A new comment cannot already have an ID");
}
Comment result = commentService.save(comment);
return ResponseEntity.created(new URI("/api/comments/" + result.getId()))
.headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString()))
.body(result);
}
开发者ID:xm-online,项目名称:xm-ms-entity,代码行数:21,代码来源:CommentResource.java
示例17: createLink
import com.icthh.xm.commons.errors.ErrorConstants; //导入依赖的package包/类
/**
* POST /links : Create a new link.
*
* @param link the link to create
* @return the ResponseEntity with status 201 (Created) and with body the new link, or with status 400 (Bad Request) if the link has already an ID
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/links")
@Timed
public ResponseEntity<Link> createLink(@Valid @RequestBody Link link) throws URISyntaxException {
log.debug("REST request to save Link : {}", link);
if (link.getId() != null) {
throw new BusinessException(ErrorConstants.ERR_BUSINESS_IDEXISTS,
"A new link cannot already have an ID");
}
Link result = linkService.save(link);
return ResponseEntity.created(new URI("/api/links/" + result.getId()))
.headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString()))
.body(result);
}
开发者ID:xm-online,项目名称:xm-ms-entity,代码行数:21,代码来源:LinkResource.java
示例18: createEvent
import com.icthh.xm.commons.errors.ErrorConstants; //导入依赖的package包/类
/**
* POST /events : Create a new event.
*
* @param event the event to create
* @return the ResponseEntity with status 201 (Created) and with body the new event, or with status 400 (Bad Request) if the event has already an ID
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/events")
@Timed
public ResponseEntity<Event> createEvent(@Valid @RequestBody Event event) throws URISyntaxException {
log.debug("REST request to save Event : {}", event);
if (event.getId() != null) {
throw new BusinessException(ErrorConstants.ERR_BUSINESS_IDEXISTS,
"A new event cannot already have an ID");
}
Event result = eventService.save(event);
return ResponseEntity.created(new URI("/api/events/" + result.getId()))
.headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString()))
.body(result);
}
开发者ID:xm-online,项目名称:xm-ms-entity,代码行数:21,代码来源:EventResource.java
示例19: createCalendar
import com.icthh.xm.commons.errors.ErrorConstants; //导入依赖的package包/类
/**
* POST /calendars : Create a new calendar.
*
* @param calendar the calendar to create
* @return the ResponseEntity with status 201 (Created) and with body the new calendar, or with status 400 (Bad Request) if the calendar has already an ID
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/calendars")
@Timed
public ResponseEntity<Calendar> createCalendar(@Valid @RequestBody Calendar calendar) throws URISyntaxException {
log.debug("REST request to save Calendar : {}", calendar);
if (calendar.getId() != null) {
throw new BusinessException(ErrorConstants.ERR_BUSINESS_IDEXISTS,
"A new calendar cannot already have an ID");
}
Calendar result = calendarService.save(calendar);
return ResponseEntity.created(new URI("/api/calendars/" + result.getId()))
.headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString()))
.body(result);
}
开发者ID:xm-online,项目名称:xm-ms-entity,代码行数:21,代码来源:CalendarResource.java
示例20: createVote
import com.icthh.xm.commons.errors.ErrorConstants; //导入依赖的package包/类
/**
* POST /votes : Create a new vote.
*
* @param vote the vote to create
* @return the ResponseEntity with status 201 (Created) and with body the new vote, or with status 400 (Bad Request) if the vote has already an ID
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/votes")
@Timed
public ResponseEntity<Vote> createVote(@Valid @RequestBody Vote vote) throws URISyntaxException {
log.debug("REST request to save Vote : {}", vote);
if (vote.getId() != null) {
throw new BusinessException(ErrorConstants.ERR_BUSINESS_IDEXISTS,
"A new vote cannot already have an ID");
}
Vote result = voteRepository.save(vote);
voteSearchRepository.save(result);
return ResponseEntity.created(new URI("/api/votes/" + result.getId()))
.headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString()))
.body(result);
}
开发者ID:xm-online,项目名称:xm-ms-entity,代码行数:22,代码来源:VoteResource.java
注:本文中的com.icthh.xm.commons.errors.ErrorConstants类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论