Package domain

Examples of domain.PermissionType


  @Override
  protected Response internalExecute(HttpServletRequest request, Session databaseSession) {
    Response response = null;
    try {
      // New event creation:
      PermissionType permisssionTypeObject = (PermissionType) databaseSession.createCriteria(PermissionType.class)
                                            .add(Restrictions.eq("id", this.permissionType))
                                            .uniqueResult();

      RepetitionType repetitionTypeObject = (RepetitionType) databaseSession.createCriteria(RepetitionType.class)
                                            .add(Restrictions.eq("id", this.repetitionType))
                                            .uniqueResult();
     
      EventType eventTypeObject = (EventType) databaseSession.createCriteria(EventType.class)
                                  .add(Restrictions.eq("id", this.eventType))
                                  .uniqueResult();
      Date fromDate = DateOperator.stringToDate(this.from);
      Date toDate = DateOperator.stringToDate(this.to);
   
      if( (null == fromDate) || (null == toDate) ) {
        throw new IllegalArgumentException("Date has wrong format");
      }
      if( !DateOperator.date1IsBeforeDate2(fromDate, toDate) ) {
        throw new IllegalArgumentException("From date should be before to date");
      }
      if( !DateOperator.isRepetitionPossible(fromDate, toDate, repetitionTypeObject) ) {
        return new Response(ResponseStatus.FAIL, "Repetition is not possible. Make sure there is a sense in the repetition type you choose");
      }
     
      User oldOwner = (User) databaseSession.get(User.class, this.oldOwner);

      if (oldOwner == null) {
        throw new IllegalArgumentException("Couldn't locate old owner of the event");
      }
     
      EventType oldEventType = (EventType) databaseSession.get(EventType.class, this.oldEventType);
     
      if (oldEventType == null) {
        throw new IllegalArgumentException("Couldn't locate old type of the event");
      }
     
      Event oldEvent = (Event) databaseSession.createCriteria(Event.class)
                    .add(Restrictions.eq("id.from", DateOperator.stringToDate(this.oldFrom) ))
                    .add(Restrictions.eq("id.to", DateOperator.stringToDate(this.oldTo)))
                    .add(Restrictions.eq("id.type", oldEventType))
                    .add(Restrictions.eq("id.owner", oldOwner))
                    .uniqueResult();
     
      if (oldEvent == null) {
        throw new IllegalArgumentException("Could not locate event in question!");
      }
     
      User currentUser = (User) request.getSession().getAttribute("currentUser");
     
      if (currentUser == null) {
        throw new SecurityException("You're not logged in");
      }

      // get permission types from database (very very dumb):
      PermissionType publicPermission = (PermissionType) databaseSession.get(PermissionType.class, new Long(1));
     
      // get admin role, yep, dumb as well.
      Role adminRole = (Role) databaseSession.get(Role.class, new Long(2));
     
      // who can edit the event:
View Full Code Here


        eventIdObject.setFrom(fromDate);
        eventIdObject.setTo(toDate);
        eventIdObject.setOwner(userObject);
        eventIdObject.setType(eventTypeObject);
       
        PermissionType permisssionTypeObject = (PermissionType) databaseSession.createCriteria(PermissionType.class).add(Restrictions.eq("id", this.permissionType)).uniqueResult();
        if(null == permisssionTypeObject) {
          return new Response(ResponseStatus.FAIL, "Not valid permisssion type");
        }
       
        RepetitionType repetitionTypeObject = (RepetitionType) databaseSession.createCriteria(RepetitionType.class).add(Restrictions.eq("id", this.repetitionType)).uniqueResult();
View Full Code Here

       
        // get current user
        User currentUser = (User) request.getSession().getAttribute("currentUser");
       
        // get permission types from database (very very dumb):
        PermissionType publicPermission = (PermissionType) databaseSession.get(PermissionType.class, new Long(1));
       
        // get admin role, yep, dumb as well.
        Role adminRole = (Role) databaseSession.get(Role.class, new Long(2));
       
        // who can edit the event:
View Full Code Here

   
    Role role2 = new Role();
    role2.setDescription("Admin");
   
    // load initial permission-types
    PermissionType permissionType1 = new PermissionType();
    permissionType1.setDescription("Public");
   
    PermissionType permissionType2 = new PermissionType();
    permissionType2.setDescription("Protected");
   
    PermissionType permissionType3 = new PermissionType();
    permissionType3.setDescription("Private");
   
    // load initial repetition-types
    RepetitionType repetitionType1 = new RepetitionType();
    repetitionType1.setDescription("None");
   
View Full Code Here

public class EventAttributesAccessPolicy {

  public static void enforce(Session databaseSession, User currentUser, List<Event> events) {
    // get permission types from database (very very dumb):
    PermissionType privatePermission = (PermissionType) databaseSession.get(PermissionType.class, new Long(3));
    PermissionType protectedPermission = (PermissionType) databaseSession.get(PermissionType.class, new Long(2));

    // get admin role, yep, dumb as well.
    Role adminRole = (Role) databaseSession.get(Role.class, new Long(2));
   
    // Remove sensitive information
View Full Code Here

TOP

Related Classes of domain.PermissionType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.