Commit | Line | Data |
---|---|---|
91fc3690 AM |
1 | /********************************************************************** |
2 | * Copyright (c) 2013 Ericsson | |
3 | * | |
4 | * All rights reserved. This program and the accompanying materials are | |
5 | * made available under the terms of the Eclipse Public License v1.0 which | |
6 | * accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
8 | * | |
9 | * Contributors: | |
10 | * Matthew Khouzam - Initial API and implementation | |
11 | **********************************************************************/ | |
12 | ||
13 | package org.eclipse.linuxtools.lttng2.ust.core.trace; | |
14 | ||
15 | import org.eclipse.core.resources.IProject; | |
16 | import org.eclipse.core.runtime.IStatus; | |
17 | import org.eclipse.core.runtime.Status; | |
18 | import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException; | |
19 | import org.eclipse.linuxtools.ctf.core.trace.CTFTrace; | |
20 | import org.eclipse.linuxtools.internal.lttng2.ust.core.Activator; | |
21 | import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace; | |
22 | ||
23 | /** | |
24 | * Class to contain LTTng-UST traces | |
25 | * | |
26 | * @author Matthew Khouzam | |
27 | * @since 2.1 | |
28 | */ | |
29 | public class LttngUstTrace extends CtfTmfTrace { | |
30 | ||
31 | /** | |
32 | * Default constructor | |
33 | */ | |
34 | public LttngUstTrace() { | |
35 | super(); | |
36 | } | |
37 | ||
38 | @Override | |
39 | public IStatus validate(final IProject project, final String path) { | |
40 | CTFTrace temp; | |
41 | IStatus status; | |
42 | /* Make sure the trace is openable as a CTF trace. */ | |
43 | try { | |
44 | temp = new CTFTrace(path); | |
45 | } catch (CTFReaderException e) { | |
46 | status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.toString(), e); | |
47 | return status; | |
48 | } catch (NullPointerException e){ | |
49 | status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.toString(), e); | |
50 | return status; | |
51 | } | |
52 | ||
53 | /* Make sure the domain is "ust" in the trace's env vars */ | |
54 | String dom = temp.getEnvironment().get("domain"); //$NON-NLS-1$ | |
55 | temp.dispose(); | |
56 | if (dom != null && dom.equals("\"ust\"")) { //$NON-NLS-1$ | |
57 | return Status.OK_STATUS; | |
58 | } | |
59 | status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.LttngUstTrace_DomainError); | |
60 | return status; | |
61 | } | |
62 | } |