/**
   * 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;
  }