package pt.iscte.ci.zas; import java.util.HashSet; import java.util.Set; import net.sourceforge.fenixedu._development.PropertiesManager; import net.sourceforge.fenixedu.applicationTier.IUserView; import net.sourceforge.fenixedu.domain.Employee; import net.sourceforge.fenixedu.domain.person.RoleType; import net.sourceforge.zas.aop.bridge.IAOPMetaData; /** * * @author rjmvo * */ public class AcademicOfficeResponsableDecider extends FenixBaseDecider { @Override public boolean internalHasAccess(IUserView subject, String protectedObjectAbstractAccessModes, IAOPMetaData aopMetaData) { if (hasRoleTypes(subject, getDeciderRoleTypes())) { if (isResponsable(subject)) { return true; } } return false; } private boolean isResponsable(final IUserView currentSubject) { final Employee employee = currentSubject.getPerson().getEmployee(); final String[] responsables = PropertiesManager.getProperty("academicServices.responsables").split(","); for (final String responsable : responsables) { if (employee.getEmployeeNumber().equals(Integer.valueOf(responsable))) { return true; } } return false; } private Set getDeciderRoleTypes() { final Set roles = new HashSet(); roles.add(RoleType.EMPLOYEE); roles.add(RoleType.ACADEMIC_ADMINISTRATIVE_OFFICE); return roles; } }