当前位置: 首页>>代码示例>>Java>>正文


Java ErrorCode类代码示例

本文整理汇总了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);
		}
	}
}
 
开发者ID:blackducksoftware,项目名称:protex-common,代码行数:33,代码来源:ProtexFacade.java

示例2: getSdkFaultErrorCode

import com.blackducksoftware.sdk.fault.ErrorCode; //导入依赖的package包/类
public ErrorCode getSdkFaultErrorCode() {
    return sdkFaultErrorCode;
}
 
开发者ID:blackducksoftware,项目名称:protex-common,代码行数:4,代码来源:ProtexFacadeException.java

示例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;
  	
  }
 
开发者ID:spdx,项目名称:ATTIC-osit,代码行数:68,代码来源:ProjectAPIWrapper.java


注:本文中的com.blackducksoftware.sdk.fault.ErrorCode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。