portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From morci...@apache.org
Subject cvs commit: jakarta-jetspeed/webapp/WEB-INF/templates/vm/screens/html ImportPsml.vm
Date Thu, 29 Jan 2004 20:36:54 GMT
morciuch    2004/01/29 12:36:54

  Modified:    .        README
  Added:       src/java/org/apache/jetspeed/modules/actions ImportPsml.java
               webapp/WEB-INF/templates/vm/screens/html ImportPsml.vm
  Log:
  Added utility template for populating db psml for the first time (see Bugzilla bug# 26536)
  
  Revision  Changes    Path
  1.28      +5 -0      jakarta-jetspeed/README
  
  Index: README
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/README,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- README	29 Oct 2003 22:55:34 -0000	1.27
  +++ README	29 Jan 2004 20:36:54 -0000	1.28
  @@ -188,6 +188,11 @@
   Then check the webapp/WEB-INF/log/jetspeed.log immediately after running import task. Actually,
the method of
   activating Torque logging will probaly change in Beta 5 but this method should still work
in Beta 2 thru Beta 4.
   
  +In release 1.5, Jetspeed ships with an on-line utility to do the initial db psml population.
You should configure
  +Jetspeed with DatabasePsmlManagerService, start it, login as an administrator and invoke
the following URL:
  +
  +http://localhost:8080/jetspeed/portal/template/ImportPsml.vm
  +
   ==============================================
   References usage notes for release 1.4
   ==============================================
  
  
  
  1.1                  jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/ImportPsml.java
  
  Index: ImportPsml.java
  ===================================================================
  
  package org.apache.jetspeed.modules.actions;
  
  // jetspeed stuff
  import org.apache.jetspeed.services.JetspeedSecurity;
  import org.apache.jetspeed.services.PsmlManager;
  import org.apache.jetspeed.services.psmlmanager.PsmlImporter;
  import org.apache.jetspeed.services.psmlmanager.PsmlManagerService;
  import org.apache.turbine.services.TurbineServices;
  import org.apache.turbine.util.Log;
  import org.apache.turbine.util.ParameterParser;
  import org.apache.turbine.util.RunData;
  
  /**
   * Import file psml into database action. This action is useful when populating
   * psml for the first time.
   * 
   * @author <a href="mark_orciuch@ngsltd.com">Mark Orciuch</a>
   * @version $Id: ImportPsml.java,v 1.1 2004/01/29 20:36:54 morciuch Exp $
   */
  public class ImportPsml extends org.apache.turbine.modules.Action
  {
  
      public static final String USER = "user";
      public static final String PASSWORD = "password";
      public static final String CHECK_IMPORT = "check-import";
  
      /**
       * Perform the action
       */
      public void doPerform(RunData data) throws Exception
      {
          try
          {
              ParameterParser parser = data.getParameters();
              //String username = parser.getString(USER, "admin");
              //String password = parser.getString(PASSWORD);
  			boolean checkImport = parser.getBoolean(CHECK_IMPORT, false);
  
              //JetspeedUser admin = JetspeedSecurity.login(username, password);
              String username = data.getUser().getUserName();
              if (!JetspeedSecurity.hasRole(username, "admin"))
              {
              	data.setMessage("Only administrator can perform this action");
                  throw new Exception("Only administrator can perform this action");
              }
  
              //
              // get a handle to the exporter service
              //
              PsmlManagerService exporterService = null;
              PsmlManagerService importerService = null;
  
              try
              {
                  exporterService = (PsmlManagerService)TurbineServices.getInstance().getService("PsmlImportManager");
              }
              catch (org.apache.turbine.services.InstantiationException e)
              {
                  String msg = "PSML Importer: error loading Psml Exporter Service";
                  data.setMessage(msg);
                  Log.error(msg, e);
              }
  
              //
              // get a handle to the importer service
              //
              try
              {
                  importerService = PsmlManager.getService();
              }
              catch (org.apache.turbine.services.InstantiationException e)
              {
                  String msg = "PSML Importer: error loading Psml Importer Service";
                  data.setMessage(msg);
                  Log.error(msg, e);
              }
  
              if (exporterService.getClass().getName().equals(importerService.getClass().getName()))
              {
                  String msg = "PSML Importer Error: Importer Class cannot equal Exporter
Class.";
                  data.setMessage(msg);
                  Log.error(msg);
              }
  
              PsmlImporter importer = new PsmlImporter();
              importer.setCheck(checkImport);
              boolean ran = importer.run(exporterService, importerService);
  
              if (ran)
              {
              	String msg = "**** PSML Importer - completed";
                  System.out.println(msg);
                  data.setMessage(msg);
              }        
              else
              {
  				String msg = "**** PSML Importer - did not run";
  				System.out.println(msg);
  				data.setMessage(msg);            	
              }
          }
          catch (Exception e)
          {
          	data.setMessage(e.getMessage());
              Log.error(e.getMessage());
          }
      }
  
  }
  
  
  1.1                  jakarta-jetspeed/webapp/WEB-INF/templates/vm/screens/html/ImportPsml.vm
  
  Index: ImportPsml.vm
  ===================================================================
  <div>
    <center>
      <table cellpadding="2" cellspacing="0" border="1" width="70%">
        <tr>
          <td align="center" colspan="3" class="INPUTFORMTITLE">
            $l10n.PSML_MANAGER_DETAIL_IMPORT_PSML
          </td>
        </tr>
        <tr>      
          <td class="INPUTFORM">
            #if ($data.Message)
              ## Message include account creation failure messages.
              <p><b>$data.Message</b></p>
            #end
            <form method="POST"                
                 enctype="application/x-www-form-urlencoded">
              <input name="$jslink.ActionKey" type="hidden" value="ImportPsml" />
              <center>
                <table border="0" cellspacing="2" cellpadding="1">
                  <tr>
                    <td COLSPAN="2"><B>This screen allows to perform the initial
psml import based on the options listed below:</B></td>
                  </tr>
                  <TR><TD>&nbsp;</TD></TR>
                  <TR>
                      <TD><B>Importer (source)</B></TD>
                      <TD>$config.getString("services.PsmlImportManager.classname")</TD>
                  </TR>
                  <TR>
                      <TD><B>Exporter (target)</B></TD>
                      <TD>$config.getString("services.PsmlManager.classname")</TD>
                  </TR>
                  <TR><TD>&nbsp;</TD></TR>                
                  <tr>
                    <td colspan="2">
                      <input name="check-import" type="checkbox">
                      ##$l10n.LOGIN_REMEMBERME
                      <B>Do not replace existing psml (checking this box will abort
import if psml is already populated)</B>
                    </td>
                  </tr>
                  <TR><TD>&nbsp;</TD></TR>                
                  <tr>
                    <td colspan="2" align="center">
                      <input name="submit" type="submit" value="$l10n.PSML_MANAGER_BROWSER_IMPORT">
                    </td>
                  </tr>
                </table>
              </form>
            </center>
          </td>
        </tr>
      </table>
    </center>
  </div>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org


Mime
View raw message