Skip to content

Commit

Permalink
Merge pull request #13 from chrismills/master
Browse files Browse the repository at this point in the history
Issue #7 and Jersey lib fix (to track the jersey jars)
  • Loading branch information
js1972 committed May 26, 2014
2 parents 9674527 + 170eee3 commit 26a25b4
Show file tree
Hide file tree
Showing 26 changed files with 43 additions and 29 deletions.
2 changes: 2 additions & 0 deletions jaylin.com.au/z_jersey_lib/_comp/libraries/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#Override .gitignore at the root level and include JAR's in this folder. The whole DC's purpose is to be a collection of libraries so we want it tracked in source control
!*.jar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,18 @@ USERNAME = dummy_user
#% type = STRING;
PASSWORD = abcdefg

## Start date for first run of pimon. Messages are collected from this date. Only read is message cache is empty.
## Start date for first run of pimon. Messages are collected from this date. Only read if message cache is empty.
## Format: dd/mm/yyyy
#? onlinemodifiable = true
#% type = STRING
START_DATE = 01/01/2014
BASE_DATE = 01/01/2014

## Maximum number of messages to read from PI on each update
#? onlinemodifiable = true
#% type = STRING
MAX_RESULTS = 5000
#% type = LONG
MESSAGE_MAX_RESULTS = 5000

