Esempio n. 1
0
  @SuppressWarnings("deprecation")
  private void _loadForm(ActionForm form, ActionRequest req, ActionResponse res) {
    try {
      StructureForm structureForm = (StructureForm) form;
      Structure structure = (Structure) req.getAttribute(WebKeys.Structure.STRUCTURE);
      BeanUtils.copyProperties(structureForm, structure);
      structureForm.setFields(structure.getFields());

      if (structure.getReviewInterval() != null) {
        String interval = structure.getReviewInterval();
        Pattern p = Pattern.compile("(\\d+)([dmy])");
        Matcher m = p.matcher(interval);
        boolean b = m.matches();
        if (b) {
          structureForm.setReviewContent(true);
          String g1 = m.group(1);
          String g2 = m.group(2);
          structureForm.setReviewIntervalNum(g1);
          structureForm.setReviewIntervalSelect(g2);
        }
      }
      if (UtilMethods.isSet(structure.getDetailPage())) {
        Identifier ident = APILocator.getIdentifierAPI().find(structure.getDetailPage());
        HTMLPage page = HTMLPageFactory.getLiveHTMLPageByIdentifier(ident);
        if (InodeUtils.isSet(page.getInode())) {
          structureForm.setDetailPage(page.getIdentifier());
        }
      }

    } catch (Exception ex) {
      Logger.debug(EditStructureAction.class, ex.toString());
    }
  }
Esempio n. 2
0
  @SuppressWarnings("deprecation")
  private Structure _loadStructure(ActionForm form, ActionRequest req, ActionResponse res)
      throws ActionException, DotDataException {

    User user = _getUser(req);
    Structure structure = new Structure();
    String inodeString = req.getParameter("inode");
    if (InodeUtils.isSet(inodeString)) {
      /*
       * long inode = Long.parseLong(inodeString); if (inode != 0) {
       * structure = StructureFactory.getStructureByInode(inode); }
       */

      if (InodeUtils.isSet(inodeString)) {
        structure = StructureFactory.getStructureByInode(inodeString);
      }
    }
    req.setAttribute(WebKeys.Structure.STRUCTURE, structure);

    boolean searchable = false;

    List<Field> fields = structure.getFields();
    for (Field f : fields) {
      if (f.isIndexed()) {
        searchable = true;
        break;
      }
    }

    if (!searchable && InodeUtils.isSet(structure.getInode())) {
      String message = "warning.structure.notsearchable";
      SessionMessages.add(req, "message", message);
    }

    if (structure.isFixed()) {
      String message = "warning.object.isfixed";
      SessionMessages.add(req, "message", message);
    }

    // Checking permissions
    _checkUserPermissions(structure, user, PermissionAPI.PERMISSION_READ);

    return structure;
  }