Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/hub 1565 #1413

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ public Response createChannel(@PathParam("channel") String channelName, String j
log.trace("put channel {} {}", channelName, json);
Optional<ChannelConfig> oldConfig = channelService.getChannelConfig(channelName, false);
ChannelConfig channelConfig = ChannelConfig.createFromJsonWithName(json, channelName);
if (channelConfig.getCreationDate()!= null) {
// If the creation date is being modified, throw a 500 error
return Response.status(Response.Status.INTERNAL_SERVER_ERROR)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Haripriya99j As informed earlier, don't introduce new logic instead make use of existing logic. Also, this logic will unnecessarily return error message while creating with creationDate but that is not the requirement. Below is the class already available to perform validation and returns error message. See how we can use make use of it.
https://github.com/flightstats/hub/blob/feature/HUB-1565/src/main/java/com/flightstats/hub/channel/ChannelValidator.java
Write test cases as well to ensure it is working as expected.

.entity("Modification of the creation date is not allowed").build();
}
if (oldConfig.isPresent()) {
ChannelConfig config = oldConfig.get();
log.trace("using old channel {} {}", config, config.getCreationDate().getTime());
Expand Down