### *** This class provides Binary Compatibility only, not Source Compatibility ***

Package com.sas.services.publish.tools

# Class PackageCleanup

java.lang.Object
com.sas.services.publish.tools.PackageCleanup

@SASScope("ALL") @BinaryCompatibilityOnly public class PackageCleanup extends Object
A Java class that provides a simple, command line interface for deleting or listing packages from a publish channel.

With SAS9 Release, the Publish Framework supports channels defined in a SAS Metadata Repository. Channels can be defined with archive or WebDAV persistent stores. When a package is published to a channel that is defined with a persistent store, the package is first persisted to that location and then it is published to all subscribers of that channel. Channels must be managed to delete old persisted packages. The Package Cleanup utility allows you to review basic information about the persisted package associated with the channel and delete both the metadata and the actual persisted package. Deletions are based on the expiration date of the package. This utility supports the deletion of packages from either type of persistent store (archive or WebDAV). The utility also supports the deletion of packages that are not to defined to any channel.

The Publishing Framework also supports the publishing of packages to an arbitrary WebDAV server (not associated to a channel). The Package Cleanup utility has been updated to support the deletion of these WebDAV packages. Given the WebDAV URL and credentials, the Package Cleanup utility searches for packages at that the specified URL location and returns the basic package information for review and deletion.

The Package Cleanup utility also supports a listing feature. The utility can be used to display package information without deleting. It can display information about packages published to a particular channel, packages that are orphaned and are no longer defined to any channel, and packages that exist on an arbitrary WebDAV server.

### Deleting Packages

When the Package Cleanup utility is invoked for deletions, the user must provide the deletion date. The user can also provide one of the following:

- a channel name to delete packages defined to a specific channel
- a WebDAV URL to delete packages found by searching the specified WebDAV location
- no channel name or URL. The user can omit the channel and the WebDAV URL so that only orphaned packages that are not defined to any channel are deleted

These arguments are parsed from the command line and the user is prompted to proceed. The user is then presented with a list of packages that meet the deletion criteria, and is prompted to proceed. If confirmed, successful deletions are reported to the console and/or a log file, and failures are listed with the exception condition.

### Listing Packages

When the Package Cleanup utility is invoked with the listing option, the user can provide one of the following:

- a channel name to display all packages defined for the specified channel
- a WebDAV URL to list packages found by searching the specified WebDAV location
- no channel name or URL. The user can omit the channel and the WebDAV URL so that only orphaned packages that are not defined to any channel are listed

An expiration date can also be provided to further subset what packages are listed. The information is parsed from the command line and the list of packages is displayed.

### Requirements

The package cleanup utility has the following requirements:

Foundation Services jar files
  The PackageCleanup utility requires the Foundation Services. Ensure that the classpath is set appropriately to include the Foundation Services jar files.
login configuration file
  The login configuration file consists of an entry that specifies which underlying authentication technology should be used by the package cleanup utility.
Metadata server options
  The -metauser, -metapass and -domain command-line arguments need to be specified. The PackageCleanup utility must bind to the repository in order to find the specified channel. These arguments provide the information needed to bind to the Metadata Server.
properties file
  The PackageCleanup utility requires a properties file that contains default setup information The PackageCleanup utility reads the text properties file from the directory where it is executing. The default name is "jps.properties". You can use a different name or full path name with the "-propertiesfile | -prop" option, like "-prop c:\\jps.properties". Note that a Windows backslash must be doubled for proper handling by Java. See the Program Arguments section for more details on what arguments are supported. The properties files contains five required properties:
  software_component
    The PackageCleanup utility must deploy the Foundation Services as it uses the Logging, User and Information services. The software_component property identifies the name of the metadata SoftwareComponent that serves as the root of the service deployment hierarchy.
  deployment_group_1
    The deployment group identifies the service group that is to be deployed.
  omr_host
    The name of the host on which the Metadata Server is running.
  omr_port
    The port on which the Metadata Server is running.
  omr_repository
    The Metadata server repository.

### Usage

Many sites will use this application with an operating system scheduler software. For Windows, this will be the AT scheduler (see Windows help), and for Unix, this will be cron (see cron -help).

#### Minimal syntax for deleting packages defined to a channel:

     java -Djava.security.auth.login.config= <your-path>/login.config
     -Djava.security.policy= <your-path>/policy
     com.sas.services.publish.tools.PackageCleanup
     -d <expiration date for deletions>
     -ch <Channel Name>
     -metauser <username when binding to the Metadata Server>
     -metapass <password to use when binding to the Metadata Server>
     -domain <authentication domain for the Metadata Server>

#### Minimal syntax for deleting orphaned packages that are not defined to a channel:

     java -Djava.security.auth.login.config= <your-path>/login.config
     -Djava.security.policy= <your-path>/policy
     com.sas.services.publish.tools.PackageCleanup
     -d <expiration date for deletions>
     -metauser <username when binding to the Metadata Server>
     -metapass <password to use when binding to the Metadata Server>
     -domain <authentication domain for the Metadata Server>

