use of org.syncany.operations.daemon.messages.api.FolderRequest in project syncany by syncany.
the class CommandLineClient method buildFolderRequestFromCommand.
private Request buildFolderRequestFromCommand(Command command, String commandName, String[] commandArgs, String root) throws Exception {
// TODO [low] Medium-dirty hack.
String thisPackage = BadRequestResponse.class.getPackage().getName();
String camelCaseMessageType = StringUtil.toCamelCase(commandName) + FolderRequest.class.getSimpleName();
String fqMessageClassName = thisPackage + "." + camelCaseMessageType;
FolderRequest folderRequest;
try {
Class<? extends FolderRequest> folderRequestClass = Class.forName(fqMessageClassName).asSubclass(FolderRequest.class);
folderRequest = folderRequestClass.newInstance();
} catch (Exception e) {
logger.log(Level.INFO, "Could not find FQCN " + fqMessageClassName, e);
throw new Exception("Cannot read request class from request type: " + commandName, e);
}
OperationOptions operationOptions = command.parseOptions(commandArgs);
int requestId = Math.abs(new Random().nextInt());
folderRequest.setRoot(root);
folderRequest.setId(requestId);
folderRequest.setOptions(operationOptions);
return folderRequest;
}
Aggregations