use of cz.metacentrum.perun.core.api.Attribute in project perun by CESNET.
the class GroupsManagerBlImpl method isThisLightweightSynchronization.
/**
* Return true if attribute group:lightweightSynchronization is set to true.
* False if not.
*
* True means: we don't want to update existing members (attributes, statuses etc.), just
* add new members and remove former members
* False means: we want to do whole synchronization process including updating operations
*
* @param sess
* @param group to be synchronized
*
* @return true if this is lightweightSynchronization, false if not
*
* @throws InternalErrorException if something happens while getting lightweightSynchronization attribute
* @throws WrongAttributeAssignmentException if bad assignment of lightweightSynchronization attribute
* @throws AttributeNotExistsException if lightweightSynchronization attribute not exists in perun Database
*/
private boolean isThisLightweightSynchronization(PerunSession sess, Group group) throws WrongAttributeAssignmentException, AttributeNotExistsException {
Attribute lightweightSynchronzationAttr = getPerunBl().getAttributesManagerBl().getAttribute(sess, group, GroupsManager.GROUPLIGHTWEIGHTSYNCHRONIZATION_ATTRNAME);
boolean lightweightSynchronization = false;
if (lightweightSynchronzationAttr != null && lightweightSynchronzationAttr.getValue() != null) {
lightweightSynchronization = (Boolean) lightweightSynchronzationAttr.getValue();
}
return lightweightSynchronization;
}
use of cz.metacentrum.perun.core.api.Attribute in project perun by CESNET.
the class ResourcesManagerBlImpl method copyAttributes.
@Override
public void copyAttributes(PerunSession sess, Resource sourceResource, Resource destinationResource) throws WrongReferenceAttributeValueException {
List<Attribute> sourceAttributes = getPerunBl().getAttributesManagerBl().getAttributes(sess, sourceResource);
List<Attribute> destinationAttributes = getPerunBl().getAttributesManagerBl().getAttributes(sess, destinationResource);
// do not get virtual attributes from source resource, they can't be set to destination
sourceAttributes.removeIf(attribute -> attribute.getNamespace().startsWith(AttributesManager.NS_RESOURCE_ATTR_VIRT));
// create intersection of destination and source attributes
List<Attribute> intersection = new ArrayList<>(destinationAttributes);
intersection.retainAll(sourceAttributes);
try {
// delete all common attributes from destination resource
getPerunBl().getAttributesManagerBl().removeAttributes(sess, destinationResource, intersection);
// add all attributes from the source resource to the destination resource
getPerunBl().getAttributesManagerBl().setAttributes(sess, destinationResource, sourceAttributes);
} catch (WrongAttributeAssignmentException ex) {
throw new InternalErrorException("Copying of attributes failed, wrong assignment.", ex);
} catch (WrongAttributeValueException ex) {
throw new ConsistencyErrorException("Copying of attributes failed.", ex);
}
}
use of cz.metacentrum.perun.core.api.Attribute in project perun by CESNET.
the class ModulesUtilsBlImpl method findCollisionResourcesWithSameGroupName.
public List<Resource> findCollisionResourcesWithSameGroupName(PerunSessionImpl sess, Group group, String namespace) throws WrongAttributeAssignmentException, AttributeNotExistsException {
Utils.notNull(sess, "perunSessionImpl");
Utils.notNull(group, "group");
Utils.notNull(namespace, "namespace");
Attribute groupUnixGroupName = getPerunBl().getAttributesManagerBl().getAttribute(sess, group, A_G_unixGroupName_namespace + ":" + namespace);
Attribute copyResourceUnixGroupName = new Attribute(getPerunBl().getAttributesManagerBl().getAttributeDefinition(sess, A_R_unixGroupName_namespace + ":" + namespace));
copyResourceUnixGroupName.setValue(groupUnixGroupName.getValue());
return getPerunBl().getResourcesManagerBl().getResourcesByAttribute(sess, copyResourceUnixGroupName);
}
use of cz.metacentrum.perun.core.api.Attribute in project perun by CESNET.
the class ModulesUtilsBlImpl method findCollisionResourcesWithSameGid.
public List<Resource> findCollisionResourcesWithSameGid(PerunSessionImpl sess, Group group, String namespace) throws WrongAttributeAssignmentException, AttributeNotExistsException {
Utils.notNull(sess, "perunSessionImpl");
Utils.notNull(group, "group");
Utils.notNull(namespace, "namespace");
Attribute groupUnixGid = getPerunBl().getAttributesManagerBl().getAttribute(sess, group, A_G_unixGID_namespace + ":" + namespace);
Attribute copyResourceUnixGid = new Attribute(getPerunBl().getAttributesManagerBl().getAttributeDefinition(sess, A_R_unixGID_namespace + ":" + namespace));
copyResourceUnixGid.setValue(groupUnixGid.getValue());
return getPerunBl().getResourcesManagerBl().getResourcesByAttribute(sess, copyResourceUnixGid);
}
use of cz.metacentrum.perun.core.api.Attribute in project perun by CESNET.
the class ModulesUtilsBlImpl method getListOfResourceGIDsFromListOfGroupGIDs.
@Override
public List<Attribute> getListOfResourceGIDsFromListOfGroupGIDs(PerunSessionImpl sess, List<Attribute> groupGIDs) throws AttributeNotExistsException {
List<Attribute> resourceGIDs = new ArrayList<>();
if (groupGIDs == null || groupGIDs.isEmpty()) {
return resourceGIDs;
}
for (Attribute a : groupGIDs) {
Attribute resourceGID = new Attribute(sess.getPerunBl().getAttributesManagerBl().getAttributeDefinition(sess, A_R_unixGID_namespace + ":" + a.getFriendlyNameParameter()));
resourceGID.setValue(a.getValue());
resourceGIDs.add(resourceGID);
}
return resourceGIDs;
}
Aggregations