Skip to content
This repository has been archived by the owner on Feb 14, 2023. It is now read-only.

Commit

Permalink
Checkstyle warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
drcgjung committed Nov 18, 2022
1 parent fec58df commit 56f4b47
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 39 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,5 @@ launchers/demo-e2e/edc-config.properties
.env
runtime_settings.properties
generated_backend.tf

bin/
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public void handleDeprovisionResult(String processId, List<StatusResult<Deprovis

private StatusResult<String> initiateRequest(TransferProcess.Type type, DataRequest dataRequest) {
// make the request idempotent: if the process exists, return
var processId = transferProcessStore.processIdForDataRequestId(dataRequest.getId(),type);
var processId = transferProcessStore.processIdForDataRequestId(dataRequest.getId(), type);
if (processId != null) {
return StatusResult.success(processId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public Result<EndpointDataReference> transform(@NotNull EndpointDataReference ed
}

private static DataAddress toHttpDataAddress(EndpointDataReference edr) {
DataAddress.Builder addressBuilder= HttpDataAddress.Builder.newInstance()
DataAddress.Builder addressBuilder = HttpDataAddress.Builder.newInstance()
.baseUrl(edr.getEndpoint())
.authKey(edr.getAuthKey())
.authCode(edr.getAuthCode())
Expand All @@ -90,7 +90,7 @@ private static DataAddress toHttpDataAddress(EndpointDataReference edr) {
var protocol = edr.getProperties().get(PROTOCOL_ID);
if (protocol != null) {
// set sub-protocol
addressBuilder=addressBuilder.type(protocol);
addressBuilder = addressBuilder.type(protocol);
}
return addressBuilder.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class HttpEndpointDataReferenceReceiverExtension implements ServiceExtens
@EdcSetting
private static final String HTTP_RECEIVER_AUTH_CODE = "edc.receiver.http.auth-code";

public static final String SPEC_SEPARATOR=",";
public static final String SPEC_SEPARATOR = ",";

@Inject
private EndpointDataReferenceReceiverRegistry receiverRegistry;
Expand All @@ -62,36 +62,36 @@ public void initialize(ServiceExtensionContext context) {
var authKey = context.getSetting(HTTP_RECEIVER_AUTH_KEY, null);
var authCode = context.getSetting(HTTP_RECEIVER_AUTH_CODE, null);

Monitor monitor= context.getMonitor();
Monitor monitor = context.getMonitor();

monitor.debug(String.format("Elaborating http endpoint receiver spec %s",endpoint));
monitor.debug(String.format("Elaborating http endpoint receiver spec %s", endpoint));

var endpoints=endpoint.split(",");
var authKeys= new String[0];
if(authKey!=null) {
authKeys=authKey.split(",");
var endpoints = endpoint.split(",");
var authKeys = new String[0];
if (authKey != null) {
authKeys = authKey.split(",");
}
var authCodes= new String[0];
if(authCode!=null) {
authCodes=authCode.split(",");
var authCodes = new String[0];
if (authCode != null) {
authCodes = authCode.split(",");
}

if(authKeys.length!=authCodes.length) {
throw new EdcException(String.format("Length of endpoints %d auth keys %d and auth codes %d do not match", endpoints.length,authKeys.length,authCodes.length));
if (authKeys.length != authCodes.length) {
throw new EdcException(String.format("Length of endpoints %d auth keys %d and auth codes %d do not match", endpoints.length, authKeys.length, authCodes.length));
}
if(authKeys.length<endpoints.length) {
monitor.warning(String.format("There are %d endpoints but only %d authorization infos. Omitting authorization for endpoints %d to %d.",endpoints.length,authKeys.length,authKeys.length+1,endpoints.length));
if (authKeys.length < endpoints.length) {
monitor.warning(String.format("There are %d endpoints but only %d authorization infos. Omitting authorization for endpoints %d to %d.", endpoints.length, authKeys.length, authKeys.length + 1, endpoints.length));
}
for(int count=0;count<endpoints.length;count++) {
monitor.debug(String.format("About to build and register new http endpoint receiver number %d for address %s",count,endpoints[count]));
String theEndpoint=endpoints[count];
String theKey="";
String theCode="";
if(authKeys.length>count) {
theKey=authKeys[count];
theCode=authCodes[count];
for (int count = 0; count < endpoints.length; count++) {
monitor.debug(String.format("About to build and register new http endpoint receiver number %d for address %s", count, endpoints[count]));
String theEndpoint = endpoints[count];
String theKey = "";
String theCode = "";
if (authKeys.length > count) {
theKey = authKeys[count];
theCode = authCodes[count];
}
var receiver = HttpEndpointDataReferenceReceiver.Builder.newInstance()
var receiver = HttpEndpointDataReferenceReceiver.Builder.newInstance()
.endpoint(theEndpoint)
.authHeader(theKey, theCode)
.httpClient(httpClient)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public TransferProcess find(String id) {
@Override
public @Nullable
String processIdForDataRequestId(String transferId, TransferProcess.Type type) {
var query = "SELECT * FROM t WHERE t.wrappedInstance.dataRequest.id = '" + transferId + "' AND t.wrappedInstance.type = '" +type.toString()+"'";
var query = "SELECT * FROM t WHERE t.wrappedInstance.dataRequest.id = '" + transferId + "' AND t.wrappedInstance.type = '" + type.toString() + "'";
var response = failsafeExecutor.get(() -> cosmosDbApi.queryItems(query));
return response
.map(this::convertToDocument)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ private Predicate<T> inPredicate(Criterion criterion) {
* implements a regex criterion
* by matching the string representation of
* a left hand operand against a regex pattern
*
* @param criterion representation
* @return regex predicate
*/
Expand All @@ -106,16 +107,16 @@ private Predicate<T> regexPredicate(Criterion criterion) {
Pattern pattern = null;

try {
if(rightOp instanceof java.util.regex.Pattern) {
pattern=(Pattern) rightOp;
if (rightOp instanceof java.util.regex.Pattern) {
pattern = (Pattern) rightOp;
} else if (rightOp instanceof String) {
pattern = Pattern.compile((String) rightOp);
}
if(pattern!=null) {
if (pattern != null) {
return pattern.matcher(String.valueOf(property)).matches();
}
} catch(PatternSyntaxException e) {
throw new IllegalArgumentException("Operator ~ the right-hand operand %s is not a valid regular expression." + rightOp.getClass().getName(),e);
} catch (PatternSyntaxException e) {
throw new IllegalArgumentException("Operator ~ the right-hand operand %s is not a valid regular expression." + rightOp.getClass().getName(), e);
}
throw new IllegalArgumentException("Operator ~ requires the right-hand operand to be a regular expression but was " + rightOp.getClass().getName());
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
Expand Down Expand Up @@ -119,22 +119,25 @@ public boolean equals(Object o) {
public Policy withTarget(String target) {
return Builder.newInstance()
.prohibitions(prohibitions.stream().flatMap(p -> {
if (p.getTarget() == null || Pattern.compile(p.getTarget()).matcher(target).matches())
if (p.getTarget() == null || Pattern.compile(p.getTarget()).matcher(target).matches()) {
return Stream.of(p.withTarget(target));
else
} else {
return Stream.empty();
}
}).collect(Collectors.toList()))
.permissions(permissions.stream().flatMap(p -> {
if (p.getTarget() == null || Pattern.compile(p.getTarget()).matcher(target).matches())
if (p.getTarget() == null || Pattern.compile(p.getTarget()).matcher(target).matches()) {
return Stream.of(p.withTarget(target));
else
} else {
return Stream.empty();
}
}).collect(Collectors.toList()))
.duties(obligations.stream().flatMap(o -> {
if (o.getTarget() == null || Pattern.compile(o.getTarget()).matcher(target).matches())
if (o.getTarget() == null || Pattern.compile(o.getTarget()).matcher(target).matches()) {
return Stream.of(o.withTarget(target));
else
} else {
return Stream.empty();
}
}).collect(Collectors.toList()))
.assigner(assigner)
.assignee(assignee)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public final class ContractId {
/**
* Returns a UUID that references the definition id and
* is based on an asset id
*
* @param definitionPart id of the contract definition
* @param assetPart id of the offered asset
* @return unique string
Expand Down

0 comments on commit 56f4b47

Please sign in to comment.