use of cz.metacentrum.perun.core.api.Service in project perun by CESNET.
the class ServicesManagerEntryIntegrationTest method getServiceByName.
@Test
public void getServiceByName() throws Exception {
System.out.println(CLASS_NAME + "getServiceByName");
service = setUpService();
assertNotNull("unable to create service", service);
Service returnedService = perun.getServicesManager().getServiceByName(sess, service.getName());
assertEquals("cannot get service by Name", returnedService, service);
}
use of cz.metacentrum.perun.core.api.Service in project perun by CESNET.
the class ServicesManagerEntryIntegrationTest method removeRequiredAttributesWhenServiceNotExists.
@Test(expected = ServiceNotExistsException.class)
public void removeRequiredAttributesWhenServiceNotExists() throws Exception {
System.out.println(CLASS_NAME + "removeRequiredAttributesWhenServiceNotExists");
List<AttributeDefinition> attributes = setUpRequiredAttribute();
perun.getServicesManager().removeRequiredAttributes(sess, new Service(), attributes);
// shouldn't find service
}
use of cz.metacentrum.perun.core.api.Service in project perun by CESNET.
the class ServicesManagerBlImpl method addDestination.
public Destination addDestination(PerunSession perunSession, List<Service> services, Facility facility, Destination destination) throws InternalErrorException, DestinationAlreadyAssignedException {
if (!getServicesManagerImpl().destinationExists(perunSession, destination)) {
try {
//Try to get the destination without id
destination = getServicesManagerImpl().getDestination(perunSession, destination.getDestination(), destination.getType());
} catch (DestinationNotExistsException ex) {
try {
destination = createDestination(perunSession, destination);
} catch (DestinationExistsException e) {
throw new ConsistencyErrorException(e);
}
}
}
for (Service s : services) {
if (!getServicesManagerImpl().destinationExists(perunSession, s, facility, destination)) {
getServicesManagerImpl().addDestination(perunSession, s, facility, destination);
getPerunBl().getAuditer().log(perunSession, "{} added to {} and {}.", destination, s, facility);
}
}
return destination;
}
use of cz.metacentrum.perun.core.api.Service in project perun by CESNET.
the class ServicesManagerBlImpl method addDestinationsForAllServicesOnFacility.
@Override
public List<Destination> addDestinationsForAllServicesOnFacility(PerunSession sess, Facility facility, Destination destination) throws InternalErrorException, DestinationAlreadyAssignedException {
List<Service> services = this.getAssignedServices(sess, facility);
List<Destination> destinations = new ArrayList<Destination>();
for (Service service : services) {
destinations.add(this.addDestination(sess, service, facility, destination));
}
return destinations;
}
use of cz.metacentrum.perun.core.api.Service in project perun by CESNET.
the class ExecServiceDependencyDaoTest method beforeClass.
@Before
public void beforeClass() {
try {
perunSession = perun.getPerunSession(new PerunPrincipal("perunTests", ExtSourcesManager.EXTSOURCE_NAME_INTERNAL, ExtSourcesManager.EXTSOURCE_INTERNAL), new PerunClient());
} catch (InternalErrorException e) {
log.error(e.toString());
}
jdbcTemplate = new JdbcPerunTemplate(dataSource);
// Test Owner
int newOwnerId = 0;
try {
newOwnerId = Utils.getNewId(jdbcTemplate, "owners_id_seq");
} catch (InternalErrorException e) {
log.error(e.toString(), e);
}
testOwner = new Owner();
testOwner.setContact("Call me babe");
testOwner.setType(OwnerType.technical);
testOwner.setName("Tester-" + Long.toHexString(System.currentTimeMillis()));
testOwner.setId(newOwnerId);
jdbcTemplate.update("insert into owners(id, name, contact, type) values (?,?,?,?)", newOwnerId, testOwner.getName(), testOwner.getContact(), testOwner.getType().toString());
// Test Service #1
testService1 = new Service();
testService1.setName("Test_service_1_" + Long.toHexString(System.currentTimeMillis()));
// Test Service #2
testService2 = new Service();
testService2.setName("Test_service_2_" + Long.toHexString(System.currentTimeMillis()));
try {
testService1.setId(servicesManager.createService(perunSession, testService1).getId());
testService2.setId(servicesManager.createService(perunSession, testService2).getId());
} catch (InternalErrorException e) {
log.error(e.toString());
} catch (PrivilegeException e) {
log.error(e.toString());
} catch (ServiceExistsException e) {
log.error(e.toString());
}
// Test ExecService #1 (Parent:testService1)
testExecService1 = new ExecService();
testExecService1.setDefaultDelay(1);
testExecService1.setDefaultRecurrence(1);
testExecService1.setEnabled(true);
testExecService1.setService(testService1);
testExecService1.setScript("/hellish/test/script");
testExecService1.setExecServiceType(ExecServiceType.GENERATE);
try {
testExecService1.setId(execServiceDao.insertExecService(testExecService1));
} catch (InternalErrorException e) {
log.error(e.toString(), e);
}
// Test ExecService #2 (Parent:testService1)
testExecService2 = new ExecService();
testExecService2.setDefaultDelay(2);
testExecService2.setDefaultRecurrence(2);
testExecService2.setEnabled(true);
testExecService2.setService(testService1);
testExecService2.setScript("/hellish/test/script2");
testExecService2.setExecServiceType(ExecServiceType.SEND);
try {
testExecService2.setId(execServiceDao.insertExecService(testExecService2));
} catch (InternalErrorException e) {
log.error(e.toString(), e);
}
// Test ExecService #3 (Parent:testService2)
testExecService3 = new ExecService();
testExecService3.setDefaultDelay(3);
testExecService3.setDefaultRecurrence(3);
testExecService3.setEnabled(true);
testExecService3.setService(testService2);
testExecService3.setScript("/hellish/test/script3");
testExecService3.setExecServiceType(ExecServiceType.SEND);
try {
testExecService3.setId(execServiceDao.insertExecService(testExecService3));
} catch (InternalErrorException e) {
log.error(e.toString(), e);
}
}
Aggregations