Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 206499
Collapse All | Expand All

(-)src-symptom-handler/org/eclipse/tptp/monitoring/symptom/provisional/handler/util/messages.properties (+2 lines)
Lines 35-37 Link Here
35
_10040 = Validating contents of symptom catalog...
35
_10040 = Validating contents of symptom catalog...
36
_10090 = Successfully imported {0}
36
_10090 = Successfully imported {0}
37
_10100 = The symptom catalog {0} is being imported by another background job. Please choose another file name.
37
_10100 = The symptom catalog {0} is being imported by another background job. Please choose another file name.
38
39
_10200 = The specified symptom catalog file is not supported by the selected importer. Please make sure you select the correct importer.
(-)src-symptom-handler/org/eclipse/tptp/monitoring/symptom/provisional/models/util/SymptomLoader.java (-7 / +32 lines)
Lines 4-10 Link Here
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id
7
 * $Id$
8
 * 
8
 * 
9
 * Contributors: 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
10
 * IBM - Initial API and implementation
Lines 91-96 Link Here
91
    private long readBytes = 0;
91
    private long readBytes = 0;
92
    private int currentPercent = 0;
92
    private int currentPercent = 0;
93
93
94
	// bug 206499
95
	private boolean isSupportedElementFound = false;
96
	public static final String V5_ROOT_ELEMENT_NAME = "symptomDatabase"; //$NON-NLS-1$
