/**
   * Register the portlets on the given configuration files
   *
   * @param xmls
   * @throws Exception
   */
  @SuppressWarnings("unchecked")
  protected Collection<Portlet> registerPortlets(BundleContext context, String[] xmls)
      throws Exception {

    String[] confFiles =
        new String[] {
          Http.URLtoString(context.getBundle().getResource(xmls[0])),
          Http.URLtoString(context.getBundle().getResource(xmls[1]))
        };

    // Read the portlets xml files and create them
    portlets = PortletManagerUtil.initWAR(null, confFiles);

    for (Portlet portlet : portlets) {

      if (portlet.getPortletClass().equals("com.liferay.portlet.JSPPortlet")) {

        Map initParams = portlet.getInitParams();
        String jspPath = (String) initParams.get(INIT_PARAM_VIEW_JSP);

        if (!jspPath.startsWith(PATH_SEPARATOR)) {
          jspPath = PATH_SEPARATOR + jspPath;
        }

        // Copy all the resources inside the folder of the given resource to the corresponding
        // dotCMS folders
        activatorUtil.moveResources(context, jspPath);
        portlet
            .getInitParams()
            .put(INIT_PARAM_VIEW_JSP, activatorUtil.getBundleFolder(context) + jspPath);
      } else if (portlet.getPortletClass().equals("com.liferay.portlet.VelocityPortlet")) {

        Map initParams = portlet.getInitParams();
        String templatePath = (String) initParams.get(INIT_PARAM_VIEW_TEMPLATE);

        if (!templatePath.startsWith(PATH_SEPARATOR)) {
          templatePath = PATH_SEPARATOR + templatePath;
        }

        // Copy all the resources inside the folder of the given resource to the corresponding
        // velocity dotCMS folders
        activatorUtil.moveVelocityResources(context, templatePath);
        portlet
            .getInitParams()
            .put(INIT_PARAM_VIEW_TEMPLATE, activatorUtil.getBundleFolder(context) + templatePath);
      }

      Logger.info(this, "Added Portlet: " + portlet.getPortletId());
    }

    return portlets;
  }
  /**
   * Method that will create and add an ActionForward to a ActionMapping, this call is mandatory for
   * the creation of ActionForwards because extra logic will be required for jsp forwards to work.
   *
   * @param actionMapping
   * @param name
   * @param path
   * @param redirect
   * @return
   * @throws Exception
   */
  protected ForwardConfig registerActionForward(
      BundleContext context,
      ActionMapping actionMapping,
      String name,
      String path,
      Boolean redirect)
      throws Exception {

    if (!path.startsWith(PATH_SEPARATOR)) {
      path = PATH_SEPARATOR + path;
    }

    String forwardMapping = activatorUtil.getBundleFolder(context) + path;

    // Creating an ForwardConfig Instance
    ForwardConfig forwardConfig = new ActionForward(name, forwardMapping, redirect);
    // Adding the ForwardConfig to the ActionConfig
    actionMapping.addForwardConfig(forwardConfig);

    // Copy all the resources inside the folder of the given resource to the corresponding dotCMS
    // folders
    activatorUtil.moveResources(context, path);

    return forwardConfig;
  }