CPD Results

The following document contains the results of PMD's CPD 6.30.0.

Duplications

File Line
com/hcl/domino/keep/dbrequests/pim/GetPerson.java 124
com/hcl/domino/keep/dbrequests/pim/GetPublicPerson.java 107
  @Override
  public void process(final DbRequestParameters<JsonObject> request) throws Exception {

    request.validate();
    final String personId = request.incoming().getString(Constants.CONTEXT_PARAM_personid);
    final Document note = request.session().getDocumentByUNID(request.db(), personId,
        DocumentScope.VALID_DOCUMENTS_ONLY);
    if (note == null) {
      throw new KeepExceptionNotFound("No contact found for %s", personId);
    }
    final Map<String, String> fieldMap = KeepUtils.getMapFromResource("/fieldMappings/Person.txt");
    final EnumSet<Note2JsonOptions> options =
        EnumSet.of(Note2JsonOptions.ONLY_LISTED_FIELDS, Note2JsonOptions.INCLUDE_RICHTEXT);
    final JsonObject result = request.session().document2Json(note, fieldMap, options);

    if (!"Person".equalsIgnoreCase(result.getString("Form"))
        && !"Group".equalsIgnoreCase(result.getString("Form"))) {
      throw new KeepExceptionNotFound("No contact found for %s", personId);
    }
    request.emit(result);
  }
}
File Line
com/hcl/domino/keep/dbrequests/pim/RulesHelper.java 329
com/hcl/domino/keep/dbrequests/pim/RulesHelper.java 421
      final List<?> actionList = ruledoc.getItemValue("ActionList");
      if (actionList == null || actionList.size() == 0) {
        return false;
      }
      for (final Object act : actionList) {
        this.addAction(act.toString());
      }
      final String sRuleFormula = this.getRuleFormula();
      if (ruledoc.hasItem(FilterFormula)) {
        ruledoc.removeItem(FilterFormula);
        ruledoc.save();
      }
      final Formula ruleFormula = this.db.getParentDominoClient().createFormula(sRuleFormula);
      ruledoc.replaceItemValue(FilterFormula, EnumSet.of(ItemFlag.SUMMARY), ruleFormula);
      ruledoc.save();
      formulaItem = ruledoc.getFirstItem(FilterFormula);
    }

    final String ruleFormula = formulaItem.getValue().toString().toLowerCase().trim();
File Line
com/hcl/domino/keep/dbrequests/data/FetchViewEntries.java 113
com/hcl/domino/keep/dbrequests/pim/GetCollection.java 86
      this.processDocuments(request, cr.results, modeName);
    } else {
      FolderViewFunctions.processViewEntries(request, cr.dc, cr.results, cr.includeUnread);
    }

    final List<Tag> metricsTags = new ArrayList<>();
    metricsTags.add(Tag.of(TagKey.CLASS_NAME.getValue(), this.getClass().getName()));
    metricsTags.add(Tag.of(TagKey.API_NAME.getValue(), this.getApiName()));
    metricsTags.add(Tag.of(TagKey.REQUEST_TYPE.getValue(), this.getRequestType().getValue()));
    KeepFactorySource.INSTANCE.getCurrentFactory()
        .getKeepStatistics()
        .getOrCreateCounter("keep.database.handler.entries.count", metricsTags)
