本文整理汇总了Java中org.eclipse.che.api.core.ServerException类的典型用法代码示例。如果您正苦于以下问题:Java ServerException类的具体用法?Java ServerException怎么用?Java ServerException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ServerException类属于org.eclipse.che.api.core包,在下文中一共展示了ServerException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPullRequests
import org.eclipse.che.api.core.ServerException; //导入依赖的package包/类
/**
* Returns the list of active pull request in given repository. Generates html url for each pull
* requests
*
* @param repositoryId the id of the repository
* @throws IOException when any io error occurs
* @throws ServerException when server responds with unexpected code
* @throws UnauthorizedException when user in not authorized to call this method
*/
public List<MicrosoftPullRequest> getPullRequests(
String account, String collection, String project, String repository, String repositoryId)
throws IOException, ServerException, UnauthorizedException {
return doGet(
templates.pullRequestsUrl(account, collection, repositoryId),
MicrosoftPullRequestList.class)
.getValue()
.stream()
.peek(
pr ->
pr.setHtmlUrl(
templates.pullRequestHtmlUrl(
account,
collection,
project,
repository,
String.valueOf(pr.getPullRequestId()))))
.collect(Collectors.toList());
}
示例2: onCreateProject
import org.eclipse.che.api.core.ServerException; //导入依赖的package包/类
@Override
public void onCreateProject(
Path projectPath, Map<String, AttributeValue> attributes, Map<String, String> options)
throws ForbiddenException, ConflictException, ServerException {
VirtualFileSystem vfs = virtualFileSystemProvider.getVirtualFileSystem();
FolderEntry baseFolder = new FolderEntry(vfs.getRoot().createFolder(projectPath.toString()));
try (InputStream packageJson =
getClass().getClassLoader().getResourceAsStream("files/default_package");
InputStream personJson =
getClass().getClassLoader().getResourceAsStream("files/default_person")) {
FolderEntry myJsonFiles = baseFolder.createFolder("myJsonFiles");
baseFolder.createFile(FILE_NAME, packageJson);
myJsonFiles.createFile("person.json", personJson);
} catch (IOException ioEx) {
throw new ServerException(ioEx.getLocalizedMessage(), ioEx);
}
}
示例3: countLinesPerFile
import org.eclipse.che.api.core.ServerException; //导入依赖的package包/类
/**
* Count LOC for all JSON files within the given project.
*
* @param projectPath the path to the project that contains the JSON files for which to calculate
* the LOC
* @return a Map mapping the file name to their respective LOC value
* @throws ServerException in case the server encounters an error
* @throws NotFoundException in case the project couldn't be found
* @throws ForbiddenException in case the operation is forbidden
*/
@GET
@Path("{projectPath}")
public Map<String, String> countLinesPerFile(@PathParam("projectPath") String projectPath)
throws ServerException, NotFoundException, ForbiddenException {
Map<String, String> linesPerFile = new LinkedHashMap<>();
RegisteredProject project = projectManager.getProject(projectPath);
for (FileEntry child : project.getBaseFolder().getChildFiles()) {
if (isJsonFile(child)) {
linesPerFile.put(child.getName(), Integer.toString(countLines(child)));
}
}
return linesPerFile;
}
示例4: getCurrentUser
import org.eclipse.che.api.core.ServerException; //导入依赖的package包/类
/**
* Get current user
*
* @return the current user or null if an error occurred during the call to 'getCurrent'
* @throws org.eclipse.che.api.core.ServerException
*/
public UserDto getCurrentUser() throws ServerException {
String url =
fromUri(baseUrl)
.path(UserService.class)
.path(UserService.class, "getCurrent")
.build()
.toString();
UserDto user;
HttpJsonRequest httpJsonRequest = httpJsonRequestFactory.fromUrl(url).useGetMethod();
try {
HttpJsonResponse response = httpJsonRequest.request();
user = response.asDto(UserDto.class);
} catch (IOException | ApiException e) {
LOG.error(e.getLocalizedMessage(), e);
throw new ServerException(e.getLocalizedMessage());
}
return user;
}
示例5: getInitiatorInfo
import org.eclipse.che.api.core.ServerException; //导入依赖的package包/类
@VisibleForTesting
String getInitiatorInfo(String initiatorId) throws ServerException {
User initiator;
Profile initiatorProfile;
try {
initiator = userManager.getById(initiatorId);
initiatorProfile = profileManager.getById(initiatorId);
} catch (NotFoundException e) {
throw new ServerException(e.getLocalizedMessage(), e);
}
Map<String, String> profileAttributes = initiatorProfile.getAttributes();
String firstName = nullToEmpty(profileAttributes.get("firstName"));
String lastName = nullToEmpty(profileAttributes.get("lastName"));
if (firstName.isEmpty() || lastName.isEmpty()) {
return initiator.getEmail();
} else {
return firstName + " " + lastName;
}
}
示例6: invite
import org.eclipse.che.api.core.ServerException; //导入依赖的package包/类
@POST
@Consumes(APPLICATION_JSON)
@ApiOperation(
value = "Invite unregistered user by email " + "or update permissions for already invited user",
notes = "Invited user will receive email notification only on invitation creation"
)
@ApiResponses({
@ApiResponse(code = 204, message = "The invitation successfully created/updated"),
@ApiResponse(code = 400, message = "Missed required parameters, parameters are not valid"),
@ApiResponse(code = 409, message = "User with specified email is already registered"),
@ApiResponse(code = 500, message = "Internal server error occurred")
})
public void invite(@ApiParam(value = "The invite to store", required = true) InviteDto inviteDto)
throws BadRequestException, NotFoundException, ConflictException, ServerException {
checkArgument(inviteDto != null, "Invite required");
checkArgument(!isNullOrEmpty(inviteDto.getEmail()), "Email required");
checkArgument(!isNullOrEmpty(inviteDto.getDomainId()), "Domain id required");
checkArgument(!isNullOrEmpty(inviteDto.getInstanceId()), "Instance id required");
checkArgument(!inviteDto.getActions().isEmpty(), "One or more actions required");
emailValidator.validateUserMail(inviteDto.getEmail());
inviteManager.store(inviteDto);
}
示例7: launch
import org.eclipse.che.api.core.ServerException; //导入依赖的package包/类
@Override
public void launch(Instance machine, Agent agent) throws ServerException, AgentStartException {
super.launch(machine, agent);
DockerNode node = (DockerNode) machine.getNode();
DockerInstance dockerMachine = (DockerInstance) machine;
try {
node.bindWorkspace();
} catch (EnvironmentException e) {
throw new AgentStartException(
format(
"Agent '%s' start failed because of an error with underlying environment. Error: %s",
agent.getId(), e.getLocalizedMessage()));
}
LOG.info(
"Docker machine has been deployed. "
+ "ID '{}'. Workspace ID '{}'. "
+ "Container ID '{}'. Node host '{}'. Node IP '{}'",
machine.getId(),
machine.getWorkspaceId(),
dockerMachine.getContainer(),
node.getHost(),
node.getIp());
}
示例8: checkContainerIsRunning
import org.eclipse.che.api.core.ServerException; //导入依赖的package包/类
@Override
protected void checkContainerIsRunning(String container) throws IOException, ServerException {
// Sometimes Swarm doesn't see newly created containers for several seconds.
// Here we retry operation to ensure that such behavior of Swarm doesn't affect the product.
try {
super.checkContainerIsRunning(container);
} catch (ContainerNotFoundException e) {
try {
Thread.sleep(SWARM_WAIT_BEFORE_REPEAT_WORKAROUND_TIME_MS);
super.checkContainerIsRunning(container);
} catch (InterruptedException ignored) {
// throw original error
throw e;
}
}
}
示例9: getRepositoryForks
import org.eclipse.che.api.core.ServerException; //导入依赖的package包/类
@Override
public List<BitbucketRepository> getRepositoryForks(String owner, String repositorySlug)
throws IOException, BitbucketException, ServerException, IllegalArgumentException {
final List<BitbucketRepository> repositories = new ArrayList<>();
BitbucketServerRepositoriesPage repositoriesPage = null;
do {
final String url =
urlTemplates.forksUrl(owner, repositorySlug)
+ (repositoriesPage != null
? "?start=" + valueOf(repositoriesPage.getNextPageStart())
: "");
repositoriesPage = getBitbucketPage(this, url, BitbucketServerRepositoriesPage.class);
repositories.addAll(
repositoriesPage
.getValues()
.stream()
.map(BitbucketServerDTOConverter::convertToBitbucketRepository)
.collect(Collectors.toList()));
} while (!repositoriesPage.isIsLastPage());
return repositories;
}
示例10: createPingRequest
import org.eclipse.che.api.core.ServerException; //导入依赖的package包/类
@Override
protected HttpJsonRequest createPingRequest(Machine devMachine) throws ServerException {
final HttpJsonRequest pingRequest = super.createPingRequest(devMachine);
final String tokenServiceUrl =
UriBuilder.fromUri(apiEndpoint)
.replacePath("api/machine/token/" + devMachine.getWorkspaceId())
.build()
.toString();
String machineToken = null;
try {
machineToken =
httpJsonRequestFactory
.fromUrl(tokenServiceUrl)
.setMethod(HttpMethod.GET)
.request()
.asDto(MachineTokenDto.class)
.getMachineToken();
} catch (ApiException | IOException ex) {
LOG.warn("Failed to get machine token", ex);
}
return machineToken == null ? pingRequest : pingRequest.setAuthorizationHeader(machineToken);
}
示例11: backupShouldThrowErrorIfMachineDoesNotContainServerWithSshPort
import org.eclipse.che.api.core.ServerException; //导入依赖的package包/类
@Test(
expectedExceptions = ServerException.class,
expectedExceptionsMessageRegExp =
"Sync port is not exposed in ws-machine. Workspace projects syncing is not possible"
)
public void backupShouldThrowErrorIfMachineDoesNotContainServerWithSshPort() throws Exception {
// given
when(machineRuntimeInfo.getServers())
.thenReturn(
singletonMap(
"23/tcp",
new ServerImpl("ref", "proto", "127.0.0.1:" + PUBLISHED_SSH_PORT, null, null)));
backupManager.backupWorkspace(WORKSPACE_ID);
// when
backupManager.backupWorkspace(WORKSPACE_ID);
}
示例12: restoreWorkspaceBackup
import org.eclipse.che.api.core.ServerException; //导入依赖的package包/类
/**
* Copy files of workspace from backups storage into container.
*
* @param workspaceId id of workspace to backup
* @param containerId id of container where data should be copied
* @param nodeHost host of a node where container is running
* @throws EnvironmentException if restore failed due to abnormal state of machines in environment
* @throws ServerException if any error occurs
*/
public void restoreWorkspaceBackup(String workspaceId, String containerId, String nodeHost)
throws ServerException, EnvironmentException {
try {
String srcPath =
workspaceIdHashLocationFinder.calculateDirPath(backupsRootDir, workspaceId).toString();
User user = getUserInfo(workspaceId, containerId);
int syncPort = getSyncPort(containerId);
restoreBackupInsideLock(
workspaceId,
srcPath,
projectFolderPath,
user.id,
user.groupId,
user.name,
nodeHost,
syncPort);
} catch (IOException e) {
LOG.error(e.getLocalizedMessage(), e);
throw new ServerException(
format(
"Can't restore file system of workspace %s in container %s",
workspaceId, containerId));
}
}
示例13: getRepositoryForks
import org.eclipse.che.api.core.ServerException; //导入依赖的package包/类
@Override
public List<BitbucketRepository> getRepositoryForks(String owner, String repositorySlug)
throws IOException, BitbucketException, ServerException {
final List<BitbucketRepository> repositories = new ArrayList<>();
BitbucketRepositoriesPage repositoryPage = newDto(BitbucketRepositoriesPage.class);
do {
final String nextPageUrl = repositoryPage.getNext();
final String url =
nextPageUrl == null ? urlTemplates.forksUrl(owner, repositorySlug) : nextPageUrl;
repositoryPage = getBitbucketPage(this, url, BitbucketRepositoriesPage.class);
repositories.addAll(repositoryPage.getValues());
} while (repositoryPage.getNext() != null);
return repositories;
}
示例14: storePullRequestUpdatedWebhook
import org.eclipse.che.api.core.ServerException; //导入依赖的package包/类
/**
* Store a 'pull request updated' webhook in webhooks property file. If a webhook with same id
* already exist it will be replaced.
*
* @param pruWebhook the webhook to store in webhooks property file
* @throws ServerException
*/
private void storePullRequestUpdatedWebhook(final PullRequestUpdatedWebhook pruWebhook)
throws ServerException {
final Set<String> factoriesIDs = pruWebhook.getFactoriesIds();
String propertyValue =
String.format(
"%s,%s,%s,%s,%s,%s,%s",
PULL_REQUEST_UPDATED_WEBHOOK.toString(),
pruWebhook.getHost(),
pruWebhook.getAccount(),
pruWebhook.getCollection(),
pruWebhook.getApiVersion(),
pruWebhook.getCredentials().first,
pruWebhook.getCredentials().second);
if (factoriesIDs.size() > 0) {
final String concatedFactoriesIDs = String.join(";", factoriesIDs);
propertyValue = propertyValue + "," + concatedFactoriesIDs;
}
storeProperty(pruWebhook.getId(), propertyValue, VSTS_WEBHOOKS_PROPERTIES_FILENAME);
}
示例15: getFactoriesForRepositoryAndBranch
import org.eclipse.che.api.core.ServerException; //导入依赖的package包/类
/**
* Get factories that contain a project for given repository and branch
*
* @param factoryIDs the set of id's of factories to check
* @param headRepositoryUrl repository that factory project must match
* @param headBranch branch that factory project must match
* @return list of factories that contain a project for given repository and branch
*/
protected List<FactoryDto> getFactoriesForRepositoryAndBranch(
final Set<String> factoryIDs,
final String headRepositoryUrl,
final String headBranch,
final CloneUrlMatcher matcher)
throws ServerException {
List<FactoryDto> factories = new ArrayList<>();
for (String factoryID : factoryIDs) {
factories.add(factoryConnection.getFactory(factoryID));
}
return factories
.stream()
.filter(
f ->
(f != null)
&& (f.getWorkspace()
.getProjects()
.stream()
.anyMatch(
p -> matcher.isCloneUrlMatching(p, headRepositoryUrl, headBranch))))
.collect(toList());
}