Skip to content

Commit

Permalink
Merge branch 'release/1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Plow74 committed Mar 27, 2017
2 parents b0936de + 4e1d8e5 commit 7e7f268
Show file tree
Hide file tree
Showing 83 changed files with 42,198 additions and 504 deletions.
444 changes: 247 additions & 197 deletions pom.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package gov.onc.xdrtesttool.controllers;

import gov.onc.xdrtesttool.entities.MessageLog;
import gov.onc.xdrtesttool.services.MessageLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
* Created by Brian on 3/9/2017.
*/
@RestController
public class MessageLogController {
private MessageLogService messageLogService;

@Autowired
public MessageLogController(MessageLogService messageLogService) {
this.messageLogService = messageLogService;
}

@RequestMapping(value = "/getlogsbyfromaddress", method = RequestMethod.GET)
public List<MessageLog> getLogsByFromAddress(@RequestParam(value = "fromAddress") String fromAddress){
return messageLogService.getLogsByFromAddress(fromAddress);
}

@RequestMapping(value = "/getlogsbyipaddress", method = RequestMethod.GET)
public List<MessageLog> getLogsByIpAddress(@RequestParam(value = "ipAddress") String ipAddress){
return messageLogService.getLogsByIpAddress(ipAddress);
}
}
85 changes: 85 additions & 0 deletions src/main/java/gov/onc/xdrtesttool/entities/MessageLog.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package gov.onc.xdrtesttool.entities;

import javax.persistence.*;
import java.util.Date;

/**
* Created by Brian on 3/9/2017.
*/
@Entity
@Table(name = "MESSAGELOG")
public class MessageLog {
@Id
@Column(name = "ID")
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
@Column(name = "REQUEST", columnDefinition = "CLOB")
private String request;
@Column(name = "RESPONSE", columnDefinition = "CLOB")
private String response;
@Column(name = "IP_ADDRESS")
private String ipAddress;
@Column(name = "FROM_ADDRESS")
private String fromAddress;
@Column(name = "DATE_LOGGED")
private String dateLogged;
@Version
@Column(name = "CREATED")
private Date created;

public String getIpAddress() {
return ipAddress;
}

public void setIpAddress(String ipAddress) {
this.ipAddress = ipAddress;
}

public String getFromAddress() {
return fromAddress;
}

public void setFromAddress(String fromAddress) {
this.fromAddress = fromAddress;
}

public long getId() {
return id;
}

public void setId(long id) {
this.id = id;
}

public String getRequest() {
return request;
}

public void setRequest(String request) {
this.request = request;
}

public String getResponse() {
return response;
}

public void setResponse(String response) {
this.response = response;
}

public String getDateLogged() {
return dateLogged.toString();
}

public void setDateLogged(String dateLogged) {
this.dateLogged = dateLogged;
}

public Date getCreated() {
return created;
}

public void setCreated(Date created) {
this.created = created;
}
}
18 changes: 9 additions & 9 deletions src/main/java/gov/onc/xdrtesttool/error/MessageReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,20 @@ public StringSource buildResponse(){
}

if(errorFlag)
sb.append(" status=\"urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Failure\"> ");
sb.append(" status=\"urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Failure\">\r\n ");
else if(warningFlag)
sb.append(" status=\"urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:PartialSuccess\"> ");
sb.append(" status=\"urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:PartialSuccess\">\r\n ");
else
sb.append(" status=\"urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Success\"> ");
sb.append(" status=\"urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Success\">\r\n ");

if(errorStr.length() > 0)
{
sb.append("<rs:RegistryErrorList>");
sb.append(errorStr.toString());
sb.append("</rs:RegistryErrorList>");
sb.append("<rs:RegistryErrorList>\r\n");
sb.append(errorStr.toString() + "\r\n");
sb.append("</rs:RegistryErrorList>\r\n");
}
sb.append("</rs:RegistryResponse>");
return new StringSource(sb.toString());
sb.append("</rs:RegistryResponse>\r\n");
return new StringSource(sb.toString() + "\r\n");
}

private String buildRegistryError(MessageRecorderItem item)
Expand All @@ -88,7 +88,7 @@ else if(item.getMessageType().equals(MessageType.Info))
str.append(" errorCode=\"" + item.getErrorCode() +"\"");
str.append(" codeContext=\"" + StringEscapeUtils.escapeXml(XDRMessages.instance.getErrorText(item.getErrorCode())) +"\"");
str.append(" location=\"" + item.getLocation() +"\"");
str.append(" />");
str.append(" />\r\n");
return str.toString();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package gov.onc.xdrtesttool.repositories;

import gov.onc.xdrtesttool.entities.MessageLog;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
* Created by Brian on 3/9/2017.
*/
@Repository
public interface MessageLogRepository extends JpaRepository<MessageLog, Long>{
List<MessageLog>findByIpAddressOrderByCreatedDesc(String ipAddress);
List<MessageLog>findByFromAddressOrderByCreatedDesc(String fromAddress);
}
34 changes: 34 additions & 0 deletions src/main/java/gov/onc/xdrtesttool/services/MessageLogService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package gov.onc.xdrtesttool.services;

import gov.onc.xdrtesttool.entities.MessageLog;
import gov.onc.xdrtesttool.repositories.MessageLogRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* Created by Brian on 3/9/2017.
*/
@Service
public class MessageLogService {
private MessageLogRepository messageLogRepository;

@Autowired
public MessageLogService(MessageLogRepository messageLogRepository) {
this.messageLogRepository = messageLogRepository;
}

public MessageLog saveLog(MessageLog messageLog){
return messageLogRepository.save(messageLog);
}

public List<MessageLog> getLogsByFromAddress(String fromAddress){
return messageLogRepository.findByFromAddressOrderByCreatedDesc(fromAddress);
}

public List<MessageLog> getLogsByIpAddress(String ipAddress) {
return messageLogRepository.findByIpAddressOrderByCreatedDesc(ipAddress);
}

}
Loading

0 comments on commit 7e7f268

Please sign in to comment.