protected void addToWar(IVirtualComponent warComp, IVirtualComponent j2eeComp, String moduleURI) {
    final IDataModel dataModel =
        DataModelFactory.createDataModel(
            new AddWebFragmentComponentToWebApplicationDataModelProvider());
    Map map =
        (Map)
            dataModel.getProperty(
                IAddWebFragmentComponentToWebApplicationDataModelProperties
                    .TARGET_COMPONENTS_TO_URI_MAP);
    map.put(j2eeComp, moduleURI);

    dataModel.setProperty(ICreateReferenceComponentsDataModelProperties.SOURCE_COMPONENT, warComp);

    List modList =
        (List)
            dataModel.getProperty(
                ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST);
    modList.add(j2eeComp);
    dataModel.setProperty(
        ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENT_LIST, modList);
    dataModel.setProperty(
        ICreateReferenceComponentsDataModelProperties.TARGET_COMPONENTS_DEPLOY_PATH,
        "/WEB-INF/lib"); //$NON-NLS-1$
    try {
      dataModel.getDefaultOperation().execute(null, null);
    } catch (ExecutionException e) {
      J2EEPlugin.logError(e);
    }
  }
  private Action getNewLiferayFacetInstallAction(String pluginType) {
    Action retval = null;
    IProjectFacetVersion newFacet = null;
    IDataModelProvider dataModel = null;

    if (ILiferayMavenConstants.PORTLET_PLUGIN_TYPE.equals(pluginType)) {
      newFacet = IPluginFacetConstants.LIFERAY_PORTLET_PROJECT_FACET.getDefaultVersion();
      dataModel = new MavenPortletPluginFacetInstallProvider();
    } else if (ILiferayMavenConstants.HOOK_PLUGIN_TYPE.equals(pluginType)) {
      newFacet = IPluginFacetConstants.LIFERAY_HOOK_PROJECT_FACET.getDefaultVersion();
      dataModel = new MavenHookPluginFacetInstallProvider();
    } else if (ILiferayMavenConstants.EXT_PLUGIN_TYPE.equals(pluginType)) {
      newFacet = IPluginFacetConstants.LIFERAY_EXT_PROJECT_FACET.getDefaultVersion();
      dataModel = new MavenExtPluginFacetInstallProvider();
    } else if (ILiferayMavenConstants.LAYOUTTPL_PLUGIN_TYPE.equals(pluginType)) {
      newFacet = IPluginFacetConstants.LIFERAY_LAYOUTTPL_PROJECT_FACET.getDefaultVersion();
      dataModel = new MavenLayoutTplPluginFacetInstallProvider();
    } else if (ILiferayMavenConstants.THEME_PLUGIN_TYPE.equals(pluginType)) {
      newFacet = IPluginFacetConstants.LIFERAY_THEME_PROJECT_FACET.getDefaultVersion();
      dataModel = new MavenThemePluginFacetInstallProvider();
    }

    if (newFacet != null) {
      final IDataModel config = DataModelFactory.createDataModel(dataModel);
      retval = new Action(Action.Type.INSTALL, newFacet, config);
    }

    return retval;
  }
 private IDataModel getWebModelConfig(String warSourceDirectory, String contextRoot) {
   IDataModel webModelCfg =
       DataModelFactory.createDataModel(new WebFacetInstallDataModelProvider());
   webModelCfg.setProperty(
       IJ2EEModuleFacetInstallDataModelProperties.CONFIG_FOLDER, warSourceDirectory);
   webModelCfg.setProperty(IWebFacetInstallDataModelProperties.CONTEXT_ROOT, contextRoot);
   webModelCfg.setProperty(IJ2EEModuleFacetInstallDataModelProperties.GENERATE_DD, false);
   return webModelCfg;
 }
 /**
  * Install a Web Facet version
  *
  * @param mavenProject
  * @param warSourceDirectory
  * @param actions
  * @param webFv
  */
 private void installWebFacet(
     MavenProject mavenProject,
     String warSourceDirectory,
     String contextRoot,
     Set<Action> actions,
     IProjectFacetVersion webFv) {
   IDataModel webModelCfg =
       DataModelFactory.createDataModel(new WebFacetInstallDataModelProvider());
   webModelCfg.setProperty(
       IJ2EEModuleFacetInstallDataModelProperties.CONFIG_FOLDER, warSourceDirectory);
   webModelCfg.setProperty(IWebFacetInstallDataModelProperties.CONTEXT_ROOT, contextRoot);
   webModelCfg.setProperty(IJ2EEModuleFacetInstallDataModelProperties.GENERATE_DD, false);
   actions.add(
       new IFacetedProject.Action(IFacetedProject.Action.Type.INSTALL, webFv, webModelCfg));
 }
  private void createServiceXmlFile(String version, boolean useSample) throws Exception {
    final IProject project = createProject("serviceXmlFiles-" + version + "-" + useSample);

    final IDataModel model =
        DataModelFactory.createDataModel(new NewServiceBuilderDataModelProvider());

    model.setProperty(NewServiceBuilderDataModelProvider.AUTHOR, "junit");
    model.setProperty(NewServiceBuilderDataModelProvider.PACKAGE_PATH, "com.liferay.sample");
    model.setProperty(NewServiceBuilderDataModelProvider.NAMESPACE, "SAMPLE");
    model.setBooleanProperty(NewServiceBuilderDataModelProvider.USE_SAMPLE_TEMPLATE, useSample);

    final IFolder folder = project.getFolder("test");

    CoreUtil.prepareFolder(folder);

    final IFile serviceXmlFile = folder.getFile("service.xml");

    assertEquals(false, serviceXmlFile.exists());

    WizardUtil.createDefaultServiceBuilderFile(
        serviceXmlFile,
        version,
        model.getBooleanProperty(NewServiceBuilderDataModelProvider.USE_SAMPLE_TEMPLATE),
        model.getStringProperty(NewServiceBuilderDataModelProvider.PACKAGE_PATH),
        model.getStringProperty(NewServiceBuilderDataModelProvider.NAMESPACE),
        model.getStringProperty(NewServiceBuilderDataModelProvider.AUTHOR),
        new NullProgressMonitor());

    assertEquals(true, serviceXmlFile.exists());

    final String serviceXmlContent = CoreUtil.readStreamToString(serviceXmlFile.getContents());

    final String expectedServiceXmlContent =
        CoreUtil.readStreamToString(
            this.getClass()
                .getResourceAsStream("files/service-sample-" + version + "-" + useSample + ".xml"));

    assertEquals(
        stripCarriageReturns(expectedServiceXmlContent), stripCarriageReturns(serviceXmlContent));
  }