Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: dcfdd7d4485f719589999b48e1cba4e51aa5b212 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*******************************************************************************
 * Copyright (c) 2010, 2013 Oracle. All rights reserved.
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0, which accompanies this distribution
 * and is available at http://www.eclipse.org/legal/epl-v10.html.
 * 
 * Contributors:
 *     Oracle - initial API and implementation
 ******************************************************************************/
package org.eclipse.jpt.jpa.eclipselink.core.internal.libval;

import java.util.HashMap;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jpt.common.core.internal.libval.LibraryValidatorTools;
import org.eclipse.jpt.common.core.libprov.JptLibraryProviderInstallOperationConfig;
import org.eclipse.jpt.common.core.libval.LibraryValidator;
import org.eclipse.jpt.jpa.core.internal.libprov.JpaOsgiBundlesLibraryProviderInstallOperationConfig;
import org.eclipse.jpt.jpa.eclipselink.core.internal.EclipseLink1_1JpaPlatformFactory;
import org.eclipse.jpt.jpa.eclipselink.core.internal.EclipseLink1_2JpaPlatformFactory;
import org.eclipse.jpt.jpa.eclipselink.core.internal.EclipseLink2_0JpaPlatformFactory;
import org.eclipse.jpt.jpa.eclipselink.core.internal.EclipseLink2_1JpaPlatformFactory;
import org.eclipse.jpt.jpa.eclipselink.core.internal.EclipseLink2_2JpaPlatformFactory;
import org.eclipse.jpt.jpa.eclipselink.core.internal.EclipseLink2_3JpaPlatformFactory;
import org.eclipse.jpt.jpa.eclipselink.core.internal.EclipseLink2_4JpaPlatformFactory;
import org.eclipse.jpt.jpa.eclipselink.core.internal.EclipseLink2_5ForJpa2_0PlatformFactory;
import org.eclipse.jpt.jpa.eclipselink.core.internal.EclipseLink2_5ForJpa2_1PlatformFactory;
import org.eclipse.jpt.jpa.eclipselink.core.internal.EclipseLinkJpaPlatformFactory;
import org.eclipse.osgi.service.resolver.VersionRange;

