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 346804
Collapse All | Expand All

(-)META-INF/MANIFEST.MF (-1 / +1 lines)
Lines 1-6 Link Here
1
Bundle-ManifestVersion: 2
1
Bundle-ManifestVersion: 2
2
Bundle-Name: %bundleName
2
Bundle-Name: %bundleName
3
Bundle-Version: 1.1.0.qualifier
3
Bundle-Version: 1.1.100.qualifier
4
Bundle-SymbolicName: org.eclipse.equinox.metatype
4
Bundle-SymbolicName: org.eclipse.equinox.metatype
5
Bundle-Activator: org.eclipse.equinox.metatype.Activator
5
Bundle-Activator: org.eclipse.equinox.metatype.Activator
6
Import-Package: javax.xml.parsers,
6
Import-Package: javax.xml.parsers,
(-)src/org/eclipse/equinox/metatype/DataParser.java (-24 / +16 lines)
Lines 100-126 Link Here
100
	/*
100
	/*
101
	 * Main method to parse specific MetaData file.
101
	 * Main method to parse specific MetaData file.
102
	 */
102
	 */
103
	public Collection<Designate> doParse() {
103
	public Collection<Designate> doParse() throws IOException, ParserConfigurationException, SAXException {
104
104
		SAXParser saxParser = _dp_parserFactory.newSAXParser();
105
		try {
105
		_dp_xmlReader = saxParser.getXMLReader();
106
			SAXParser saxParser = _dp_parserFactory.newSAXParser();
106
		_dp_xmlReader.setContentHandler(new RootHandler());
107
			_dp_xmlReader = saxParser.getXMLReader();
107
		_dp_xmlReader.setErrorHandler(new MyErrorHandler(System.err));
108
			_dp_xmlReader.setContentHandler(new RootHandler());
108
		InputStream is = _dp_url.openStream();
109
			_dp_xmlReader.setErrorHandler(new MyErrorHandler(System.err));
109
		InputSource isource = new InputSource(is);
110
			InputStream is = _dp_url.openStream();
110
		logger.log(LogService.LOG_DEBUG, "Starting to parse " + _dp_url); //$NON-NLS-1$					
111
			InputSource isource = new InputSource(is);
111
		_dp_xmlReader.parse(isource);
112
			logger.log(LogService.LOG_DEBUG, "Starting to parse " + _dp_url); //$NON-NLS-1$					
113
			_dp_xmlReader.parse(isource);
114
		} catch (ParserConfigurationException pce) {
115
			pce.printStackTrace();
116
			return null;
117
		} catch (SAXException saxe) {
118
			saxe.printStackTrace();
119
			return null;
120
		} catch (IOException ioe) {
121
			ioe.printStackTrace();
122
			return null;
123
		}
124
		return designates;
112
		return designates;
125
	}
113
	}
126
114
Lines 279-285 Link Here
279
			if (_dp_designateHandlers.size() == 0) {
267
			if (_dp_designateHandlers.size() == 0) {
280
				// Schema defines at least one DESIGNATE is required.
268
				// Schema defines at least one DESIGNATE is required.
281
				_isParsedDataValid = false;
269
				_isParsedDataValid = false;
282
				logger.log(LogService.LOG_ERROR, "DataParser.finished() " + NLS.bind(MetaTypeMsg.MISSING_ELEMENT, DESIGNATE)); //$NON-NLS-1$
270
				logger.log(LogService.LOG_WARNING, "DataParser.finished() " + NLS.bind(MetaTypeMsg.MISSING_ELEMENT, DESIGNATE)); //$NON-NLS-1$
283
				return;
271
				return;
284
			}
272
			}
285
			Enumeration<DesignateHandler> designateHandlerKeys = _dp_designateHandlers.elements();
273
			Enumeration<DesignateHandler> designateHandlerKeys = _dp_designateHandlers.elements();
Lines 460-465 Link Here
460
			}
448
			}
