Search in sources :

Example 11 with FacilityNotExistsException

use of cz.metacentrum.perun.core.api.exceptions.FacilityNotExistsException in project perun by CESNET.

the class EventProcessorImpl method getFacilityEntityIdValue.

/**
	 * Get entityID value from perun by facilityId.
	 *
	 * @param facilityId the facilityId
	 * @return value of entityID or null, if value is null or user not exists yet
	 * @throws InternalErrorException if some exception is thrown from RPC
	 */
private String getFacilityEntityIdValue(int facilityId) throws InternalErrorException {
    Facility facility = null;
    try {
        facility = Rpc.FacilitiesManager.getFacilityById(ldapcManager.getRpcCaller(), facilityId);
    } catch (PrivilegeException ex) {
        throw new InternalErrorException("There are no privilegies for getting facility by id.", ex);
    } catch (FacilityNotExistsException ex) {
        //If facility not exist in perun now, probably will be deleted in next step so its ok. The value is null anyway.
        return null;
    }
    cz.metacentrum.perun.core.api.Attribute entityID = null;
    try {
        entityID = Rpc.AttributesManager.getAttribute(ldapcManager.getRpcCaller(), facility, AttributesManager.NS_FACILITY_ATTR_DEF + ":entityID");
    } catch (PrivilegeException ex) {
        throw new InternalErrorException("There are no privilegies for getting facility attribute.", ex);
    } catch (AttributeNotExistsException ex) {
        throw new InternalErrorException("There is no such attribute.", ex);
    } catch (FacilityNotExistsException ex) {
        //If facility not exist in perun now, probably will be deleted in next step so its ok. The value is null anyway.
        return null;
    } catch (WrongAttributeAssignmentException ex) {
        throw new InternalErrorException("There is problem with wrong attribute assignment exception.", ex);
    }
    if (entityID.getValue() == null)
        return null;
    else
        return (String) entityID.getValue();
}
Also used : WrongAttributeAssignmentException(cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException) AttributeNotExistsException(cz.metacentrum.perun.core.api.exceptions.AttributeNotExistsException) PrivilegeException(cz.metacentrum.perun.core.api.exceptions.PrivilegeException) FacilityNotExistsException(cz.metacentrum.perun.core.api.exceptions.FacilityNotExistsException) InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException) cz.metacentrum.perun.core.api(cz.metacentrum.perun.core.api)

Aggregations

FacilityNotExistsException (cz.metacentrum.perun.core.api.exceptions.FacilityNotExistsException)11 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)8 Facility (cz.metacentrum.perun.core.api.Facility)7 PrivilegeException (cz.metacentrum.perun.core.api.exceptions.PrivilegeException)5 Attribute (cz.metacentrum.perun.core.api.Attribute)4 ExecService (cz.metacentrum.perun.taskslib.model.ExecService)4 ArrayList (java.util.ArrayList)4 User (cz.metacentrum.perun.core.api.User)3 ServiceNotExistsException (cz.metacentrum.perun.core.api.exceptions.ServiceNotExistsException)3 UserNotExistsException (cz.metacentrum.perun.core.api.exceptions.UserNotExistsException)3 Date (java.util.Date)3 Group (cz.metacentrum.perun.core.api.Group)2 PerunSession (cz.metacentrum.perun.core.api.PerunSession)2 Resource (cz.metacentrum.perun.core.api.Resource)2 Service (cz.metacentrum.perun.core.api.Service)2 AttributeNotExistsException (cz.metacentrum.perun.core.api.exceptions.AttributeNotExistsException)2 ConsistencyErrorException (cz.metacentrum.perun.core.api.exceptions.ConsistencyErrorException)2 MemberNotExistsException (cz.metacentrum.perun.core.api.exceptions.MemberNotExistsException)2 WrongAttributeAssignmentException (cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException)2 DispatcherQueue (cz.metacentrum.perun.dispatcher.jms.DispatcherQueue)2