Repository
Class SaveSubs

java.lang.Object
  extended byRepository.SaveSubs
Direct Known Subclasses:
RepoASubs, RepoSubs

class SaveSubs
extends java.lang.Object

Handling of subscribers serialization and common operations.

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, 1
Author:
Alexis Grandemange

Field Summary
private  java.util.HashMap archCache
          Cache of archive full data.
(package private)  SubscribeBean subBean
          Model using the subscribers TreeMap.
 
Constructor Summary
(package private) SaveSubs()
           
 
Method Summary
protected  java.lang.String addArch(java.lang.String arch, java.lang.String owner, java.lang.String host, java.lang.String docUrl, java.lang.String date, boolean runInstall, java.util.ArrayList addedSubscribers, boolean isDelta)
           
private  void checkArchive(java.lang.String arch, Archive a)
          Check if the archive unpublish is pending and if there is still a PageBox where the archive is published.
protected  boolean checkSub(java.lang.String url, java.lang.String pbUser, java.lang.String pbPasswd)
          Checks if the subscriber can be contacted.
protected  DeleteRc delArch(java.lang.String url, Subscriber sub, java.lang.String arch, java.lang.String publisher, java.lang.String owner, java.lang.String host, boolean runInstall, boolean toForce, boolean keepDir)
           
protected  void dumpSubs()
          Displays the subscriber state.
private  void fullAdd(java.lang.String arch, ArchiveStatus as, java.lang.String date, java.lang.String user, java.lang.String owner, java.lang.String docUrl, boolean runInstall, boolean created)
          Deploy the full archive for an already installed Web archive.
protected  void notify2(java.lang.String owner, java.lang.String host, java.lang.String arch, RepoQueryIF.UrlStatus[] subs)
          Notifies the success or failure of a deployment set.
protected  void notifyFix2(java.lang.String owner, java.lang.String host, java.lang.String subscriber, FixArch[] archives, boolean isArchiveSub)
          Notifies the fix of a setting problem.
protected  byte[] readArchive(java.lang.String owner, java.lang.String host, java.lang.String path)
          Reads the archive in a byte array.
private  void relay(java.lang.String arch, java.lang.String owner, java.lang.String host, java.lang.String docUrl, java.lang.String date, java.lang.String oldDate, boolean runInstall, boolean isUpdate, java.util.ArrayList subs, byte[] archData)
           
protected  void retryDeploy()
          Retry deploy and undeploy.
protected  java.lang.String save(java.lang.String owner, java.lang.String host, java.lang.String path)
          Saves subscribers on the path file.
protected  java.lang.String unsub(java.lang.String owner, java.lang.String host, java.lang.String url, boolean toForce)
          Removes a subscriber from the repository.
protected  java.lang.String updateArch(java.lang.String arch, java.lang.String owner, java.lang.String host, java.lang.String docUrl, java.lang.String date, java.lang.String oldDate, boolean runInstall, java.util.ArrayList updatedSubscribers)
           
protected  java.lang.String updateRep(java.lang.String owner, java.lang.String host, java.lang.String url, java.lang.String pbUser, java.lang.String pbPasswd, int grade)
          Updates archive subscriber information on a repository.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

subBean

SubscribeBean subBean
Model using the subscribers TreeMap.


archCache

private java.util.HashMap archCache
Cache of archive full data. Used by retryDeploy and fullAdd.

Constructor Detail

SaveSubs

SaveSubs()
Method Detail

save

protected java.lang.String save(java.lang.String owner,
                                java.lang.String host,
                                java.lang.String path)
Saves subscribers on the path file.

Parameters:
owner - user who requested the add
host - user host
path - file path
Returns:
null or error string

addArch

protected java.lang.String addArch(java.lang.String arch,
                                   java.lang.String owner,
                                   java.lang.String host,
                                   java.lang.String docUrl,
                                   java.lang.String date,
                                   boolean runInstall,
                                   java.util.ArrayList addedSubscribers,
                                   boolean isDelta)

relay

