本文整理汇总了Java中com.blackducksoftware.sdk.fault.ErrorCode类的典型用法代码示例。如果您正苦于以下问题:Java ErrorCode类的具体用法?Java ErrorCode怎么用?Java ErrorCode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ErrorCode类属于com.blackducksoftware.sdk.fault包,在下文中一共展示了ErrorCode类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkProjectExists
import com.blackducksoftware.sdk.fault.ErrorCode; //导入依赖的package包/类
public boolean checkProjectExists(final String projectName)
throws ServerConfigException, ServerConnectionException, ProtexFacadeException {
if (StringUtils.isBlank(projectName)) {
throw new IllegalArgumentException("Need to provide the name of the Protex Project to be checked.");
}
try {
final Project proj = serverProxy.getProjectApi().getProjectByName(projectName);
if (proj != null) {
logger.info("The project '" + projectName + "' exists.");
return true;
} else {
return false;
}
} catch (final SdkFault e) {
if (e.getFaultInfo() != null && e.getFaultInfo().getErrorCode() != null) {
if (e.getFaultInfo().getErrorCode().equals(ErrorCode.INVALID_CREDENTIALS)) {
throw new ProtexFacadeException(
"Error checking the project '" + projectName + "' :" + e.getMessage(), e);
}
if (e.getFaultInfo().getErrorCode().equals(ErrorCode.PROJECT_NOT_FOUND)) {
logger.info("The project '" + projectName + "' does not exist.");
return false;
}
throw new ProtexFacadeException("Error checking the project '" + projectName + "' : " + e.getMessage(),
e);
} else {
logger.error(e.getMessage(), e);
throw new ProtexFacadeException("Error checking the project '" + projectName + "' : " + e.getMessage(),
e);
}
}
}
示例2: getSdkFaultErrorCode
import com.blackducksoftware.sdk.fault.ErrorCode; //导入依赖的package包/类
public ErrorCode getSdkFaultErrorCode() {
return sdkFaultErrorCode;
}
示例3: createProject
import com.blackducksoftware.sdk.fault.ErrorCode; //导入依赖的package包/类
private static String createProject(
String newProjectName,
AnalysisSourceLocation newAnalysisSourceLocation,
UIResponseObserver observer) {
if(observer == null) {
observer = new DefaultUIResponseObserver();
}
if(isExistedProjectName(newProjectName) == true) {
observer.setFailMessage("\""+newProjectName+"\" is already existed.");
log.debug("\""+newProjectName+"\" is already existed.");
return null;
}
String projectID = null;
ProjectRequest pRequest = new ProjectRequest();
PolicyCheckResult p = ProjectNamePolicy.checkProjectName(newProjectName);
if(p.getResult() != PolicyCheckResult.PROJECT_NAME_OK) {
observer.setFailMessage(p.getResultMsg());
return null;
}
final String DESCRIPTION = "This project is created by OSI - "
+ DateUtil.getCurrentTime("[%1$tY/%1$tm/%1$te(%1$ta) %1$tl:%1$tM:%1$tS %1$tp]");
pRequest.setName(newProjectName);
pRequest.setDescription(DESCRIPTION);
if(newAnalysisSourceLocation != null) {
pRequest.setAnalysisSourceLocation(newAnalysisSourceLocation);
}
try{
projectID = ProtexSDKAPIManager.getProjectAPI().createProject(pRequest, LicenseCategory.PROPRIETARY);
} catch (SdkFault e) {
log.warn(e);
ErrorCode errorCode = e.getFaultInfo().getErrorCode();
try {
Thread.sleep(1000);
} catch (InterruptedException ie) {
ie.printStackTrace();
}
if(errorCode == ErrorCode.DUPLICATE_PROJECT_NAME) {
String[] button = {"OK"};
JOptionPane.showOptionDialog( // block
null,
"The project name \""+newProjectName+"\" is already created by other user.",
"Duplicated project name",
JOptionPane.YES_OPTION,
JOptionPane.ERROR_MESSAGE,
null,
button,
"OK");
}
return null;
}
if(projectID == null)
return null;
setScanIgnorePattern(projectID, ProjectNamePolicy.IGNORED_PATTERN, observer);
observer.pushMessage("[ok]\n");
return projectID;
}