94
97
95
	public SymptomLoader() {
98
	public SymptomLoader() {
96
		super();
99
		super();
Lines 115-122 Link Here
115
	 */
118
	 */
116
	public void endElement(String namespaceURI, String localName, String qName) throws SAXException {
119
	public void endElement(String namespaceURI, String localName, String qName) throws SAXException {
117
		if (qName.equals(MATCH_PATTERN_CLASS)) {
120
		if (qName.equals(MATCH_PATTERN_CLASS)) {
121
			isSupportedElementFound = true;
118
			createMatchPattern();
122
			createMatchPattern();
119
		} else if (qName.equals(SOLUTION_CLASS)) {
123
		} else if (qName.equals(SOLUTION_CLASS)) {
124
			isSupportedElementFound = true;
120
			createSolution();
125
			createSolution();
121
		}
126
		}
122
127
Lines 192-200 Link Here
192
    		}
197
    		}
193
198
194
    		try {
199
    		try {
195
200
				if (isSupportedElementFound) {
196
				saveResource(container.eResource());
201
					saveResource(container.eResource());
197
202
				}
198
			} catch (Exception exc) {
203
			} catch (Exception exc) {
199
				errMsg = exc.toString();
204
				errMsg = exc.toString();
200
                // bugzilla 137186
205
                // bugzilla 137186
Lines 268-274 Link Here
268
273
269
    		try {
274
    		try {
270
				is.close();
275
				is.close();
271
				saveResource(container.eResource());
276
				if (isSupportedElementFound) {
277
					saveResource(container.eResource());
278
				}
272
			} catch (Exception exc) {
279
			} catch (Exception exc) {
273
				errMsg = exc.toString();
280
				errMsg = exc.toString();
274
    			// bugzilla 137186
281
    			// bugzilla 137186
Lines 296-302 Link Here
296
			return;
303
			return;
297
		}
304
		}
298
305
299
		parse(is);
306
		try {
307
			parse(is);
308
		} finally {
309
			is.close();
310
		}
300
	}
311
	}
301
312
302
	protected SAXParser makeParser() throws ParserConfigurationException, SAXException {
313
	protected SAXParser makeParser() throws ParserConfigurationException, SAXException {
Lines 389-394 Link Here
389
////			parser.setErrorHandler(this);
400
////			parser.setErrorHandler(this);
390
////			parser.setContentHandler(this);
401
////			parser.setContentHandler(this);
391
//			parser.parse(inputSource);
402
//			parser.parse(inputSource);
403
			isSupportedElementFound = false;
392
			parser.parse(inputSource, this);
404
			parser.parse(inputSource, this);
393
			if(processingXPath && symptom!=null && rule!=null){
405
			if(processingXPath && symptom!=null && rule!=null){
394
				xPathExpression.append("]");            
406
				xPathExpression.append("]");            
Lines 396-402 Link Here
396
				xPathExpression.setLength(0); 
408
				xPathExpression.setLength(0); 
397
				processingXPath = false;
409
				processingXPath = false;
398
			}
410
			}
399
411
			if (!isSupportedElementFound) {
412
				// well-formed XML but unsupported format
413
				throw new FormatNotSupportedException(LogSDBMessages.getString("_10200"));
414
			}
400
		} catch (SAXException se) {
415
		} catch (SAXException se) {
401
			errMsg = se.getMessage();
416
			errMsg = se.getMessage();
402
			ModelDebugger.log(se);
417
			ModelDebugger.log(se);
Lines 415-431 Link Here
415
	 */
430
	 */
416
	public void startElement(String namespaceURI, String localName, String elementName, Attributes atts) throws SAXException {
431
	public void startElement(String namespaceURI, String localName, String elementName, Attributes atts) throws SAXException {
417
		if (elementName.equals(V5_RUNTIME_CLASS)) {
432
		if (elementName.equals(V5_RUNTIME_CLASS)) {
433
			isSupportedElementFound = true;
418
			createContainer(atts);
434
			createContainer(atts);
419
		} else if (elementName.equals(V5_MATCH_PATTERN_CLASS)) {
435
		} else if (elementName.equals(V5_MATCH_PATTERN_CLASS)) {
436
			isSupportedElementFound = true;
420
			createMatchPattern(atts);
437
			createMatchPattern(atts);
421
		} else if (elementName.equals(V5_SOLUTION_CLASS)) {
438
		} else if (elementName.equals(V5_SOLUTION_CLASS)) {
439
			isSupportedElementFound = true;
422
			createSolution(atts);
440
			createSolution(atts);
423
		} else if (elementName.equals(V5_SYMPTOM_CLASS)) {
441
		} else if (elementName.equals(V5_SYMPTOM_CLASS)) {
442
			isSupportedElementFound = true;
424
			createSymptom(atts);
443
			createSymptom(atts);
425
		} else if (elementName.equals(V5_DIRECTIVE_CLASS)) {
444
		} else if (elementName.equals(V5_DIRECTIVE_CLASS)) {
445
			isSupportedElementFound = true;
426
			createDirective(atts);
446
			createDirective(atts);
427
		} else if (elementName.equals(SYMPTOM_CLASS)) {
447
		} else if (elementName.equals(SYMPTOM_CLASS)) {
448
			isSupportedElementFound = true;
428
			createV4Symptom(atts);
449
			createV4Symptom(atts);
450
        } else if (elementName.equals(RUNTIME_CLASS)) {
451
			isSupportedElementFound = true;
452
		} else if (elementName.equals(V5_ROOT_ELEMENT_NAME)) {
453
			isSupportedElementFound = true;
429
		}
454
		}
430
455
431
		// bugzilla 137186
456
		// bugzilla 137186
(-)src-symptom-handler/org/eclipse/tptp/monitoring/symptom/provisional/models/util/SDBLoader.java (-12 / +36 lines)
Lines 73-78 Link Here
73
    private long readBytes = 0;
73
    private long readBytes = 0;
74
    private int currentPercent = 0;
74
    private int currentPercent = 0;
75
75
76
	// bug 206499
77
	private boolean isSupportedElementFound = false;
78
	public static final String V5_ROOT_ELEMENT_NAME = "symptomDatabase"; //$NON-NLS-1$
79
76
    //~ Constructors -------------------------------------------------------------------------------
80
    //~ Constructors -------------------------------------------------------------------------------
77
81
78
    public SDBLoader() {
82
    public SDBLoader() {
Lines 104-111 Link Here
104
     */
108
     */
105
    public void endElement(String namespaceURI, String localName, String qName) throws SAXException {
109
    public void endElement(String namespaceURI, String localName, String qName) throws SAXException {
106
        if (qName.equals(MATCH_PATTERN_CLASS)) {
110
        if (qName.equals(MATCH_PATTERN_CLASS)) {
111
            isSupportedElementFound = true;
107
            createMatchPattern();
112
            createMatchPattern();
108
        } else if (qName.equals(SOLUTION_CLASS)) {
113
        } else if (qName.equals(SOLUTION_CLASS)) {
114
            isSupportedElementFound = true;
109
            createSolution();
115
            createSolution();
110
        }
116
        }
111
117
Lines 182-192 Link Here
182
    		}
188
    		}
183
189
184
    		try {
190
    		try {
185
                Map options = new HashMap();
191
				if (isSupportedElementFound) {
186
192
					Map options = new HashMap();
187
                options.put(XMIResource.OPTION_DECLARE_XML, Boolean.TRUE);
193
					options.put(XMIResource.OPTION_DECLARE_XML, Boolean.TRUE);
188
                _symptomDB.eResource().save(options);
194
					_symptomDB.eResource().save(options);
189
195
				}
190
            } catch (Exception exc) {
196
            } catch (Exception exc) {
191
                errMsg = exc.toString();
197
                errMsg = exc.toString();
192
                // bugzilla 137186
198
                // bugzilla 137186
Lines 253-263 Link Here
253
259
254
    		try {
260
    		try {
255
            	 is.close();
261
            	 is.close();
256
            	Map options = new HashMap();
262
     			if (isSupportedElementFound) {
257
263
					Map options = new HashMap();
258
                options.put(XMIResource.OPTION_DECLARE_XML, Boolean.TRUE);
264
					options.put(XMIResource.OPTION_DECLARE_XML, Boolean.TRUE);
259
                _symptomDB.eResource().save(options);
265
					_symptomDB.eResource().save(options);
260
               
266
				}
261
            } catch (Exception exc) {
267
            } catch (Exception exc) {
262
                errMsg = exc.toString();
268
                errMsg = exc.toString();
263
    			// bugzilla 137186
269
    			// bugzilla 137186
Lines 286-292 Link Here
286
            return;
292
            return;
287
        }
293
        }
288
294
289
        parse(is);
295
        try {
296
			parse(is);
297
		} finally {
298
			is.close();
299
		}
290
    }
300
    }
291
301
292
	protected SAXParser makeParser() throws ParserConfigurationException, SAXException {
302
	protected SAXParser makeParser() throws ParserConfigurationException, SAXException {
Lines 381-388 Link Here
381
////            parser.setErrorHandler(this);
391
////            parser.setErrorHandler(this);
382
////            parser.setContentHandler(this);
392
////            parser.setContentHandler(this);
383
//			parser.parse(inputSource);
393
//			parser.parse(inputSource);
394
			isSupportedElementFound = false;
384
			parser.parse(inputSource, this);
395
			parser.parse(inputSource, this);
385
           
396
			if (!isSupportedElementFound) {
397
				// well-formed XML but unsupported format
398
				throw new FormatNotSupportedException(LogSDBMessages.getString("_10200"));
399
			}
386
        } catch (SAXException se) {
400
        } catch (SAXException se) {
387
            errMsg = se.getMessage();
401
            errMsg = se.getMessage();
388
            ModelDebugger.log(se);
402
            ModelDebugger.log(se);
Lines 401-417 Link Here
401
     */
415
     */
402
    public void startElement(String namespaceURI, String localName, String elementName, Attributes atts) throws SAXException {
416
    public void startElement(String namespaceURI, String localName, String elementName, Attributes atts) throws SAXException {
403
        if (elementName.equals(V5_RUNTIME_CLASS)) {
417
        if (elementName.equals(V5_RUNTIME_CLASS)) {
418
            isSupportedElementFound = true;
404
            createRuntime(atts);
419
            createRuntime(atts);
405
        } else if (elementName.equals(V5_MATCH_PATTERN_CLASS)) {
420
        } else if (elementName.equals(V5_MATCH_PATTERN_CLASS)) {
421
            isSupportedElementFound = true;
406
            createMatchPattern(atts);
422
            createMatchPattern(atts);
407
        } else if (elementName.equals(V5_SOLUTION_CLASS)) {
423
        } else if (elementName.equals(V5_SOLUTION_CLASS)) {
424
            isSupportedElementFound = true;
408
            createSolution(atts);
425
            createSolution(atts);
409
        } else if (elementName.equals(V5_SYMPTOM_CLASS)) {
426
        } else if (elementName.equals(V5_SYMPTOM_CLASS)) {
427
            isSupportedElementFound = true;
410
            createSymptom(atts);
428
            createSymptom(atts);
411
        } else if (elementName.equals(V5_DIRECTIVE_CLASS)) {
429
        } else if (elementName.equals(V5_DIRECTIVE_CLASS)) {
430
            isSupportedElementFound = true;
412
            createDirective(atts);
431
            createDirective(atts);
413
        } else if (elementName.equals(SYMPTOM_CLASS)) {
432
        } else if (elementName.equals(SYMPTOM_CLASS)) {
433
            isSupportedElementFound = true;
414
            createV4Symptom(atts);
434
            createV4Symptom(atts);
435
        } else if (elementName.equals(RUNTIME_CLASS)) {
436
			isSupportedElementFound = true;
437
		} else if (elementName.equals(V5_ROOT_ELEMENT_NAME)) {
438
			isSupportedElementFound = true;
415
        }
439
        }
416
440
417
		// bugzilla 137186
441
		// bugzilla 137186
(-)src-symptom-handler/org/eclipse/tptp/monitoring/symptom/provisional/models/util/FormatNotSupportedException.java (+38 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id$
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
13
package org.eclipse.tptp.monitoring.symptom.provisional.models.util;
14
15
/**
16
 * Signals that the specified file is not supported by the importer.
17
 * 
18
 * @author ygotoh
19
 */
20
public class FormatNotSupportedException extends Exception {
21
22
	public FormatNotSupportedException() {
23
		super();
24
	}
25
26
	public FormatNotSupportedException(String message, Throwable cause) {
27
		super(message, cause);
28
	}
29
30
	public FormatNotSupportedException(String message) {
31
		super(message);
32
	}
33
34
	public FormatNotSupportedException(Throwable cause) {
35
		super(cause);
36
	}
37
38
}

Return to bug 206499