@Test public void testActivateSpaceCall() { String id = "123454321"; fileControl.handleCommand(MasterFileControl.COMMAND_PREFIX_SPACE_ACTIVATE + id); verify(masterApiControllerManager, times(1)).activateSpace(id); }
void handleCommand(String command) { spaceEnvironment.getLog().info(String.format("Master file control received command %s", command)); try { if (COMMAND_SHUTDOWN.equalsIgnoreCase(command)) { spaceSystemControl.shutdown(); } else if (COMMAND_CALCULATE_ACTIVITY_HASHES.equalsIgnoreCase(command)) { calculateActivityHashes(); } else if (COMMAND_SPACE_CONTROLLERS_SHUTDOWN_ALL.equalsIgnoreCase(command)) { masterApiSpaceControllerManager.shutdownAllSpaceControllers(); } else if (COMMAND_SPACE_CONTROLLERS_SHUTDOWN_ALL_ACTIVITIES.equalsIgnoreCase(command)) { masterApiSpaceControllerManager.shutdownAllActivitiesAllSpaceControllers(); } else if (command.startsWith(COMMAND_PREFIX_LIVE_ACTIVITY_GROUP_STARTUP)) { String id = command.substring(COMMAND_PREFIX_LIVE_ACTIVITY_GROUP_STARTUP.length()); masterApiSpaceControllerManager.startupLiveActivityGroup(id); } else if (command.startsWith(COMMAND_PREFIX_LIVE_ACTIVITY_GROUP_SHUTDOWN)) { String id = command.substring(COMMAND_PREFIX_LIVE_ACTIVITY_GROUP_SHUTDOWN.length()); masterApiSpaceControllerManager.shutdownLiveActivityGroup(id); } else if (command.startsWith(COMMAND_PREFIX_LIVE_ACTIVITY_GROUP_ACTIVATE)) { String id = command.substring(COMMAND_PREFIX_LIVE_ACTIVITY_GROUP_ACTIVATE.length()); masterApiSpaceControllerManager.activateLiveActivityGroup(id); } else if (command.startsWith(COMMAND_PREFIX_LIVE_ACTIVITY_GROUP_DEACTIVATE)) { String id = command.substring(COMMAND_PREFIX_LIVE_ACTIVITY_GROUP_DEACTIVATE.length()); masterApiSpaceControllerManager.deactivateLiveActivityGroup(id); } else if (command.startsWith(COMMAND_PREFIX_SPACE_STARTUP)) { String id = command.substring(COMMAND_PREFIX_SPACE_STARTUP.length()); masterApiSpaceControllerManager.startupSpace(id); } else if (command.startsWith(COMMAND_PREFIX_SPACE_SHUTDOWN)) { String id = command.substring(COMMAND_PREFIX_SPACE_SHUTDOWN.length()); masterApiSpaceControllerManager.shutdownSpace(id); } else if (command.startsWith(COMMAND_PREFIX_SPACE_ACTIVATE)) { String id = command.substring(COMMAND_PREFIX_SPACE_ACTIVATE.length()); masterApiSpaceControllerManager.activateSpace(id); } else if (command.startsWith(COMMAND_PREFIX_SPACE_DEACTIVATE)) { String id = command.substring(COMMAND_PREFIX_SPACE_DEACTIVATE.length()); masterApiSpaceControllerManager.deactivateSpace(id); } else if (command.startsWith(COMMAND_PREFIX_SCRIPT_RUN)) { String id = command.substring(COMMAND_PREFIX_SCRIPT_RUN.length()); masterApiAutomationManager.runNamedScript(id); } else { spaceEnvironment.getLog().warn(String.format("Unknown command to master file control %s", command)); } } catch (Exception e) { spaceEnvironment.getLog().error(String.format("Exception while executing master file control %s", command), e); } }
MasterFileControl implements DirectoryWatcherListener { void handleCommand(String command) { spaceEnvironment.getLog().info(String.format("Master file control received command %s", command)); try { if (COMMAND_SHUTDOWN.equalsIgnoreCase(command)) { spaceSystemControl.shutdown(); } else if (COMMAND_CALCULATE_ACTIVITY_HASHES.equalsIgnoreCase(command)) { calculateActivityHashes(); } else if (COMMAND_SPACE_CONTROLLERS_SHUTDOWN_ALL.equalsIgnoreCase(command)) { masterApiSpaceControllerManager.shutdownAllSpaceControllers(); } else if (COMMAND_SPACE_CONTROLLERS_SHUTDOWN_ALL_ACTIVITIES.equalsIgnoreCase(command)) { masterApiSpaceControllerManager.shutdownAllActivitiesAllSpaceControllers(); } else if (command.startsWith(COMMAND_PREFIX_LIVE_ACTIVITY_GROUP_STARTUP)) { String id = command.substring(COMMAND_PREFIX_LIVE_ACTIVITY_GROUP_STARTUP.length()); masterApiSpaceControllerManager.startupLiveActivityGroup(id); } else if (command.startsWith(COMMAND_PREFIX_LIVE_ACTIVITY_GROUP_SHUTDOWN)) { String id = command.substring(COMMAND_PREFIX_LIVE_ACTIVITY_GROUP_SHUTDOWN.length()); masterApiSpaceControllerManager.shutdownLiveActivityGroup(id); } else if (command.startsWith(COMMAND_PREFIX_LIVE_ACTIVITY_GROUP_ACTIVATE)) { String id = command.substring(COMMAND_PREFIX_LIVE_ACTIVITY_GROUP_ACTIVATE.length()); masterApiSpaceControllerManager.activateLiveActivityGroup(id); } else if (command.startsWith(COMMAND_PREFIX_LIVE_ACTIVITY_GROUP_DEACTIVATE)) { String id = command.substring(COMMAND_PREFIX_LIVE_ACTIVITY_GROUP_DEACTIVATE.length()); masterApiSpaceControllerManager.deactivateLiveActivityGroup(id); } else if (command.startsWith(COMMAND_PREFIX_SPACE_STARTUP)) { String id = command.substring(COMMAND_PREFIX_SPACE_STARTUP.length()); masterApiSpaceControllerManager.startupSpace(id); } else if (command.startsWith(COMMAND_PREFIX_SPACE_SHUTDOWN)) { String id = command.substring(COMMAND_PREFIX_SPACE_SHUTDOWN.length()); masterApiSpaceControllerManager.shutdownSpace(id); } else if (command.startsWith(COMMAND_PREFIX_SPACE_ACTIVATE)) { String id = command.substring(COMMAND_PREFIX_SPACE_ACTIVATE.length()); masterApiSpaceControllerManager.activateSpace(id); } else if (command.startsWith(COMMAND_PREFIX_SPACE_DEACTIVATE)) { String id = command.substring(COMMAND_PREFIX_SPACE_DEACTIVATE.length()); masterApiSpaceControllerManager.deactivateSpace(id); } else if (command.startsWith(COMMAND_PREFIX_SCRIPT_RUN)) { String id = command.substring(COMMAND_PREFIX_SCRIPT_RUN.length()); masterApiAutomationManager.runNamedScript(id); } else { spaceEnvironment.getLog().warn(String.format("Unknown command to master file control %s", command)); } } catch (Exception e) { spaceEnvironment.getLog().error(String.format("Exception while executing master file control %s", command), e); } } }
MasterFileControl implements DirectoryWatcherListener { void handleCommand(String command) { spaceEnvironment.getLog().info(String.format("Master file control received command %s", command)); try { if (COMMAND_SHUTDOWN.equalsIgnoreCase(command)) { spaceSystemControl.shutdown(); } else if (COMMAND_CALCULATE_ACTIVITY_HASHES.equalsIgnoreCase(command)) { calculateActivityHashes(); } else if (COMMAND_SPACE_CONTROLLERS_SHUTDOWN_ALL.equalsIgnoreCase(command)) { masterApiSpaceControllerManager.shutdownAllSpaceControllers(); } else if (COMMAND_SPACE_CONTROLLERS_SHUTDOWN_ALL_ACTIVITIES.equalsIgnoreCase(command)) { masterApiSpaceControllerManager.shutdownAllActivitiesAllSpaceControllers(); } else if (command.startsWith(COMMAND_PREFIX_LIVE_ACTIVITY_GROUP_STARTUP)) { String id = command.substring(COMMAND_PREFIX_LIVE_ACTIVITY_GROUP_STARTUP.length()); masterApiSpaceControllerManager.startupLiveActivityGroup(id); } else if (command.startsWith(COMMAND_PREFIX_LIVE_ACTIVITY_GROUP_SHUTDOWN)) { String id = command.substring(COMMAND_PREFIX_LIVE_ACTIVITY_GROUP_SHUTDOWN.length()); masterApiSpaceControllerManager.shutdownLiveActivityGroup(id); } else if (command.startsWith(COMMAND_PREFIX_LIVE_ACTIVITY_GROUP_ACTIVATE)) { String id = command.substring(COMMAND_PREFIX_LIVE_ACTIVITY_GROUP_ACTIVATE.length()); masterApiSpaceControllerManager.activateLiveActivityGroup(id); } else if (command.startsWith(COMMAND_PREFIX_LIVE_ACTIVITY_GROUP_DEACTIVATE)) { String id = command.substring(COMMAND_PREFIX_LIVE_ACTIVITY_GROUP_DEACTIVATE.length()); masterApiSpaceControllerManager.deactivateLiveActivityGroup(id); } else if (command.startsWith(COMMAND_PREFIX_SPACE_STARTUP)) { String id = command.substring(COMMAND_PREFIX_SPACE_STARTUP.length()); masterApiSpaceControllerManager.startupSpace(id); } else if (command.startsWith(COMMAND_PREFIX_SPACE_SHUTDOWN)) { String id = command.substring(COMMAND_PREFIX_SPACE_SHUTDOWN.length()); masterApiSpaceControllerManager.shutdownSpace(id); } else if (command.startsWith(COMMAND_PREFIX_SPACE_ACTIVATE)) { String id = command.substring(COMMAND_PREFIX_SPACE_ACTIVATE.length()); masterApiSpaceControllerManager.activateSpace(id); } else if (command.startsWith(COMMAND_PREFIX_SPACE_DEACTIVATE)) { String id = command.substring(COMMAND_PREFIX_SPACE_DEACTIVATE.length()); masterApiSpaceControllerManager.deactivateSpace(id); } else if (command.startsWith(COMMAND_PREFIX_SCRIPT_RUN)) { String id = command.substring(COMMAND_PREFIX_SCRIPT_RUN.length()); masterApiAutomationManager.runNamedScript(id); } else { spaceEnvironment.getLog().warn(String.format("Unknown command to master file control %s", command)); } } catch (Exception e) { spaceEnvironment.getLog().error(String.format("Exception while executing master file control %s", command), e); } }  }
MasterFileControl implements DirectoryWatcherListener { void handleCommand(String command) { spaceEnvironment.getLog().info(String.format("Master file control received command %s", command)); try { if (COMMAND_SHUTDOWN.equalsIgnoreCase(command)) { spaceSystemControl.shutdown(); } else if (COMMAND_CALCULATE_ACTIVITY_HASHES.equalsIgnoreCase(command)) { calculateActivityHashes(); } else if (COMMAND_SPACE_CONTROLLERS_SHUTDOWN_ALL.equalsIgnoreCase(command)) { masterApiSpaceControllerManager.shutdownAllSpaceControllers(); } else if (COMMAND_SPACE_CONTROLLERS_SHUTDOWN_ALL_ACTIVITIES.equalsIgnoreCase(command)) { masterApiSpaceControllerManager.shutdownAllActivitiesAllSpaceControllers(); } else if (command.startsWith(COMMAND_PREFIX_LIVE_ACTIVITY_GROUP_STARTUP)) { String id = command.substring(COMMAND_PREFIX_LIVE_ACTIVITY_GROUP_STARTUP.length()); masterApiSpaceControllerManager.startupLiveActivityGroup(id); } else if (command.startsWith(COMMAND_PREFIX_LIVE_ACTIVITY_GROUP_SHUTDOWN)) { String id = command.substring(COMMAND_PREFIX_LIVE_ACTIVITY_GROUP_SHUTDOWN.length()); masterApiSpaceControllerManager.shutdownLiveActivityGroup(id); } else if (command.startsWith(COMMAND_PREFIX_LIVE_ACTIVITY_GROUP_ACTIVATE)) { String id = command.substring(COMMAND_PREFIX_LIVE_ACTIVITY_GROUP_ACTIVATE.length()); masterApiSpaceControllerManager.activateLiveActivityGroup(id); } else if (command.startsWith(COMMAND_PREFIX_LIVE_ACTIVITY_GROUP_DEACTIVATE)) { String id = command.substring(COMMAND_PREFIX_LIVE_ACTIVITY_GROUP_DEACTIVATE.length()); masterApiSpaceControllerManager.deactivateLiveActivityGroup(id); } else if (command.startsWith(COMMAND_PREFIX_SPACE_STARTUP)) { String id = command.substring(COMMAND_PREFIX_SPACE_STARTUP.length()); masterApiSpaceControllerManager.startupSpace(id); } else if (command.startsWith(COMMAND_PREFIX_SPACE_SHUTDOWN)) { String id = command.substring(COMMAND_PREFIX_SPACE_SHUTDOWN.length()); masterApiSpaceControllerManager.shutdownSpace(id); } else if (command.startsWith(COMMAND_PREFIX_SPACE_ACTIVATE)) { String id = command.substring(COMMAND_PREFIX_SPACE_ACTIVATE.length()); masterApiSpaceControllerManager.activateSpace(id); } else if (command.startsWith(COMMAND_PREFIX_SPACE_DEACTIVATE)) { String id = command.substring(COMMAND_PREFIX_SPACE_DEACTIVATE.length()); masterApiSpaceControllerManager.deactivateSpace(id); } else if (command.startsWith(COMMAND_PREFIX_SCRIPT_RUN)) { String id = command.substring(COMMAND_PREFIX_SCRIPT_RUN.length()); masterApiAutomationManager.runNamedScript(id); } else { spaceEnvironment.getLog().warn(String.format("Unknown command to master file control %s", command)); } } catch (Exception e) { spaceEnvironment.getLog().error(String.format("Exception while executing master file control %s", command), e); } }  void startup(); void shutdown(); @Override void onFileAdded(File file); @Override void onFileRemoved(File file); void setSpaceEnvironment(InteractiveSpacesEnvironment spaceEnvironment); void setSpaceSystemControl(InteractiveSpacesSystemControl spaceSystemControl); void setMasterApiSpaceControllerManager(MasterApiSpaceControllerManager masterApiControllerManager); void setMasterApiAutomationManager(MasterApiAutomationManager masterApiAutomationManager); void setActivityRepository(ActivityRepository activityRepository); void setActivityRepositoryManager(ActivityRepositoryManager activityRepositoryManager); }
MasterFileControl implements DirectoryWatcherListener { void handleCommand(String command) { spaceEnvironment.getLog().info(String.format("Master file control received command %s", command)); try { if (COMMAND_SHUTDOWN.equalsIgnoreCase(command)) { spaceSystemControl.shutdown(); } else if (COMMAND_CALCULATE_ACTIVITY_HASHES.equalsIgnoreCase(command)) { calculateActivityHashes(); } else if (COMMAND_SPACE_CONTROLLERS_SHUTDOWN_ALL.equalsIgnoreCase(command)) { masterApiSpaceControllerManager.shutdownAllSpaceControllers(); } else if (COMMAND_SPACE_CONTROLLERS_SHUTDOWN_ALL_ACTIVITIES.equalsIgnoreCase(command)) { masterApiSpaceControllerManager.shutdownAllActivitiesAllSpaceControllers(); } else if (command.startsWith(COMMAND_PREFIX_LIVE_ACTIVITY_GROUP_STARTUP)) { String id = command.substring(COMMAND_PREFIX_LIVE_ACTIVITY_GROUP_STARTUP.length()); masterApiSpaceControllerManager.startupLiveActivityGroup(id); } else if (command.startsWith(COMMAND_PREFIX_LIVE_ACTIVITY_GROUP_SHUTDOWN)) { String id = command.substring(COMMAND_PREFIX_LIVE_ACTIVITY_GROUP_SHUTDOWN.length()); masterApiSpaceControllerManager.shutdownLiveActivityGroup(id); } else if (command.startsWith(COMMAND_PREFIX_LIVE_ACTIVITY_GROUP_ACTIVATE)) { String id = command.substring(COMMAND_PREFIX_LIVE_ACTIVITY_GROUP_ACTIVATE.length()); masterApiSpaceControllerManager.activateLiveActivityGroup(id); } else if (command.startsWith(COMMAND_PREFIX_LIVE_ACTIVITY_GROUP_DEACTIVATE)) { String id = command.substring(COMMAND_PREFIX_LIVE_ACTIVITY_GROUP_DEACTIVATE.length()); masterApiSpaceControllerManager.deactivateLiveActivityGroup(id); } else if (command.startsWith(COMMAND_PREFIX_SPACE_STARTUP)) { String id = command.substring(COMMAND_PREFIX_SPACE_STARTUP.length()); masterApiSpaceControllerManager.startupSpace(id); } else if (command.startsWith(COMMAND_PREFIX_SPACE_SHUTDOWN)) { String id = command.substring(COMMAND_PREFIX_SPACE_SHUTDOWN.length()); masterApiSpaceControllerManager.shutdownSpace(id); } else if (command.startsWith(COMMAND_PREFIX_SPACE_ACTIVATE)) { String id = command.substring(COMMAND_PREFIX_SPACE_ACTIVATE.length()); masterApiSpaceControllerManager.activateSpace(id); } else if (command.startsWith(COMMAND_PREFIX_SPACE_DEACTIVATE)) { String id = command.substring(COMMAND_PREFIX_SPACE_DEACTIVATE.length()); masterApiSpaceControllerManager.deactivateSpace(id); } else if (command.startsWith(COMMAND_PREFIX_SCRIPT_RUN)) { String id = command.substring(COMMAND_PREFIX_SCRIPT_RUN.length()); masterApiAutomationManager.runNamedScript(id); } else { spaceEnvironment.getLog().warn(String.format("Unknown command to master file control %s", command)); } } catch (Exception e) { spaceEnvironment.getLog().error(String.format("Exception while executing master file control %s", command), e); } }  void startup(); void shutdown(); @Override void onFileAdded(File file); @Override void onFileRemoved(File file); void setSpaceEnvironment(InteractiveSpacesEnvironment spaceEnvironment); void setSpaceSystemControl(InteractiveSpacesSystemControl spaceSystemControl); void setMasterApiSpaceControllerManager(MasterApiSpaceControllerManager masterApiControllerManager); void setMasterApiAutomationManager(MasterApiAutomationManager masterApiAutomationManager); void setActivityRepository(ActivityRepository activityRepository); void setActivityRepositoryManager(ActivityRepositoryManager activityRepositoryManager); static final int DIRECTORY_SCAN_TIME; static final String FOLDER_RUN_CONTROL; static final String COMMAND_SHUTDOWN; static final String COMMAND_CALCULATE_ACTIVITY_HASHES; static final String COMMAND_SPACE_CONTROLLERS_SHUTDOWN_ALL; static final String COMMAND_SPACE_CONTROLLERS_SHUTDOWN_ALL_ACTIVITIES; static final String COMMAND_PREFIX_LIVE_ACTIVITY_GROUP_STARTUP; static final String COMMAND_PREFIX_LIVE_ACTIVITY_GROUP_ACTIVATE; static final String COMMAND_PREFIX_LIVE_ACTIVITY_GROUP_SHUTDOWN; static final String COMMAND_PREFIX_LIVE_ACTIVITY_GROUP_DEACTIVATE; static final String COMMAND_PREFIX_SPACE_STARTUP; static final String COMMAND_PREFIX_SPACE_SHUTDOWN; static final String COMMAND_PREFIX_SPACE_ACTIVATE; static final String COMMAND_PREFIX_SPACE_DEACTIVATE; static final String COMMAND_PREFIX_SCRIPT_RUN; }