|
Added
Link Here
|
| 1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2010 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 |
* |
| 8 |
* Contributors: |
| 9 |
* IBM Corporation - initial API and implementation |
| 10 |
*******************************************************************************/ |
| 11 |
package org.eclipse.jst.j2ee.internal.ui; |
| 12 |
|
| 13 |
import java.util.ArrayList; |
| 14 |
import java.util.List; |
| 15 |
|
| 16 |
import org.eclipse.core.resources.IProject; |
| 17 |
import org.eclipse.core.runtime.IConfigurationElement; |
| 18 |
import org.eclipse.core.runtime.IStatus; |
| 19 |
import org.eclipse.core.runtime.MultiStatus; |
| 20 |
import org.eclipse.core.runtime.Status; |
| 21 |
import org.eclipse.jst.j2ee.internal.ui.J2EEModuleDependenciesPropertyPage.ClasspathEntryProxy; |
| 22 |
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; |
| 23 |
import org.eclipse.wst.common.componentcore.resources.IVirtualReference; |
| 24 |
import org.eclipse.wst.common.componentcore.ui.Messages; |
| 25 |
import org.eclipse.wst.common.componentcore.ui.ModuleCoreUIPlugin; |
| 26 |
import org.eclipse.wst.common.componentcore.ui.internal.propertypage.verifier.DeploymentAssemblyVerifierHelper; |
| 27 |
import org.eclipse.wst.common.componentcore.ui.internal.propertypage.verifier.IDeploymentAssemblyVerifier; |
| 28 |
import org.eclipse.wst.common.componentcore.ui.internal.propertypage.verifier.VerifierRegistryReader; |
| 29 |
import org.eclipse.wst.common.componentcore.ui.propertypage.AddModuleDependenciesPropertiesPage.ComponentResourceProxy; |
| 30 |
import org.eclipse.wst.server.core.IRuntime; |
| 31 |
|
| 32 |
public class J2EEModuleDeploymentAssemblyVerifierHelper { |
| 33 |
|
| 34 |
|
| 35 |
/** |
| 36 |
* This method will use the facet framework to find all registered verifiers based on installed facets and runtimes. |
| 37 |
* All the verifiers will have an opportunity to verify and return status on the proposed component mappings |
| 38 |
* @param component |
| 39 |
* @param runtime |
| 40 |
* @param resourceMappingsChanged |
| 41 |
* @param resourceMappings |
| 42 |
* @param currentReferences |
| 43 |
* @param currentClasspathEntries |
| 44 |
* @return IStatus |
| 45 |
*/ |
| 46 |
public static IStatus verify(IVirtualComponent component,IRuntime runtime, ArrayList<IVirtualReference> currentReferences, ArrayList<ComponentResourceProxy> resourceMappings, boolean resourceMappingsChanged, List<ClasspathEntryProxy> currentClasspathEntries) { |
| 47 |
IProject project = component.getProject(); |
| 48 |
|
| 49 |
List verifiers = DeploymentAssemblyVerifierHelper.collectAllVerifiers(project,runtime); |
| 50 |
if (verifiers.isEmpty()) return Status.OK_STATUS; |
| 51 |
MultiStatus masterStatus = new MultiStatus(ModuleCoreUIPlugin.PLUGIN_ID, IStatus.OK, Messages.DeploymentAssemblyVerifierHelper_0,null); |
| 52 |
|
| 53 |
for (int i = 0; i < verifiers.size(); i++) { |
| 54 |
if (!(verifiers.get(i) instanceof IConfigurationElement)) |
| 55 |
continue; |
| 56 |
IDeploymentAssemblyVerifier verifier = null; |
| 57 |
try { |
| 58 |
verifier = (IDeploymentAssemblyVerifier) ((IConfigurationElement) verifiers.get(i)).createExecutableExtension(VerifierRegistryReader.VERIFIER_CLASS); |
| 59 |
J2EEModuleDeploymentAssemblyVerifierData data = new J2EEModuleDeploymentAssemblyVerifierData(component, runtime,currentReferences,resourceMappings,resourceMappingsChanged,currentClasspathEntries ); |
| 60 |
IStatus verifyStatus = verifier.verify(data); |
| 61 |
masterStatus.add(verifyStatus); |
| 62 |
} catch (Exception e) { |
| 63 |
ModuleCoreUIPlugin.log(e); |
| 64 |
continue; |
| 65 |
} |
| 66 |
|
| 67 |
} |
| 68 |
return masterStatus; |
| 69 |
} |
| 70 |
} |