## Maximum number of log entries to retrieve for each message
#? onlinemodifiable = true
#% type = LONG
LOG_ENTRY_MAX_RESULTS = 1000
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,19 @@ public class ApplicationProperties implements ApplicationPropertiesLocal {
private static final String HOST_URL = "HOST_URL";
private static final String USERNAME = "USERNAME";
private static final String PASSWORD = "PASSWORD";
private static final String START_DATE = "START_DATE";
private static final String MAX_RESULTS = "MAX_RESULTS";
private static final String BASE_DATE = "BASE_DATE";
private static final String MESSAGE_MAX_RESULTS = "MESSAGE_MAX_RESULTS";
private static final String LOG_ENTRY_MAX_RESULTS = "LOG_ENTRY_MAX_RESULTS";

private Location logger = Location.getLocation("pimon.application.properties");
private String hostUrl;
private String username;
private String password;
private String startDate;
private String maxResults;
private String baseDate;
private String messageMaxResults;
private String logEntryMaxResults;

public ApplicationProperties() {
logger.infoT("Creating the logger");
try {
InitialContext ctx = new InitialContext();
ApplicationPropertiesAccess appConfigAccess = (ApplicationPropertiesAccess) ctx.lookup("ApplicationConfiguration");
Expand All @@ -51,8 +52,9 @@ public ApplicationProperties() {
hostUrl = appProps.getProperty(HOST_URL);
username = appProps.getProperty(USERNAME);
password = appProps.getProperty(PASSWORD);
startDate = appProps.getProperty(START_DATE);
maxResults = appProps.getProperty(MAX_RESULTS);
baseDate = appProps.getProperty(BASE_DATE);
messageMaxResults = appProps.getProperty(MESSAGE_MAX_RESULTS);
logEntryMaxResults = appProps.getProperty(LOG_ENTRY_MAX_RESULTS);
}
catch (Exception e) {
logger.errorT("EXCEPTION: " + e.getMessage());
Expand Down Expand Up @@ -98,19 +100,23 @@ public String getPassword() {
return password;
}

public Date getStartDate() {
public Date getBaseDate() {
Date d = null;

try {
d = new SimpleDateFormat("dd/MM/yyyy", Locale.ENGLISH).parse(startDate);
d = new SimpleDateFormat("dd/MM/yyyy", Locale.ENGLISH).parse(baseDate);
} catch (ParseException e) {
throw new RuntimeException("ApplicationProperties exception: Unable to parse start_date: " + startDate);
throw new RuntimeException("ApplicationProperties exception: Unable to parse start_date: " + baseDate);
};

return d;
}

public int getMaxResults() {
return Integer.parseInt(maxResults);
public int getMessageMaxResults() {
return Integer.parseInt(messageMaxResults);
}

public int getLogEntryMaxResults() {
return Integer.parseInt(logEntryMaxResults);
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
package au.com.jaylin.persistence.ejbs;
import java.util.Date;

import javax.ejb.Local;

@Local
public interface ApplicationPropertiesLocal {
public String getHostUrl();
public String getUsername();
public String getPassword();
public int getMessageMaxResults();
public Date getBaseDate();
public int getLogEntryMaxResults();
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,12 @@ class MessageDetails {
*/
@Stateless
public class PIMessageHandler implements PIMessageHandlerLocal {
private static final int GET_LOG_ENTRIES_MAX_RESULTS = 1000;
private static final int GET_MESSAGES_MAX_RESULTS = 5000;

@EJB
private PIMessageFacadeLocal piMessageFacade;
@EJB
ApplicationPropertiesLocal properties;
@EJB
ApplicationPropertiesLocal appProperties;
@EJB
WebServiceEndPointLocal ws;

private AdapterFilter filter;
Expand Down Expand Up @@ -91,15 +89,15 @@ public OperationStatus readPIDataAndCache() {
List<AdapterFrameworkData> messages = callWSAndGetMessageList();
groupAndStoreMessages(messages);

// *** ADD ERROR MANAGEMENT HERE ***
//TODO *** ADD ERROR MANAGEMENT HERE ***
status.status = "success";
return status;
}

private List<AdapterFrameworkData> callWSAndGetMessageList() {
MessageSearchReturnValue result = null;
try {
result = ws.call().getMessageList(filter, GET_MESSAGES_MAX_RESULTS);
result = ws.call().getMessageList(filter, appProperties.getMessageMaxResults());
}
catch (Exception e) {
logger.errorT("PIMessageHandler.callWSAndGetMessageList() -> getMessageList() WS call failed: " + e.getMessage());
Expand Down Expand Up @@ -128,7 +126,7 @@ public List<LogEntry> readMessageLogByMsgId(String msgId) {
List<PIMessage> messages = piMessageFacade.findPIMonMsgsById(msgId);
PIMessage message = messages.get(0);

auditLogEntryDataArray = ws.call().getLogEntries(message.getMessage_key(), false, GET_LOG_ENTRIES_MAX_RESULTS, null, null);
auditLogEntryDataArray = ws.call().getLogEntries(message.getMessage_key(), false, appProperties.getLogEntryMaxResults(), null, null);
}
catch (IndexOutOfBoundsException ioob) {
logger.errorT("Failed to read message in readMessageLogByMsgId(): '" + msgId + "'; Exception: " + ioob.getMessage());
Expand Down Expand Up @@ -164,7 +162,7 @@ public OperationStatus cancelIndividualMessageByMsgId(String msgId) {
results = ws.call().cancelMessages(messageKeys);
}
catch (Exception e) {
//what goes here?!?
//TODO what goes here?!?
throw new RuntimeException("*** HOLY SHIT *** FAILED TO CANCEL MSG LOG FOR MSGKEY: " + message.getMessage_key() + " --- " + e.getMessage() + " --- " + e.getClass());
}

Expand Down Expand Up @@ -201,7 +199,7 @@ public OperationStatus resendIndividualMessageByMsgId(String msgId) {
results = ws.call().resendMessages(messageKeys);
}
catch (Exception e) {
//what goes here?!?
//TODO what goes here?!?
throw new RuntimeException("*** HOLY SHIT *** FAILED TO RE-SEND MSG LOG FOR MSGKEY: " + message.getMessage_key() + " --- " + e.getMessage() + " --- " + e.getClass());
}

Expand Down Expand Up @@ -235,10 +233,8 @@ public OperationStatus resendIndividualMessageByMsgId(String msgId) {
private void setupWSFilterParams() {
Date d = piMessageFacade.getPIMonMsgsLatestEndTime();
if (d == null) {
// set a start time-stamp (one-off for when data table is empty)
Calendar cal = Calendar.getInstance();
cal.set(PITimeStamp.INITIAL_START_YEAR, PITimeStamp.INITIAL_START_MONTH, PITimeStamp.INITIAL_START_DAY, 0, 0, 0);
d = cal.getTime();
logger.infoT(String.format("No previous messages found, using default base date: %s to find messages from", appProperties.getBaseDate().toString()));
d = appProperties.getBaseDate();
}

filter.setFromTime(new PITimeStamp().getXMLTimeStampWithSlidingWindow(d, PITimeStamp.TimeStampType.from));
Expand Down

0 comments on commit 26a25b4

Please sign in to comment.