Package org.vosao.entity

Examples of org.vosao.entity.ContentPermissionEntity


  }

  private boolean isChangeGranted(List<Long> ids) {
    if (ids.size() > 0) {
      CommentEntity comment = getDao().getCommentDao().getById(ids.get(0));
      ContentPermissionEntity permission = getContentPermissionBusiness()
          .getPermissioncomment.getPageUrl(),
              VosaoContext.getInstance().getUser());
      if (permission != null) {
        return permission.isChangeGranted();
      }
    }   
    return false;
  }
View Full Code Here


    }
    if (vo.get("cached") != null) {
      page.setCached(Boolean.valueOf(vo.get("cached")));
    }
    String languageCode = vo.get("languageCode");
    ContentPermissionEntity perm = getBusiness()
        .getContentPermissionBusiness().getPermission(
            page.getFriendlyURL(),
            VosaoContext.getInstance().getUser());
    boolean approve = Boolean.valueOf(vo.get("approve"));
    if (approve && perm.isPublishGranted()) {
      page.setState(PageState.APPROVED);
    } else {
      page.setState(PageState.EDIT);
    }
    if (!perm.isChangeGranted(languageCode)) {
      return ServiceResponse.createErrorResponse(Messages.get(
          "access_denied"));
    }
    if (vo.get("publishDate") != null) {
      try {
View Full Code Here

      return ServiceResponse
          .createErrorResponse(Messages.get("page.change_type"));
    }
    page.setModDate(new Date());
    page.setModUserEmail(VosaoContext.getInstance().getUser().getEmail());
    ContentPermissionEntity perm = getBusiness()
        .getContentPermissionBusiness().getPermission(
            page.getFriendlyURL(),
            VosaoContext.getInstance().getUser());
    page.setState(PageState.EDIT);
    if (!perm.isChangeGranted()) {
      return ServiceResponse.createErrorResponse(Messages.get(
          "access_denied"));
    }
    getPageBusiness().save(page);
    getPageBusiness().saveContent(page, language, content);
View Full Code Here

    getDao().getUserGroupDao().save(userGroup);
  }
 
  private void addPermission(String url, GroupEntity group,
      ContentPermissionType perm) {
    ContentPermissionEntity p = new ContentPermissionEntity(url,
        perm, group.getId());
    getDao().getContentPermissionDao().save(p);
  }
View Full Code Here

    addPermission("/", guests, ContentPermissionType.READ);
    addPermission("/about", guests, ContentPermissionType.DENIED);
    addPermission("/about", developers, ContentPermissionType.READ);
    addPermission("/about/team", developers, ContentPermissionType.WRITE);
    addPermission("/", managers, ContentPermissionType.PUBLISH);
    ContentPermissionEntity p = getBusiness().getContentPermissionBusiness()
        .getPermission("/", developer);
    assertEquals(ContentPermissionType.READ, p.getPermission());
    p = getBusiness().getContentPermissionBusiness().getPermission(
        "/about", developer);
    assertEquals(ContentPermissionType.READ, p.getPermission());
    p = getBusiness().getContentPermissionBusiness().getPermission(
        "/about/team", developer);
    assertEquals(ContentPermissionType.WRITE, p.getPermission());
    p = getBusiness().getContentPermissionBusiness().getPermission(
        "/about/team", manager);
    assertEquals(ContentPermissionType.PUBLISH, p.getPermission());
    p = getBusiness().getContentPermissionBusiness().getPermission(
        "/about/team", manager);
    assertEquals(ContentPermissionType.PUBLISH, p.getPermission());
    p = getBusiness().getContentPermissionBusiness().getGuestPermission(
        "/");
    assertEquals(ContentPermissionType.READ, p.getPermission());
    p = getBusiness().getContentPermissionBusiness().getGuestPermission(
        "/about");
    assertEquals(ContentPermissionType.DENIED, p.getPermission());
    p = getBusiness().getContentPermissionBusiness().getGuestPermission(
        "/about/team");
    assertEquals(ContentPermissionType.DENIED, p.getPermission());
    p = getBusiness().getContentPermissionBusiness().getGuestPermission(
        "/services");
    assertEquals(ContentPermissionType.READ, p.getPermission());
    p = getBusiness().getContentPermissionBusiness().getGuestPermission(
        "/services/php");
    assertEquals(ContentPermissionType.READ, p.getPermission());
    p = getBusiness().getContentPermissionBusiness().getPermission(
        "/about/team", dev2);
    assertEquals(ContentPermissionType.PUBLISH, p.getPermission());
  }
