Dozer mapping to map between credential entity and resources
diff --git a/credential-store/credential-api/pom.xml b/credential-store/credential-api/pom.xml
index 024f783..817ef74 100644
--- a/credential-store/credential-api/pom.xml
+++ b/credential-store/credential-api/pom.xml
@@ -19,7 +19,13 @@
<dependency>
<groupId>net.sf.dozer</groupId>
<artifactId>dozer</artifactId>
- <version>5.5.1</version>
+ <version>5.4.0</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.apache.airavata.custos</groupId>
diff --git a/credential-store/credential-api/src/main/java/org/apache/custos/credential/api/controllers/SSHCredentialsController.java b/credential-store/credential-api/src/main/java/org/apache/custos/credential/api/controllers/SSHCredentialsController.java
index e78a489..b949526 100644
--- a/credential-store/credential-api/src/main/java/org/apache/custos/credential/api/controllers/SSHCredentialsController.java
+++ b/credential-store/credential-api/src/main/java/org/apache/custos/credential/api/controllers/SSHCredentialsController.java
@@ -3,10 +3,11 @@
import org.apache.airavata.custos.credentials.ssh.SSHCredentialEntity;
import org.apache.airavata.custos.vault.VaultManager;
import org.apache.custos.credential.api.resources.SSHCredential;
+import org.dozer.DozerBeanMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@RestController
@@ -15,14 +16,11 @@
@Autowired
private VaultManager vaultManager;
+ final private DozerBeanMapper mapper = new DozerBeanMapper();
- @RequestMapping("/ssh/{gateway}/{token}")
+ @RequestMapping(value = "/ssh/{gateway}/{token}", method = RequestMethod.GET)
public SSHCredential getSSHCredential(@PathVariable("gateway") String gateway, @PathVariable("token") String token) throws Exception {
SSHCredentialEntity credentialEntity = vaultManager.getCredentialEntity(SSHCredentialEntity.class, token, gateway);
- SSHCredential resource = new SSHCredential();
- resource.setPassphrase(credentialEntity.getPassphrase());
- resource.setPrivateKey(credentialEntity.getPrivateKey());
- resource.setPublicKey(credentialEntity.getPublicKey());
- return resource;
+ return mapper.map(credentialEntity, SSHCredential.class);
}
}