@Override
 @Nonnull
 @ReturnsMutableCopy
 public Map<String, IFileItem[]> getAllUploadedFileItemsComplete() {
   final Map<String, IFileItem[]> ret = new HashMap<String, IFileItem[]>();
   final Enumeration<String> aEnum = getAttributeNames();
   while (aEnum.hasMoreElements()) {
     final String sAttrName = aEnum.nextElement();
     final Object aAttrValue = getAttributeObject(sAttrName);
     if (aAttrValue instanceof IFileItem)
       ret.put(sAttrName, new IFileItem[] {(IFileItem) aAttrValue});
     else if (aAttrValue instanceof IFileItem[])
       ret.put(sAttrName, ArrayHelper.getCopy((IFileItem[]) aAttrValue));
   }
   return ret;
 }
  @Nonnull
  protected IHCNode getTabWithUsers(
      @Nonnull final Locale aDisplayLocale,
      @Nonnull final Collection<? extends IUser> aUsers,
      @Nonnull @Nonempty final String sTableID) {
    final boolean bSeparateLoginName = !useEmailAddressAsLoginName();
    final AccessManager aMgr = AccessManager.getInstance();
    // List existing
    final List<HCCol> aCols = new ArrayList<HCCol>();
    aCols.add(new HCCol(200));
    if (bSeparateLoginName) aCols.add(new HCCol(200));
    aCols.add(HCCol.star());
    aCols.add(new HCCol(150));
    aCols.add(createActionCol(3));
    final IHCTable<?> aTable =
        getStyler().createTable(ArrayHelper.newArray(aCols, HCCol.class)).setID(sTableID);
    final HCRow aHeaderRow = aTable.addHeaderRow();
    aHeaderRow.addCell(EText.HEADER_NAME.getDisplayText(aDisplayLocale));
    if (bSeparateLoginName)
      aHeaderRow.addCell(EText.HEADER_LOGINNAME.getDisplayText(aDisplayLocale));
    aHeaderRow.addCells(
        EText.HEADER_EMAIL.getDisplayText(aDisplayLocale),
        EText.HEADER_USERGROUPS.getDisplayText(aDisplayLocale),
        EWebBasicsText.MSG_ACTIONS.getDisplayText(aDisplayLocale));

    for (final IUser aCurUser : aUsers) {
      final ISimpleURL aViewLink = createViewURL(aCurUser);

      final HCRow aRow = aTable.addBodyRow();
      aRow.addCell(
          new HCA(aViewLink).addChild(SecurityUI.getUserDisplayName(aCurUser, aDisplayLocale)));
      if (bSeparateLoginName) aRow.addCell(new HCA(aViewLink).addChild(aCurUser.getLoginName()));
      aRow.addCell(new HCA(aViewLink).addChild(aCurUser.getEmailAddress()));

      // User groups
      final Collection<IUserGroup> aUserGroups =
          aMgr.getAllUserGroupsWithAssignedUser(aCurUser.getID());
      final StringBuilder aUserGroupsStr = new StringBuilder();
      for (final IUserGroup aUserGroup :
          ContainerHelper.getSorted(
              aUserGroups, new ComparatorHasName<IUserGroup>(aDisplayLocale))) {
        if (aUserGroupsStr.length() > 0) aUserGroupsStr.append(", ");
        aUserGroupsStr.append(aUserGroup.getName());
      }
      aRow.addCell(new HCA(aViewLink).addChild(aUserGroupsStr.toString()));

      final IHCCell<?> aActionCell = aRow.addCell();

      // Edit user
      if (isEditAllowed(aCurUser)) aActionCell.addChild(createEditLink(aCurUser, aDisplayLocale));
      else aActionCell.addChild(createEmptyAction());

      // Copy
      aActionCell.addChild(createCopyLink(aCurUser, aDisplayLocale));

      // Reset password of user
      if (canResetPassword(aCurUser)) {
        aActionCell.addChild(
            new HCA(
                    LinkUtils.getSelfHref()
                        .add(CHCParam.PARAM_ACTION, ACTION_RESET_PASSWORD)
                        .add(CHCParam.PARAM_OBJECT, aCurUser.getID()))
                .setTitle(
                    EText.TITLE_RESET_PASSWORD.getDisplayTextWithArgs(
                        aDisplayLocale, SecurityUI.getUserDisplayName(aCurUser, aDisplayLocale)))
                .addChild(getResetPasswordIcon()));
      } else aActionCell.addChild(createEmptyAction());
    }

    final HCNodeList aNodeList = new HCNodeList();
    aNodeList.addChild(aTable);

    final DataTables aDataTables = getStyler().createDefaultDataTables(aTable, aDisplayLocale);
    aDataTables.getOrCreateColumnOfTarget(3).addClass(CSS_CLASS_ACTION_COL).setSortable(false);
    aDataTables.setInitialSorting(1, ESortOrder.ASCENDING);
    aNodeList.addChild(aDataTables);

    // Required for best layout inside a tab!
    aTable.removeAllColumns();

    return aNodeList;
  }
  /**
   * Called after successful external validation
   *
   * @param aItem Uploaded file item
   * @param aContext The non-<code>null</code> Upload context
   * @return The file which has been written in on the server, or <code>null</code> in case of an
   *     error
   * @throws FileUploadException
   */
  @Nullable
  private static File _handleUploadFileItem(
      @Nonnull final IFileItem aItem, @Nonnull final UploadContext aContext)
      throws FileUploadException {
    final String sFieldName = aItem.getFieldName();
    final String sSourceFileName = aItem.getName();
    final String sContentType = aItem.getContentType();
    final boolean bInMemory = aItem.isInMemory();
    final long nSizeInBytes = aItem.getSize();
    File aUploadedFile = null;

    s_aLogger.info(
        "Processing file item [field:"
            + sFieldName
            + ", file:"
            + sSourceFileName
            + ", contenttype:"
            + sContentType
            + ", inmemory:"
            + bInMemory
            + ", size:"
            + nSizeInBytes
            + (aContext.getPostProcessor() == null
                ? ""
                : ", post processor "
                    + CGStringHelper.getClassLocalName(aContext.getPostProcessor()))
            + "]");

    // Validate the original filename
    final IUploadFilenameFilter aFilter = aContext.getFilenameFilter();
    if (aFilter != null && !aFilter.matchesFilter(sSourceFileName)) {
      FileUploadProgressListener.getInstance()
          .setFailed(
              aFilter.getErrorCode(),
              aFilter.getErrorMessage(),
              ArrayHelper.newArray(aFilter.getErrorArguments(), String.class));
      final String sMsg =
          "Uploaded file '"
              + sSourceFileName
              + "' does not satisfy the active filename filter!"; //$NON-NLS-2$
      s_aLogger.warn(sMsg);
      throw new FileUploadException(sMsg);
    }

    final IUploadFileSizeFilter aSizeFilter = aContext.getFileSizeFilter();
    if (aSizeFilter != null && !aSizeFilter.matchesFilter(Long.valueOf(nSizeInBytes))) {
      FileUploadProgressListener.getInstance()
          .setFailed(
              EFileUploadText.ERROR_FILESIZE_EXCEEDED.getStringPropertyName(),
              EFileUploadText.ERROR_FILESIZE_EXCEEDED,
              sSourceFileName,
              SizeHelper.getSizeHelperOfLocale(Locale.US)
                  .getAsMatching(aSizeFilter.getMaxBytes(), 2));
      final String sMsg =
          "Uploaded file '"
              + sSourceFileName
              + "' does not satisfy the maximum file size filter!"; //$NON-NLS-2$
      s_aLogger.warn(sMsg);
      throw new FileUploadException(sMsg);
    }

    // Size may be 0 if no file was selected
    if (nSizeInBytes > 0) {
      // Set the post processor only, if a file is present, to avoid endless
      // loops on "post processing file ..."
      final FileUploadProgressListener aProgListener = FileUploadProgressListener.getInstance();
      final IUploadPostProcessor aPostProcessor = aContext.getPostProcessor();
      if (aPostProcessor != null) {
        aProgListener.setPostProcessor(aPostProcessor);
      }
      // Ensure the file does not contain any harmful characters etc.
      final String sFileName = FileUploadHelper.getUnifiedFilename(aItem);
      String sTargetFileName = aContext.getTargetFileName();
      if (StringHelper.hasNoText(sTargetFileName)) {
        sTargetFileName = sFileName;
      }
      final String sTargetDir =
          FilenameHelper.getAbsoluteWithEnsuredParentDirectory(
              aContext.getUploadDirectory(), FilenameHelper.getPath(sTargetFileName));

      // This is the main copy action
      aUploadedFile =
          FileUploadHelper.saveUploadedFile(
              aItem,
              new File(sTargetDir),
              FilenameHelper.getBaseName(sTargetFileName),
              FilenameHelper.getExtension(sTargetFileName));

      if (aUploadedFile == null) {
        // Something went wrong in copying
        s_aLogger.error("Upload failed.");
      } else {
        s_aLogger.info(
            "Upload completed successfully to destination " + aUploadedFile.getAbsolutePath());
        if (aPostProcessor != null) {
          s_aLogger.info("Starting post processing...");
          try {
            aProgListener.setPostProcessing();
            final UploadPostProcessingResult aResult =
                aPostProcessor.performPostProcessing(
                    aUploadedFile, sFileName, aContext.getProperties());
            aProgListener.setPostProcessorResult(aResult);
          } catch (final RuntimeException ex) {
            // Catch any exception
            s_aLogger.error("Internal error in post processing", ex);
            aProgListener.setPostProcessorResult(
                new UploadPostProcessingResult(
                    ESuccess.FAILURE,
                    EFileUploadText.ERROR_POST_PROCESSING,
                    EFileUploadText.ERROR_POST_PROCESSING.getStringPropertyName(),
                    null));
          }
        }
      }
    } else {
      FileUploadProgressListener.getInstance()
          .setFailed(
              EFileUploadText.ERROR_NO_FILE_OR_EMPTY.getStringPropertyName(),
              EFileUploadText.ERROR_NO_FILE_OR_EMPTY);
      final String sMsg =
          "No file or empty file selected: '" + sSourceFileName + "'!"; // $NON-NLS-2$
      s_aLogger.warn(sMsg);
      throw new FileUploadException(sMsg);
    }
    return aUploadedFile;
  }
 /** @return An array with all search terms. Never <code>null</code> nor empty. */
 @Nonnull
 @ReturnsMutableCopy
 @Nonempty
 public final String[] getAllSearchTerms() {
   return ArrayHelper.getCopy(m_aSearchTerms);
 }
 @Deprecated
 @Nonnull
 public String[] getValueNames() {
   return ArrayHelper.newArray(m_aAttributes.keySet(), String.class);
 }