PageBoxLib
Class DeployImpl

java.lang.Object
  extended byPageBoxLib.TokenImpl
      extended byPageBoxLib.DeployImpl
All Implemented Interfaces:
DeployIF, java.rmi.Remote, TokenIF

public class DeployImpl
extends TokenImpl
implements DeployIF

Deployment Web Service.

Changes:

alexis.grandemange@pagebox.net

Copyright (c) 2002-2004 Alexis Grandemange

This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU Lesser General Public License
 as published by the Free Software Foundation; version 2.1 of the
 License.
 This library is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 GNU Lesser General Public License for more details.
 A copy of the GNU Lesser General Public License lesser.txt should be
 included in the distribution.

Version:
0, 1, 0
Author:
Alexis Grandemange

Nested Class Summary
 
Nested classes inherited from class PageBoxLib.TokenImpl
TokenImpl.Context, TokenImpl.TokenThread
 
Nested classes inherited from class PageBoxLib.DeployIF
DeployIF.Status, DeployIF.UrlUser
 
Field Summary
(package private)  java.util.TreeMap archives
          Archives currently installed Key: archive name Value: Archive object
(package private)  ASInstallIF ASInstaller
          Application Server Installation object
(package private) static int COPY
          Copy
(package private) static int INSTALL
          Installation from docURL
(package private) static int NONE
          No authorization
(package private)  RepoTest rt
          Used to test the Repository
(package private)  RuleHandler.Rule rule
          Memory representation of rules.xml
(package private)  boolean rulesOK
          True if initialize succeeded
(package private)  java.lang.String subUrl
          URL of the DeployIF web service of this PageBox
(package private)  java.lang.String target
          Actual target from rule.target
 
Fields inherited from class PageBoxLib.TokenImpl
ctx, log, period, pingFrame, tcbi, tctx, tt, workDir
 
Constructor Summary
DeployImpl()
           
 
Method Summary
 DeployIF.Status add(java.lang.String arch, java.lang.String downloadURL, java.lang.String owner, byte[] archData, java.lang.String date, java.lang.String oldDate, java.lang.String docURL, java.lang.String user, boolean isUpdate, boolean runInstall, DeployIF.UrlUser[] relayed)
          DeployIF method.
private  DeployIF.Status addToPbArchs(java.lang.String arch, java.lang.String downloadURL, java.lang.String owner, byte[] archData, java.lang.String date, java.lang.String oldDate, java.lang.String docURL, java.lang.String user, boolean isUpdate, boolean runInstall, DeployIF.UrlUser[] relayed)
          Deploys an archive and returns a status.
 DeployIF.Status delete(java.lang.String arch, java.lang.String downloadURL, java.lang.String owner, java.lang.String user, boolean runRemove, boolean keepDir)
          DeployIF method.
private  void deleteDir(java.io.File f)
          Recursive directory delete.
private  DeployIF.Status deleteFromPbArchs(java.lang.String arch, java.lang.String downloadURL, java.lang.String owner, java.lang.String user, boolean runRemove, boolean keepDir)
          Undeploys an archive and returns a status.
 void destroy()
          ServiceLifeCycle method.
 java.lang.String getArchPath(java.lang.String arch)
          DeployIF method.
 java.lang.String getAudit(java.lang.String arch, java.lang.String owner, java.lang.String user, java.lang.String downloadURL)
          DeployIF method.
private static java.lang.String getAuthFromRule(int rule)
          Format a rule string for tracing
private  void init()
          Common initialization stuff.
 void init(java.lang.Object context)
          ServiceLifeCycle method.
 void init2(ServletContext ctx)
          Method called by HTTPDeploy
private  boolean initialize()
          Authorization restore from rules.xml.
private  DeployIF.Status install(java.lang.String arch, java.lang.String downloadURL, java.lang.String docURL, byte[] archData, boolean isUpdate, boolean isUpdate2, boolean runInstall, int auth, InstallHelper ih)
          Installs an archive and returns a status.
private  java.util.ArrayList listRules(java.util.HashMap rules)
          Enumerates publisherRules or repositoryRules.
 java.lang.String rename(java.lang.String oldDownloadURL, java.lang.String newDownloadURL, java.lang.String user)
          DeployIF method.
private  java.lang.String renameRepository(java.lang.String oldDownloadURL, java.lang.String newDownloadURL, java.lang.String user)
          Change the repository URL.
private  java.lang.String renameRepository2(java.lang.String oldDownloadURL, java.lang.String newDownloadURL)
          Change the repository URL.
