Пример #1
0
  /**
   * Perform the xsl export modification
   *
   * @param request The HTTP request
   * @throws AccessDeniedException the {@link AccessDeniedException}
   * @return The URL to go after performing the action
   */
  public String doModifyXslExport(HttpServletRequest request) throws AccessDeniedException {
    if (!RBACService.isAuthorized(
        XslExport.RESOURCE_TYPE,
        RBAC.WILDCARD_RESOURCES_ID,
        XslExportResourceIdService.PERMISSION_MODIFY,
        getUser())) {
      throw new AccessDeniedException(MESSAGE_PERMISSION_DENIED);
    }

    XslExport xslExport;
    String strIdXslExport = request.getParameter(PARAMETER_ID_XSL_EXPORT);
    int nIdXslExport = Integer.parseInt(strIdXslExport);
    xslExport = XslExportHome.findByPrimaryKey(nIdXslExport);

    String strError = getXslExportData(request, xslExport);

    if (strError != null) {
      return strError;
    }

    // if xslExport
    File fileStore = XslExportHome.findByPrimaryKey(nIdXslExport).getFile();

    if (xslExport.getFile() != null) {
      // the file has been modified
      File fileSource = xslExport.getFile();
      // init id file source and id physical file before update
      fileSource.setIdFile(fileStore.getIdFile());

      if (fileStore.getPhysicalFile() != null) {
        fileSource
            .getPhysicalFile()
            .setIdPhysicalFile(fileStore.getPhysicalFile().getIdPhysicalFile());
      }

      FileHome.update(fileSource);
    } else {
      xslExport.setFile(fileStore);
    }

    XslExportHome.update(xslExport);

    return getJspManageXslExport(request);
  }