-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(irs):[#249] changed return type of get all policies to match new…
… format
- Loading branch information
1 parent
7a8b34d
commit a72d875
Showing
6 changed files
with
169 additions
and
55 deletions.
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
31 changes: 31 additions & 0 deletions
31
irs-policy-store/src/main/java/org/eclipse/tractusx/irs/policystore/models/Context.java
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2022,2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) | ||
* Copyright (c) 2021,2024 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* 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. | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
********************************************************************************/ | ||
package org.eclipse.tractusx.irs.policystore.models; | ||
|
||
/** | ||
* Context representation for get all policies response | ||
*/ | ||
public record Context(String odrl) { | ||
private static final String ODRL_VALUE = "http://www.w3.org/ns/odrl/2/"; | ||
|
||
public static Context getDefault() { | ||
return new Context(ODRL_VALUE); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
irs-policy-store/src/main/java/org/eclipse/tractusx/irs/policystore/models/Payload.java
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2022,2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) | ||
* Copyright (c) 2021,2024 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* 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. | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
********************************************************************************/ | ||
package org.eclipse.tractusx.irs.policystore.models; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.Builder; | ||
import org.eclipse.tractusx.irs.edc.client.policy.Policy; | ||
|
||
/** | ||
* Payload representation for get all policies response | ||
*/ | ||
@Builder | ||
public record Payload( | ||
@JsonProperty("@context") Context context, | ||
@JsonProperty("@id") String policyId, | ||
Policy policy | ||
) { | ||
|
||
} |
43 changes: 43 additions & 0 deletions
43
...olicy-store/src/main/java/org/eclipse/tractusx/irs/policystore/models/PolicyResponse.java
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2022,2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) | ||
* Copyright (c) 2021,2024 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* 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. | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
********************************************************************************/ | ||
package org.eclipse.tractusx.irs.policystore.models; | ||
|
||
import java.time.OffsetDateTime; | ||
|
||
import lombok.Builder; | ||
import org.eclipse.tractusx.irs.edc.client.policy.Policy; | ||
|
||
/** | ||
* Policy representation for get all policies response | ||
*/ | ||
@Builder | ||
public record PolicyResponse(OffsetDateTime validUntil, Payload payload) { | ||
|
||
public static PolicyResponse fromPolicy(final Policy policy) { | ||
return PolicyResponse.builder() | ||
.validUntil(policy.getValidUntil()) | ||
.payload(Payload.builder() | ||
.policyId(policy.getPolicyId()) | ||
.context(Context.getDefault()) | ||
.policy(policy) | ||
.build()) | ||
.build(); | ||
} | ||
} |
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