private  java.lang.String restorePbArchs()
          Parse PbArchives.xml and set the archives HashMap.
private  java.lang.String savePbArchs()
          Save the archives HashMap in PbArchives.xml.
private  void saveRules()
          Save rules.xml.
private  DeployIF.Status uninstall(java.lang.String arch, java.lang.String downloadURL, java.lang.String docURL, boolean isUpdate, boolean runRemove, int auth, java.util.HashMap resources)
          Uninstalls an archive and returns a status.
 
Methods inherited from class PageBoxLib.TokenImpl
end, frameSend, frameSend2, frameSend3, test, tokenInit, tokenRenameRepository
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface PageBoxLib.TokenIF
frameSend
 

Field Detail

archives

java.util.TreeMap archives
Archives currently installed


subUrl

java.lang.String subUrl
URL of the DeployIF web service of this PageBox


target

java.lang.String target
Actual target from rule.target


NONE

static final int NONE
No authorization

See Also:
Constant Field Values

COPY

static final int COPY
Copy

See Also:
Constant Field Values

INSTALL

static final int INSTALL
Installation from docURL

See Also:
Constant Field Values

ASInstaller

ASInstallIF ASInstaller
Application Server Installation object


rulesOK

boolean rulesOK
True if initialize succeeded


rt

RepoTest rt
Used to test the Repository


rule

RuleHandler.Rule rule
Memory representation of rules.xml

Constructor Detail

DeployImpl

public DeployImpl()
Method Detail

add

public DeployIF.Status add(java.lang.String arch,
                           java.lang.String downloadURL,
                           java.lang.String owner,
                           byte[] archData,
                           java.lang.String date,
                           java.lang.String oldDate,
                           java.lang.String docURL,
                           java.lang.String user,
                           boolean isUpdate,
                           boolean runInstall,
                           DeployIF.UrlUser[] relayed)
DeployIF method.

Deploys an archive and returns a status.

Specified by:
add in interface DeployIF
Parameters:
arch - archive name.
downloadURL - download URL.
owner - user who published the archive.
archData - archive data.
date - publication date and time.
oldDate - expected previous publication date and time.
docURL - documentation URL.
user - user who subscribed the PageBox.
isUpdate - if true delta update
runInstall - if true run the Application server installer (Web application)
relayed - PageBox instances to deploy
Returns:
Status object

delete

public DeployIF.Status delete(java.lang.String arch,
                              java.lang.String downloadURL,
                              java.lang.String owner,
                              java.lang.String user,
                              boolean runRemove,
                              boolean keepDir)
DeployIF method.

Undeploys an archive and returns a status.

Specified by:
delete in interface DeployIF
Parameters:
arch - archive name.
downloadURL - download URL.
owner - user who published the archive.
user - user who subscribed the PageBox.
runRemove - if true run the Application server installer (Web application)
keepDir - keep directory
Returns:
Status object

rename

public java.lang.String rename(java.lang.String oldDownloadURL,
                               java.lang.String newDownloadURL,
                               java.lang.String user)
DeployIF method.

Change the repository URL.

Specified by:
rename in interface DeployIF
Parameters:
oldDownloadURL - previous download URL for some archives
newDownloadURL - new download URL for these archives
user - user who subscribed the PageBox.
Returns:
status.

init

public void init(java.lang.Object context)
          throws ServiceException
ServiceLifeCycle method.

Called at initialization.

Parameters:
context - ServletEndpoint Context
Throws:
ServiceException

init2

public void init2(ServletContext ctx)
Method called by HTTPDeploy

Parameters:
ctx - servlet context

init

private void init()
Common initialization stuff.


destroy

public void destroy()
ServiceLifeCycle method. Called at destruction.


renameRepository

private java.lang.String renameRepository(java.lang.String oldDownloadURL,
                                          java.lang.String newDownloadURL,
                                          java.lang.String user)
Change the repository URL. The new repository URL shouldn't be already defined.

Parameters:
oldDownloadURL - previous download URL for some archives
newDownloadURL - new download URL for these archives
user - user who subscribed the PageBox.
Returns:
status.

renameRepository2

private java.lang.String renameRepository2(java.lang.String oldDownloadURL,
                                           java.lang.String newDownloadURL)
Change the repository URL.

Parameters:
oldDownloadURL - previous download URL for some archives
newDownloadURL - new download URL for these archives
Returns:
status null if OK.

saveRules

private void saveRules()
Save rules.xml. Called by renameRepository.


addToPbArchs

