Package com.claymus.site.module.block

Examples of com.claymus.site.module.block.Block


  @Override
  public BlockDTO get(String encoded) throws UserException {
    Module module = ModuleData.getModule(ModuleHelper.class);
    User user = UserData.getUser();
    Block block = BlockData.getBlock(KeyFactory.stringToKey(encoded));

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


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

    BlockType blockData = BlockData.getBlockType(blockDTO.getClass().getSimpleName().replace("DTO", ""));
    Block block = new Block(blockData, blockDTO.getLocation());
    block.update(blockDTO);
    block = BlockData.createBlock(block);
    if(block == null)
      throw new ServerException("Block could not be created. Please try again later.");
  }
View Full Code Here

  @Override
  public void update(String encoded, BlockDTO blockDTO) throws ServerException, UserException {
    Module module = ModuleData.getModule(ModuleHelper.class);
    User user = UserData.getUser();
    Key key = KeyFactory.stringToKey(encoded);
    Block block = BlockData.getBlock(key);

    int accessLevel = module.getAccessLevel(user.getRole());
    if(accessLevel >= ModuleHelper.ADD_EDIT || (accessLevel == ModuleHelper.ADD && block.getOwner().equals(user))) {
      if(BlockData.updateBlock(key, blockDTO) == null)
        throw new ServerException("Block 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();
        Block block = BlockData.getBlock(KeyFactory.stringToKey(token));
        blocks.add(block);
        weights.add(block.getWeight());
      }

      Collections.sort(weights);

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

        { { 3, 1, "FOOTER" } }, };
  }

  protected void printBlocks(List<Block> blocks, PrintWriter out) throws IOException {
    for (int i = 0; i < blocks.size(); i++) {
      Block block = blocks.get(i);

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

      out.print(block.getHTML());

//      String blockTitle = block.getTitle();
//      if(blockTitle != null) {
//        out.print("<div class='claymus-h2'>");
//        out.print(blockTitle);
View Full Code Here

TOP

Related Classes of com.claymus.site.module.block.Block

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.