Skip to content

Commit

Permalink
Create wallet API skeleton for review ref: eclipse-tractusx#1
Browse files Browse the repository at this point in the history
  • Loading branch information
nitin-vavdiya committed May 17, 2023
1 parent d238a8f commit e1345f7
Show file tree
Hide file tree
Showing 16 changed files with 585 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .idea/copyright/Eclipse_Foundation.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/copyright/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 33 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
plugins {
id 'java'
id 'org.springframework.boot' version '3.0.6'
id 'io.spring.dependency-management' version '1.1.0'
id 'org.springframework.boot' version "${springBootVersion}"
id 'io.spring.dependency-management' version "${springDependencyVersion}"
id "jacoco"
}

group = 'org.eclipse.tractusx'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '17'
group = "${groupName}"
version = "${applicationVersion}"
sourceCompatibility = JavaVersion.VERSION_17

configurations {
compileOnly {
Expand All @@ -19,7 +20,7 @@ repositories {
}

ext {
set('springCloudVersion', "2022.0.2")

}

dependencies {
Expand All @@ -29,19 +30,45 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.cloud:spring-cloud-starter-openfeign'
implementation 'org.liquibase:liquibase-core'
//implementation 'org.eclipse.tractusx.ssi:cx-ssi-lib:0.0.3'
runtimeOnly 'org.postgresql:postgresql'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation "org.testcontainers:testcontainers"
testImplementation "org.testcontainers:postgresql"
testImplementation "org.testcontainers:junit-jupiter"

}

dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
mavenBom("org.testcontainers:testcontainers-bom:${testContainerVersion}")
}
}

tasks.named('test') {
useJUnitPlatform()
}

test {
finalizedBy jacocoTestReport
}

jacocoTestReport {
dependsOn test
}

jacoco {
toolVersion = "${jacocoVersion}"
}

jacocoTestReport {
reports {
xml.required = false
csv.required = false
html.required = true
}
}
7 changes: 7 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
springCloudVersion=2022.0.2
testContainerVersion=1.18.0
jacocoVersion=0.8.8
springBootVersion=3.0.6
springDependencyVersion=1.1.0
groupName=org.eclipse.tractusx
applicationVersion=0.0.1-SNAPSHOT
Original file line number Diff line number Diff line change
@@ -1,11 +1,40 @@
/*
* *******************************************************************************
* Copyright (c) 2021,2023 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.managedidentitywallets;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
* The type Managed identity wallets application.
*/
@SpringBootApplication
public class ManagedIdentityWalletsApplication {

/**
* The entry point of application.
*
* @param args the input arguments
*/
public static void main(String[] args) {
SpringApplication.run(ManagedIdentityWalletsApplication.class, args);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Copyright (c) 2023 | smartSense
*/

package org.eclipse.tractusx.managedidentitywallets.config;

import org.springframework.web.bind.annotation.RestControllerAdvice;


/**
* The type Rest exception handler.
*/
@RestControllerAdvice
public class RestExceptionHandler {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* *******************************************************************************
* Copyright (c) 2021,2023 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.managedidentitywallets.constant;

/**
* The type Rest uri.
*/
public class RestURI {

/**
* The constant WALLET.
*/
public static final String WALLET = "/wallet";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* *******************************************************************************
* Copyright (c) 2021,2023 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.managedidentitywallets.controller;

import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.eclipse.tractusx.managedidentitywallets.constant.RestURI;
import org.eclipse.tractusx.managedidentitywallets.dao.entity.Wallet;
import org.eclipse.tractusx.managedidentitywallets.dto.CreateWalletRequest;
import org.eclipse.tractusx.managedidentitywallets.service.WalletService;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
* The type Wallet controller.
*/
@RestController
@RequiredArgsConstructor
public class WalletController {

private final WalletService service;

/**
* Create wallet response entity.
*
* @param request the request
* @return the response entity
*/
@PostMapping(path = RestURI.WALLET, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Wallet> createWallet(@Valid @RequestBody CreateWalletRequest request){
return ResponseEntity.status(HttpStatus.CREATED).body(service.createWallet(request));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* *******************************************************************************
* Copyright (c) 2021,2023 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.managedidentitywallets.dao.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.Column;
import jakarta.persistence.MappedSuperclass;
import jakarta.persistence.Temporal;
import jakarta.persistence.TemporalType;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import java.util.Date;

/**
* The type Base entity.
*/
@MappedSuperclass
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class BaseEntity {

@JsonIgnore
@CreationTimestamp
@Temporal(value = TemporalType.TIMESTAMP)
@Column(nullable = false)
private Date createdAt;

@JsonIgnore
@UpdateTimestamp
@Temporal(value = TemporalType.TIMESTAMP)
private Date modifiedAt;

@JsonIgnore
private String modifiedFrom;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* *******************************************************************************
* Copyright (c) 2021,2023 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.managedidentitywallets.dao.entity;


import jakarta.persistence.*;
import lombok.*;

/**
* The type Wallet.
*/
@Getter
@Setter
@Entity
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class Wallet extends BaseEntity{

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", columnDefinition = "serial", nullable = false, unique = true)
private Long id;

@Column(nullable = false, unique = true)
private String did;

@Column(nullable = false, unique = true)
private String bpn;

@Column(nullable = false)
private String algorithm;

@Column(nullable = false)
private Boolean active;

@Column(nullable = false)
private Boolean authority;

@Column(nullable = false)
private String didDocument;

}
Loading

0 comments on commit e1345f7

Please sign in to comment.