Skip to content

Commit

Permalink
FAB-16290 Make metadata fields lower case
Browse files Browse the repository at this point in the history
As part of the effort to homogonize the package structure, the key names
will (soon) be required to be lower case.  This CR simply modifies the
generated metadata keys to conform to this standard.

Change-Id: Ida23c333c9bbe33d60afb1e6667cba19813b5656
Signed-off-by: Jason Yellick <jyellick@us.ibm.com>
  • Loading branch information
Jason Yellick committed Sep 3, 2019
1 parent 31727ee commit 33e43ee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ static byte[] generatePackageMataDataBytes(String label, String path, Transactio
if (path == null) {
path = "";
}
return format("{\"Path\":%s,\"Type\":\"%s\",\"Label\":%s}", new Gson().toJson(path), type.toPackageName(), new Gson().toJson(label)).getBytes(UTF_8);
return format("{\"path\":%s,\"type\":\"%s\",\"label\":%s}", new Gson().toJson(path), type.toPackageName(), new Gson().toJson(label)).getBytes(UTF_8);
}

public JsonObject getMetaInfJson() throws IOException {
Expand Down Expand Up @@ -380,7 +380,7 @@ public TransactionRequest.Type getType() throws IOException {
JsonObject metaInfJson = getMetaInfJson();
if (null != metaInfJson) {

String type = metaInfJson.containsKey("Type") ? metaInfJson.getString("Type") : null;
String type = metaInfJson.containsKey("type") ? metaInfJson.getString("type") : null;
if (null != type) {

return TransactionRequest.Type.fromPackageName(type);
Expand All @@ -393,7 +393,7 @@ public String getLabel() throws IOException {
JsonObject metaInfJson = getMetaInfJson();
if (null != metaInfJson) {

String label = metaInfJson.containsKey("Label") ? metaInfJson.getString("Label") : null;
String label = metaInfJson.containsKey("label") ? metaInfJson.getString("label") : null;
if (null != label) {

return label;
Expand All @@ -406,7 +406,7 @@ public String getPath() throws IOException {
JsonObject metaInfJson = getMetaInfJson();
if (null != metaInfJson) {

return metaInfJson.containsKey("Path") ? metaInfJson.getString("Path") : null;
return metaInfJson.containsKey("path") ? metaInfJson.getString("path") : null;
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public void testGoLangCode() throws Exception {
assertTrue(lifecycleChaincodePackage.getAsBytes().length > 1);

JsonObject metaInfJson = lifecycleChaincodePackage.getMetaInfJson();
Assert.assertEquals(metaInfJson.getString("Path"), "github.com/example_cc");
Assert.assertEquals(metaInfJson.getString("Type"), "golang");
Assert.assertEquals(metaInfJson.getString("path"), "github.com/example_cc");
Assert.assertEquals(metaInfJson.getString("type"), "golang");
Assert.assertEquals(lifecycleChaincodePackage.getType(), TransactionRequest.Type.GO_LANG);
Assert.assertEquals(lifecycleChaincodePackage.getPath(), "github.com/example_cc");
Assert.assertEquals(lifecycleChaincodePackage.getLabel(), "mylabel");
Expand Down

0 comments on commit 33e43ee

Please sign in to comment.