package net.sourceforge.fenixedu.domain.security; import java.util.ArrayList; import java.util.List; import net.sourceforge.fenixedu.domain.RootDomainObject; import net.sourceforge.fenixedu.domain.User; import org.joda.time.DateTime; public class PathRestrictionTemplate extends PathRestrictionTemplate_Base { public PathRestrictionTemplate() { super(); this.setRootDomainObject(RootDomainObject.getInstance()); } public PathRestrictionTemplate(String label, String whyMessage, String urlPathRegex, Boolean responsibleAvailableForContact, String responsibleEmail, DateTime startDate, DateTime endDate) { this(); this.setLabel(label); this.setWhyMessage(whyMessage); this.setUrlPathRegex(urlPathRegex); this.setResponsibleAvailableForContact(responsibleAvailableForContact); this.setResponsibleEmail(responsibleEmail); this.setStart(startDate); this.setEnd(endDate); } public void blockUser(User user) { PathRestriction pathRestriction = new PathRestriction(); pathRestriction.setUser(user); pathRestriction.setPathRestrictionTemplate(this); pathRestriction.setEnd(getEnd()); } public void blockUsers(User... users) { for (User user : users) { blockUser(user); } } public void clearAllActiveRestrictions() { List activeRestrictions = new ArrayList(getAppliedRestrictionsCount()); for (PathRestriction pathRestriction : getAppliedRestrictions()) { if (pathRestriction.isActive()) { activeRestrictions.add(pathRestriction); } } for (PathRestriction pathRestriction : activeRestrictions) { pathRestriction.delete(); } } }