當前位置: 首頁>>代碼示例>>Java>>正文


Java DataIntegrityViolationException.getMessage方法代碼示例

本文整理匯總了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());
		}
	}
}
 
開發者ID:oneops,項目名稱:oneops,代碼行數:24,代碼來源:CmRestController.java

示例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;
	}
}
 
開發者ID:oneops,項目名稱:oneops,代碼行數:35,代碼來源:TransistorRestController.java

示例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;
	}
}
 
開發者ID:oneops,項目名稱:oneops,代碼行數:36,代碼來源:TransistorRestController.java

示例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());
		}
	}
}
 
開發者ID:oneops,項目名稱:oneops,代碼行數:30,代碼來源:CmRestController.java

示例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;
	}
}
 
開發者ID:oneops,項目名稱:oneops,代碼行數:47,代碼來源:TransistorRestController.java


注:本文中的org.springframework.dao.DataIntegrityViolationException.getMessage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。