461
449
462
			String ad_type_val = atts.getValue(TYPE);
450
			String ad_type_val = atts.getValue(TYPE);
451
			if (ad_type_val == null) {
452
				_isParsedDataValid = false;
453
				logger.log(LogService.LOG_ERROR, "DataParser.init(String, Attributes, Vector) " + NLS.bind(MetaTypeMsg.MISSING_ATTRIBUTE, TYPE, name)); //$NON-NLS-1$
454
				return;
455
			}
463
			if (ad_type_val.equalsIgnoreCase(STRING)) {
456
			if (ad_type_val.equalsIgnoreCase(STRING)) {
464
				_dataType = AttributeDefinition.STRING;
457
				_dataType = AttributeDefinition.STRING;
465
			} else if (ad_type_val.equalsIgnoreCase(LONG)) {
458
			} else if (ad_type_val.equalsIgnoreCase(LONG)) {
Lines 482-490 Link Here
482
				_dataType = AttributeDefinition.PASSWORD;
475
				_dataType = AttributeDefinition.PASSWORD;
483
			} else {
476
			} else {
484
				_isParsedDataValid = false;
477
				_isParsedDataValid = false;
485
				logger.log(LogService.LOG_ERROR, "DataParser.init(String, Attributes, Vector) " + NLS.bind(MetaTypeMsg.MISSING_ATTRIBUTE, TYPE, name)); //$NON-NLS-1$
478
				logger.log(LogService.LOG_ERROR, "DataParser.init(String, Attributes, Vector) " + NLS.bind(MetaTypeMsg.INVALID_TYPE, new Object[] {ad_type_val, _dp_url, _dp_bundle.getBundleId()})); //$NON-NLS-1$
486
				return;
479
				return;
487
488
			}
480
			}
489
481
490
			String ad_cardinality_str = atts.getValue(CARDINALITY);
482
			String ad_cardinality_str = atts.getValue(CARDINALITY);
