Skip to content
This repository has been archived by the owner on May 2, 2024. It is now read-only.

Commit

Permalink
javadoc for command line client
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusholl committed Jan 30, 2018
1 parent 810749f commit 07a8ecf
Show file tree
Hide file tree
Showing 17 changed files with 84 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package sap.prd.cmintegration.cli;

/**
* Root for all exceptions related to the command line client in the
* narrower sense.
*/
class CMCommandLineException extends RuntimeException {

private static final long serialVersionUID = 5251372712902531523L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import sap.ai.st.cm.plugins.ciintegration.odataclient.CMODataClient;

/**
* Provides {@link CMODataClient} instances.
*/
class ClientFactory {

private static ClientFactory instance;
Expand All @@ -16,6 +19,13 @@ static synchronized ClientFactory getInstance() {
return instance;
}

/**
* Provides a new instance of {@link CMODataClient}
* @param serviceUrl The OData endpoint of the SAP Solution Manager
* @param serviceUser The service user.
* @param servicePassword The password for authenticating.
* @return A new instance of {@link CMODataClient}
*/
CMODataClient newClient(String serviceUrl, String serviceUser, String servicePassword) {
return new CMODataClient(serviceUrl, serviceUser, servicePassword);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package sap.prd.cmintegration.cli;

/**
* Root class for all commands.
*/
abstract class Command {

protected final String host, user, password;
Expand All @@ -10,5 +13,11 @@ protected Command(String host, String user, String password) {
this.password = password;
}

/**
* Contains the command specific logic. E.g. performs a
* call to SAP Solution Manager, parses the result and
* provides it via System.out to the caller of the command line.
* @throws Exception In case of trouble.
*/
abstract void execute() throws Exception;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* Contains the name of the command as it is used from the command line.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@interface CommandDescriptor {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,18 @@

import sap.ai.st.cm.plugins.ciintegration.odataclient.CMODataClient;

/**
* Helpers for using/calling commands.
*/
class Commands {

final static private Logger logger = LoggerFactory.getLogger(Commands.class);
private final static String DASH = "-";
private final static String TWO_DASHES = DASH+DASH;

/**
* The common command line options used by all commands.
*/
static class CMOptions {

static Option USER = new Option("u", "user", true, "Service user."),
Expand All @@ -58,6 +64,9 @@ static Option clone(Option o) {
}
}

/**
* Common helper methods.
*/
static class Helpers {

static Options getStandardOptions() {
Expand Down Expand Up @@ -138,7 +147,7 @@ static String getArgsLogString(String[] args) {
}

/**
*
* @param args The <code>args</code> array handed over to the command.
* @return A copy of <code>args</code>. The password parameter, identified by a preceding
* <code>-p</code> is replaced by asterisks.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
import sap.ai.st.cm.plugins.ciintegration.odataclient.CMODataClient;
import sap.ai.st.cm.plugins.ciintegration.odataclient.CMODataTransport;

/**
* Command for creating a transport for a change in SAP Solution Manager.
*/
@CommandDescriptor(name = "create-transport")
class CreateTransport extends Command {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package sap.prd.cmintegration.cli;

/**
* Used in case a status is encounter where any further processing inside
* the command line client does not make sense. The exit code transported
* alongside with this exception is used as exit code of the Java Virtual
* Machine.
*/
class ExitException extends CMCommandLineException {

private static final long serialVersionUID = -3269137608207801150L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Launcher class which launches another class and handels {@link ExitException}s. In case
* an ExitExcpetion is encountered the exit code contained in that exception is used
* as return code when exiting the Java Virtual Machine.
*/
class ExitWrapper {
final static private Logger logger = LoggerFactory.getLogger(ExitWrapper.class);
public final static void main(String[] args) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
import sap.ai.st.cm.plugins.ciintegration.odataclient.CMODataChange;
import sap.ai.st.cm.plugins.ciintegration.odataclient.CMODataClient;

/**
* Command for retrieving the status of a change.
*/
@CommandDescriptor(name = "is-change-in-development")
class GetChangeStatus extends Command {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
import sap.ai.st.cm.plugins.ciintegration.odataclient.CMODataClient;
import sap.ai.st.cm.plugins.ciintegration.odataclient.CMODataTransport;

/**
* Command for for retrieving the transport of a change. Depending on the options
* handed over to that command only the mofifiable transports are
* returned.
*/
@CommandDescriptor(name="get-transports")
class GetChangeTransports extends Command {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@

import sap.ai.st.cm.plugins.ciintegration.odataclient.CMODataTransport;

/**
* Command for retrieving the description of a transport.
*/
@CommandDescriptor(name="get-transport-description")
class GetTransportDescription extends TransportRelated {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

import sap.ai.st.cm.plugins.ciintegration.odataclient.CMODataTransport;

/**
* Checks if a transport is modifiable.
*/
@CommandDescriptor(name="is-transport-modifiable")
class GetTransportModifiable extends TransportRelated {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@

import sap.ai.st.cm.plugins.ciintegration.odataclient.CMODataTransport;

/**
* Command for retrieving the owner of a transport.
*/
@CommandDescriptor(name="get-transport-owner")
class GetTransportOwner extends TransportRelated {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@

import sap.ai.st.cm.plugins.ciintegration.odataclient.CMODataClient;

/**
* Command for releasing a transport.
*/
@CommandDescriptor(name="release-transport")
class ReleaseTransport extends Command {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
import sap.ai.st.cm.plugins.ciintegration.odataclient.CMODataClient;
import sap.ai.st.cm.plugins.ciintegration.odataclient.CMODataTransport;

/**
* Base class for all transport related commands.
*/
abstract class TransportRelated extends Command {

final static private Logger logger = LoggerFactory.getLogger(TransportRelated.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@

import sap.ai.st.cm.plugins.ciintegration.odataclient.CMODataClient;

/**
* Command for uploading a file into a transport.
*/
@CommandDescriptor(name="upload-file-to-transport")
class UploadFileToTransport extends Command {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Contains a command line client for connecting to SAP Solution
* Manager. The classes contained in this package are not
* intended for being reused as an API.<br>
* For more details how to use the command line client use
* <code>&lt;CLIENT_HOME&gt;/bin/cmclient --help</code>
*/
package sap.prd.cmintegration.cli;

0 comments on commit 07a8ecf

Please # to comment.