Skip to content

Commit

Permalink
Revert "Validation for Existance of entity"
Browse files Browse the repository at this point in the history
This reverts commit aa6eb34.
  • Loading branch information
TanmoySG authored Jun 17, 2022
1 parent d879fdb commit 1a22931
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
10 changes: 2 additions & 8 deletions handlers/publishers/publisher.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as filesystem from 'fs';
import { nanoid } from "nanoid";
import { JSONWriterGeneric } from '../utilities/jsonWriter.js';
import { StandardizeIdentifier } from '../utilities/identifierUtility.js';
import { validateNewPublisher, validateExistingPublisher } from "./validate.js";
import { validateNewPublisher } from "./validate.js";
import { createContextRegistry } from '../contexts/context.js';

const PublisherRegistryFilePath = "logfiles/PublisherRegistry.json";
Expand All @@ -16,12 +16,6 @@ export function getPublishersRegistry() {

export function addToPublisherRegistry(newPublisher, callback) {
const PublisherRegistry = getPublishersRegistry();
if (validateExistingPublisher(newPublisher["publisher"], PublisherRegistry)) {
callback({
status: "failed",
message: "Publisher Exists"
})
}
if (validateNewPublisher(newPublisher, PublisherRegistry)) {
const StandardizedPublisherIdentifier = StandardizeIdentifier(newPublisher["publisher"]);
const publisherNamespacePath = "logfiles/" + StandardizedPublisherIdentifier;
Expand All @@ -42,7 +36,7 @@ export function addToPublisherRegistry(newPublisher, callback) {
callback({
status: "success",
message: "Publisher Created!",
publisher: StandardizedPublisherIdentifier
publisher : StandardizedPublisherIdentifier
});
});
});
Expand Down
16 changes: 10 additions & 6 deletions handlers/publishers/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,17 @@ export function validateLog(LogBody) {
}

export function validateNewPublisher(newPublisher, PublisherRegistry) {
if ("publisher" in newPublisher && "origin" in newPublisher) {
if (newPublisher["publisher"].length != 0 && newPublisher["origin"].length != 0) {
return true
if (validateExistingPublisher(newPublisher["publisher"], PublisherRegistry)) {
return false
} else {
if ("publisher" in newPublisher && "origin" in newPublisher) {
if (newPublisher["publisher"].length != 0 && newPublisher["origin"].length != 0) {
return true
} else {
return false
}
} else {
return false
}
} else {
return false
}
}
}

0 comments on commit 1a22931

Please sign in to comment.