#### Minimal syntax for deleting packages published to a WebDAV server:

     java -Djava.security.auth.login.config= <your-path>/login.config
     -Djava.security.policy= <your-path>/policy
     com.sas.services.publish.tools.PackageCleanup
     -url <WebDAV URL>
     -username <username when binding to WebDAV server>
     -password <password when binding to WebDAV server>
     -d <expiration date for deletions>
     -metauser <username when binding to the Metadata Server>
     -metapass <password to use when binding to the Metadata Server>
     -domain <authentication domain for the Metadata Server>

#### Minimal syntax for listing packages defined to a channel:

     java -Djava.security.auth.login.config= <your-path>/login.config
     -Djava.security.policy= <your-path>/policy
     com.sas.services.publish.tools.PackageCleanup
     -list
     -ch <Channel Name>
     -metauser <username when binding to the Metadata Server>
     -metapass <password to use when binding to the Metadata Server>
     -domain <authentication domain for the Metadata Server>

#### Minimal syntax for listing orphaned packages that are not defined to a channel:

     java -Djava.security.auth.login.config= <your-path>/login.config
     -Djava.security.policy= <your-path>/policy
     com.sas.services.publish.tools.PackageCleanup
     -metauser <username when binding to the Metadata Server>
     -metapass <password to use when binding to the Metadata Server>
     -domain <authentication domain for the Metadata Server>
     -list

#### Minimal syntax for listing packages published to a WebDAV server:

     java -Djava.security.auth.login.config= <your-path>/login.config
     -Djava.security.policy= <your-path>/policy
     com.sas.services.publish.tools.PackageCleanup
     -list
     -url <WebDAV URL>
     -username <username when binding to WebDAV server>
     -password <password when binding to WebDAV server>
     -metauser <username when binding to the Metadata Server>
     -metapass <password to use when binding to the Metadata Server>
     -domain <authentication domain for the Metadata Server>

### Defaults

Prompting for Deletions

User is prompted to proceed after reviewing impending deletions. By default, the user is presented with a list of all packages that meet the deletion criteria. The user is then prompted to see if they want to proceed with the deletion of all the packages. To override the default, specify "-prompteach". The user will be prompted to delete each package that meets the deletion criteria. After each package is processed, a final list of all packages that were selected is provided to the user. The user can choose to delete all of those packages that were selected or exit without actual package deletions.

The prompting feature is completely turned off by "-noprompt". Execution with a scheduler service must use the "-noprompt" option, unless shell programming is provided to respond to the prompts. It is best to run with prompting when learning how to use the application. In this way, the user can review proper date formatting and correct package deletion candidates, with the option to exit without actual package deletions.

Logging

Application activity is reported to the Java standard out console. If a log file is desired, use the "-logfile | -log" option, like "-log c:\\mylog.file". If the log file already exists, the log lines are appended to the current file.

Deleting Packages with no expiration date specified

If a package does not have an expiration date assigned, it is ignored. If you wish to delete packages with missing expiration dates, use the "-deletenodate" option.

Deleting Specific Packages

When deleting packages, specify "-package" or "-pkg" along with the "-d" option (expiration date), to further subset which packages are deleted. The "-package" option allows you to specify the name of the package to delete.

Deleting Packages defined in WebDAV

To delete packages from a specific WebDAV server, specify the "-url" option along with the "-username" and "-password" options. The cleanup utility will use these options to bind to the WebDAV server and search for packages to delete. This option cannot be specified when the "-channel" option.

Debug Information

Specify "-debug" to turn on debug level information. This will provide debug information for all of the Foundation Services as well as the utility program. This option should only be used when trying to determine why the utility is not running properly.

### Program Arguments

Usage: java com.sas.services.publish.tools.PackageCleanup args

     where args include:
        -channel | -ch <channel name> channel to process
        -deletionDate | -d <expiration date for deletion or listing of packages>
            Format: yyyyy.MM.dd 'at' hh:mm a reference Javadoc for java.text.SimpleDateFormat
            Only packages with expiration dates before this specified date will be listed or deleted.
        -list display a list of packages only (no deletion will occur)
        -metauser <username> username to use when binding to the Metdata Server
        -metapass <password> password to use when binding to the Metdata Server
        -domain <domain> authentication domain for the Metadata Server
        -package | -pkg <package name> name of package to delete
        -url <WebDAV URL> WebDAV URL to use when searching for packages to delete
        -username <username> username to use when binding to WebDAV server identified by 'url' property
        -password <password> password to use when binding to WebDAV server identified by 'url' property
        -logfile | -log <file name> name of log file
        -noprompt no user confirmation of deletes.
        -deletenodate delete/list packages that have no expiration date defined.
        -prompteach confirm each package for deletion.
        -afterDate | -a <the after expiration date for deletion or listing of packages>
            Format: yyyyy.MM.dd 'at' hh:mm a reference Javadoc for java.text.SimpleDateFormat
            Only packages with expiration dates after this specified date will be listed or deleted.
        -debug print debug information for all the Foundation Services.
        -help print this help message.

