Skip to content

Commit

Permalink
feat(dsp-negotiation): implement spi module
Browse files Browse the repository at this point in the history
  • Loading branch information
juliapampus committed Apr 12, 2023
1 parent 116a591 commit a9005e6
Show file tree
Hide file tree
Showing 4 changed files with 157 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright (c) 2023 Fraunhofer Institute for Software and Systems Engineering
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* Fraunhofer Institute for Software and Systems Engineering - initial API and implementation
*
*/

package org.eclipse.edc.protocol.dsp.negotiation.spi;

public interface NegotiationApiPath {

String BASE_PATH = "/negotiations/";
String INITIAL_CONTRACT_REQUEST = "request";
String CONTRACT_REQUEST = "/request";
String CONTRACT_OFFER = "/offers";
String EVENT = "/events";
String AGREEMENT = "/agreement";
String VERIFICATION = "/verification";
String TERMINATION = "/termination";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright (c) 2023 Fraunhofer Institute for Software and Systems Engineering
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* Fraunhofer Institute for Software and Systems Engineering - initial API and implementation
*
*/

package org.eclipse.edc.protocol.dsp.negotiation.spi;

public interface NegotiationProperty {

String DELIMITER = ":";
String PROCESS_ID = "processId";
String EVENT_TYPE = "eventType";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
* Copyright (c) 2023 Fraunhofer Institute for Software and Systems Engineering
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* Fraunhofer Institute for Software and Systems Engineering - initial API and implementation
*
*/

package org.eclipse.edc.protocol.dsp.negotiation.spi.types;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;

import java.util.List;
import java.util.Objects;

@JsonTypeName("dspace:ContractNegotiationError")
@JsonDeserialize(builder = NegotiationError.Builder.class)
public class NegotiationError {

private String processId;

private String code;

private List<String> reasons; // TODO should be object?

@JsonProperty("dspace:processId")
public String getProcessId() {
return processId;
}

@JsonProperty("dspace:code")
public String getCode() {
return code;
}

@JsonProperty("dspace:reason")
public List<String> getReasons() {
return reasons;
}

@JsonPOJOBuilder(withPrefix = "")
public static class Builder {
private final NegotiationError error;

private Builder() {
error = new NegotiationError();
}

@JsonCreator
public static NegotiationError.Builder newInstance() {
return new NegotiationError.Builder();
}

public NegotiationError.Builder processId(String processId) {
error.processId = processId;
return this;
}

public NegotiationError.Builder code(String code) {
error.code = code;
return this;
}

public NegotiationError.Builder reasons(List<String> reasons) {
error.reasons = reasons;
return this;
}

public NegotiationError build() {
Objects.requireNonNull(error.processId, "The processId must be specified");
Objects.requireNonNull(error.code, "The code must be specified");

return error;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright (c) 2023 Fraunhofer Institute for Software and Systems Engineering
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* Fraunhofer Institute for Software and Systems Engineering - initial API and implementation
*
*/

package org.eclipse.edc.protocol.dsp.negotiation.spi.types;

public interface NegotiationEventType {

String ACCEPTED = "ACCEPTED";
String FINALIZED = "FINALIZED";

}

0 comments on commit a9005e6

Please sign in to comment.