tmf/lttng: Update 2014 copyrights
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.ust.core / src / org / eclipse / linuxtools / lttng2 / ust / core / trace / LttngUstTrace.java
index fd87ac97309471a864a855ac99a2d8b27e67216b..9547717a25f0ae49fec434536363e74cefedba5f 100644 (file)
@@ -1,5 +1,5 @@
 /**********************************************************************
- * Copyright (c) 2013 Ericsson
+ * Copyright (c) 2013, 2014 Ericsson
  *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
@@ -9,11 +9,12 @@
  * Contributors:
  *   Matthew Khouzam - Initial API and implementation
  *   Alexandre Montplaisir - Add UST callstack state system
+ *   Marc-Andre Laperle - Handle BufferOverflowException (Bug 420203)
  **********************************************************************/
 
 package org.eclipse.linuxtools.lttng2.ust.core.trace;
 
-import java.io.File;
+import java.nio.BufferOverflowException;
 
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.runtime.IStatus;
@@ -21,14 +22,8 @@ import org.eclipse.core.runtime.Status;
 import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
 import org.eclipse.linuxtools.ctf.core.trace.CTFTrace;
 import org.eclipse.linuxtools.internal.lttng2.ust.core.Activator;
-import org.eclipse.linuxtools.internal.lttng2.ust.core.trace.callstack.LttngUstCallStackProvider;
-import org.eclipse.linuxtools.tmf.core.callstack.CallStackStateProvider;
 import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace;
-import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
-import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateProvider;
-import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateSystem;
-import org.eclipse.linuxtools.tmf.core.statesystem.TmfStateSystemFactory;
-import org.eclipse.linuxtools.tmf.core.trace.TmfTraceManager;
+import org.eclipse.linuxtools.tmf.core.trace.TraceValidationStatus;
 
 /**
  * Class to contain LTTng-UST traces
@@ -38,8 +33,7 @@ import org.eclipse.linuxtools.tmf.core.trace.TmfTraceManager;
  */
 public class LttngUstTrace extends CtfTmfTrace {
 
-    /** Name of the history file for the callstack state system */
-    private static final String CALLSTACK_FILENAME = "ust-callstack.ht"; //$NON-NLS-1$
+    private static final int CONFIDENCE = 100;
 
     /**
      * Default constructor
@@ -48,6 +42,12 @@ public class LttngUstTrace extends CtfTmfTrace {
         super();
     }
 
+    /**
+     * {@inheritDoc}
+     * <p>
+     * This implementation sets the confidence to 100 if the trace is a valid
+     * CTF trace in the "ust" domain.
+     */
     @Override
     public IStatus validate(final IProject project, final String path)  {
         CTFTrace temp;
@@ -56,10 +56,13 @@ public class LttngUstTrace extends CtfTmfTrace {
         try {
             temp = new CTFTrace(path);
         } catch (CTFReaderException e) {
-            status = new Status(IStatus.ERROR,  Activator.PLUGIN_ID, e.toString(), e);
+            status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.toString(), e);
+            return status;
+        } catch (NullPointerException e) {
+            status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.toString(), e);
             return status;
-        } catch (NullPointerException e){
-            status = new Status(IStatus.ERROR,  Activator.PLUGIN_ID, e.toString(), e);
+        } catch (final BufferOverflowException e) {
+            status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.LttngUstTrace_TraceReadError + ": " + Messages.LttngUstTrace_MalformedTrace); //$NON-NLS-1$
             return status;
         }
 
@@ -67,31 +70,9 @@ public class LttngUstTrace extends CtfTmfTrace {
         String dom = temp.getEnvironment().get("domain"); //$NON-NLS-1$
         temp.dispose();
         if (dom != null && dom.equals("\"ust\"")) { //$NON-NLS-1$
-            return Status.OK_STATUS;
+            return new TraceValidationStatus(CONFIDENCE, Activator.PLUGIN_ID);
         }
         status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.LttngUstTrace_DomainError);
         return status;
     }
-
-    @Override
-    public IStatus buildStateSystem() {
-        super.buildStateSystem();
-
-        /*
-         * Build the state system for the UST Callstack (will be empty if the
-         * required events are not present).
-         */
-        String directory = TmfTraceManager.getSupplementaryFileDir(this);
-        final File htFile = new File(directory + CALLSTACK_FILENAME);
-        ITmfStateProvider csInput = new LttngUstCallStackProvider(this);
-
-        try {
-            ITmfStateSystem ss = TmfStateSystemFactory.newFullHistory(htFile, csInput, false);
-            registerStateSystem(CallStackStateProvider.ID, ss);
-        }  catch (TmfTraceException e) {
-            return new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e);
-        }
-
-        return Status.OK_STATUS;
-    }
 }
This page took 0.026645 seconds and 5 git commands to generate.