示例#1
0
 @Override
 public void init(ServletConfig config) throws ServletException {
   HelperLoader.init();
   ServletContext servletContext = config.getServletContext();
   ServletRegistration jspServlet = servletContext.getServletRegistration("jsp");
   jspServlet.addMapping(ConfigHelper.getAppJspPath() + "*");
   ServletRegistration defaultServlet = servletContext.getServletRegistration("default");
   defaultServlet.addMapping(ConfigHelper.getAppAssetPath() + "*");
 }
  private void updateConfigFile() throws EnhancedException {

    // for SDK cobundles with JDK - see if cobundled JDK exists and use that
    // checks for jdk7 directory since we only have JDK 7 cobundles

    if (org.glassfish.installer.util.FileUtils.isFileExist(
        productRef.getInstallLocation() + File.separator + "jdk7")) {
      jdkHome = productRef.getInstallLocation() + File.separator + "jdk7";

      // on Unix, set executable permissions to jdk7/bin/* and jdk7/jre/bin/*
      if (!OSUtils.isWindows()) {
        org.glassfish.installer.util.FileUtils.setAllFilesExecutable(
            productRef.getInstallLocation() + File.separator + "jdk7" + File.separator + "bin");
        org.glassfish.installer.util.FileUtils.setAllFilesExecutable(
            productRef.getInstallLocation()
                + File.separator
                + "jdk7"
                + File.separator
                + "jre"
                + File.separator
                + "bin");
      }
    } else {

      // For all installation modes, fetch JAVA_HOME from panel;
      // on MacOS and AIX use java.home property since panel is skipped

      try {
        if (OSUtils.isMac() || OSUtils.isAix()) {
          jdkHome = System.getProperty("java.home");
        } else {
          jdkHome = ConfigHelper.getStringValue("JDKSelection.directory.SELECTED_JDK");
        }
      } catch (Exception e) {
        jdkHome = new File(System.getProperty("java.home")).getParent();
        if (OSUtils.isMac() || OSUtils.isAix()) {
          jdkHome = System.getProperty("java.home");
        }
      }
    }
    LOGGER.log(Level.INFO, Msg.get("UPDATE_CONFIG_HEADER", null));
    LOGGER.log(Level.INFO, Msg.get("JDK_HOME", new String[] {jdkHome}));
    // write jdkHome value to asenv.bat on Windows, asenv.conf on non-Windows platform...
    try {
      FileIOUtils configFile = new FileIOUtils();
      configFile.openFile(productRef.getConfigFilePath());
      /* Add AS_JAVA to end of buffer and file. */
      if (OSUtils.isWindows()) {
        configFile.appendLine("set AS_JAVA=" + jdkHome);
      } else {
        configFile.appendLine("AS_JAVA=" + jdkHome);
      }
      configFile.saveFile();
      configFile.closeFile();
    } catch (Exception ex) {
      LOGGER.log(Level.FINEST, ex.getMessage());
    }
  }
  /**
   * The doGet method of the servlet. <br>
   * This method is called when a form has its tag value method equals to get.
   *
   * @param request the request send by the client to the server
   * @param response the response send by the server to the client
   * @throws ServletException if an error occurred
   * @throws IOException if an error occurred
   */
  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    try {
      String samlId = request.getParameter("id");
      if (StringUtils.isEmpty(samlId)) {
        throw new RuntimeException("Missing ID!");
      }
      String hostname = request.getParameter("hostname");
      String port = request.getParameter("port");
      String protocol = request.getParameter("protocol");

      Properties properties = ConfigHelper.getConfigProperties();
      NetworkConnectorManager connectionManager =
          ConfigHelper.getNetworkConnectorManager(properties);
      ArtifactResolvServiceClient client = new ArtifactResolvServiceClientImpl(properties);
      connectionManager.setProtocol(protocol);

      if (StringUtils.isNotEmpty(hostname)) {
        connectionManager.setServerName(hostname);
      }

      if (StringUtils.isNotEmpty(port)) {
        connectionManager.setServerPort(Integer.parseInt(port));
      }

      String responseXML = client.submit(connectionManager.getConnector(), samlId);
      // request.setAttribute("responseFormatXML", XMLFormat.formatXml(responseXML));

      responseXML = StringUtils.replace(responseXML, "<", "&lt;");
      responseXML = StringUtils.replace(responseXML, ">", "&gt;");
      request.setAttribute("responseXML", responseXML);
      this.getServletConfig()
          .getServletContext()
          .getRequestDispatcher("/WEB-INF/jsp/test-tool/view_message.jsp")
          .forward(request, response);
      // response.setContentType("text/xml;charset=UTF-8");
      // PrintWriter writer = response.getWriter();
      // writer.write(responseXML);
      // writer.flush();
    } catch (ClientException e) {
      throw new ServletException(e);
    } catch (Exception e) {
      throw new ServletException(e);
    }
  }
 protected AbstractColumnFamilyRecordWriter(Configuration conf) {
   this.conf = conf;
   this.ringCache = new RingCache(conf);
   this.queueSize =
       conf.getInt(
           AbstractColumnFamilyOutputFormat.QUEUE_SIZE, 32 * FBUtilities.getAvailableProcessors());
   batchThreshold = conf.getLong(AbstractColumnFamilyOutputFormat.BATCH_THRESHOLD, 32);
   consistencyLevel = ConsistencyLevel.valueOf(ConfigHelper.getWriteConsistencyLevel(conf));
 }
 public static Connection getConnection() {
   Connection conn = CONNECTION_HOLDER.get();
   if (conn == null) {
     String driver = ConfigHelper.getJdbcDriver();
     String url = ConfigHelper.getJdbcUrl();
     String userName = ConfigHelper.getJdbcUserName();
     String passwd = ConfigHelper.getJdbcPassword();
     try {
       Class.forName(driver);
       conn = DriverManager.getConnection(url, userName, passwd);
     } catch (Exception e) {
       LOGGER.error("get connection error", e);
       throw new RuntimeException(e);
     } finally {
       CONNECTION_HOLDER.set(conn);
     }
   }
   return conn;
 }
  public static void main(String[] args) throws Exception {
    if (args.length < 2) {
      System.err.println(
          "Usage: java "
              + WorkflowExecutionHistoryPrinter.class.getName()
              + " <workflowId> <runId>");
      System.exit(1);
    }
    ConfigHelper configHelper = ConfigHelper.createConfig();
    AmazonSimpleWorkflow swfService = configHelper.createSWFClient();
    String domain = configHelper.getDomain();

    WorkflowExecution workflowExecution = new WorkflowExecution();
    String workflowId = args[0];
    workflowExecution.setWorkflowId(workflowId);
    String runId = args[1];
    workflowExecution.setRunId(runId);
    System.out.println(
        WorkflowExecutionUtils.prettyPrintHistory(swfService, domain, workflowExecution, true));
  }