File Line
com/hcl/domino/keep/tools/MimeHelper.java 120
com/hcl/domino/keep/tools/MimeHelper.java 387
      int currSiblingFound = -1; // We haven't found any
      for (int i = 0; i < parts.getCount(); i++) {
        final BodyPart body = parts.getBodyPart(i);
        if (body.getContentType().startsWith(mimeType)) {
          currSiblingFound++;
          if (currSiblingFound == sibling) {
            try (InputStream in = body.getInputStream()) {
              result.appendBytes(ByteStreams.toByteArray(in));
              break;
            } catch (final Exception e) {
              MimeHelper.logger.error(e.getMessage(), e);
            }
          }
        }
      }
    } catch (IOException | MessagingException e) {
      MimeHelper.logger.error(String.format("Mime extraction for %s, field %s failed with %s",
File Line
com/hcl/domino/keep/admin/AbstractAsyncDominoAcl.java 61
com/hcl/domino/keep/dbrequests/pim/GetMailboxInfo.java 137
    result.put("roles", aclEntry.getRoles());
    final Set<AclFlag> flags = aclEntry.getAclFlags();
    final List<String> flagEntries = new ArrayList<>();
    for (final AclFlag flag : flags) {
      switch (flag) {
        case GROUP:
        case PERSON:
        case SERVER:
          result.put("type", flag.name());
          break;
        default:
          flagEntries.add(flag.name());
          break;
      }
      result.put("flags", flagEntries);
      if (!result.containsKey("type")) {
        result.put("type", "");
      }
    }
    return result;
  }
File Line
com/hcl/domino/keep/dbrequests/pim/GetPeople.java 42
com/hcl/domino/keep/dbrequests/pim/GetTemplates.java 41
  public GetPeople(final JsonObject requestParams, final Vertx vertx) {
    super(requestParams, vertx);
  }

  /**
   * processPayload returns a list of Contacts. The API takes three optional
   * parameters passed in through the payload object.
   *
   * @param count How many Contacts to return
   * @param skip How many Contact entries to skip (for paging)
   * @param mailboxid Alternate mailbox id
   */
  @Override
  protected void processPayload(final KeepJnxSession s, final Database db,
      final JsonObject payload) {

    Integer count = Constants.PIM_DEFAUlT_RETRIEVAL_COUNT;
    Integer skip = 0;
    Integer reqCount, reqSkip;

    // Validate parameters
    if (payload != null && !payload.isEmpty()) {
      reqCount = payload.getInteger("count");
      count = reqCount != null && reqCount > 0 ? reqCount : count;
      reqSkip = payload.getInteger("skip");
      skip = reqSkip != null && reqSkip >= 0 ? reqSkip : skip;
    }

    // Set parameters and do fetch, note that fetch is looking for "start" which is skip+1
    payload.put(Constants.CONTEXT_PARAM_name, Constants.RESERVED_NOTES_VIEWNAME_Contacts);
File Line
com/hcl/domino/keep/dbrequests/designcode/UpdateCreateForm.java 94
com/hcl/domino/keep/dbrequests/designcode/UpdateCreateView.java 96
      this.createField(doc, (JsonObject) field);
    }
    doc.closeDocument();
    final String rawDXL = out.toString();
    out.close();

    final DxlImporter importer = KeepFactorySource.INSTANCE.getCurrentFactory().getDominoAPI()
        .getDxlImporter(request.session().getClient());

    importer.setExitOnFirstFatalError(false);
    importer.setDesignImportOption(DXLImportOption.REPLACE_ELSE_CREATE);
    importer.setDocumentsImportOption(DXLImportOption.IGNORE);
    importer.setACLImportOption(DXLImportOption.IGNORE);
    importer.setUnknownTokenLogOption(DXLLogOption.WARNING);
    importer.setReplaceDbProperties(false);
    importer.setReplicaRequiredForReplaceOrUpdate(false);
    importer.importDxl(rawDXL, request.db());

    // Import log includes stuff even if it works. So check note
    boolean success = false;
    final GenericFormOrSubform formNote =
File Line
com/hcl/domino/keep/dbrequests/data/FetchViewEntries.java 118
com/hcl/domino/keep/dbrequests/data/Query.java 153
    final List<Tag> metricsTags = new ArrayList<>();
    metricsTags.add(Tag.of(TagKey.CLASS_NAME.getValue(), this.getClass().getName()));
    metricsTags.add(Tag.of(TagKey.API_NAME.getValue(), this.getApiName()));
    metricsTags.add(Tag.of(TagKey.REQUEST_TYPE.getValue(), this.getRequestType().getValue()));
    KeepFactorySource.INSTANCE.getCurrentFactory()
        .getKeepStatistics()
        .getOrCreateCounter("keep.database.handler.entries.count", metricsTags)
        .increment(totRows);
File Line
com/hcl/domino/keep/dbrequests/data/FetchViewEntries.java 118
com/hcl/domino/keep/dbrequests/data/Query.java 153
com/hcl/domino/keep/dbrequests/pim/EmptyTrash.java 81
com/hcl/domino/keep/dbrequests/pim/GetCollection.java 91
    final List<Tag> metricsTags = new ArrayList<>();
    metricsTags.add(Tag.of(TagKey.CLASS_NAME.getValue(), this.getClass().getName()));
    metricsTags.add(Tag.of(TagKey.API_NAME.getValue(), this.getApiName()));
    metricsTags.add(Tag.of(TagKey.REQUEST_TYPE.getValue(), this.getRequestType().getValue()));
    KeepFactorySource.INSTANCE.getCurrentFactory()
        .getKeepStatistics()
        .getOrCreateCounter("keep.database.handler.entries.count", metricsTags)
File Line
com/hcl/domino/keep/handlers/core/FetchOdataList.java 69
com/hcl/domino/keep/handlers/core/GetOdataMetadata.java 66
          incomingObservable.request(1);
        },
        error -> {
          if (error instanceof KeepExceptionType) {
            final int code = ((KeepExceptionType) error).getKeepErrorType().getValue();
            this.endWithError(ctx, code, error.getMessage(), false);
          } else {
            String msg = error.getMessage();
            msg = msg.replaceAll("[^a-zA-Z0-9]", " ");
            this.endWithError(ctx, 500, msg, false);
          }
        },
        () -> {
          response.setChunked(false);
          response.putHeader("OData-Version", "4.0");
File Line
com/hcl/domino/keep/tools/KeepMustacheHelper.java 169
com/hcl/domino/keep/tools/KeepMustacheHelper.java 191
  private Set<Entry<String, Object>> fromJson(final JsonObject source) {
    final HashMap<String, Object> result = new HashMap<>();
    source.getMap().forEach((key, value) -> {
      if (value instanceof JsonObject) {
        result.put(key, this.fromJson((JsonObject) value));
      } else if (value instanceof JsonArray) {
        result.put(key, this.fromJson((JsonArray) value));
      } else {
        result.put(key, value);
      }
    });

    return result.entrySet();