CPD Results

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

Duplications

File Line
com/hcl/domino/keep/handlers/core/ExecuteGroovy.java 34
com/hcl/domino/keep/handlers/core/ExecuteJavaScript.java 34
public class ExecuteGroovy extends DefaultJsonHandler {

  private final Set<String> permittedParams =
      new HashSet<>(Arrays.asList("query", "view", "document", "collection"));

  private JsonObject cleanupEntry(final Map.Entry<String, String> entry) {
    final JsonObject result = new JsonObject();
    final String name = entry.getKey();
    if (name.equals("collection")) {
      final String[] members = entry.getValue().split(",");
      result.put(name, new JsonArray(Arrays.asList(members)));
    } else {
      result.put(name, entry.getValue());
    }
    return result;
  }

  @Override
  protected Future<JsonObject> prepareRequestBody(final RoutingContext ctx,
      final MultiMap headers) {

    final JsonObject message = new JsonObject();
    final JsonObject context = new JsonObject();
    final JsonObject request = new JsonObject();
    final JsonObject headerJson = new JsonObject();
    final String body = ctx.getBodyAsString();

    StreamSupport.stream(ctx.queryParams().spliterator(), false)
        .filter(entry -> this.permittedParams.contains(entry.getKey()))
        .map(this::cleanupEntry)
        .collect(KeepCollectors.jsonCollector(context));

    headers.forEach(entry -> headerJson.put(entry.getKey(), entry.getValue()));

    request.put(Constants.REQUEST_BODY, body);

    message.put(Constants.HEADER_HEADERS, headerJson);
    request.put("context", context);
    message.put(Constants.REQUEST_BODY, request);
    return Future.succeededFuture(message);
  }

}
File Line
com/hcl/domino/keep/dbrequests/data/FetchViewEntries.java 74
com/hcl/domino/keep/dbrequests/pim/GetCollection.java 53
      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).increment(totRows);
File Line
com/hcl/domino/keep/tools/MimeHelper.java 119
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/dbrequests/pim/RulesHelper.java 344
com/hcl/domino/keep/dbrequests/pim/RulesHelper.java 436
      if (localActionList == null || localActionList.size() == 0) {
        return false;
      }
      for (final Object act : localActionList) {
        this.addAction(act.toString());
      }
      final String sRuleFormula = this.getRuleFormula();
      if (ruledoc.hasItem(FilterFormula)) {
        ruledoc.removeItem(FilterFormula);
        ruledoc.save();
      }
      final Formula localRuleFormula = client.createFormula(sRuleFormula);
      ruledoc.replaceItemValue(FilterFormula, EnumSet.of(ItemFlag.SUMMARY), localRuleFormula);
      ruledoc.save();
      formulaItem = ruledoc.getFirstItem(FilterFormula);
    }

    final String localRuleFormula = formulaItem.getValue().toString().toLowerCase().trim();
File Line
com/hcl/domino/keep/dbrequests/data/FetchViewEntries.java 79
com/hcl/domino/keep/dbrequests/data/Query.java 143
    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 79
com/hcl/domino/keep/dbrequests/data/Query.java 143
com/hcl/domino/keep/dbrequests/pim/EmptyTrash.java 66
com/hcl/domino/keep/dbrequests/pim/GetCollection.java 58
    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/tools/KeepMustacheHelper.java 171
com/hcl/domino/keep/tools/KeepMustacheHelper.java 193
  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();