本文整理汇总了Java中org.springframework.dao.DataIntegrityViolationException.getMessage方法的典型用法代码示例。如果您正苦于以下问题:Java DataIntegrityViolationException.getMessage方法的具体用法?Java DataIntegrityViolationException.getMessage怎么用?Java DataIntegrityViolationException.getMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.dao.DataIntegrityViolationException
的用法示例。
在下文中一共展示了DataIntegrityViolationException.getMessage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createCIRelation
import org.springframework.dao.DataIntegrityViolationException; //导入方法依赖的package包/类
@RequestMapping(method=RequestMethod.POST, value="/cm/simple/relations")
@ResponseBody
public CmsCIRelationSimple createCIRelation(
@RequestParam(value="value", required = false) String valueType,
@RequestBody CmsCIRelationSimple relSimple,
@RequestHeader(value="X-Cms-Scope", required = false) String scope,
@RequestHeader(value="X-Cms-User", required = false) String userId) throws CIValidationException {
scopeVerifier.verifyScope(scope, relSimple);
CmsCIRelation rel = cmsUtil.custCIRelationSimple2CIRelation(relSimple, valueType);
rel.setCreatedBy(userId);
try {
CmsCIRelation newRel = cmManager.createRelation(rel);
return cmsUtil.custCIRelation2CIRelationSimple(newRel, valueType,false);
} catch (DataIntegrityViolationException dive) {
if (dive instanceof DuplicateKeyException) {
throw new CIValidationException(CmsError.CMS_DUPCI_NAME_ERROR, dive.getMessage());
} else {
throw new CmsException(CmsError.CMS_EXCEPTION, dive.getMessage());
}
}
}
示例2: generateDesign
import org.springframework.dao.DataIntegrityViolationException; //导入方法依赖的package包/类
@RequestMapping(value="/assemblies/{assemblyId}/platforms", method = RequestMethod.POST)
@ResponseBody
public Map<String,Long> generateDesign(
@PathVariable long assemblyId,
@RequestBody CmsRfcCISimple platRfcSimple,
@RequestHeader(value="X-Cms-User", required = false) String userId,
@RequestHeader(value="X-Cms-Scope", required = false) String scope){
if (userId == null) userId = "oneops-system";
long startTime = System.currentTimeMillis();
CmsRfcCI platRfc = util.custRfcCISimple2RfcCI(platRfcSimple);
try {
long platformCiId = dManager.generatePlatform(platRfc, assemblyId, userId, scope);
Map<String,Long> result = new HashMap<>(1);
result.put("platformCiId", platformCiId);
long tookTime = System.currentTimeMillis() - startTime;
logger.debug("Time to generate Design - " + tookTime);
return result;
} catch (DataIntegrityViolationException dive) {
if (dive instanceof DuplicateKeyException) {
throw new CIValidationException(CmsError.CMS_DUPCI_NAME_ERROR, dive.getMessage());
} else {
throw new TransistorException(CmsError.CMS_EXCEPTION, dive.getMessage());
}
} catch (CmsBaseException te) {
logger.error(te);
te.printStackTrace();
throw te;
}
}
示例3: clonePlatform
import org.springframework.dao.DataIntegrityViolationException; //导入方法依赖的package包/类
@RequestMapping(value="/platforms/{fromPlatformId}/clone", method = RequestMethod.POST)
@ResponseBody
public Map<String,Long> clonePlatform(
@PathVariable long fromPlatformId,
@RequestBody CmsRfcCISimple platRfcSimple,
@RequestHeader(value="X-Cms-User", required = false) String userId,
@RequestHeader(value="X-Cms-Scope", required = false) String scope){
if (userId == null) userId = "oneops-system";
try {
long startTime = System.currentTimeMillis();
CmsRfcCI platRfc = util.custRfcCISimple2RfcCI(platRfcSimple);
long platformId = dManager.clonePlatform(platRfc, null, fromPlatformId, userId, scope);
Map<String,Long> result = new HashMap<>(1);
result.put("platformCiId", platformId);
long tookTime = System.currentTimeMillis() - startTime;
logger.debug("Time to generate Design - " + tookTime);
return result;
} catch (DataIntegrityViolationException dive) {
if (dive instanceof DuplicateKeyException) {
throw new CIValidationException(CmsError.CMS_DUPCI_NAME_ERROR, dive.getMessage());
} else {
throw new TransistorException(CmsError.CMS_EXCEPTION, dive.getMessage());
}
} catch (CmsBaseException te) {
logger.error(te);
te.printStackTrace();
throw te;
}
}
示例4: createCISimple
import org.springframework.dao.DataIntegrityViolationException; //导入方法依赖的package包/类
@RequestMapping(method=RequestMethod.POST, value="/cm/simple/cis")
@ResponseBody
public CmsCISimple createCISimple(
@RequestParam(value="value", required = false) String valueType,
@RequestBody CmsCISimple ciSimple,
@RequestHeader(value="X-Cms-Scope", required = false) String scope,
@RequestHeader(value="X-Cms-User", required = false) String userId) throws CIValidationException {
scopeVerifier.verifyScope(scope, ciSimple);
CmsCI newCi = cmsUtil.custCISimple2CI(ciSimple, valueType);
newCi.setCiId(0);
newCi.setCiGoid(null);
newCi.setCreatedBy(userId);
try {
CmsCI ci = cmManager.createCI(newCi);
updateAltNs(ci.getCiId(), ciSimple);
logger.debug(ci.getCiId());
CmsCISimple cmsCISimple = cmsUtil.custCI2CISimple(ci, valueType);
cmsCISimple.setAltNs(ciSimple.getAltNs());
return cmsCISimple;
} catch (DataIntegrityViolationException dive) {
if (dive instanceof DuplicateKeyException) {
throw new CIValidationException(CmsError.CMS_DUPCI_NAME_ERROR, dive.getMessage());
} else {
throw new CmsException(CmsError.CMS_EXCEPTION, dive.getMessage());
}
}
}
示例5: cloneAssembly
import org.springframework.dao.DataIntegrityViolationException; //导入方法依赖的package包/类
@RequestMapping(value="/assemblies/{fromAssemblyId}/clone", method = RequestMethod.POST)
@ResponseBody
public Map<String,Long> cloneAssembly(
@PathVariable long fromAssemblyId,
@RequestBody CmsCISimple targetCISimple,
@RequestHeader(value="X-Cms-User", required = false) String userId,
@RequestHeader(value="X-Cms-Scope", required = false) String scope){
if (userId == null) userId = "oneops-system";
try {
long startTime = System.currentTimeMillis();
if (targetCISimple.getCiAttributes().get("description") == null) {
targetCISimple.addCiAttribute("description", null);
}
CmsCI targetCI = util.custCISimple2CI(targetCISimple, null);
long resultCiId = 0;
if ("account.Assembly".equals(targetCI.getCiClassName())) {
resultCiId = dManager.cloneAssembly(targetCI, fromAssemblyId, userId, scope);
} else if ("account.Design".equals(targetCI.getCiClassName())) {
resultCiId = dManager.saveAssemblyAsCatalog(targetCI, fromAssemblyId, userId, scope);
} else {
throw new TransistorException(CmsError.TRANSISTOR_BAD_CLASS_NAME, "Bad class name");
}
Map<String,Long> result = new HashMap<>(1);
result.put("resultCiId", resultCiId);
long tookTime = System.currentTimeMillis() - startTime;
logger.debug("Time to generate Assembly/Catalog - " + tookTime);
return result;
} catch (DataIntegrityViolationException dive) {
if (dive instanceof DuplicateKeyException) {
throw new CIValidationException(CmsError.CMS_DUPCI_NAME_ERROR, dive.getMessage());
} else {
throw new TransistorException(CmsError.CMS_EXCEPTION, dive.getMessage());
}
} catch (CmsBaseException te) {
logger.error(te);
te.printStackTrace();
throw te;
}
}