Skip to main content
summaryrefslogtreecommitdiffstats
blob: c8b14682d550a6881425ee69767a705c1e21f62a (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
/*******************************************************************************
 * Copyright (c) 2010 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.internal.ui;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jst.j2ee.internal.ui.J2EEModuleDependenciesPropertyPage.ClasspathEntryProxy;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
import org.eclipse.wst.common.componentcore.resources.IVirtualReference;
import org.eclipse.wst.common.componentcore.ui.Messages;
import org.eclipse.wst.common.componentcore.ui.ModuleCoreUIPlugin;
import org.eclipse.wst.common.componentcore.ui.internal.propertypage.verifier.DeploymentAssemblyVerifierHelper;
import org.eclipse.wst.common.componentcore.ui.internal.propertypage.verifier.IDeploymentAssemblyVerifier;
import org.eclipse.wst.common.componentcore.ui.internal.propertypage.verifier.VerifierRegistryReader;
import org.eclipse.wst.common.componentcore.ui.propertypage.AddModuleDependenciesPropertiesPage.ComponentResourceProxy;
import org.eclipse.wst.server.core.IRuntime;

public class J2EEModuleDeploymentAssemblyVerifierHelper {
	
	
	/**
	 * This method will use the facet framework to find all registered verifiers based on installed facets and runtimes.
	 * All the verifiers will have an opportunity to verify and return status on the proposed component mappings
	 * @param component
	 * @param runtime
	 * @param resourceMappingsChanged 
	 * @param resourceMappings 
	 * @param currentReferences 
	 * @param currentClasspathEntries
	 * @return IStatus
	 */
	public static IStatus verify(IVirtualComponent component,IRuntime runtime, ArrayList<IVirtualReference> currentReferences, ArrayList<ComponentResourceProxy> resourceMappings, boolean resourceMappingsChanged, List<ClasspathEntryProxy> currentClasspathEntries) {
		IProject project = component.getProject();
		
		List verifiers = DeploymentAssemblyVerifierHelper.collectAllVerifiers(project,runtime);
		if (verifiers.isEmpty()) return Status.OK_STATUS;
		MultiStatus masterStatus = new MultiStatus(ModuleCoreUIPlugin.PLUGIN_ID, IStatus.OK, Messages.DeploymentAssemblyVerifierHelper_0,null); 
		
		for (int i = 0; i < verifiers.size(); i++) {
			if (!(verifiers.get(i) instanceof IConfigurationElement))
				continue;
			IDeploymentAssemblyVerifier verifier = null;
			try {
				verifier = (IDeploymentAssemblyVerifier) ((IConfigurationElement) verifiers.get(i)).createExecutableExtension(VerifierRegistryReader.VERIFIER_CLASS);
				J2EEModuleDeploymentAssemblyVerifierData data = new J2EEModuleDeploymentAssemblyVerifierData(component, runtime,currentReferences,resourceMappings,resourceMappingsChanged,currentClasspathEntries );
				IStatus verifyStatus = verifier.verify(data);
				if(verifyStatus != null && verifyStatus.isMultiStatus()) {
					masterStatus.addAll(verifyStatus);
				} else {
					masterStatus.add(verifyStatus);
				}
			} catch (Exception e) {
				ModuleCoreUIPlugin.log(e);
				continue;
			}
			
		}
		return masterStatus;
	}	
}

Back to the top