use of org.eclipse.che.api.core.NotFoundException in project che by eclipse.
the class MavenServerService method getEffectivePom.
/**
* Returns maven effective pom file.
*
* @param projectPath
* path to the opened pom file
* @return content of the effective pom
* @throws ServerException
* when getting mount point has a problem
* @throws NotFoundException
* when current pom file isn't exist
* @throws ForbiddenException
* when response code is 403
*/
@GET
@Path("effective/pom")
@Produces(TEXT_XML)
public String getEffectivePom(@QueryParam("projectpath") String projectPath) throws ServerException, NotFoundException, ForbiddenException {
RegisteredProject project = projectRegistry.getProject(projectPath);
if (project == null) {
throw new NotFoundException("Project " + projectPath + " doesn't exist");
}
MavenServerWrapper mavenServer = wrapperManager.getMavenServer(MavenWrapperManager.ServerType.DOWNLOAD);
try {
mavenServer.customize(projectManager.copyWorkspaceCache(), terminal, notifier, false, false);
VirtualFileEntry pomFile = project.getBaseFolder().getChild("pom.xml");
if (pomFile == null) {
throw new NotFoundException("pom.xml doesn't exist");
}
return mavenServer.getEffectivePom(pomFile.getVirtualFile().toIoFile(), Collections.emptyList(), Collections.emptyList());
} finally {
wrapperManager.release(mavenServer);
}
}
use of org.eclipse.che.api.core.NotFoundException in project che by eclipse.
the class JpaProfileDao method getById.
@Override
@Transactional
public ProfileImpl getById(String userId) throws NotFoundException, ServerException {
requireNonNull(userId, "Required non-null id");
try {
final EntityManager manager = managerProvider.get();
final ProfileImpl profile = manager.find(ProfileImpl.class, userId);
if (profile == null) {
throw new NotFoundException(format("Couldn't find profile for user with id '%s'", userId));
}
manager.refresh(profile);
return profile;
} catch (RuntimeException x) {
throw new ServerException(x.getLocalizedMessage(), x);
}
}
use of org.eclipse.che.api.core.NotFoundException in project che by eclipse.
the class JpaUserDao method doUpdate.
@Transactional
protected void doUpdate(UserImpl update) throws NotFoundException {
final EntityManager manager = managerProvider.get();
final UserImpl user = manager.find(UserImpl.class, update.getId());
if (user == null) {
throw new NotFoundException(format("Couldn't update user with id '%s' because it doesn't exist", update.getId()));
}
final String password = update.getPassword();
if (password != null) {
update.setPassword(encryptor.encrypt(password));
} else {
update.setPassword(user.getPassword());
}
manager.merge(update);
manager.flush();
}
use of org.eclipse.che.api.core.NotFoundException in project che by eclipse.
the class JpaUserDao method getByAliasAndPassword.
@Override
@Transactional
public UserImpl getByAliasAndPassword(String emailOrName, String password) throws NotFoundException, ServerException {
requireNonNull(emailOrName, "Required non-null email or name");
requireNonNull(password, "Required non-null password");
try {
final UserImpl user = managerProvider.get().createNamedQuery("User.getByAliasAndPassword", UserImpl.class).setParameter("alias", emailOrName).getSingleResult();
if (!encryptor.test(password, user.getPassword())) {
throw new NotFoundException(format("User with email or name '%s' and given password doesn't exist", emailOrName));
}
return erasePassword(user);
} catch (NoResultException x) {
throw new NotFoundException(format("User with email or name '%s' and given password doesn't exist", emailOrName));
} catch (RuntimeException x) {
throw new ServerException(x.getLocalizedMessage(), x);
}
}
use of org.eclipse.che.api.core.NotFoundException in project che by eclipse.
the class JpaSshDao method doRemove.
@Transactional
protected void doRemove(String owner, String service, String name) throws NotFoundException {
EntityManager manager = managerProvider.get();
SshPairImpl entity = manager.find(SshPairImpl.class, new SshPairPrimaryKey(owner, service, name));
if (entity == null) {
throw new NotFoundException(format("Ssh pair with service '%s' and name '%s' was not found.", service, name));
}
manager.remove(entity);
manager.flush();
}
Aggregations