Package com.claymus.site.module.content

Examples of com.claymus.site.module.content.Content


    if(accessLevel < ModuleHelper.ADD)
      throw new UserException();

    Page page = PageData.getPage(KeyFactory.stringToKey(pageEncoded));
    ContentType contentData = ContentData.getContentType(contentDTO.getClass().getSimpleName().replace("DTO", ""));
    Content content = new Content(contentData, page.getId(), contentDTO.getLocation());
    content.update(contentDTO);
    content = ContentData.createContent(content);
    if(content == null)
      throw new ServerException("Content could not be created. Please try again later.");
  }
View Full Code Here


  @Override
  public void update(String encoded, ContentDTO contentDTO) throws ServerException, UserException {
    Module module = ModuleData.getModule(ModuleHelper.class);
    User user = UserData.getUser();
    Key key = KeyFactory.stringToKey(encoded);
    Content content = ContentData.getContent(key);

    int accessLevel = module.getAccessLevel(user.getRole());
    if(accessLevel >= ModuleHelper.ADD_EDIT || (accessLevel == ModuleHelper.ADD && content.getOwner().equals(user))) {
      if(ContentData.updateContent(key, contentDTO) == null)
        throw new ServerException("Content could not be saved. Please try again later.");
    } else {
      throw new UserException();
    }
View Full Code Here

      LinkedList<Long> weights = new LinkedList<Long>();

      StringTokenizer st = new StringTokenizer(encodedList.get(i), ",");
      while(st.hasMoreTokens()) {
        String token = st.nextToken();
        Content content = ContentData.getContent(KeyFactory.stringToKey(token));
        if(content.getPageId() == page.getId()) {
          contentList.add(content);
          weights.add(content.getWeight());
        }
      }

      Collections.sort(weights);

      for(int j = 0; j < contentList.size(); j++) {
        Content content = contentList.get(j);
        content = ContentData.updateContentOrder(content.getKey(), weights.get(j), locations.get(i));
        if(content == null)
          throw new ServerException("Operation failed partially or fully. <a href=''>Refresh</a> page to see the changes.");
      }
    }
  }
View Full Code Here

      PageLayout pageLayout = new Simple();

      List<Content> contentList = new LinkedList<Content>();
      for(ContentType contentData : contentsData)
        contentList.add(new Content(contentData, 0, pageLayout.getDefaultLocation()));

      page = new Page(uri, contentList.get(0).getName(), pageLayout);

      contents = new LinkedList<List<Content>>();
      contents.add(contentList);

    } else if((page = PageData.getPage(uri)) != null) { // User pages
      PageLayout pageLayout = page.getLayout();
      contents = new LinkedList<List<Content>>();
      for(String[] location : pageLayout.getLocations())
        contents.add(ContentData.getContents(page.getId(), location[1], userRoleKey));

    } else { // Error Pages
      PageLayout pageLayout = new Simple();

      Content content = new Content(new Error404(), 0, pageLayout.getDefaultLocation());
      List<Content> contentList = new LinkedList<Content>();
      contentList.add(content);

      page = new Page(uri, content.getName(), pageLayout);

      contents = new LinkedList<List<Content>>();
      contents.add(contentList);
    }
View Full Code Here

    }
  }

  public void printContent(List<Content> contents, PrintWriter out) throws IOException {
    for (int i = 0; i < contents.size(); i++) {
      Content content = contents.get(i);

      out.print("<div class='claymus-content'>");

      out.print(content.getHTML());

//      if (aContent.getTitle() != null) {
//        out.print("<div class='claymus-h1'>");
//        out.print(content.getTitle());
//        out.print("</div>");
View Full Code Here

  @Override
  public ContentDTO get(String pageEncoded, String encoded) throws ServerException, UserException {
    Module module = ModuleData.getModule(ModuleHelper.class);
    User user = UserData.getUser();
    Page page = PageData.getPage(KeyFactory.stringToKey(pageEncoded));
    Content content = ContentData.getContent(KeyFactory.stringToKey(encoded));

    if(page.getId() != content.getPageId())
      throw new ServerException();

    int accessLevel = module.getAccessLevel(user.getRole());
    if(accessLevel >= ModuleHelper.ADD_EDIT || (accessLevel == ModuleHelper.ADD && content.getOwner().equals(user))) {
      ContentDTO contentDTO = content.getDTO();
      contentDTO.setLocations(page.getLayout().getLocations());
      contentDTO.setRoles(getRoles());
      return contentDTO;
    } else {
      throw new UserException();
View Full Code Here

TOP

Related Classes of com.claymus.site.module.content.Content

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.