Exemplo n.º 1
0
  public ActionForward uploadFile(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    IViewState viewState = RenderUtils.getViewState("upload");
    if (viewState == null) {
      return prepareFileUpload(mapping, form, request, response);
    }

    UnitFileUploadBean bean = (UnitFileUploadBean) viewState.getMetaObject().getObject();
    RenderUtils.invalidateViewState();

    if (!bean.getUnit().getAllowedPeopleToUploadFilesSet().contains(AccessControl.getPerson())) {
      return manageFiles(mapping, form, request, response);
    }

    try (InputStream stream = bean.getUploadFile()) {
      CreateUnitFile.run(
          ByteStreams.toByteArray(stream),
          bean.getFileName(),
          bean.getName(),
          bean.getDescription(),
          bean.getTags(),
          bean.getGroup(),
          getUnit(request),
          getLoggedPerson(request));
    } catch (DomainException | IOException e) {
      addActionMessage(request, e.getMessage());
    }
    return manageFiles(mapping, form, request, response);
  }
    @Override
    public void linkPressed(IViewState viewState, HtmlActionLink link) {
      if (getDestination() != null) {
        viewState.setAttribute(ManageableListRenderer.MANAGED_SLOT_NAME, slot.getName());
        viewState.setAttribute(ManageableListRenderer.MANAGED_SLOT_KEY, slot.getKey());

        viewState.setCurrentDestination(getDestination());
      }
    }
 protected boolean hasInvalidViewState() {
   List<IViewState> viewStates =
       (List<IViewState>)
           RenderersRequestProcessorImpl.getCurrentRequest()
               .getAttribute(LifeCycleConstants.VIEWSTATE_PARAM_NAME);
   boolean valid = true;
   if (viewStates != null) {
     for (IViewState state : viewStates) {
       valid &= state.isValid();
     }
   }
   return valid;
 }
 protected void invalidateDocumentFileRelatedViewStates() {
   List<IViewState> viewStates =
       new ArrayList<IViewState>(
           (List<IViewState>)
               RenderersRequestProcessorImpl.getCurrentRequest()
                   .getAttribute(LifeCycleConstants.VIEWSTATE_PARAM_NAME));
   if (viewStates != null) {
     for (IViewState state : viewStates) {
       if (state.getId().indexOf("individualCandidacyProcessBean.document.file") > -1) {
         RenderUtils.invalidateViewState(state.getId());
       }
     }
   }
 }
Exemplo n.º 5
0
  public ActionForward editFile(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    IViewState viewState = RenderUtils.getViewState("editFile");
    if (viewState != null) {
      UnitFileBean bean = (UnitFileBean) viewState.getMetaObject().getObject();
      EditUnitFile.run(
          bean.getFile(), bean.getName(), bean.getDescription(), bean.getTags(), bean.getGroup());
    }
    return manageFiles(mapping, form, request, response);
  }
    @Override
    public void execute(IViewState viewState) {
      if (hidden.getValue() != null && hidden.getValue().equalsIgnoreCase("true")) {
        String destinationName = this.destination == null ? "postback" : this.destination;
        ViewDestination destination = viewState.getDestination(destinationName);

        if (destination != null) {
          viewState.setCurrentDestination(destination);
        } else {
          viewState.setCurrentDestination("postBack");
        }

        hidden.setValue("false");
        viewState.setSkipValidation(true);
      }
    }
Exemplo n.º 7
0
  public ActionForward editPersistedGroup(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    IViewState viewState = RenderUtils.getViewState("editGroup");
    if (viewState != null) {
      try {
        PersistentGroupMembersBean bean =
            (PersistentGroupMembersBean) viewState.getMetaObject().getObject();
        if (bean.getIstId() != null) {
          bean.getPeople().add(bean.getIstId());
        }
        EditPersistentGroup.run(bean.getGroup(), bean.getName(), bean.getPeople(), bean.getUnit());
      } catch (DomainException e) {
        addActionMessage(request, e.getMessage());
      }
    }
    return configureGroups(mapping, form, request, response);
  }
Exemplo n.º 8
0
  public ActionForward showPublications(
      ActionMapping mapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    Unit unit = getUnit(request);

    IViewState viewState = RenderUtils.getViewState("executionYearIntervalBean");

    ExecutionYearIntervalBean bean;
    if (viewState != null) {
      bean = (ExecutionYearIntervalBean) viewState.getMetaObject().getObject();
    } else {
      bean = generateSearchBean();
    }

    request.setAttribute("executionYearIntervalBean", bean);

    preparePublicationsForResponse(request, unit, bean);

    return mapping.findForward("showPublications");
  }
Exemplo n.º 9
0
  public ActionForward createPersistedGroup(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    IViewState viewState = RenderUtils.getViewState("createGroup");
    if (viewState != null) {
      PersistentGroupMembersBean bean =
          (PersistentGroupMembersBean) viewState.getMetaObject().getObject();
      if (bean.getIstId() != null) {
        bean.getPeople().add(bean.getIstId());
      }
      if (bean.getPeople().isEmpty()) {
        addActionMessage(request, "accessGroupManagement.empty");
        return mapping.findForward("createPersistedGroup");
      }
      CreatePersistentGroup.run(bean.getUnit(), bean.getName(), bean.getPeople(), bean.getType());
    }

    return configureGroups(mapping, form, request, response);
  }