Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
blob: 56d1046239c8cec718cef0d5afc80ed2234a1a48 (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
/*******************************************************************************
 * Copyright (c) 2001, 2005 IBM Corporation and others.
 * 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:
 * IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.jst.j2ee.common.internal.util;


import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.jst.j2ee.application.internal.impl.ApplicationFactoryImpl;
import org.eclipse.jst.j2ee.client.internal.impl.ClientFactoryImpl;
import org.eclipse.jst.j2ee.ejb.internal.impl.EjbFactoryImpl;
import org.eclipse.jst.j2ee.internal.MOFJ2EEResourceHandler;
import org.eclipse.jst.j2ee.jca.internal.impl.JcaFactoryImpl;
import org.eclipse.jst.j2ee.webapplication.internal.impl.WebapplicationFactoryImpl;


public class CommonUtil {
public static boolean isDeploymentDescriptorRoot(EObject o) {
	return isDeploymentDescriptorRoot(o, true);
}
public static boolean isDeploymentDescriptorRoot(EObject o, boolean includeEars) {
	EObject meta = o.eClass();
	return (includeEars && meta == eClassApplication()) ||
		meta == eClassApplicationClient() ||
		meta == eClassEJBJar() ||
		meta == eClassWebApp() ||
		meta == eClassConnector();
}
public static boolean isDeploymentDescriptorRoot(Object o) {
	return isDeploymentDescriptorRoot(o, true);
}
public static boolean isDeploymentDescriptorRoot(Object o, boolean includeEARs) {
	if (o instanceof EObject)
		return isDeploymentDescriptorRoot((EObject)o, includeEARs);
	return false;
}
protected static EClass eClassApplication() {
	return ApplicationFactoryImpl.getPackage().getApplication();
}
protected static EClass eClassApplicationClient() {
	return ClientFactoryImpl.getPackage().getApplicationClient();
}
protected static EClass eClassEJBJar() {
	return EjbFactoryImpl.getPackage().getEJBJar();
}
protected static EClass eClassWebApp() {
	return WebapplicationFactoryImpl.getPackage().getWebApp();
}

protected static EClass eClassConnector() {
	return JcaFactoryImpl.getPackage().getConnector();
}
/**
 * Safety check method to ensure that the version of the dd object can be computed.
 */
public static void checkDDObjectForVersion(EObject dd) {
	if (dd.eIsProxy()) {
		String proxyUri = ((InternalEObject)dd).eProxyURI().toString();
		String message = MOFJ2EEResourceHandler.getString(MOFJ2EEResourceHandler.J2EE_VERSION_PROXY_ERROR, new Object[]{proxyUri}); 
		throw new IllegalStateException(message);
	} else if (dd.eResource() == null) {
		String message = MOFJ2EEResourceHandler.J2EE_VERSION_NULL_ERROR; 
		throw new IllegalStateException(message);
	}
}

}







Back to the top