示例#7
0
  /**
   * @short Create the environment for following tests.
   * @descr create an empty test frame, where we can load different components inside.
   */
  @Before
  public void before() {
    m_aLog =
        new Protocol(
            Protocol.MODE_HTML | Protocol.MODE_STDOUT,
            Protocol.FILTER_NONE,
            utils.getUsersTempDir() + "/complex_log_ascii_01.html");

    try {
      // get uno service manager from global test environment
      m_xSMGR = getMSF();

      // get another helper to e.g. create test documents
      m_aSOF = SOfficeFactory.getFactory(m_xSMGR);

      // create AutoSave instance
      m_xAutoSave = theAutoRecovery.get(connection.getComponentContext());

      // prepare AutoSave
      // make sure it will be started every 1 min
      ConfigHelper aConfig =
          new ConfigHelper(
              connection.getComponentContext(), "org.openoffice.Office.Recovery", false);
      aConfig.writeRelativeKey("AutoSave", "Enabled", Boolean.TRUE);
      aConfig.writeRelativeKey("AutoSave", "TimeIntervall", Integer.valueOf(1)); // 1 min
      aConfig.flush();
      aConfig = null;

      // is needed to parse dispatch commands
      m_xURLParser =
          UnoRuntime.queryInterface(
              XURLTransformer.class, m_xSMGR.createInstance("com.sun.star.util.URLTransformer"));

    } catch (java.lang.Throwable ex) {
      m_aLog.log(ex);
      fail("Couldn't create test environment");
    }
  }
 public static byte[] decompressWithProcessor(final byte[] value) {
   byte[] result = new byte[0];
   //
   // result = (byte[]) compressProcessorCacheFactory
   // .execute(new CacheCallback<CompressProcessor>() {
   // public Object doInAction(CompressProcessor obj)
   // throws CacheException {
   // try {
   // return obj.uncompress(value);
   // } catch (Exception ex) {
   // throw new CacheException(ex);
   // } finally {
   // }
   // }
   // });
   //
   CompressProcessor obj = new CompressProcessorImpl();
   obj.setCompress(ConfigHelper.isCompress());
   obj.setCompressType(ConfigHelper.getCompressType());
   result = obj.uncompress(value);
   //
   return result;
 }
示例#9
0
 static {
   String basePackage = ConfigHelper.getAppBasePackage();
   CLASS_SET = ClassUtil.getClassSet(basePackage);
 }