private DeployIF.Status addToPbArchs(java.lang.String arch,
                                     java.lang.String downloadURL,
                                     java.lang.String owner,
                                     byte[] archData,
                                     java.lang.String date,
                                     java.lang.String oldDate,
                                     java.lang.String docURL,
                                     java.lang.String user,
                                     boolean isUpdate,
                                     boolean runInstall,
                                     DeployIF.UrlUser[] relayed)
Deploys an archive and returns a status.

Parameters:
arch - archive name.
downloadURL - download URL.
owner - user who published the archive.
archData - archive data.
date - publication date and time.
oldDate - expected previous publication date and time.
docURL - documentation URL.
user - user who requested the deploy.
isUpdate - if true delta update
runInstall - if true run the Application server installer (Web application)
relayed - PageBox instances to deploy
Returns:
Status object

listRules

private java.util.ArrayList listRules(java.util.HashMap rules)
Enumerates publisherRules or repositoryRules.

Parameters:
rules - publisherRules or repositoryRules
Returns:
ArrayList whose elements are log StringBuffer

deleteFromPbArchs

private DeployIF.Status deleteFromPbArchs(java.lang.String arch,
                                          java.lang.String downloadURL,
                                          java.lang.String owner,
                                          java.lang.String user,
                                          boolean runRemove,
                                          boolean keepDir)
Undeploys an archive and returns a status.

Parameters:
arch - archive name.
downloadURL - download URL.
owner - user who published the archive.
user - user who requested the deploy.
runRemove - if true run the Application server installer (Web application)
keepDir - keep directory
Returns:
Status object

install

private DeployIF.Status install(java.lang.String arch,
                                java.lang.String downloadURL,
                                java.lang.String docURL,
                                byte[] archData,
                                boolean isUpdate,
                                boolean isUpdate2,
                                boolean runInstall,
                                int auth,
                                InstallHelper ih)
Installs an archive and returns a status.

In 0.0.7 we chose using getCause (1.4) rather than getException (1.2) to retrieve the first exception. Replace getCause by getException if needed.

Parameters:
arch - archive name.
downloadURL - download URL.
docURL - documentation URL.
archData - archive data.
isUpdate - if true delta update
isUpdate2 - if true replaces an older version
runInstall - if true run the Application server installer (Web application)
auth - COPY or INSTALL authorization
Returns:
Status object

uninstall

private DeployIF.Status uninstall(java.lang.String arch,
                                  java.lang.String downloadURL,
                                  java.lang.String docURL,
                                  boolean isUpdate,
                                  boolean runRemove,
                                  int auth,
                                  java.util.HashMap resources)
Uninstalls an archive and returns a status.

In 0.0.7 we chose using getCause (1.4) rather than getException (1.2) to retrieve the first exception. Replace getCause by getException if needed.

Parameters:
arch - archive name.
docURL - documentation URL.
isUpdate - if true don't delete the archive
runRemove - if true run the Application server installer (Web application)
auth - COPY or INSTALL authorization
Returns:
Status object

deleteDir

private void deleteDir(java.io.File f)
Recursive directory delete.

Parameters:
f - directory File object

getArchPath

public java.lang.String getArchPath(java.lang.String arch)
DeployIF method. Returns an archive path: The URL of archive pages is normally rootPath/archive_without_extension. Method added for the PageBox API support. Also used to check if credentials and connectity are fine (ping method).

Specified by:
getArchPath in interface DeployIF
Parameters:
arch - archive name
Returns:
URL of archive pages

restorePbArchs

private java.lang.String restorePbArchs()
Parse PbArchives.xml and set the archives HashMap.

Returns:
status.

savePbArchs

private java.lang.String savePbArchs()
Save the archives HashMap in PbArchives.xml.


initialize

private boolean initialize()
Authorization restore from rules.xml.

Returns:
true if handler available

getAuthFromRule

private static final java.lang.String getAuthFromRule(int rule)
Format a rule string for tracing

Parameters:
rule - NONE, COPY or INSTALL
Returns:
"NONE", "COPY" or "INSTALL" depending on rule value

getAudit

public java.lang.String getAudit(java.lang.String arch,
                                 java.lang.String owner,
                                 java.lang.String user,
                                 java.lang.String downloadURL)
DeployIF method. Returns the audit entries specific to an archive on a PageBox

Specified by:
getAudit in interface DeployIF
Parameters:
arch - archive name
owner - user who published the archive.
user - user who subscribed the PageBox.
downloadURL - download URL.
Returns:
audit entries