use of cz.metacentrum.perun.core.bl.ResourcesManagerBl in project perun by CESNET.
the class urn_perun_group_attribute_def_def_adName_o365muTest method setUp.
@Before
public void setUp() throws Exception {
classInstance = new urn_perun_group_attribute_def_def_adName_o365mu();
attributeToCheck = new Attribute();
sess = mock(PerunSessionImpl.class);
reqAttribute1 = new Attribute();
reqAttribute2 = new Attribute();
// perunBl
PerunBl perunBl = mock(PerunBl.class);
when(sess.getPerunBl()).thenReturn(perunBl);
// managers
attributesManagerBl = mock(AttributesManagerBl.class);
when(perunBl.getAttributesManagerBl()).thenReturn(attributesManagerBl);
resourcesManagerBl = mock(ResourcesManagerBl.class);
when(perunBl.getResourcesManagerBl()).thenReturn(resourcesManagerBl);
// specific methods
when(attributesManagerBl.getAttribute(sess, resource1, AttributesManager.NS_RESOURCE_ATTR_DEF + ":adOuName")).thenReturn(reqAttribute1);
when(attributesManagerBl.getAttribute(sess, resource2, AttributesManager.NS_RESOURCE_ATTR_DEF + ":adOuName")).thenReturn(reqAttribute2);
}
use of cz.metacentrum.perun.core.bl.ResourcesManagerBl in project perun by CESNET.
the class ServicesManagerBlImpl method deleteService.
/*
* Tables with reference to service:
* - service_required_attrs
* - service_denials
* - resource_services
* - facility_service_destinations
* - service_service_packages
* - tasks
* - authz
*/
@Override
public void deleteService(PerunSession perunSession, Service service, boolean forceFlag) throws RelationExistsException, ServiceAlreadyRemovedException {
List<Resource> assignedResources = this.getAssignedResources(perunSession, service);
if (forceFlag) {
// Remove all denials for this service
getServicesManagerImpl().unblockService(service.getId());
// Remove from assigned resources
ResourcesManagerBl resourcesManager = getPerunBl().getResourcesManagerBl();
for (Resource resource : assignedResources) {
try {
resourcesManager.removeService(perunSession, resource, service);
// Remove from facility_service_destinations
Facility facility = getPerunBl().getFacilitiesManagerBl().getFacilityById(perunSession, resource.getFacilityId());
removeAllDestinations(perunSession, service, facility);
} catch (ServiceNotAssignedException | FacilityNotExistsException e) {
// should not happen
throw new InternalErrorException("Error removing service", e);
}
}
// Remove from service packages
getServicesManagerImpl().removeServiceFromAllServicesPackages(perunSession, service);
// Remove all related tasks
getPerunBl().getTasksManagerBl().removeAllTasksForService(perunSession, service);
} else {
if (assignedResources.size() > 0) {
throw new RelationExistsException("Service is defined on some resource");
}
}
getServicesManagerImpl().removeAllRequiredAttributes(perunSession, service);
getServicesManagerImpl().deleteService(perunSession, service);
getPerunBl().getAuditer().log(perunSession, new ServiceDeleted(service));
}
use of cz.metacentrum.perun.core.bl.ResourcesManagerBl in project perun by CESNET.
the class urn_perun_resource_attribute_def_def_unixGroupName_namespaceTest method setUp.
@Before
public void setUp() throws Exception {
classInstance = new urn_perun_resource_attribute_def_def_unixGroupName_namespace();
attributeToCheck = new Attribute();
attributeToCheck.setFriendlyName("unixGID-namespace");
sess = mock(PerunSessionImpl.class);
PerunBl perunBl = mock(PerunBl.class);
when(sess.getPerunBl()).thenReturn(perunBl);
AttributesManagerBl attributesManagerBl = mock(AttributesManagerBl.class);
when(perunBl.getAttributesManagerBl()).thenReturn(attributesManagerBl);
when(sess.getPerunBl().getAttributesManagerBl().getAttributeDefinition(sess, AttributesManager.NS_GROUP_ATTR_DEF + ":unixGroupName-namespace:")).thenReturn(attributeToCheck);
GroupsManagerBl groupsManagerBl = mock(GroupsManagerBl.class);
when(sess.getPerunBl().getGroupsManagerBl()).thenReturn(groupsManagerBl);
ModulesUtilsBl modulesUtilsBl = mock(ModulesUtilsBl.class);
when(sess.getPerunBl().getModulesUtilsBl()).thenReturn(modulesUtilsBl);
ResourcesManagerBl resourcesManagerBl = mock(ResourcesManagerBl.class);
when(sess.getPerunBl().getResourcesManagerBl()).thenReturn(resourcesManagerBl);
}
use of cz.metacentrum.perun.core.bl.ResourcesManagerBl in project perun by CESNET.
the class urn_perun_resource_attribute_def_def_homeMountPointsTest method setUp.
@Before
public void setUp() throws Exception {
classInstance = new urn_perun_resource_attribute_def_def_homeMountPoints();
attributeToCheck = new Attribute();
reqAttribute = new Attribute();
sess = mock(PerunSessionImpl.class);
Facility facility = new Facility();
List<String> value = new ArrayList<>();
value.add("/example");
attributeToCheck.setValue(value);
reqAttribute.setValue(value);
PerunBl perunBl = mock(PerunBl.class);
when(sess.getPerunBl()).thenReturn(perunBl);
AttributesManagerBl attributesManagerBl = mock(AttributesManagerBl.class);
when(perunBl.getAttributesManagerBl()).thenReturn(attributesManagerBl);
when(sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, facility, AttributesManager.NS_FACILITY_ATTR_DEF + ":homeMountPoints")).thenReturn(reqAttribute);
ResourcesManagerBl resourcesManagerBl = mock(ResourcesManagerBl.class);
when(perunBl.getResourcesManagerBl()).thenReturn(resourcesManagerBl);
when(resourcesManagerBl.getFacility(sess, resource)).thenReturn(facility);
}
Aggregations