use of org.openstack4j.model.identity.v3.Project in project camel by apache.
the class ProjectProducer method doUpdate.
private void doUpdate(Exchange exchange) {
final Message msg = exchange.getIn();
final Project in = messageToProject(msg);
final Project out = osV3Client.identity().projects().update(in);
msg.setBody(out);
}
use of org.openstack4j.model.identity.v3.Project in project camel by apache.
the class ProjectProducer method messageToProject.
private Project messageToProject(Message message) {
Project project = message.getBody(Project.class);
if (project == null) {
Map headers = message.getHeaders();
ProjectBuilder builder = Builders.project();
ObjectHelper.notEmpty(message.getHeader(OpenstackConstants.NAME, String.class), "Name");
builder.name(message.getHeader(OpenstackConstants.NAME, String.class));
if (headers.containsKey(KeystoneConstants.DOMAIN_ID)) {
builder.domainId(message.getHeader(KeystoneConstants.DOMAIN_ID, String.class));
}
if (headers.containsKey(KeystoneConstants.DESCRIPTION)) {
builder.description(message.getHeader(KeystoneConstants.DESCRIPTION, String.class));
}
if (headers.containsKey(KeystoneConstants.PARENT_ID)) {
builder.parentId(message.getHeader(KeystoneConstants.PARENT_ID, String.class));
}
project = builder.build();
}
return project;
}
use of org.openstack4j.model.identity.v3.Project in project camel by apache.
the class ProjectProducer method doGet.
private void doGet(Exchange exchange) {
final Message msg = exchange.getIn();
final String id = msg.getHeader(OpenstackConstants.ID, String.class);
ObjectHelper.notEmpty(id, "Project ID");
final Project result = osV3Client.identity().projects().get(id);
msg.setBody(result);
}
use of org.openstack4j.model.identity.v3.Project in project camel by apache.
the class ProjectProducerTest method setUp.
@Before
public void setUp() {
producer = new ProjectProducer(endpoint, client);
when(projectService.create(any(Project.class))).thenReturn(testOSproject);
when(projectService.get(anyString())).thenReturn(testOSproject);
List<Project> getAllList = new ArrayList<>();
getAllList.add(testOSproject);
getAllList.add(testOSproject);
doReturn(getAllList).when(projectService).list();
dummyProject = createProject();
when(testOSproject.getName()).thenReturn(dummyProject.getName());
when(testOSproject.getDescription()).thenReturn(dummyProject.getDescription());
}
use of org.openstack4j.model.identity.v3.Project in project TrakEM2 by trakem2.
the class DBLoader method getProjects.
/**
* Fetch all existing projects from the database.
*/
public Project[] getProjects() {
synchronized (db_lock) {
// connect if disconnected
if (!connectToDatabase()) {
return null;
}
Project[] projects = null;
try {
ResultSet r = connection.prepareStatement("SELECT title, id FROM ab_projects ORDER BY id").executeQuery();
ArrayList<Project> al_projects = new ArrayList<Project>();
while (r.next()) {
al_projects.add(new Project(r.getLong("id"), r.getString("title")));
}
r.close();
projects = new Project[al_projects.size()];
al_projects.toArray(projects);
} catch (Exception e) {
IJError.print(e);
return null;
}
return projects;
}
}
Aggregations