@SuppressWarnings("nls")
public class EclipseLinkEclipseLinkBundlesLibraryValidator
	implements LibraryValidator
{
	public IStatus validate(JptLibraryProviderInstallOperationConfig config) {
		return validate((JpaOsgiBundlesLibraryProviderInstallOperationConfig) config);
	}

	private IStatus validate(JpaOsgiBundlesLibraryProviderInstallOperationConfig config) {
		String jpaPlatformID = config.getJpaPlatformConfig().getId();
		HashMap<String, VersionRange> bundleVersionRanges = PLATFORM_BUNDLE_VERSION_RANGES.get(jpaPlatformID);
		return LibraryValidatorTools.validateBundleVersions(config, bundleVersionRanges);
	}

	/**
	 * Map(platform ID => Map(bundle name => version range))
	 */
	private static final HashMap<String, HashMap<String, VersionRange>> PLATFORM_BUNDLE_VERSION_RANGES = buildPlatformBundleVersionRanges();

	private static HashMap<String, HashMap<String, VersionRange>> buildPlatformBundleVersionRanges() {
		HashMap<String, HashMap<String, VersionRange>> versionRanges = new HashMap<String, HashMap<String, VersionRange>>();
		versionRanges.put(EclipseLinkJpaPlatformFactory.ID,    buildEclipseLink1_0BundleVersionRanges());
		versionRanges.put(EclipseLink1_1JpaPlatformFactory.ID, buildEclipseLink1_1BundleVersionRanges());
		versionRanges.put(EclipseLink1_2JpaPlatformFactory.ID, buildEclipseLink1_2BundleVersionRanges());
		versionRanges.put(EclipseLink2_0JpaPlatformFactory.ID, buildEclipseLink2_0BundleVersionRanges());
		versionRanges.put(EclipseLink2_1JpaPlatformFactory.ID, buildEclipseLink2_1BundleVersionRanges());
		versionRanges.put(EclipseLink2_2JpaPlatformFactory.ID, buildEclipseLink2_2BundleVersionRanges());
		versionRanges.put(EclipseLink2_3JpaPlatformFactory.ID, buildEclipseLink2_3BundleVersionRanges());
		versionRanges.put(EclipseLink2_4JpaPlatformFactory.ID, buildEclipseLink2_4BundleVersionRanges());
		versionRanges.put(EclipseLink2_5ForJpa2_0PlatformFactory.ID, buildEclipseLink2_5BundleVersionRanges());
		versionRanges.put(EclipseLink2_5ForJpa2_1PlatformFactory.ID, buildEclipseLink2_5BundleVersionRanges());
		return versionRanges;
	}

	private static HashMap<String, VersionRange> buildEclipseLink1_0BundleVersionRanges() {
		HashMap<String, VersionRange> versionRanges = new HashMap<String, VersionRange>();
		versionRanges.put("org.eclipse.persistence.core",  new VersionRange("[1.0, 3.0)"));
		versionRanges.put("org.eclipse.persistence.jpa",   new VersionRange("[1.0, 3.0)"));
		versionRanges.put("org.eclipse.persistence.asm",   new VersionRange("[1.0, 3.0)"));
		versionRanges.put("org.eclipse.persistence.antlr", new VersionRange("[1.0, 3.0)"));
		return versionRanges;
	}

	private static HashMap<String, VersionRange> buildEclipseLink1_1BundleVersionRanges() {
		HashMap<String, VersionRange> versionRanges = new HashMap<String, VersionRange>();
		versionRanges.put("org.eclipse.persistence.core",  new VersionRange("[1.1, 3.0)"));
		versionRanges.put("org.eclipse.persistence.jpa",   new VersionRange("[1.1, 3.0)"));
		versionRanges.put("org.eclipse.persistence.asm",   new VersionRange("[1.1, 3.0)"));
		versionRanges.put("org.eclipse.persistence.antlr", new VersionRange("[1.1, 3.0)"));
		return versionRanges;
	}

	private static HashMap<String, VersionRange> buildEclipseLink1_2BundleVersionRanges() {
		HashMap<String, VersionRange> versionRanges = new HashMap<String, VersionRange>();
		versionRanges.put("org.eclipse.persistence.core",  new VersionRange("[1.2, 3.0)"));
		versionRanges.put("org.eclipse.persistence.jpa",   new VersionRange("[1.2, 3.0)"));
		versionRanges.put("org.eclipse.persistence.asm",   new VersionRange("[1.2, 3.0)"));
		versionRanges.put("org.eclipse.persistence.antlr", new VersionRange("[1.2, 3.0)"));
		return versionRanges;
	}

	private static HashMap<String, VersionRange> buildEclipseLink2_0BundleVersionRanges() {
		HashMap<String, VersionRange> versionRanges = new HashMap<String, VersionRange>();
		versionRanges.put("org.eclipse.persistence.core",  new VersionRange("[2.0, 3.0)"));
		versionRanges.put("org.eclipse.persistence.jpa",   new VersionRange("[2.0, 3.0)"));
		versionRanges.put("org.eclipse.persistence.asm",   new VersionRange("[2.0, 3.0)"));
		versionRanges.put("org.eclipse.persistence.antlr", new VersionRange("[2.0, 3.0)"));
		return versionRanges;
	}

	private static HashMap<String, VersionRange> buildEclipseLink2_1BundleVersionRanges() {
		HashMap<String, VersionRange> versionRanges = new HashMap<String, VersionRange>();
		versionRanges.put("org.eclipse.persistence.core",  new VersionRange("[2.1, 3.0)"));
		versionRanges.put("org.eclipse.persistence.jpa",   new VersionRange("[2.1, 3.0)"));
		versionRanges.put("org.eclipse.persistence.asm",   new VersionRange("[2.1, 3.0)"));
		versionRanges.put("org.eclipse.persistence.antlr", new VersionRange("[2.1, 3.0)"));
		return versionRanges;
	}

	private static HashMap<String, VersionRange> buildEclipseLink2_2BundleVersionRanges() {
		HashMap<String, VersionRange> versionRanges = new HashMap<String, VersionRange>();
		versionRanges.put("org.eclipse.persistence.core",  new VersionRange("[2.2, 3.0)"));
		versionRanges.put("org.eclipse.persistence.jpa",   new VersionRange("[2.2, 3.0)"));
		versionRanges.put("org.eclipse.persistence.asm",   new VersionRange("[2.2, 3.0)"));
		versionRanges.put("org.eclipse.persistence.antlr", new VersionRange("[2.2, 3.0)"));
		return versionRanges;
	}

	private static HashMap<String, VersionRange> buildEclipseLink2_3BundleVersionRanges() {
		HashMap<String, VersionRange> versionRanges = new HashMap<String, VersionRange>();
		versionRanges.put("org.eclipse.persistence.core",  new VersionRange("[2.3, 3.0)"));
		versionRanges.put("org.eclipse.persistence.jpa",   new VersionRange("[2.3, 3.0)"));
		versionRanges.put("org.eclipse.persistence.asm",   new VersionRange("[2.3, 3.0)"));
		versionRanges.put("org.eclipse.persistence.antlr", new VersionRange("[2.3, 3.0)"));
		return versionRanges;
	}

	private static HashMap<String, VersionRange> buildEclipseLink2_4BundleVersionRanges() {
		HashMap<String, VersionRange> versionRanges = new HashMap<String, VersionRange>();
		versionRanges.put("org.eclipse.persistence.core",  new VersionRange("[2.4, 3.0)"));
		versionRanges.put("org.eclipse.persistence.jpa",   new VersionRange("[2.4, 3.0)"));
		versionRanges.put("org.eclipse.persistence.asm",   new VersionRange("[2.4, 3.0)"));
		versionRanges.put("org.eclipse.persistence.antlr", new VersionRange("[2.4, 3.0)"));
		return versionRanges;
	}

	private static HashMap<String, VersionRange> buildEclipseLink2_5BundleVersionRanges() {
		HashMap<String, VersionRange> versionRanges = new HashMap<String, VersionRange>();
		versionRanges.put("org.eclipse.persistence.core",  new VersionRange("[2.5, 3.0)"));
		versionRanges.put("org.eclipse.persistence.jpa",   new VersionRange("[2.5, 3.0)"));
		versionRanges.put("org.eclipse.persistence.asm",   new VersionRange("[2.5, 3.0)"));
		versionRanges.put("org.eclipse.persistence.antlr", new VersionRange("[2.5, 3.0)"));
		return versionRanges;
	}
}

Back to the top