mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-26 14:02:06 +01:00
Formatting fixes.
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@10848 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
181e5649fc
commit
d42b40496d
1 changed files with 35 additions and 29 deletions
|
@ -132,6 +132,7 @@ public class AdHocCommandManager {
|
||||||
* command for the connection related to this command manager. The
|
* command for the connection related to this command manager. The
|
||||||
* <code>name</name> is the human readable name of the command.
|
* <code>name</name> is the human readable name of the command.
|
||||||
* The <code>class</code> is the class of the command
|
* The <code>class</code> is the class of the command
|
||||||
|
*
|
||||||
* @param node the unique identifier of the command.
|
* @param node the unique identifier of the command.
|
||||||
* @param name the human readable name of the command.
|
* @param name the human readable name of the command.
|
||||||
* @param clazz the class of the command.
|
* @param clazz the class of the command.
|
||||||
|
@ -223,12 +224,13 @@ public class AdHocCommandManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* <ul>
|
||||||
* <li>Adds listeners to the connection</li>
|
* <li>Adds listeners to the connection</li>
|
||||||
* <li>Registers the ad-hoc command feature to the ServiceDiscoveryManager</li>
|
* <li>Registers the ad-hoc command feature to the ServiceDiscoveryManager</li>
|
||||||
* <li>Registers the items of the feature</li>
|
* <li>Registers the items of the feature</li>
|
||||||
* <li>Adds packet listeners to handle execution requests</li>
|
* <li>Adds packet listeners to handle execution requests</li>
|
||||||
* <li>Creates and start the session sweeper</li>
|
* <li>Creates and start the session sweeper</li>
|
||||||
*
|
* </ul>
|
||||||
*/
|
*/
|
||||||
private void init() {
|
private void init() {
|
||||||
// Register the new instance and associate it with the connection
|
// Register the new instance and associate it with the connection
|
||||||
|
@ -358,18 +360,22 @@ public class AdHocCommandManager {
|
||||||
* Process the AdHoc-Command packet that request the execution of some
|
* Process the AdHoc-Command packet that request the execution of some
|
||||||
* action of a command. If this is the first request, this method checks,
|
* action of a command. If this is the first request, this method checks,
|
||||||
* before executing the command, if:
|
* before executing the command, if:
|
||||||
|
* <ul>
|
||||||
* <li>The requested command exists</li>
|
* <li>The requested command exists</li>
|
||||||
* <li>The requester has permissions to execute it</li>
|
* <li>The requester has permissions to execute it</li>
|
||||||
* <li>The command has more than one stage, if so, it saves the command and
|
* <li>The command has more than one stage, if so, it saves the command and
|
||||||
* session ID for further use</li>
|
* session ID for further use</li>
|
||||||
|
* </ul>
|
||||||
*
|
*
|
||||||
* <br>
|
* <br>
|
||||||
* <br>
|
* <br>
|
||||||
* If this is not the first request, this method checks, before executing
|
* If this is not the first request, this method checks, before executing
|
||||||
* the command, if:
|
* the command, if:
|
||||||
|
* <ul>
|
||||||
* <li>The session ID of the request was stored</li>
|
* <li>The session ID of the request was stored</li>
|
||||||
* <li>The session life do not exceed the time out</li>
|
* <li>The session life do not exceed the time out</li>
|
||||||
* <li>The action to execute is one of the available actions</li>
|
* <li>The action to execute is one of the available actions</li>
|
||||||
|
* </ul>
|
||||||
*
|
*
|
||||||
* @param requestData
|
* @param requestData
|
||||||
* the packet to process.
|
* the packet to process.
|
||||||
|
@ -459,7 +465,8 @@ public class AdHocCommandManager {
|
||||||
// Sends the response packet
|
// Sends the response packet
|
||||||
connection.sendPacket(response);
|
connection.sendPacket(response);
|
||||||
|
|
||||||
} catch (XMPPException e) {
|
}
|
||||||
|
catch (XMPPException e) {
|
||||||
// If there is an exception caused by the next, complete,
|
// If there is an exception caused by the next, complete,
|
||||||
// prev or cancel method, then that error is returned to the
|
// prev or cancel method, then that error is returned to the
|
||||||
// requester.
|
// requester.
|
||||||
|
@ -548,20 +555,24 @@ public class AdHocCommandManager {
|
||||||
// If it is the last stage then the command is
|
// If it is the last stage then the command is
|
||||||
// completed
|
// completed
|
||||||
response.setStatus(Status.completed);
|
response.setStatus(Status.completed);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
// Otherwise it is still executing
|
// Otherwise it is still executing
|
||||||
response.setStatus(Status.executing);
|
response.setStatus(Status.executing);
|
||||||
}
|
}
|
||||||
} else if (Action.complete.equals(action)) {
|
}
|
||||||
|
else if (Action.complete.equals(action)) {
|
||||||
command.increaseStage();
|
command.increaseStage();
|
||||||
command.complete(new Form(requestData.getForm()));
|
command.complete(new Form(requestData.getForm()));
|
||||||
response.setStatus(Status.completed);
|
response.setStatus(Status.completed);
|
||||||
// Remove the completed session
|
// Remove the completed session
|
||||||
executingCommands.remove(sessionId);
|
executingCommands.remove(sessionId);
|
||||||
} else if (Action.prev.equals(action)) {
|
}
|
||||||
|
else if (Action.prev.equals(action)) {
|
||||||
command.decreaseStage();
|
command.decreaseStage();
|
||||||
command.prev();
|
command.prev();
|
||||||
} else if (Action.cancel.equals(action)) {
|
}
|
||||||
|
else if (Action.cancel.equals(action)) {
|
||||||
command.cancel();
|
command.cancel();
|
||||||
response.setStatus(Status.canceled);
|
response.setStatus(Status.canceled);
|
||||||
// Remove the canceled session
|
// Remove the canceled session
|
||||||
|
@ -632,20 +643,17 @@ public class AdHocCommandManager {
|
||||||
/**
|
/**
|
||||||
* Creates a new instance of a command to be used by a new execution request
|
* Creates a new instance of a command to be used by a new execution request
|
||||||
*
|
*
|
||||||
* @param commandNode
|
* @param commandNode the command node that identifies it.
|
||||||
* the command node that identifies it.
|
* @param sessionID the session id of this execution.
|
||||||
* @param sessionID
|
|
||||||
* the session id of this execution.
|
|
||||||
* @return the command instance to execute.
|
* @return the command instance to execute.
|
||||||
* @throws XMPPException
|
* @throws XMPPException if there is problem creating the new instance.
|
||||||
* if there is problem creating the new instance
|
|
||||||
*/
|
*/
|
||||||
private LocalCommand newInstanceOfCmd(String commandNode, String sessionID)
|
private LocalCommand newInstanceOfCmd(String commandNode, String sessionID)
|
||||||
throws XMPPException {
|
throws XMPPException
|
||||||
// TODO Evaluate the possibility of using a factory for creating the new
|
{
|
||||||
// instances.
|
// TODO Evaluate the possibility of using a factory for creating the new instances.
|
||||||
AdHocCommandInfo commandInfo = commands.get(commandNode);
|
AdHocCommandInfo commandInfo = commands.get(commandNode);
|
||||||
LocalCommand command = null;
|
LocalCommand command;
|
||||||
try {
|
try {
|
||||||
command = (LocalCommand) commandInfo.getCmdClass().newInstance();
|
command = (LocalCommand) commandInfo.getCmdClass().newInstance();
|
||||||
command.setSessionID(sessionID);
|
command.setSessionID(sessionID);
|
||||||
|
@ -684,15 +692,13 @@ public class AdHocCommandManager {
|
||||||
private static class AdHocCommandInfo {
|
private static class AdHocCommandInfo {
|
||||||
|
|
||||||
private String node;
|
private String node;
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
private String ownerJID;
|
private String ownerJID;
|
||||||
|
|
||||||
private Class cmdClass;
|
private Class cmdClass;
|
||||||
|
|
||||||
public AdHocCommandInfo(String node, String name, String ownerJID,
|
public AdHocCommandInfo(String node, String name, String ownerJID,
|
||||||
Class cmdClass) {
|
Class cmdClass)
|
||||||
|
{
|
||||||
this.node = node;
|
this.node = node;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.ownerJID = ownerJID;
|
this.ownerJID = ownerJID;
|
||||||
|
|
Loading…
Reference in a new issue