Skip to content

Commit

Permalink
Merge pull request #27 from upb-uc4/release/version_0_8_0
Browse files Browse the repository at this point in the history
Release/version 0 8 0
  • Loading branch information
matthias-geuchen authored Sep 18, 2020
2 parents 63651a7 + 7decdc3 commit bba300a
Show file tree
Hide file tree
Showing 13 changed files with 1,301 additions and 612 deletions.
50 changes: 50 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,53 @@
# [v0.8.0](https://github.com/upb-uc4/hyperledger_chaincode/compare/v0.7.2...v0.8.0) (2020-09-14)

## Feature
-

## Bug Fixes
- fix tests not throwing error when querying ```getPrivateDataUTF8``` for empty string [#25](https://github.com/upb-uc4/hlf-chaincode/pull/25)

## Refactor
-


## Usability
-



# [v0.7.2](https://github.com/upb-uc4/hyperledger_chaincode/compare/v0.7.1...v0.7.2) (2020-09-9)

## Feature
-

## Bug Fixes
- split up *collections_config* for dev/production network [#21](https://github.com/upb-uc4/hlf-chaincode/pull/21)

## Refactor
- refactor ```addEntryToMatriculation``` to take list of entries [#20](https://github.com/upb-uc4/hlf-chaincode/pull/20)
- refactor error format to conform to api [#37](https://github.com/upb-uc4/api/pull/37), [#39](https://github.com/upb-uc4/api/pull/39)


## Usability
-


# [v0.7.1](https://github.com/upb-uc4/hyperledger_chaincode/compare/v0.7.0...v0.7.1) (2020-09-7)

## Feature
- move sensitive data to transient data field and store data in private data collection [#17](https://github.com/upb-uc4/hlf-chaincode/pull/17)

## Bug Fixes
-

## Refactor
- refactor tests for private data transactions


## Usability
-


# [v0.7.0](https://github.com/upb-uc4/hyperledger_chaincode/compare/v0.6.0.1...v0.7.0) (2020-08-31)

## Feature
Expand Down
10 changes: 10 additions & 0 deletions chaincode/collections_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"name": "TestCollection",
"policy": "OR('org1MSP.member','org2MSP.member')",
"requiredPeerCount": 0,
"maxPeerCount": 3,
"blockToLive": 0,
"memberOnlyRead": true
}
]
10 changes: 10 additions & 0 deletions chaincode/collections_config_dev.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"name": "TestCollection",
"policy": "OR('SampleOrgMSP.member')",
"requiredPeerCount": 0,
"maxPeerCount": 3,
"blockToLive": 0,
"memberOnlyRead": true
}
]
89 changes: 28 additions & 61 deletions chaincode/src/main/java/de/upb/cs/uc4/chaincode/GsonWrapper.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package de.upb.cs.uc4.chaincode;

import com.google.gson.*;
import com.google.gson.stream.JsonReader;
import de.upb.cs.uc4.chaincode.model.Dummy;
import org.jsoup.Jsoup;
import org.jsoup.safety.Whitelist;
import org.threeten.bp.LocalDate;
import org.threeten.bp.format.DateTimeFormatter;
import org.threeten.bp.format.DateTimeParseException;

import java.io.FileReader;
import java.io.Reader;
import java.lang.reflect.Type;

Expand All @@ -18,84 +16,49 @@ public class GsonWrapper {
private static final Gson gson = new GsonBuilder()
.registerTypeAdapter(
LocalDate.class,
new JsonDeserializer<LocalDate>() {
@Override
public LocalDate deserialize(
JsonElement json,
Type type,
JsonDeserializationContext jsonDeserializationContext
) throws JsonParseException {
try {
return LocalDate.parse(json.getAsJsonPrimitive().getAsString());
} catch (DateTimeParseException e) {
return null;
}
(JsonDeserializer<LocalDate>) (json, type, jsonDeserializationContext) -> {
try {
return LocalDate.parse(json.getAsJsonPrimitive().getAsString());
} catch (DateTimeParseException e) {
return null;
}
})
.registerTypeAdapter(
LocalDate.class,
new JsonSerializer<LocalDate>() {
@Override
public JsonElement serialize(LocalDate date, Type typeOfSrc, JsonSerializationContext context) {
return new JsonPrimitive(date.format(DateTimeFormatter.ISO_LOCAL_DATE)); // "yyyy-mm-dd"
}
(JsonSerializer<LocalDate>) (date, typeOfSrc, context) -> {
return new JsonPrimitive(date.format(DateTimeFormatter.ISO_LOCAL_DATE)); // "yyyy-mm-dd"
})
.registerTypeAdapter(
Integer.class,
new JsonDeserializer<Integer>() {
@Override
public Integer deserialize(
JsonElement json,
Type type,
JsonDeserializationContext jsonDeserializationContext
) throws JsonParseException {
try {
return json.getAsInt();
} catch (RuntimeException e) {
return null;
}
(JsonDeserializer<Integer>) (json, type, jsonDeserializationContext) -> {
try {
return json.getAsInt();
} catch (RuntimeException e) {
return null;
}
})
.registerTypeAdapter(
Dummy.class,
new JsonSerializer<Dummy>() {
@Override
public JsonElement serialize(Dummy dummy, Type typeOfSrc, JsonSerializationContext context) {
return new JsonPrimitive(dummy.getContent()); // "yyyy-mm-dd"
}
(JsonSerializer<Dummy>) (dummy, typeOfSrc, context) -> {
return new JsonPrimitive(dummy.getContent()); // "yyyy-mm-dd"
})
.registerTypeAdapter(
Dummy.class,
new JsonDeserializer<Dummy>() {
@Override
public Dummy deserialize(
JsonElement json,
Type type,
JsonDeserializationContext jsonDeserializationContext
) throws JsonParseException {
try {
String s = json.toString();
if (s.charAt(0) == '"') {
s = s.substring(1, s.length()-1);
}
return new Dummy(s);
} catch (RuntimeException e) {
return null;
(JsonDeserializer<Dummy>) (json, type, jsonDeserializationContext) -> {
try {
String s = json.toString();
if (s.charAt(0) == '"') {
s = s.substring(1, s.length()-1);
}
return new Dummy(s);
} catch (RuntimeException e) {
return null;
}
})
.registerTypeAdapter(
String.class,
new JsonDeserializer<String>() {
@Override
public String deserialize(
JsonElement json,
Type type,
JsonDeserializationContext jsonDeserializationContext
) throws JsonParseException {
return Jsoup.clean(json.getAsJsonPrimitive().getAsString(), Whitelist.none());
}
})
(JsonDeserializer<String>) (json, type, jsonDeserializationContext) ->
Jsoup.clean(json.getAsJsonPrimitive().getAsString(), Whitelist.none()))
.create();

public <T> T fromJson(String json, Class<T> t) throws JsonSyntaxException {
Expand All @@ -113,4 +76,8 @@ public <T> T fromJson(Reader reader, Class<T> t) {
public <T> T fromJson(Reader reader, Type type) {
return gson.fromJson(reader, type);
}

public <T> T fromJson(String json, Type type) {
return gson.fromJson(json, type);
}
}
Loading

0 comments on commit bba300a

Please sign in to comment.