### Examples

### Misc Examples

     java -Djava.security.auth.login.config=C:/myconfig/login.config
     -Djava.security.policy=c:/myconfig/policy
     com.sas.services.publish.tools.PackageCleanup -ch myChannel -d "10000.10.07
     at 12:59 PM" -metauser userA -metapass pass1 -domain DefaultAuth

This second example uses the "-prompteach" option. This will require that the user confirm each package for deletion.

     java -Djava.security.auth.login.config=C:/myconfig/login.config
     -Djava.security.policy=c:/myconfig/policy
     com.sas.services.publish.tools.PackageCleanup -ch myWebDAVChannel -d
     "2004.10.07 at 12:00 PM" -metauser userX -metapass mypass -domain
     DefaultAuth -prompteach

This example deletes all packages defined to the channel "myChannel" that have an expiration date prior to 10/07/10000 at 12:59PM.

     java -Djava.security.auth.login.config=C:/myconfig/login.config
     -Djava.security.policy=c:/myconfig/policy
     com.sas.services.publish.tools.PackageCleanup -ch myChannel -d "10000.10.07
     at 12:59 PM" -metauser userX -metapass mypass -domain DefaultAuth

This example deletes all packages defined to the channel "myChannel" that have an expiration date prior to 10/07/10000 at 12:59PM.

     java -Djava.security.auth.login.config=C:/myconfig/login.config
     -Djava.security.policy=c:/myconfig/policy
     com.sas.services.publish.tools.PackageCleanup -ch myChannel -d "10000.10.07
     at 12:59 PM" -metauser userX -metapass mypass -domain DefaultAuth

This example deletes a specific package defined to the channel, "myChannel". The "-pkg" option is specified to identify the exact package to delete. This will delete the package named, s109513698.spk, that has an expiration date prior to 10/07/10000 at 12:59PM.

     java -Djava.security.auth.login.config=C:/myconfig/login.config
     -Djava.security.policy=c:/myconfig/policy
     com.sas.services.publish.tools.PackageCleanup -ch myChannel -d "10000.10.07
     at 12:59 PM" -pkg s109513698.spk -metauser userX -metapass mypass -domain
     DefaultAuth

This example deletes all packages that are not defined to any channel. Only packages that are not defined to a channel and have an expiration date prior to 10/07/10000 at 12:59PM, will be deleted.

     java -Djava.security.auth.login.config=C:/myconfig/login.config
     -Djava.security.policy=c:/myconfig/policy
     com.sas.services.publish.tools.PackageCleanup -d "10000.10.07 at 12:59 PM"
     -metauser userX -metapass mypass -domain DefaultAuth

This example deletes packages that have been published to a WebDAV server. The utility binds to the server using the specified URL, and deletes all packages published to that location with an expiration date prior to 10/07/10000 at 12:59PM.

     java -Djava.security.auth.login.config=C:/myconfig/login.config
     -Djava.security.policy=c:/myconfig/policy
     com.sas.services.publish.tools.PackageCleanup -d "10000.10.07 at 12:59 PM"
     -url http://myhost.com/Sales/Packages -username davUser -password davPassword
     -metauser userX -metapass mypass -domain DefaultAuth

This example deletes a specific package from the specified WebDAV server. The "-pkg" option is used to provide the name of the package to delete. The utility binds to the server using the specified URL, and deletes the package named "s3964865240".

     java -Djava.security.auth.login.config=C:/myconfig/login.config
     -Djava.security.policy=c:/myconfig/policy
     com.sas.services.publish.tools.PackageCleanup -d "10000.10.07 at 12:59 PM"
     -metauser userX -metapass mypass -domain DefaultAuth -url
     http://myhost.com/Sales/Packages -username davUser -password davPassword -pkg
     s3964865240

This example deletes all packages defined to the channel "myChannel" that have an expiration date between 01/07/2013 at 12:59PM and 12/07/2013 at 12:59PM. The -a option is specified to indicate that the expiration date must be after (greater than) 12/07/2013 at 12:59PM.

     java -Djava.security.auth.login.config=C:/myconfig/login.config
     -Djava.security.policy=c:/myconfig/policy
     com.sas.services.publish.tools.PackageCleanup -ch myChannel
     -a "2013.01.07 at 12:59 PM"  -d "2013.12.07 at 12:59 PM"
     -metauser userX -metapass mypass -domain DefaultAuth

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `PackageCleanup()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static void`
  `main(String[] args)`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### PackageCleanup

    public PackageCleanup()

- ## Method Details

  - ### main

    public static void main(String[] args)