use of org.eclipse.che.api.core.ServerException in project che by eclipse.
the class StackLoaderTest method predefinedStackWithValidJsonShouldBeCreated2.
@Test
public void predefinedStackWithValidJsonShouldBeCreated2() throws ServerException, NotFoundException, ConflictException {
URL url = Resources.getResource("stacks.json");
URL urlFolder = Thread.currentThread().getContextClassLoader().getResource("stack_img");
doThrow(new ServerException("Internal server error")).when(stackDao).update(any());
stackLoader = new StackLoader(url.getPath(), urlFolder.getPath(), stackDao, null);
stackLoader.start();
verify(stackDao, times(5)).update(any());
verify(stackDao, times(5)).create(any());
}
use of org.eclipse.che.api.core.ServerException in project che by eclipse.
the class WorkspaceDaoTest method shouldNotRemoveWorkspaceWhenSubscriberThrowsExceptionOnWorkspaceRemoving.
@Test(dependsOnMethods = "shouldGetWorkspaceById")
public void shouldNotRemoveWorkspaceWhenSubscriberThrowsExceptionOnWorkspaceRemoving() throws Exception {
final WorkspaceImpl workspace = workspaces[0];
CascadeEventSubscriber<BeforeWorkspaceRemovedEvent> subscriber = mockCascadeEventSubscriber();
doThrow(new ServerException("error")).when(subscriber).onCascadeEvent(any());
eventService.subscribe(subscriber, BeforeWorkspaceRemovedEvent.class);
try {
workspaceDao.remove(workspace.getId());
fail("WorkspaceDao#remove had to throw server exception");
} catch (ServerException ignored) {
}
assertEquals(workspaceDao.get(workspace.getId()), workspace);
eventService.unsubscribe(subscriber, BeforeWorkspaceRemovedEvent.class);
}
use of org.eclipse.che.api.core.ServerException in project che by eclipse.
the class JpaPreferenceDao method getPreferences.
@Override
@Transactional
public Map<String, String> getPreferences(String userId) throws ServerException {
requireNonNull(userId);
try {
final EntityManager manager = managerProvider.get();
final PreferenceEntity prefs = manager.find(PreferenceEntity.class, userId);
return prefs == null ? new HashMap<>() : prefs.getPreferences();
} catch (RuntimeException ex) {
throw new ServerException(ex.getLocalizedMessage(), ex);
}
}
use of org.eclipse.che.api.core.ServerException in project che by eclipse.
the class ComposerProjectInitializer method onProjectInitialized.
@Override
public void onProjectInitialized(ProjectRegistry registry, FolderEntry projectFolder) throws ServerException, ForbiddenException, ConflictException, NotFoundException {
String[] commandLine = { "composer", "install" };
File workDir = projectFolder.getVirtualFile().toIoFile();
try {
ComposerCommandExecutor.execute(commandLine, workDir);
} catch (TimeoutException | IOException | InterruptedException e) {
throw new ServerException(e);
}
}
use of org.eclipse.che.api.core.ServerException in project che by eclipse.
the class ApiInfoService method readApiInfo.
private ApiInfo readApiInfo() throws ServerException {
try {
URL url = ApiInfoService.class.getProtectionDomain().getCodeSource().getLocation();
try (JarFile jar = new JarFile(new File(url.toURI()))) {
final Manifest manifest = requireNonNull(jar.getManifest(), "Manifest must not be null");
final Attributes mainAttributes = manifest.getMainAttributes();
final DtoFactory dtoFactory = DtoFactory.getInstance();
return dtoFactory.createDto(ApiInfo.class).withSpecificationVendor(mainAttributes.getValue("Specification-Vendor")).withImplementationVendor(mainAttributes.getValue("Implementation-Vendor")).withSpecificationTitle("Codenvy REST API").withSpecificationVersion(mainAttributes.getValue("Specification-Version")).withImplementationVersion(mainAttributes.getValue("Implementation-Version")).withScmRevision(mainAttributes.getValue("SCM-Revision"));
}
} catch (Exception e) {
LOG.error(e.getMessage(), e);
throw new ServerException("Unable read info about API. Contact support for assistance.");
}
}
Aggregations