Example #1
0
  private PathEntry putPathEntry(Entity entity, Locale locale) {
    final PathEntry pathEntry = new PathEntry();

    final String entityName = entity.getName();

    pathEntry.setDescription(msg(locale, UPDATE_DESC_KEY, entityName));
    pathEntry.setOperationId(msg(locale, UPDATE_ID_KEY, entityName));
    pathEntry.setProduces(json());
    pathEntry.addTag(entity.getClassName());

    pathEntry.addParameter(updateEntityParameter(entity, locale));

    addCommonResponses(pathEntry, locale);
    pathEntry.addResponse(HttpStatus.OK, updatedItemResponse(entity, locale));
    pathEntry.addResponse(HttpStatus.NOT_FOUND, notFoundResponse(entity, locale));

    return pathEntry;
  }
Example #2
0
  private PathEntry readPathEntry(Entity entity, Locale locale) {
    final PathEntry pathEntry = new PathEntry();

    final String entityName = entity.getName();

    pathEntry.setDescription(msg(locale, READ_DESC_KEY, entityName));
    pathEntry.setOperationId(msg(locale, READ_ID_KEY, entityName));
    pathEntry.setProduces(json());
    pathEntry.addTag(entity.getClassName());

    pathEntry.setParameters(queryParamsParameters(entity.getFieldsExposedByRest(), locale));
    pathEntry.addParameter(idQueryParameter(locale));

    pathEntry.addResponse(HttpStatus.OK, readResponse(entity, locale));
    addCommonResponses(pathEntry, locale);

    return pathEntry;
  }
Example #3
0
  private PathEntry lookupPathEntry(Entity entity, Lookup lookup, Locale locale) {
    final PathEntry pathEntry = new PathEntry();

    pathEntry.setDescription(msg(locale, LOOKUP_DESC_KEY, lookup.getLookupName()));
    pathEntry.setOperationId(lookup.getMethodName());
    pathEntry.setProduces(json());
    pathEntry.addTag(entity.getClassName());

    pathEntry.setParameters(lookupParameters(entity, lookup, locale));

    pathEntry.addResponse(HttpStatus.OK, lookupResponse(entity, lookup, locale));
    addCommonResponses(pathEntry, locale);

    if (lookup.isSingleObjectReturn()) {
      pathEntry.addResponse(HttpStatus.NOT_FOUND, lookup404Response(entity, locale));
    }

    return pathEntry;
  }
Example #4
0
  private PathEntry deletePathEntry(Entity entity, Locale locale) {
    final PathEntry pathEntry = new PathEntry();

    final String entityName = entity.getName();

    pathEntry.setDescription(msg(locale, DELETE_DESC_KEY, entityName));
    pathEntry.setOperationId(msg(locale, DELETE_ID_KEY, entityName));
    pathEntry.setProduces(json());
    pathEntry.addTag(entity.getClassName());

    pathEntry.addParameter(deleteIdPathParameter(locale));

    addCommonResponses(pathEntry, locale);
    pathEntry.addResponse(HttpStatus.OK, deleteResponse(entity, locale));

    return pathEntry;
  }
Example #5
0
 private void addCommonResponses(PathEntry pathEntry, Locale locale) {
   pathEntry.addResponse(HttpStatus.BAD_REQUEST, badRequestResponse(locale));
   pathEntry.addResponse(HttpStatus.FORBIDDEN, forbiddenResponse(locale));
 }