This repository has been archived by the owner on Aug 7, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
change affiliation field from mandatory to optional #3
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9a2038b
change affiliation field from mandatory to optional
SandySun2000 bd1c9d9
no change on required field
SandySun2000 e2562b8
modify readme.md to adapt GUI changes
SandySun2000 412cfea
add images to support readme.md
SandySun2000 b1e0a7b
reformat the images
SandySun2000 beb1700
resolving Rick's comment
SandySun2000 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -171,7 +171,9 @@ String getName() { | |
} | ||
|
||
String getMspid() { | ||
return value.getString("mspid"); | ||
if(value.containsKey("mspid")) | ||
return value.getString("mspid"); | ||
return null; | ||
} | ||
|
||
public OrganizationConfig.CertificateAuthorityConfig getCertificateAuthority(String name) { | ||
|
@@ -210,7 +212,9 @@ private CertificateAuthorityConfig(String name, JsonObject value, String mspid) | |
} | ||
|
||
public String getCAName() { | ||
return value.getString("caName"); | ||
if(value.containsKey("caName")) | ||
return value.getString("caName"); | ||
return null; | ||
} | ||
|
||
NetworkConfigUser getRegistrar(String name) { | ||
|
@@ -232,7 +236,8 @@ public Map<String, NetworkConfigUser> getRegistrars() { | |
|
||
NetworkConfigUser networkConfigUser = new NetworkConfigUser(registrar.getEnrollId(), | ||
OrganizationConfig.this.getMspid(), registrar.getEnrollSecret()); | ||
networkConfigUser.affiliation = registrar.getAffiliation(); | ||
if(registrar.getAffiliation() != null) | ||
networkConfigUser.affiliation = registrar.getAffiliation(); | ||
|
||
ret.put(registrar.getEnrollId(), networkConfigUser); | ||
|
||
|
@@ -276,7 +281,9 @@ class PeerConfig extends EndPoint { | |
} | ||
|
||
public String getEventURL() { | ||
return value.getString("eventUrl"); | ||
if(value.containsKey("eventUrl")) | ||
return value.getString("eventUrl"); | ||
return null; | ||
} | ||
|
||
} | ||
|
@@ -292,15 +299,21 @@ class Registrar { | |
} | ||
|
||
public String getEnrollId() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again I think there would always be an id here |
||
return value.getString("enrollId"); | ||
if(value.containsKey("enrollId")) | ||
return value.getString("enrollId"); | ||
return null; | ||
} | ||
|
||
public String getAffiliation() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here this seems appropriate |
||
return value.getString("affiliation"); | ||
if(value.containsKey("affiliation")) | ||
return value.getString("affiliation"); | ||
return null; | ||
} | ||
|
||
public String getEnrollSecret() { | ||
return value.getString("enrollSecret"); | ||
if(value.containsKey("enrollSecret")) | ||
return value.getString("enrollSecret"); | ||
return null; | ||
} | ||
|
||
} | ||
|
@@ -316,15 +329,20 @@ class EndPoint { | |
} | ||
|
||
public String getURL() { | ||
return value.getString("url"); | ||
if(value.containsKey("url")) | ||
return value.getString("url"); | ||
return null; | ||
|
||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public String getTLSCerts() { | ||
return value.getJsonObject("tlsCACerts").getString("pem"); | ||
if(value.containsKey("tlsCACerts")) | ||
return value.getJsonObject("tlsCACerts").getString("pem"); | ||
return null; | ||
|
||
} | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would be careful here and in other places as I don't think these are optional. If they're not present probably should throw some type of exeception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the field is required, should I remove the checking?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's one option. I would think better throwing an exception with an error that the field was missing from the NetworkConfig document.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you done some testing with this change ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only do the testing with "affiliation" change from the Jason file. I will leave those fields untouched then