From 5506e9362a34bd0c3bdf01a67498e9b8b36eee1c Mon Sep 17 00:00:00 2001 From: Brad Gonzales Date: Mon, 31 Mar 2014 11:45:22 -0500 Subject: [PATCH] Issue #2937 Separate room logging into a subdirectory to separate room logs from other logging. Updated abstract_setup.xml to check the javaUtilities baseline directory and the cots directory for dependency jars so that symbolic links are not needed in order to build. Fixes for Archive log access and search. Change-Id: I7ca111cebb4dae998ce1390f3bb73b0f48eb7174 Former-commit-id: d4659c48a6851cd0f29d2ac480cabf26c63c6e3e [formerly 404faeeca051f6cbc54f38a31385c9fc98fa8fb3] [formerly d4659c48a6851cd0f29d2ac480cabf26c63c6e3e [formerly 404faeeca051f6cbc54f38a31385c9fc98fa8fb3] [formerly 15e1b7a7f66145925209beceb6b66840ca7bb58d [formerly 480c86e5bbe6866b8c4c285006d3d7f7fed2b056]]] Former-commit-id: 15e1b7a7f66145925209beceb6b66840ca7bb58d Former-commit-id: 1c685a9eb69ab1144625055bce1da94e8cb1769a [formerly 2f56fd3c9d910fa788aec79c1469dcd043219c04] Former-commit-id: 4940c40a7f207b113a79a4009962f84318580d8c --- .../ui/actions/ArchiveViewerAction.java | 5 +- .../ui/session/SearchComposite.java | 7 ++- .../ant/abstract/abstract_setup.xml | 23 +++++++-- .../collaboration.dataserver/build.xml | 2 +- .../DetailedFeedLogPlugin.java | 47 +++++++++++++++---- 5 files changed, 63 insertions(+), 21 deletions(-) diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/ArchiveViewerAction.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/ArchiveViewerAction.java index 0d49f8904a..d8b7bb3b8a 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/ArchiveViewerAction.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/actions/ArchiveViewerAction.java @@ -43,8 +43,9 @@ import com.raytheon.viz.ui.views.CaveWorkbenchPageManager; * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Jul 5, 2012 bsteffen Initial creation + * Jul 5, 2012 bsteffen Initial creation * Jan 28, 2014 2698 bclement changed sessionName to sessionId + * Mar 31, 2014 2937 bgonzale Use session name for log retrieval. * * * @@ -75,7 +76,7 @@ public class ArchiveViewerAction extends Action { public ArchiveViewerAction(IVenueSession session) { super("View Log...", IconUtil.getImageDescriptor(Activator.getDefault() .getBundle(), "log.gif")); - sessionId = session.getVenue().getId(); + sessionId = session.getVenue().getName(); } @Override diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SearchComposite.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SearchComposite.java index eeab32eb12..32aca872ca 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SearchComposite.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/session/SearchComposite.java @@ -52,6 +52,8 @@ import org.eclipse.swt.widgets.Text; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * May 31, 2012 bgonzale Initial creation + * Mar 31, 2014 2937 bgonzale Fix error where text was continually appended + * during search. * * * @@ -422,10 +424,7 @@ public class SearchComposite extends Composite { * the text to set */ private void setText(String text) { - if (this.text == null) { - this.text = new StringBuilder(); - } - this.text.append(text); + this.text = new StringBuilder(text); } /** diff --git a/javaUtilities/build.openfire.plugin/ant/abstract/abstract_setup.xml b/javaUtilities/build.openfire.plugin/ant/abstract/abstract_setup.xml index 3640629186..e355a015aa 100644 --- a/javaUtilities/build.openfire.plugin/ant/abstract/abstract_setup.xml +++ b/javaUtilities/build.openfire.plugin/ant/abstract/abstract_setup.xml @@ -76,11 +76,24 @@ --> - - - - - + + + + + + + + + + + + + + + + + + diff --git a/javaUtilities/collaboration.dataserver/build.xml b/javaUtilities/collaboration.dataserver/build.xml index 31bc9093f1..8987ec8147 100644 --- a/javaUtilities/collaboration.dataserver/build.xml +++ b/javaUtilities/collaboration.dataserver/build.xml @@ -7,7 +7,7 @@ - + diff --git a/javaUtilities/com.raytheon.openfire.plugin.detailedfeedlog/java/com/raytheon/openfire/plugin/detailedfeedlog/DetailedFeedLogPlugin.java b/javaUtilities/com.raytheon.openfire.plugin.detailedfeedlog/java/com/raytheon/openfire/plugin/detailedfeedlog/DetailedFeedLogPlugin.java index 5da4a23d8d..dbdff52b5e 100644 --- a/javaUtilities/com.raytheon.openfire.plugin.detailedfeedlog/java/com/raytheon/openfire/plugin/detailedfeedlog/DetailedFeedLogPlugin.java +++ b/javaUtilities/com.raytheon.openfire.plugin.detailedfeedlog/java/com/raytheon/openfire/plugin/detailedfeedlog/DetailedFeedLogPlugin.java @@ -25,6 +25,7 @@ import java.io.FileNotFoundException; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; +import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; @@ -64,7 +65,11 @@ import com.raytheon.openfire.plugin.detailedfeedlog.listener.DetailedFeedLogEven * * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Jul 23, 2012 mnash Initial creation + * Jul 23, 2012 mnash Initial creation + * Mar 31, 2014 2937 bgonzale Separate room logging from other logging + * in a 'Rooms' subdirectory so that readLogInfo() + * only parses room logs. Add finally block to close + * the buffered readers. * * * @@ -110,9 +115,13 @@ public class DetailedFeedLogPlugin implements Plugin, PropertyEventListener { public static final String SITE_INFO = "Site"; - private SimpleDateFormat dateFormat = new SimpleDateFormat( + private static final String ROOM_DIR = "Rooms"; + + private DateFormat dateFormat = new SimpleDateFormat( "MM/dd/yyyy h:mm a"); + private File ROOM_LOG_DIR; + /* * (non-Javadoc) * @@ -127,6 +136,16 @@ public class DetailedFeedLogPlugin implements Plugin, PropertyEventListener { entries = new HashMap>(); + // log dir for rooms + String logDirName = Log.getLogDirectory() + ROOM_DIR; + File logDir = new File(logDirName); + try { + logDir.mkdir(); + } catch (SecurityException e) { + logger.error("Failed to create Room log directory.", e); + } + ROOM_LOG_DIR = logDir; + // read the log in from the file readLogInfo(); @@ -163,15 +182,14 @@ public class DetailedFeedLogPlugin implements Plugin, PropertyEventListener { } private void readLogInfo() { - Log.getLogDirectory(); - File logDir = new File(Log.getLogDirectory()); - File[] files = logDir.listFiles(); + File[] files = ROOM_LOG_DIR.listFiles(); for (File file : files) { + BufferedReader bReader = null; try { logger.info("Reading " + file.getName()); FileReader reader = new FileReader(file); - BufferedReader bReader = new BufferedReader(reader); + bReader = new BufferedReader(reader); while (bReader.ready()) { String line = bReader.readLine(); String[] splitLine = line.split("\\|"); @@ -193,6 +211,17 @@ public class DetailedFeedLogPlugin implements Plugin, PropertyEventListener { logger.error("Unable to parse date", e); } catch (ArrayIndexOutOfBoundsException e) { logger.info("Unable to read " + file.getName(), e); + } finally { + if (bReader != null) { + try { + bReader.close(); + } catch (IOException e) { + StringBuilder sb = new StringBuilder( + "Failed to close log file: ").append(file + .getAbsolutePath()); + logger.error(sb.toString(), e); + } + } } } } @@ -208,7 +237,8 @@ public class DetailedFeedLogPlugin implements Plugin, PropertyEventListener { user = UserManager.getInstance().getUser( message.getFrom().getResource()); } catch (UserNotFoundException e) { - logger.error("Unable to get user", e); + logger.error("Unable to get user for Room: " + room + + " and Message: " + message.toXML(), e); } String site = getSiteFromPresence(user); @@ -285,12 +315,11 @@ public class DetailedFeedLogPlugin implements Plugin, PropertyEventListener { * Write out the current in memory log to a file */ private void writeToFile() { - String logDir = Log.getLogDirectory(); try { // writes out each log file for each room, all active and permanent, // and for rooms that the purge has not removed all logs yet for (String room : entries.keySet()) { - File file = new File(logDir + room + ".log"); + File file = new File(ROOM_LOG_DIR, room + ".log"); FileWriter writer = new FileWriter(file); for (LogEntry entry : entries.get(room)) {