Package com.claymus.site.module.page

Examples of com.claymus.site.module.page.Page


    int accessLevel = module.getAccessLevel(user.getRole());
    if(accessLevel < ModuleHelper.ADD)
      throw new UserException();

    Page page = PageData.getPage(pageDTO.getUri());
    if(page != null)
      throw new ServerException("Page with uri " + "<a href='" + page.getUri() + "'>" + page.getUri() + "</a> already exists. Please enter a different uri.");

    page = new Page(pageDTO);
    if(PageData.createPage(page) == null)
      throw new ServerException("Page could not be created. Please try again later.");

    return KeyFactory.keyToString(page.getKey());
  }
View Full Code Here


  @Override
  public void update(PageDTO pageDTO) throws ServerException, UserException {
    Module module = ModuleData.getModule(ModuleHelper.class);
    User user = UserData.getUser();
    Page page = PageData.getPage(pageDTO.getUri());

    int accessLevel = module.getAccessLevel(user.getRole());
    if(accessLevel >= ModuleHelper.ADD_EDIT || (accessLevel == ModuleHelper.ADD && page.getCreator().equals(user))) {
      if(PageData.updatePage(pageDTO) == null)
        throw new ServerException("Page could not be saved. Please try again.");
    } else {
      throw new UserException();
    }
View Full Code Here

@SuppressWarnings("serial")
public class ContentServiceImpl extends RemoteServiceServlet implements ContentService {

  @Override
  public String[][] getLocations(String pageEncoded) {
    Page page = PageData.getPage(KeyFactory.stringToKey(pageEncoded));
    return page.getLayout().getLocations();
  }
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

    int accessLevel = module.getAccessLevel(user.getRole());
    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 saveOrder(String pageEncoded, LinkedList<String> locations, LinkedList<String> encodedList) throws ServerException, UserException {
    Module module = ModuleData.getModule(ModuleHelper.class);
    User user = UserData.getUser();
    Page page = PageData.getPage(KeyFactory.stringToKey(pageEncoded));

    int accessLevel = module.getAccessLevel(user.getRole());
    if(accessLevel < ModuleHelper.ADD)
      throw new UserException();

    for(int i = 0; i < locations.size(); i++) {
      LinkedList<Content> contentList = new LinkedList<Content>();
      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());
        }
      }
View Full Code Here

    doRequest(req, resp);
  }

  protected void doRequest(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    String uri = req.getRequestURI();
    Page page = null;
    List<List<Content>> contents = null;
    User user = UserData.getUser();
    UserRole userRole = user.getRole();
    Key userRoleKey = userRole.getKey();

    if(uri.startsWith("/_ah/")) { // Administer pages
      String str = uri.substring(5);
      String moduleId = str.split("/")[0];

      Module module = ModuleData.getModule(moduleId);
      List<ContentType> contentsData = module == null
          ? new LinkedList<ContentType>()
          : module.getPageContents(str.split("/"), user);

      if(contentsData.size() == 0)
        contentsData.add(new Error404());

      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);
    }

    List<List<Block>> blocks = new LinkedList<List<Block>>();
    String[][] blockLocations = ThemeData.getTheme().getLocations();
    for(String[] location : blockLocations)
      blocks.add(BlockData.getBlocks(location[1], uri, userRoleKey));

    page.serve(contents, blocks, ThemeData.getTheme());
  }
View Full Code Here

  public ContentType getPageContent(String[] tokens, User user) {
    String pageEncoded = ClaymusMain.getRequest().getParameter("page");
    if(pageEncoded == null)
      return null;

    final Page page = PageData.getPage(KeyFactory.stringToKey(pageEncoded));
    if(page == null)
      return null;

    int accessLevel = getAccessLevel(user.getRole());

    if(tokens.length == 1) {
      if(accessLevel >= ModuleHelper.VIEW_ONLY)
        return new ManageContents(accessLevel, page, user);
      else
        return new Error401();

    } else if(tokens.length == 2 && tokens[1].equals("add")) {
      if(accessLevel >= ModuleHelper.ADD)
        return new ContentTypes(page);
      else
        return new Error401();

    } else if(tokens.length == 2 && tokens[1].equals("new")) {
      String contentType = ClaymusMain.getRequest().getParameter("type");
      if(contentType == null)
        return null;

      final ContentType contentData = ContentData.getContentType(contentType);
      if(contentData == null)
        return null;

      if(! contentData.hasEditor())
        return null;

      if(accessLevel >= ModuleHelper.ADD)
        return new ContentType() {

          @Override
          public String getName() {
            return page.getTitle() != null
                ? page.getTitle() + " \u00BB Add Content \u00BB " + contentData.getName()
                : "(no title)"     + " \u00BB Add Content \u00BB " + contentData.getName();
          }

          @Override
          protected String getHTML() {
            String html = "<div class='claymus-h1'>" + getName() + "</div>";
            html += contentData.getEditor();
            return html;
          }

        };
      else
        return new Error401();

    } else if(tokens.length == 2 && tokens[1].equals("edit")) {
      String encoded = ClaymusMain.getRequest().getParameter("key");
      if(encoded == null)
        return null;

      final Content content = ContentData.getContent(KeyFactory.stringToKey(encoded));
      if(content == null)
        return null;

      if(page.getId() != content.getPageId())
        return null;

      if(accessLevel >= ModuleHelper.ADD_EDIT || (accessLevel == ModuleHelper.ADD && content.getOwner().equals(user)))
        return new ContentType() {

          @Override
          public String getName() {
            return page.getTitle() != null
                ? page.getTitle() + " \u00BB Edit Content \u00BB " + content.getName()
                : "(no title)"     + " \u00BB Edit Content \u00BB " + content.getName();
          }

          @Override
          protected String getHTML() {
View Full Code Here

  @Override
  public PageDTO get(String encoded) throws UserException {
    Module module = ModuleData.getModule(ModuleHelper.class);
    User user = UserData.getUser();
    Page page = PageData.getPage(KeyFactory.stringToKey(encoded));

    int accessLevel = module.getAccessLevel(user.getRole());
    if(accessLevel >= ModuleHelper.ADD_EDIT || (accessLevel == ModuleHelper.ADD && page.getCreator().equals(user))) {
      PageDTO pageDTO = page.getDTO();
      pageDTO.setLayouts(getLayouts());
      return pageDTO;
    } else {
      throw new UserException();
    }
View Full Code Here

TOP

Related Classes of com.claymus.site.module.page.Page

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.