private void relay(java.lang.String arch,
                   java.lang.String owner,
                   java.lang.String host,
                   java.lang.String docUrl,
                   java.lang.String date,
                   java.lang.String oldDate,
                   boolean runInstall,
                   boolean isUpdate,
                   java.util.ArrayList subs,
                   byte[] archData)

updateArch

protected java.lang.String updateArch(java.lang.String arch,
                                      java.lang.String owner,
                                      java.lang.String host,
                                      java.lang.String docUrl,
                                      java.lang.String date,
                                      java.lang.String oldDate,
                                      boolean runInstall,
                                      java.util.ArrayList updatedSubscribers)

delArch

protected DeleteRc delArch(java.lang.String url,
                           Subscriber sub,
                           java.lang.String arch,
                           java.lang.String publisher,
                           java.lang.String owner,
                           java.lang.String host,
                           boolean runInstall,
                           boolean toForce,
                           boolean keepDir)

unsub

protected java.lang.String unsub(java.lang.String owner,
                                 java.lang.String host,
                                 java.lang.String url,
                                 boolean toForce)
Removes a subscriber from the repository.

Parameters:
owner - user who requested the subscribe
host - user host
url - URL of the subscribed PageBox
toForce - true if the subscriber should be removed from the repository even if it cannot be contacted
Returns:
info or error string

readArchive

protected byte[] readArchive(java.lang.String owner,
                             java.lang.String host,
                             java.lang.String path)
Reads the archive in a byte array.

Parameters:
owner - user who requested the subscribe
host - user host
path - archive path
Returns:
null in case of error or read archive

notify2

protected void notify2(java.lang.String owner,
                       java.lang.String host,
                       java.lang.String arch,
                       RepoQueryIF.UrlStatus[] subs)
Notifies the success or failure of a deployment set. Updates subscribers accordingly.

Parameters:
owner - user who requested the subscribe
host - user host
arch - archive name
subs - array of UrlStatus objects

notifyFix2

protected void notifyFix2(java.lang.String owner,
                          java.lang.String host,
                          java.lang.String subscriber,
                          FixArch[] archives,
                          boolean isArchiveSub)
Notifies the fix of a setting problem.

Parameters:
owner - user who requested the subscribe
host - user host
subscriber - PageBox whose setting problem was fixed
archives - archive whose status is fixed
isArchiveSub - true if archive subscribers false if subscribers

dumpSubs

protected void dumpSubs()
Displays the subscriber state. Called by Retry.


retryDeploy

protected void retryDeploy()
Retry deploy and undeploy.


updateRep

protected java.lang.String updateRep(java.lang.String owner,
                                     java.lang.String host,
                                     java.lang.String url,
                                     java.lang.String pbUser,
                                     java.lang.String pbPasswd,
                                     int grade)
Updates archive subscriber information on a repository. Try removing archives in authentication state.

Parameters:
owner - user who requested the subscribe
host - user host
url - URL of the subscribed PageBox
pbUser - PageBox user name
pbPasswd - PageBox password
grade - grade
Returns:
info or error string

checkArchive

private void checkArchive(java.lang.String arch,
                          Archive a)
Check if the archive unpublish is pending and if there is still a PageBox where the archive is published.

Parameters:
arch - archive maybe in pending remove
a - Archive object

fullAdd

private void fullAdd(java.lang.String arch,
                     ArchiveStatus as,
                     java.lang.String date,
                     java.lang.String user,
                     java.lang.String owner,
                     java.lang.String docUrl,
                     boolean runInstall,
                     boolean created)
Deploy the full archive for an already installed Web archive.

Note: deployer.setUrl must have been called before.

Parameters:
arch - archive to deploy
as - status of this archive in subscribers
date - publication date
user - subscriber of the target PageBox
owner - publisher of the archive
runInstall - run application server installer if true
created - true if archice being created on subscribed PageBox

checkSub

protected boolean checkSub(java.lang.String url,
                           java.lang.String pbUser,
                           java.lang.String pbPasswd)
Checks if the subscriber can be contacted.

Parameters:
url - URL of the subscribed PageBox
pbUser - PageBox user name
pbPasswd - PageBox password
Returns:
boolean false when the PageBox cannot be contacted.