示例#10
0
  @Override
  protected void service(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {

    String requestMethod = req.getMethod().toLowerCase();
    String requestPath = req.getPathInfo();
    Handler handler = ControllerHelper.getHandler(requestMethod, requestPath);
    if (handler != null) {

      Class<?> controllerClass = handler.getControllerClass();
      Object controllerBean = BeanHelper.getBean(controllerClass);
      Map<String, Object> paramMap = new HashMap<String, Object>();
      Enumeration<String> paramNames = req.getParameterNames();
      while (paramNames.hasMoreElements()) {
        String paramName = paramNames.nextElement();
        String paramValue = req.getParameter(paramName);
        paramMap.put(paramName, paramValue);
      }
      String body = CodecUtil.decodeURL(StreamUtil.getString(req.getInputStream()));
      if (StringUtil.isNotEmpty(body)) {
        String[] params = StringUtil.splitString(body, "&");
        if (ArrayUtil.isNotEmpty(params)) {
          for (String param : params) {
            String[] array = StringUtil.splitString(param, "=");
            if (ArrayUtil.isNotEmpty(array) && array.length == 2) {
              String paramName = array[0];
              String paramValue = array[1];
              paramMap.put(paramName, paramValue);
            }
          }
        }
      }

      Param param = new Param(paramMap);
      Method actionMethod = handler.getActionMethod();
      Object result = ReflectionUtil.invokeMethod(controllerBean, actionMethod, param);
      if (result instanceof View) {
        View view = (View) result;
        String path = view.getPath();
        if (StringUtil.isNotEmpty(path)) {
          if (path.startsWith("/")) {
            resp.sendRedirect(req.getContextPath() + path);
          } else {
            Map<String, Object> model = view.getModel();
            for (Map.Entry<String, Object> entry : model.entrySet()) {
              req.setAttribute(entry.getKey(), entry.getValue());
            }
            req.getRequestDispatcher(ConfigHelper.getAppJspPath() + path).forward(req, resp);
          }
        }

      } else if (result instanceof Data) {
        Data data = (Data) result;
        Object model = data.getModel();
        if (model != null) {
          resp.setContentType("application/json");
          resp.setCharacterEncoding("UTF-8");
          PrintWriter writer = resp.getWriter();
          String json = JsonUtil.toJSON(model);
          writer.write(json);
          writer.flush();
          writer.close();
        }
      }
    }
  }
示例#11
0
  /* Run configuration steps for update tool component. */
  public void configureUpdatetool() throws Exception {

    // set execute permissions for UC utilities
    if (!OSUtils.isWindows()) {
      LOGGER.log(Level.INFO, Msg.get("SETTING_EXECUTE_PERMISSIONS_FOR_UPDATETOOL", null));
      org.glassfish.installer.util.FileUtils.setExecutable(
          productRef.getInstallLocation() + "/bin/pkg");
      org.glassfish.installer.util.FileUtils.setExecutable(
          productRef.getInstallLocation() + "/bin/updatetool");
    }

    setupUpdateToolScripts();

    // check whether to bootstrap at all
    if (!ConfigHelper.getBooleanValue("UpdateTool.Configuration.BOOTSTRAP_UPDATETOOL")) {
      LOGGER.log(Level.INFO, Msg.get("SKIPPING_UPDATETOOL_BOOTSTRAP", null));
    } else {
      boolean allowUpdateCheck =
          ConfigHelper.getBooleanValue("UpdateTool.Configuration.ALLOW_UPDATE_CHECK");
      String proxyHost = configData.get("PROXY_HOST");
      String proxyPort = configData.get("PROXY_PORT");
      // populate bootstrap properties
      Properties props = new Properties();
      if (OSUtils.isWindows()) {
        props.setProperty("image.path", productRef.getInstallLocation().replace('\\', '/'));
      } else {
        props.setProperty("image.path", productRef.getInstallLocation());
      }
      props.setProperty("install.pkg", "true");
      if (!OSUtils.isAix()) {
        props.setProperty("install.updatetool", "true");
      } else {
        props.setProperty("install.updatetool", "false");
      }
      props.setProperty("optin.update.notification", allowUpdateCheck ? "true" : "false");

      props.setProperty("optin.usage.reporting", allowUpdateCheck ? "true" : "false");
      if ((proxyHost.length() > 0) && (proxyPort.length() > 0)) {
        props.setProperty("proxy.URL", "http://" + proxyHost + ":" + proxyPort);
      }
      LOGGER.log(Level.INFO, Msg.get("BOOTSTRAPPING_UPDATETOOL", null));
      LOGGER.log(Level.FINEST, props.toString());

      // explicitly refreshing catalogs, workaround for bootstrap issue
      // proceed to bootstrap if there is an exception
      try {
        SystemInfo.initUpdateToolProps(props);
        Image img = new Image(productRef.getInstallLocation());
        img.refreshCatalogs();
      } catch (Exception e) {
        LOGGER.log(Level.FINEST, e.getMessage());
      }

      // invoke bootstrap
      Bootstrap.main(props, LOGGER);
    }
    // Create the required windows start->menu shortcuts for updatetool.
    if (OSUtils.isWindows()) {
      createUpdatetoolShortCuts();
    }
  }
示例#12
0
 /**
  * Attempt to load the hoya client resource. If the resource is not on the CP an empty config is
  * returned.
  *
  * @return a config
  */
 public static Configuration loadHoyaClientConfigurationResource() {
   return ConfigHelper.loadFromResource(HoyaKeys.HOYA_CLIENT_RESOURCE);
 }
示例#13
0
 /**
  * Register the client resource in {@link HoyaKeys#HOYA_CLIENT_RESOURCE} for Configuration
  * instances.
  *
  * @return true if the resource could be loaded
  */
 public static URL registerHoyaClientResource() {
   return ConfigHelper.registerDefaultResource(HoyaKeys.HOYA_CLIENT_RESOURCE);
 }