use of org.platformlayer.RepositoryException in project platformlayer by platformlayer.
the class JdbcJobRepository method findJob.
@Override
@JdbcTransaction
public JobData findJob(PlatformLayerKey jobKey) throws RepositoryException {
DbHelper db = new DbHelper();
try {
ProjectId projectId = jobKey.getProject();
String jobId = jobKey.getItemIdString();
JobEntity execution = db.queries.findJob(db.mapToValue(projectId), jobId);
if (execution == null) {
return null;
}
return mapFromEntity(execution, jobKey);
} catch (SQLException e) {
throw new RepositoryException("Error listing job executions", e);
} finally {
db.close();
}
}
use of org.platformlayer.RepositoryException in project platformlayer by platformlayer.
the class JdbcJobRepository method toXml.
private String toXml(Action action) throws RepositoryException {
Object o;
try {
Marshaller marshaller = jaxbContext.createMarshaller();
StringWriter writer = new StringWriter();
marshaller.marshal(action, writer);
return writer.toString();
} catch (JAXBException e) {
throw new RepositoryException("Error serializing action", e);
}
}
use of org.platformlayer.RepositoryException in project platformlayer by platformlayer.
the class JdbcJobRepository method insertJob.
@Override
@JdbcTransaction
public String insertJob(ProjectId projectId, JobData jobData) throws RepositoryException {
DbHelper db = new DbHelper();
try {
String jobId = UUID.randomUUID().toString();
JobEntity entity = new JobEntity();
entity.project = db.mapToValue(projectId);
entity.jobId = jobId;
entity.actionXml = toXml(jobData.action);
entity.target = jobData.targetId.getUrl();
int updateCount = db.queries.insert(entity);
if (updateCount != 1) {
throw new RepositoryException("Unexpected number of rows inserted");
}
return jobId;
} catch (SQLException e) {
throw new RepositoryException("Error inserting job execution", e);
} finally {
db.close();
}
}
use of org.platformlayer.RepositoryException in project platformlayer by platformlayer.
the class JdbcUserRepository method listProjectsByUserId.
@Override
@JdbcTransaction
public List<ProjectEntity> listProjectsByUserId(int userId) throws RepositoryException {
DbHelper db = new DbHelper();
try {
List<ProjectEntity> projects = Lists.newArrayList();
projects.addAll(db.findProjectsByUserId(userId));
return projects;
} catch (SQLException e) {
throw new RepositoryException("Error reading groups", e);
} finally {
db.close();
}
}
use of org.platformlayer.RepositoryException in project platformlayer by platformlayer.
the class JdbcUserRepository method listAllProjectNames.
@Override
@JdbcTransaction
public List<String> listAllProjectNames(String prefix) throws RepositoryException {
String match;
if (prefix == null) {
match = "%";
} else {
match = prefix + "%";
}
DbHelper db = new DbHelper();
try {
return db.listProjects(match);
} catch (SQLException e) {
throw new RepositoryException("Error listing projects", e);
} finally {
db.close();
}
}
Aggregations