(-)src/org/eclipse/equinox/metatype/ExternalMessages.properties (-1 / +3 lines)
Lines 14-19 Link Here
14
UNEXPECTED_ELEMENT=Unexpected element {0}.
14
UNEXPECTED_ELEMENT=Unexpected element {0}.
15
UNEXPECTED_TEXT=Unexpected text {0}.
15
UNEXPECTED_TEXT=Unexpected text {0}.
16
MISSING_ATTRIBUTE=Missing attribute {0} in tag {1}.
16
MISSING_ATTRIBUTE=Missing attribute {0} in tag {1}.
17
INVALID_TYPE=Invalid attribute definition type {0} in metadata XML at {1} for bundle ID {2}.
17
MISSING_DESIGNATE_PID_AND_FACTORYPID=A <Designate> element must specify either the 'pid' or 'factoryPid' attribute.
18
MISSING_DESIGNATE_PID_AND_FACTORYPID=A <Designate> element must specify either the 'pid' or 'factoryPid' attribute.
18
OCD_ID_NOT_FOUND=Object Class Definition ID not found {0}.
19
OCD_ID_NOT_FOUND=Object Class Definition ID not found {0}.
19
MISSING_ELEMENT=Missing element {0} (Reference ID = {1}.
20
MISSING_ELEMENT=Missing element {0} (Reference ID = {1}.
Lines 32-35 Link Here
32
ASK_INVALID_LOCALE=OCD(ID=\"{0}\") cannot support this locale \"{1}\".
33
ASK_INVALID_LOCALE=OCD(ID=\"{0}\") cannot support this locale \"{1}\".
33
MISSING_REQUIRED_PARAMETER=Missing required parameter: {0}
34
MISSING_REQUIRED_PARAMETER=Missing required parameter: {0}
34
TOKENIZER_GOT_INVALID_DATA=The Tokenizer got invalid data.
35
TOKENIZER_GOT_INVALID_DATA=The Tokenizer got invalid data.
35
INVALID_PID_METATYPE_PROVIDER_IGNORED=Bundle {0} with ID {1} provided a MetaTypeProvider with an invalid property. Property {2} with value {3} was not of the expected type (String, String[], or Collection<String>) and will be ignored.
36
INVALID_PID_METATYPE_PROVIDER_IGNORED=Bundle {0} with ID {1} provided a MetaTypeProvider with an invalid property. Property {2} with value {3} was not of the expected type (String, String[], or Collection<String>) and will be ignored.
37
METADATA_PARSE_ERROR=Unable to parse metadata XML at {0} for bundle ID {1}.
(-)src/org/eclipse/equinox/metatype/MetaTypeInformationImpl.java (-2 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2010 IBM Corporation and others.
2
 * Copyright (c) 2005, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
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
Lines 32-38 Link Here
32
	/**
32
	/**
33
	 * Constructor of class MetaTypeInformationImpl.
33
	 * Constructor of class MetaTypeInformationImpl.
34
	 */
34
	 */
35
	MetaTypeInformationImpl(Bundle bundle, SAXParserFactory parserFactory, LogService logger) throws java.io.IOException {
35
	MetaTypeInformationImpl(Bundle bundle, SAXParserFactory parserFactory, LogService logger) {
36
		super(bundle, parserFactory, logger);
36
		super(bundle, parserFactory, logger);
37
	}
37
	}
38
38
(-)src/org/eclipse/equinox/metatype/MetaTypeMsg.java (-5 / +2 lines)
Lines 16-29 Link Here
16
	private static final String BUNDLE_NAME = "org.eclipse.equinox.metatype.ExternalMessages"; //$NON-NLS-1$
16
	private static final String BUNDLE_NAME = "org.eclipse.equinox.metatype.ExternalMessages"; //$NON-NLS-1$
17
17
18
	public static String SERVICE_DESCRIPTION;
18
	public static String SERVICE_DESCRIPTION;
19
20
	public static String UNEXPECTED_ELEMENT;
19
	public static String UNEXPECTED_ELEMENT;
21
	public static String UNEXPECTED_TEXT;
20
	public static String UNEXPECTED_TEXT;
22
	public static String MISSING_ATTRIBUTE;
21
	public static String MISSING_ATTRIBUTE;
22
	public static String INVALID_TYPE;
23
	public static String MISSING_DESIGNATE_PID_AND_FACTORYPID;
23
	public static String MISSING_DESIGNATE_PID_AND_FACTORYPID;
24
	public static String OCD_ID_NOT_FOUND;
24
	public static String OCD_ID_NOT_FOUND;
25
	public static String MISSING_ELEMENT;
25
	public static String MISSING_ELEMENT;
26
27
	public static String EXCEPTION_MESSAGE;
26
	public static String EXCEPTION_MESSAGE;
28
	public static String NULL_IS_INVALID;
27
	public static String NULL_IS_INVALID;
29
	public static String VALUE_OUT_OF_RANGE;
28
	public static String VALUE_OUT_OF_RANGE;
Lines 33-46 Link Here
33
	public static String INCONSISTENT_OPTIONS;
32
	public static String INCONSISTENT_OPTIONS;
34
	public static String INVALID_OPTIONS;
33
	public static String INVALID_OPTIONS;
35
	public static String INVALID_DEFAULTS;
34
	public static String INVALID_DEFAULTS;
36
37
	public static String METADATA_NOT_FOUND;
35
	public static String METADATA_NOT_FOUND;
38
	public static String ASK_INVALID_LOCALE;
36
	public static String ASK_INVALID_LOCALE;
39
40
	public static String MISSING_REQUIRED_PARAMETER;
37
	public static String MISSING_REQUIRED_PARAMETER;
41
42
	public static String TOKENIZER_GOT_INVALID_DATA;
38
	public static String TOKENIZER_GOT_INVALID_DATA;
43
	public static String INVALID_PID_METATYPE_PROVIDER_IGNORED;
39
	public static String INVALID_PID_METATYPE_PROVIDER_IGNORED;
40
	public static String METADATA_PARSE_ERROR;
44
41
45
	static {
42
	static {
46
		// initialize resource bundles
43
		// initialize resource bundles
(-)src/org/eclipse/equinox/metatype/MetaTypeProviderImpl.java (-6 / +8 lines)
Lines 49-55 Link Here
49
	/**
49
	/**
50
	 * Constructor of class MetaTypeProviderImpl.
50
	 * Constructor of class MetaTypeProviderImpl.
51
	 */
51
	 */
52
	MetaTypeProviderImpl(Bundle bundle, SAXParserFactory parserFactory, LogService logger) throws IOException {
52
	MetaTypeProviderImpl(Bundle bundle, SAXParserFactory parserFactory, LogService logger) {
53
53
54
		this._bundle = bundle;
54
		this._bundle = bundle;
55
		this.logger = logger;
55
		this.logger = logger;
Lines 83-89 Link Here
83
	 * @return void
83
	 * @return void
84
	 * @throws IOException If there are errors accessing the metadata.xml file
84
	 * @throws IOException If there are errors accessing the metadata.xml file
85
	 */
85
	 */
86
	private boolean readMetaFiles(Bundle bundle, SAXParserFactory parserFactory) throws IOException {
86
	private boolean readMetaFiles(Bundle bundle, SAXParserFactory parserFactory) {
87
		BundleWiring wiring = bundle.adapt(BundleWiring.class);
87
		BundleWiring wiring = bundle.adapt(BundleWiring.class);
88
		if (wiring == null)
88
		if (wiring == null)
89
			return false;
89
			return false;
Lines 95-110 Link Here
95
			DataParser parser = new DataParser(bundle, entry, parserFactory, logger);
95
			DataParser parser = new DataParser(bundle, entry, parserFactory, logger);
96
			try {
96
			try {
97
				Collection<Designate> designates = parser.doParse();
97
				Collection<Designate> designates = parser.doParse();
98
				if (!designates.isEmpty())
98
				if (!designates.isEmpty()) {
99
					result = true;
99
					result = true;
100
				}
100
				for (Designate designate : designates) {
101
				for (Designate designate : designates) {
101
					if (designate.isFactory())
102
					if (designate.isFactory()) {
102
						_allFPidOCDs.put(designate.getFactoryPid(), designate.getObjectClassDefinition());
103
						_allFPidOCDs.put(designate.getFactoryPid(), designate.getObjectClassDefinition());
103
					else
104
					} else {
104
						_allPidOCDs.put(designate.getPid(), designate.getObjectClassDefinition());
105
						_allPidOCDs.put(designate.getPid(), designate.getObjectClassDefinition());
106
					}
105
				}
107
				}
106
			} catch (Exception e) {
108
			} catch (Exception e) {
107
				// ignore
109
				logger.log(LogService.LOG_ERROR, NLS.bind(MetaTypeMsg.METADATA_PARSE_ERROR, new Object[] {entry, bundle.getBundleId()}), e);
108
			}
110
			}
109
		}
111
		}
110
		return result;
112
		return result;
(-)src/org/eclipse/equinox/metatype/MetaTypeServiceImpl.java (-20 / +13 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2010 IBM Corporation and others.
2
 * Copyright (c) 2005, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
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
Lines 10-19 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.equinox.metatype;
11
package org.eclipse.equinox.metatype;
12
12
13
import java.io.IOException;
13
import java.security.AccessController;
14
import java.security.*;
14
import java.security.PrivilegedExceptionAction;
15
import java.util.Hashtable;
15
import java.util.Hashtable;
16
import javax.xml.parsers.SAXParserFactory;
16
import javax.xml.parsers.SAXParserFactory;
17
import org.eclipse.osgi.util.NLS;
17
import org.osgi.framework.*;
18
import org.osgi.framework.*;
18
import org.osgi.service.log.LogService;
19
import org.osgi.service.log.LogService;
19
import org.osgi.service.metatype.MetaTypeInformation;
20
import org.osgi.service.metatype.MetaTypeInformation;
Lines 46-78 Link Here
46
	 * @see org.osgi.service.metatype.MetaTypeService#getMetaTypeInformation(org.osgi.framework.Bundle)
47
	 * @see org.osgi.service.metatype.MetaTypeService#getMetaTypeInformation(org.osgi.framework.Bundle)
47
	 */
48
	 */
48
	public MetaTypeInformation getMetaTypeInformation(Bundle bundle) {
49
	public MetaTypeInformation getMetaTypeInformation(Bundle bundle) {
49
50
		return getMetaTypeProvider(bundle);
50
		MetaTypeInformation mti;
51
		try {
52
			mti = getMetaTypeProvider(bundle);
53
		} catch (IOException e) {
54
			logger.log(LogService.LOG_ERROR, "IOException in MetaTypeInformation:getMetaTypeInformation(Bundle bundle)"); //$NON-NLS-1$
55
			e.printStackTrace();
56
			mti = null;
57
		}
58
		return mti;
59
	}
51
	}
60
52
61
	/**
53
	/**
62
	 * Internal Method - to get MetaTypeProvider object.
54
	 * Internal Method - to get MetaTypeProvider object.
63
	 */
55
	 */
64
	private MetaTypeInformation getMetaTypeProvider(final Bundle b) throws java.io.IOException {
56
	private MetaTypeInformation getMetaTypeProvider(final Bundle b) {
65
57
		final LogService loggerTemp = this.logger;
58
		final ServiceTracker<Object, Object> tracker = this.metaTypeProviderTracker;
66
		try {
59
		try {
67
			Long bID = new Long(b.getBundleId());
60
			Long bID = new Long(b.getBundleId());
68
			synchronized (_mtps) {
61
			synchronized (_mtps) {
69
				if (_mtps.containsKey(bID))
62
				if (_mtps.containsKey(bID))
70
					return _mtps.get(bID);
63
					return _mtps.get(bID);
71
				// Avoid synthetic accessor method warnings.
64
				// Avoid synthetic accessor method warnings.
72
				final LogService loggerTemp = this.logger;
65
73
				final ServiceTracker<Object, Object> tracker = this.metaTypeProviderTracker;
74
				MetaTypeInformation mti = AccessController.doPrivileged(new PrivilegedExceptionAction<MetaTypeInformation>() {
66
				MetaTypeInformation mti = AccessController.doPrivileged(new PrivilegedExceptionAction<MetaTypeInformation>() {
75
					public MetaTypeInformation run() throws IOException {
67
					public MetaTypeInformation run() {
76
						MetaTypeInformationImpl impl = new MetaTypeInformationImpl(b, _parserFactory, loggerTemp);
68
						MetaTypeInformationImpl impl = new MetaTypeInformationImpl(b, _parserFactory, loggerTemp);
77
						if (!impl._isThereMeta)
69
						if (!impl._isThereMeta)
78
							return new MetaTypeProviderTracker(b, loggerTemp, tracker);
70
							return new MetaTypeProviderTracker(b, loggerTemp, tracker);
Lines 82-89 Link Here
82
				_mtps.put(bID, mti);
74
				_mtps.put(bID, mti);
83
				return mti;
75
				return mti;
84
			}
76
			}
85
		} catch (PrivilegedActionException pae) {
77
		} catch (Exception e) {
86
			throw (IOException) pae.getException();
78
			logger.log(LogService.LOG_ERROR, NLS.bind(MetaTypeMsg.EXCEPTION_MESSAGE, e.getMessage()), e);
79
			return new MetaTypeProviderTracker(b, loggerTemp, tracker);
87
		}
80
		}
88
	}
81
	}
89
82

Return to bug 346804