For up-to-date product documentation, see the IBM MobileFirst Foundation Developer Center.
Calling the mfpadm Ant task
We can use the mfpadm Ant task and its associated commands to administer MobileFirst applications.
Syntax
Call the mfpadm Ant task as follows:
<mfpadm url=... user=... password=...|passwordfile=... [secure=...]> some commands </mfpadm>
Attributes
The mfpadm Ant task has the following attributes:
Table 1. List of <mfpadm> attributes Attribute Description Required Default url The base URL of the MobileFirst web application for administration services Yes secure Whether to avoid operations with security risks No true user The user name for accessing the MobileFirst administration services Yes password The password for the user Either one is required passwordfile The file that contains the password for the user timeout Timeout for the entire REST service access, in seconds No connectTimeout Timeout for establishing a network connection, in seconds No socketTimeout Timeout for detecting the loss of a network connection, in seconds No connectionRequestTimeout Timeout for obtaining an entry from a connection request pool, in seconds No lockTimeout Timeout for acquiring a lock No
- url
The base URL preferably uses the HTTPS protocol. For example, if we use default ports and context roots, use the following URL.
- For WebSphere® Application Server: https://server:9443/worklightadmin
- For Tomcat: https://server:8443/worklightadmin
- secure
- The default value is true. Setting secure="false" might have the following effects:
- The user and password might be transmitted in an unsecured way, possibly even through unencrypted HTTP.
- The server's SSL certificates are accepted even if self-signed or if they were created for a different host name than the specified server's host name.
- password
Specify the password either in the Ant script, through the password attribute, or in a separate file that you pass through the passwordfile attribute. The password is sensitive information and therefore needs to be protected. You must prevent other users on the same computer from knowing this password. To secure the password, before you enter the password into a file, remove the read permissions of the file for users other than yourself. For example, we can use one of the following commands:
- On UNIX: chmod 600 adminpassword.txt
- On Windows: cacls adminpassword.txt /P Administrators:F %USERDOMAIN%\%USERNAME%:F
Additionally, you might want to obfuscate the password to hide it from an occasional glimpse. To do so, use the mfpadm config password command to store the obfuscated password in a configuration file. Then, we can copy and paste the obfuscated password to the Ant script or to the password file.
The mfpadm call contains commands that are encoded in inner elements. These commands are executed in the order in which they are listed. If one of the commands fails, the remaining commands are not executed, and the mfpadm call fails.
Elements
We can use the following elements in mfpadm calls:
Table 2. Elements that can be used in <mfpadm> Element Description Count show-info Shows user and configuration information 0..∞ show-global-config Shows global configuration information 0..∞ show-diagnostics Shows diagnostics information 0..∞ show-versions Shows versions information 0..∞ unlock Releases the general-purpose lock 0..∞ list-runtimes Lists the runtimes 0..∞ show-runtime Shows information about a runtime 0..∞ delete-runtime Deletes a runtime 0..∞ show-user-config Shows the user configuration of a runtime 0..∞ set-user-config Specifies the user configuration of a runtime 0..∞ show-confidential-clients Shows the configurations of confidential clients of a runtime 0..∞ set-confidential-clients Specifies the configurations of confidential clients of a runtime 0..∞ set-confidential-clients-rule Specifies a rule for the confidential clients configuration of a runtime 0..∞ list-adapters Lists the adapters 0..∞ deploy-adapter Deploys an adapter 0..∞ show-adapter Shows information about an adapter 0..∞ delete-adapter Deletes an adapter 0..∞ adapter Other operations on an adapter 0..∞ list-apps Lists the apps 0..∞ deploy-app Deploys an app 0..∞ show-app Shows information about an app 0..∞ delete-app Deletes an app 0..∞ show-app-version Shows information about an app version 0..∞ delete-app-version Delete a version of an app 0..∞ app Other operations on an app 0..∞ app-version Other operations on an app version 0..∞ list-devices Lists the devices 0..∞ remove-device Removes a device 0..∞ device Other operations for a device 0..∞ list-farm-members Lists the members of the server farm 0..∞ remove-farm-member Removes a server farm member 0..∞
XML Format
The output of most commands is in XML, and the input to specific commands, such as <set-accessrule>, is in XML too. We can find the XML schemas of these XML formats in the product_install_dir/MobileFirstServer/mfpadm-schemas/ directory. The commands that receive an XML response from the server verify that this response conforms to the specific schema. We can disable this check by specifying the attribute xmlvalidation="none".
Output character set
Normal output from the mfpadm Ant task is encoded in the encoding format of the current locale. On Windows, this encoding format is the so-called "ANSI code page". The effects are as follows:
- Characters outside of this character set are converted to question marks when they are output.
- When the output goes to a Windows command prompt window (cmd.exe), non-ASCII characters are incorrectly displayed because such windows assume characters to be encoded in the so-called "OEM code page".
To work around this limitation:
- On operating systems other than Windows, use a locale whose encoding is UTF-8. This locale is the default locale on Red Hat Linux and OS X. Many other operating systems have the en_US.UTF-8 locale.
- Or use the attribute output="some file name" to redirect the output of a mfpadm command to a file.
Parent topic: Administering MobileFirst applications through Ant