public String provideIframePanelUri(ActivityInstance ai, View view) {
    String uri = null;

    try {
      FacesContext jsfContext = FacesContext.getCurrentInstance();

      // must prefix root relative URIs with the current context root
      if (isIceFacesPanel(ai)) {
        uri = jsfContext.getExternalContext().getRequestContextPath() + providePanelUri(ai);
      } else {
        // TODO configure servlet mapping
        uri =
            jsfContext.getExternalContext().getRequestContextPath()
                + "/faces"
                + VIEW_ID_NON_IFACE_FACELET_CONTAINER;
      }
    } catch (Exception e) {
      // not in JSF?
      trace.warn("Failed determining context root.", e);
    }

    if (StringUtils.isNotEmpty(uri)) {
      uri += (-1 == uri.indexOf("?")) ? "?" : "&";
      uri +=
          IframePanelConstants.QSTR_VIEW_URL
              + "="
              + new String(Base64.encode(view.getUrl().getBytes()));
    }

    return uri;
  }
Exemplo n.º 2
0
 private static void addArgument(
     StringBuilder programAttributes,
     String name,
     String value,
     boolean encode,
     boolean separator) {
   if (separator) {
     programAttributes.append(' '); // $NON-NLS-1$
   }
   programAttributes.append("--"); // $NON-NLS-1$
   programAttributes.append(name); // $NON-NLS-1$
   programAttributes.append(' ');
   programAttributes.append(encode ? new String(Base64.encode(value.getBytes())) : value);
 }
Exemplo n.º 3
0
  public static boolean deployModel(
      List<IResource> resources, String carnotHome, String carnotWork) {
    boolean deployed = false;

    if (null != resources && !resources.isEmpty()) {
      try {
        IProject project = getCommonProject(resources);
        ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
        ILaunchConfigurationType type =
            manager.getLaunchConfigurationType(
                IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION);
        ILaunchConfigurationWorkingCopy wc =
            type.newInstance(null, "Infinity Process Model Deployment"); // $NON-NLS-1$
        wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, project.getName());
        wc.setAttribute(
            IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER,
            ModelingCoreActivator.ID_DEPLOY_MODEL_CP_PROVIDER);
        wc.setAttribute(
            IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME,
            ModelDeploymentTool.class.getName());
        // Activate if debugging deployment is needed.
        // String debug =
        // " -Xdebug -Xnoagent -Djava.compiler=NONE
        // -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000";
        // String debug =
        // " -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000";
        wc.setAttribute(
            IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,
            "-Xms50m -Xmx256m" + getLocaleArgs()); // $NON-NLS-1$
        // "-Xms50m -Xmx256m" + debug);

        boolean version =
            PlatformUI.getPreferenceStore().getBoolean(BpmProjectNature.PREFERENCE_DEPLOY_version);

        String realm =
            PlatformUI.getPreferenceStore().getString(BpmProjectNature.PREFERENCE_DEPLOY_realm);
        String partition =
            PlatformUI.getPreferenceStore().getString(BpmProjectNature.PREFERENCE_DEPLOY_partition);
        String user =
            PlatformUI.getPreferenceStore().getString(BpmProjectNature.PREFERENCE_DEPLOY_id);
        String password =
            PlatformUI.getPreferenceStore().getString(BpmProjectNature.PREFERENCE_DEPLOY_password);
        String domain =
            PlatformUI.getPreferenceStore().getString(BpmProjectNature.PREFERENCE_DEPLOY_domain);

        StringBuilder programAttributes = new StringBuilder();
        boolean separator = false;
        for (IResource resource : resources) {
          // addArgument(programAttributes, "filename64", resource.getLocation().toOSString(), true,
          // separator);
          // separator = true;
          try {
            String fileName = resource.getLocation().toOSString();
            String encodedFileName =
                new String(Base64.encode(fileName.getBytes(XpdlUtils.UTF8_ENCODING)));
            addArgument(
                programAttributes, "filename64", encodedFileName, false, separator); // $NON-NLS-1$
            separator = true;
          } catch (UnsupportedEncodingException e) {
            // should never happen since UTF-8 is standard supported on all java versions.
            e.printStackTrace();
          }
        }
        if (version) {
          addArgument(
              programAttributes,
              "version",
              Boolean.TRUE.toString(),
              false,
              true); //$NON-NLS-1$ //$NON-NLS-2$
        }

        if (!StringUtils.isEmpty(user) && !StringUtils.isEmpty(password)) {
          addArgument(programAttributes, "user", user, true, true); // $NON-NLS-1$
          addArgument(
              programAttributes, "password", password, true, true); // $NON-NLS-1$

          if (!StringUtils.isEmpty(realm)) {
            addArgument(programAttributes, "realm", realm, true, true); // $NON-NLS-1$
          }

          if (!StringUtils.isEmpty(partition)) {
            addArgument(
                programAttributes, "partition", partition, true, true); // $NON-NLS-1$
          }

          if (!StringUtils.isEmpty(domain)) {
            addArgument(programAttributes, "domain", domain, true, true); // $NON-NLS-1$
          }
        }

        wc.setAttribute(
            IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, programAttributes.toString());

        wc.setAttribute(CarnotToolClasspathProvider.ATTR_HOME_LOCATION, carnotHome);
        wc.setAttribute(CarnotToolClasspathProvider.ATTR_WORK_LOCATION, carnotWork);

        wc.setAttribute(
            CarnotToolClasspathProvider.ATTR_EXTRA_LOCATION,
            BpmCoreLibrariesClasspathContainer.getLibraryLocation(
                    DeployPlugin.PLUGIN_ID, new String[] {"bin", ""})
                .toString()); //$NON-NLS-1$ //$NON-NLS-2$

        ILaunchConfiguration config = wc.doSave();
        ILaunch toolLaunch = config.launch(ILaunchManager.RUN_MODE, null);

        deployed = (0 < toolLaunch.getProcesses().length);

        config.delete();
        wc.delete();
      } catch (CoreException e) {
        // TODO
        e.printStackTrace();
      }
    }
    return deployed;
  }