View Full Code Here

    implements ContentPermissionBusiness {

  @Override
  public ContentPermissionEntity getGuestPermission(final String url) {
    GroupEntity guests = getDao().getGroupDao().getGuestsGroup();
    ContentPermissionEntity result = getGroupPermission(url, guests.getId());
    result.setUrl(url);
    return result;
  }
View Full Code Here

      final UserEntity user) {
    if (user == null) {
      return getGuestPermission(url);
    }
    if (user.isAdmin()) {
      return new ContentPermissionEntity(url, ContentPermissionType.ADMIN);
    }
    List<UserGroupEntity> userGroups = getDao().getUserGroupDao()
        .selectByUser(user.getId());
    userGroups.add(new UserGroupEntity(getDao().getGroupDao()
        .getGuestsGroup().getId(), user.getId()));
    List<ContentPermissionEntity> permissions = new ArrayList<ContentPermissionEntity>();
    for (UserGroupEntity userGroup : userGroups) {
      ContentPermissionEntity contentPermission = getGroupPermission(url,
          userGroup.getGroupId());
      if (contentPermission != null) {
        permissions.add(contentPermission);
      }
    }
    ContentPermissionEntity result = consolidatePermissions(permissions);
    result.setUrl(url);
    return result;
  }
View Full Code Here

    return result;
  }

  private ContentPermissionEntity consolidatePermissions(
      List<ContentPermissionEntity> permissions) {
    ContentPermissionEntity result = new ContentPermissionEntity();
    result.setPermission(ContentPermissionType.DENIED);
    result.setAllLanguages(false);
    Set<String> languages = new HashSet<String>();
    for (ContentPermissionEntity perm : permissions) {
      if (perm.isMyPermissionHigher(result)) {
        result.setPermission(perm.getPermission());
        if (perm.isAllLanguages()) {
          result.setAllLanguages(true);
        }
        languages.addAll(perm.getLanguagesList());
      }
    }
    String langs = "";
    for (String lang : languages) {
      langs += (langs.equals("") ? "" : ",") + lang;
    }
    result.setLanguages(langs);
    return result;
  }
View Full Code Here

  }

  private ContentPermissionEntity getGroupPermission(String url, Long groupId) {
    String myUrl = url;
    while (myUrl != null) {
      ContentPermissionEntity perm = getDao().getContentPermissionDao()
          .getByUrlGroup(myUrl, groupId);
      if (perm != null) {
        return perm;
      }
      if (myUrl.equals("/")) {
View Full Code Here

  }

  @Override
  public void setPermission(String url, GroupEntity group,
      ContentPermissionType permission, String languages) {
    ContentPermissionEntity perm = getDao().getContentPermissionDao()
        .getByUrlGroup(url, group.getId());
    if (perm == null) {
      perm = new ContentPermissionEntity();
      perm.setUrl(url);
      perm.setGroupId(group.getId());
    }
    if (languages == null) {
      perm.setAllLanguages(true);
    } else {
      perm.setAllLanguages(false);
      perm.setLanguages(languages);
    }
    perm.setPermission(permission);
    getDao().getContentPermissionDao().save(perm);
    getFolderBusiness().createFolder("/page" + url);
  }
View Full Code Here

TOP

Related Classes of org.vosao.entity.ContentPermissionEntity

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.