Package org.damour.base.client.objects

Examples of org.damour.base.client.objects.PermissibleObject


    if (authUser == null) {
      throw new SimpleMessageException("User is not authenticated.");
    }
    Transaction tx = session.get().beginTransaction();
    try {
      PermissibleObject hibPermissibleObject = ((PermissibleObject) session.get().load(PermissibleObject.class, permissibleObject.getId()));
      if (!authUser.isAdministrator() && !hibPermissibleObject.getOwner().equals(authUser)) {
        throw new SimpleMessageException("User is not authorized to set permissions on this object.");
      }
      session.get().evict(authUser);

      SecurityHelper.deletePermissions(session.get(), permissibleObject);
      for (Permission permission : permissions) {
        session.get().save(permission);
      }

      List<Field> fields = ReflectionCache.getFields(permissibleObject.getClass());
      for (Field field : fields) {
        try {
          // do not update parent permission only our 'owned' objects
          if (!"parent".equals(field.getName())) {
            Object obj = field.get(permissibleObject);
            if (obj instanceof PermissibleObject) {
              PermissibleObject childObj = (PermissibleObject) obj;
              childObj.setGlobalRead(permissibleObject.isGlobalRead());
              childObj.setGlobalWrite(permissibleObject.isGlobalWrite());
              childObj.setGlobalExecute(permissibleObject.isGlobalExecute());
              childObj.setGlobalCreateChild(permissibleObject.isGlobalCreateChild());
              SecurityHelper.deletePermissions(session.get(), childObj);
              for (Permission permission : permissions) {
                Permission newPerm = new Permission();
                newPerm.setPermissibleObject(childObj);
                newPerm.setSecurityPrincipal(permission.getSecurityPrincipal());
View Full Code Here


    Tag hibTag = ((Tag) session.get().load(Tag.class, tagMembership.getTag().getId()));
    if (hibTag == null) {
      throw new SimpleMessageException("Tag not found: " + tagMembership.getTag().getId());
    }

    PermissibleObject hibPermissibleObject = ((PermissibleObject) session.get().load(PermissibleObject.class, tagMembership.getPermissibleObject().getId()));
    if (hibPermissibleObject == null) {
      throw new SimpleMessageException("PermissibleObject not found: " + tagMembership.getPermissibleObject());
    }

    Transaction tx = session.get().beginTransaction();
View Full Code Here

    Tag hibTag = ((Tag) session.get().load(Tag.class, tag.getId()));
    if (hibTag == null) {
      throw new SimpleMessageException("Category not found: " + tag);
    }

    PermissibleObject hibPermissibleObject = ((PermissibleObject) session.get().load(PermissibleObject.class, permissibleObject.getId()));
    if (hibPermissibleObject == null) {
      throw new SimpleMessageException("PermissibleObject not found: " + permissibleObject);
    }

    Transaction tx = session.get().beginTransaction();
View Full Code Here

    return "Unknown";
  }

  private String getLocation() {
    List<String> parentFolders = new ArrayList<String>();
    PermissibleObject parentFolder = permissibleObject.getParent();
    while (parentFolder != null) {
      parentFolders.add(parentFolder.getName());
      parentFolder = parentFolder.getParent();
    }
    Collections.reverse(parentFolders);
    String location = "";
    for (String parent : parentFolders) {
      location += "/" + parent;
View Full Code Here

    folderNameTextBox.setVisibleLength(60);
    PromptDialogBox dialogBox = new PromptDialogBox("Enter New Folder Name", "OK", null, "Cancel", false, true);
    dialogBox.setContent(folderNameTextBox);
    dialogBox.setCallback(new IDialogCallback() {
      public void okPressed() {
        PermissibleObject parentFolder = null;
        if (repositoryTree.getLastItem() != null && repositoryTree.getLastItem().getUserObject() instanceof PermissibleObject) {
          PermissibleObject permissibleObject = (PermissibleObject) repositoryTree.getLastItem().getUserObject();
          parentFolder = permissibleObject.getParent();
        }
        AsyncCallback<Folder> callback = new AsyncCallback<Folder>() {
          public void onFailure(Throwable caught) {
            MessageDialogBox messageDialog = new MessageDialogBox("Error", caught.getMessage(), false, true, true);
            messageDialog.center();
View Full Code Here

    }
    if (lastItem != null && lastItem != item) {
      lastItem.setSelected(false);
    }
    lastItem = item;
    PermissibleObject permissibleObject = (PermissibleObject) item.getUserObject();
    if (permissibleObject != null) {
      lastItemId = permissibleObject.getId();
    }
  }
View Full Code Here

    }
    if (lastItem != null && lastItem != item) {
      lastItem.setSelected(false);
    }
    lastItem = item;
    PermissibleObject permissibleObject = (PermissibleObject) item.getUserObject();
    if (permissibleObject != null) {
      lastItemId = permissibleObject.getId();
    }
    if (permissibleObject instanceof Folder) {
      if (item.getState()) {
        openFolderIds.add(((Folder) permissibleObject).getId());
      } else if (permissibleObject != null) {
View Full Code Here

    }
    buildingTree = false;
  }

  private void findAndOpenNode(Long folderIdToOpen, TreeItem parent) {
    PermissibleObject permissibleObject = (PermissibleObject) parent.getUserObject();
    if (permissibleObject != null && permissibleObject.getId().equals(lastItemId)) {
      if (parent.getParentItem() != null) {
        parent.getParentItem().setState(true);
      }
      setSelectedItem(parent, false);
      parent.setSelected(true);
View Full Code Here

  public void searchTest() {
    Session session = HibernateUtil.getInstance().getSession();
    System.out.println(HibernateUtil.getInstance().getHbm2ddlMode());
    Transaction tx = session.beginTransaction();

    PermissibleObject obj1 = new PermissibleObject();
    obj1.setName("abc");
    session.save(obj1);

    PermissibleObject obj2 = new PermissibleObject();
    obj2.setName("xxx");
    obj2.setKeywords("keywords are awesome");
    session.save(obj2);

    PermissibleObject obj3 = new PermissibleObject();
    obj3.setName("ghi");
    obj3.setDescription("description");
    session.save(obj3);

    tx.commit();

    List<PermissibleObjectTreeNode> results = PermissibleObjectHelper.search(session, null, null, PermissibleObject.class, "abc xxx", "name", true, true, true, true, false);
View Full Code Here

    user.setUsername("mdamour1976");
    session.save(user);

    // create 100 files which have global read = true
    for (int i = 0; i < 1; i++) {
      PermissibleObject parent = new PermissibleObject();
      parent.setName("globalRead:true " + i);
      parent.setOwner(user);
      parent.setGlobalRead(true);
      session.save(parent);

      for (int k = 0; k < 5; k++) {
        PermissibleObject folder = new PermissibleObject();
        folder.setName("globalRead:true " + i);
        folder.setOwner(user);
        folder.setGlobalRead(true);
        folder.setParent(parent);
        session.save(folder);

        for (int z = 0; z < 5; z++) {
          File file = new File();
          file.setName("globalRead:true " + z);
          file.setOwner(user);
          file.setGlobalRead(true);
          file.setParent(folder);
          session.save(file);
        }
      }
    }

    User user2 = new User();
    user2.setUsername("nobody");
    session.save(user2);

    for (int j = 0; j < 1; j++) {
      File file = new File();
      file.setName("HAS PERM " + j);
      file.setOwner(user);
      session.save(file);

      Permission perm = new Permission();
      perm.readPerm = true;
      perm.setSecurityPrincipal(user2);
      perm.setPermissibleObject(file);
      session.save(perm);
    }

    for (int j = 0; j < 1; j++) {
      PermissibleObject folder = new PermissibleObject();
      folder.setName("HAS PERM " + j);
      folder.setOwner(user);
      session.save(folder);

      Permission perm = new Permission();
      perm.readPerm = true;
      perm.setSecurityPrincipal(user2);
      perm.setPermissibleObject(folder);
      session.save(perm);
    }

    for (int j = 0; j < 1; j++) {
      PermissibleObject folder = new PermissibleObject();
      folder.setName("user owns, but does not have perm");
      folder.setOwner(user2);
      session.save(folder);

      Permission perm = new Permission();
      perm.setReadPerm(true);
      perm.setSecurityPrincipal(user);
View Full Code Here

TOP

Related Classes of org.damour.base.client.objects.PermissibleObject

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.