public void onCreate() {
    super.onCreate();
    Log.d(PluginConstants.LOG_TAG, "Enter LiveViewService.onCreate.");

    // Load menu icon
    int iconId = PluginUtils.getDynamicResourceId(this, "icon", "drawable");
    mMenuIcon = PluginUtils.storeIconToFile(this, getResources(), iconId, MENU_ICON_FILENAME);
  }
Example #2
0
  public void execute() throws MojoExecutionException {

    setFormatters();

    createoutputDir();

    CompilerOptions options = createCompilerOptions();

    // Activate loggers if specified. If the logging is activated but there
    // is no log file, no output will be generated.
    CompilerLogging.activateLoggers(logging);
    CompilerLogging.setLogFile(logFile);

    File profileDirectory = new File(sourceDirectory, profiles);

    Set<File> objects = PluginUtils.collectPanSources(profileDirectory);

    CompilerResults results = Compiler.run(options, null, objects);

    boolean hadError = results.print(verbose);

    if (hadError) {
      throw new MojoExecutionException("pan language syntax check failed");
    }
  }
Example #3
0
 /**
  * @param message The message to be displayed or <code>null</code> to display a Password prompt
  * @param link the {@link CryptedLink}
  * @return the entered password
  * @throws DecrypterException if the user aborts the input
  */
 public static String getUserInput(final String message, final CryptedLink link)
     throws DecrypterException {
   final String password = PluginUtils.askPassword(message, link);
   if (password == null) {
     throw new DecrypterException(DecrypterException.PASSWORD);
   }
   return password;
 }
Example #4
0
 /**
  * @param message The message to be displayed or <code>null</code> to display a Password prompt
  * @param link the {@link DownloadLink}
  * @return the entered password
  * @throws PluginException if the user aborts the input
  */
 public static String getUserInput(final String message, final DownloadLink link)
     throws PluginException {
   final String password = PluginUtils.askPassword(message, link);
   if (password == null) {
     throw new PluginException(
         LinkStatus.ERROR_FATAL, JDL.L("plugins.errors.wrongpassword", "Password wrong"));
   }
   return password;
 }
 @Override
 public void enterChatMode(String number) {
   Logger.d(TAG, "enterChatMode() entry, number " + number);
   if (PluginUtils.getMessagingMode() == 0) {
     if (number.startsWith(IpMessageConsts.JOYN_START)) {
       number = number.substring(4);
     }
   }
   Message controllerMessage =
       PluginController.obtainMessage(
           ChatController.EVENT_SHOW_WINDOW, PhoneUtils.formatNumberToInternational(number));
   controllerMessage.sendToTarget();
   if ((PluginUtils.getMessagingMode() == 1) && (PluginUtils.translateThreadId(number) == 1)) {
     Logger.v(TAG, "enterChatMode(), open Window = " + number);
     Intent intent = new Intent(InvitationDialog.ACTION);
     intent.putExtra(RcsNotification.CONTACT, number);
     intent.putExtra(InvitationDialog.KEY_STRATEGY, InvitationDialog.STRATEGY_IPMES_SEND_BY_SMS);
     intent.putExtra("showDialog", true);
     intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
     AndroidFactory.getApplicationContext().startActivity(intent);
   }
   super.enterChatMode(number);
 }
 @Override
 public void exitFromChatMode(String number) {
   Logger.d(TAG, "exitFromChatMode() entry, number " + number);
   if (PluginUtils.getMessagingMode() == 0) {
     if (number.startsWith(IpMessageConsts.JOYN_START)) {
       number = number.substring(4);
     }
   }
   Message controllerMessage =
       PluginController.obtainMessage(
           ChatController.EVENT_HIDE_WINDOW, PhoneUtils.formatNumberToInternational(number));
   controllerMessage.sendToTarget();
   super.exitFromChatMode(number);
 }
 /**
  * Get the {@link Subject} from somewhere.
  *
  * <p>If per-request subject caching is enabled, the request is checked first. If no subject is
  * present there, DeadboltHandler#getSubject is called. The resulting subject, if any, is cached
  * in the request.
  *
  * <p>If per-request subject caching is not enabled, DeadboltHandler#getSubject is called.
  *
  * @param deadboltHandler
  * @param ctx
  * @return
  */
 public static Subject getSubject(DeadboltHandler deadboltHandler, Http.Context ctx) {
   Object cachedUser = ctx.args.get(PluginConfigKeys.CACHE_DEADBOLT_USER);
   Subject subject = null;
   try {
     if (PluginUtils.isUserCacheEnabled()) {
       if (cachedUser != null) {
         subject = (Subject) cachedUser;
       } else {
         subject = deadboltHandler.getSubject(ctx);
         ctx.args.put(PluginConfigKeys.CACHE_DEADBOLT_USER, subject);
       }
     } else {
       subject = deadboltHandler.getSubject(ctx);
     }
   } catch (Exception e) {
     Logger.error("Error getting subject: " + e.getMessage(), e);
   }
   return subject;
 }
  public void onStart(Intent intent, int startId) {
    super.onStart(intent, startId);
    Log.d(PluginConstants.LOG_TAG, "Enter LiveViewService.onStart.");

    if (intent.getBooleanExtra(INTENT_EXTRA_ANNOUNCE, false)) {
      Bundle extras = intent.getExtras();
      if (extras != null) {
        try {
          if (mLiveView != null) {
            mLiveView.sendAnnounce(
                mPluginId,
                mMenuIcon,
                extras.getString(INTENT_EXTRA_TITLE),
                extras.getString(INTENT_EXTRA_TEXT),
                System.currentTimeMillis(),
                "");
            Log.d(PluginConstants.LOG_TAG, "Announce sent to LiveView Application");
          } else {
            Log.d(PluginConstants.LOG_TAG, "LiveView Application not reachable");
          }
        } catch (Exception e) {
          Log.e(PluginConstants.LOG_TAG, "Failed to send announce", e);
        }
      }

    } else {
      // We end up here when LiveView Application probes the plugin
      if (isAlreadyRunning()) {
        Log.d(PluginConstants.LOG_TAG, "Already started.");
      } else {
        // Init
        mPluginName =
            PluginUtils.getDynamicResourceString(this, PluginConstants.RESOURCE_STRING_PLUGIN_NAME);

        // Bind to LiveView
        connectToLiveView();

        // Singleton
        alreadyRunning = true;
      }
    }
  }
 @Override
 public void sendChatMode(String number, int status) {
   Logger.d(TAG, "sendChatMode() the number is " + number + " status is " + status);
   boolean isEmpty = true;
   if (PluginUtils.getMessagingMode() == 0) {
     if (number.startsWith(IpMessageConsts.JOYN_START)) {
       number = number.substring(4);
     }
   }
   if (status == ContactStatus.STOP_TYPING) {
     isEmpty = true;
   } else if (status == ContactStatus.TYPING) {
     isEmpty = false;
   }
   Message controllerMessage =
       PluginController.obtainMessage(
           ChatController.EVENT_TEXT_CHANGED,
           PhoneUtils.formatNumberToInternational(number),
           isEmpty);
   controllerMessage.sendToTarget();
 }
 public File loadSharedPlugin() {
   return PluginUtils.findSharedDirectory(pluginDirectories);
 }
Example #11
0
  @Test
  public void testHotDeploy() throws Exception {
    // Grab the ServerPluginRegistry
    PluginRegistry theRegistry = PluginUtils.getPluginRegistry();
    assertNotNull("PluginRegistry should exist.", theRegistry);
    assertTrue(theRegistry instanceof ServerPluginRegistry);
    ServerPluginRegistry registry = (ServerPluginRegistry) theRegistry;

    // Let's shut down the asynchronous reloader and hot deployer because we want to do this
    // synchronously.
    HotDeployer hotDeployer = registry.getHotDeployer();
    Reloader reloader = registry.getReloader();
    registry.stopHotDeployer();
    registry.stopReloader();

    // Assert that there are currently no plugins
    assertEquals("There should be no plugins.", 0, registry.getPluginEnvironments().size());
    assertEquals(
        "Resource loader should have no children.", 0, registry.getResourceLoaders().size());

    // query the hot deployer directly about it's added and removed plugins
    assertEquals("There should be no plugins added.", 0, hotDeployer.getAddedPlugins().size());
    assertEquals("There should be no plugins removed.", 0, hotDeployer.getRemovedPlugins().size());
    hotDeployer.run();
    assertEquals("There should still be no plugins.", 0, registry.getPluginEnvironments().size());

    // now let's copy a plugin over and run the hot deployer
    String pluginZipFileLocation =
        getBaseDir() + "/src/test/resources/org/kuali/rice/kew/plugin/ziptest.zip";
    File pluginZipFile = new File(pluginZipFileLocation);
    assertTrue("Plugin file '" + pluginZipFileLocation + "' should exist", pluginZipFile.exists());
    assertTrue(
        "Plugin file '" + pluginZipFileLocation + "' should be a file", pluginZipFile.isFile());
    FileUtils.copyFileToDirectory(pluginZipFile, pluginDir);

    assertEquals("There should be one plugin added.", 1, hotDeployer.getAddedPlugins().size());
    assertEquals("There should be no plugins removed.", 0, hotDeployer.getRemovedPlugins().size());

    hotDeployer.run();

    // the plugin should have been hot deployed
    assertEquals(
        "Plugin should have been hot deployed.", 1, registry.getPluginEnvironments().size());

    // check added plugins again, it should now indicate no new added plugins
    assertEquals("There should be no plugins added.", 0, hotDeployer.getAddedPlugins().size());
    assertEquals("There should be no plugins removed.", 0, hotDeployer.getRemovedPlugins().size());

    // verify that the resource loading and the registry are sane and properly set up with the new
    // plugin
    assertEquals(
        "Resource loader should have 1 plugin child.", 1, registry.getResourceLoaders().size());
    Plugin plugin = (Plugin) registry.getResourceLoaders().get(0);
    assertEquals(
        "Plugin has wrong name.",
        new QName(CoreConfigHelper.getApplicationId(), "ziptest"),
        plugin.getName());
    assertTrue("Plugin should be started.", plugin.isStarted());
    assertEquals(
        "Plugin in resource loader and environment should be the same.",
        plugin,
        registry.getPluginEnvironment(plugin.getName().getLocalPart()).getPlugin());

    // The reloader should have a reference to the environment
    assertEquals(
        "Reloader should have a reference to environment.", 1, reloader.getReloadables().size());

    // now remove the plugin and ensure that it goes away
    FileUtils.forceDelete(new File(pluginDir, "ziptest.zip"));
    assertEquals("There should be no plugins added.", 0, hotDeployer.getAddedPlugins().size());
    assertEquals("There should be one plugin removed.", 1, hotDeployer.getRemovedPlugins().size());
    hotDeployer.run();

    // verify that the resource loading and the registry no longer contain the plugin
    assertEquals("No plugins should be deployed.", 0, registry.getPluginEnvironments().size());
    assertEquals(
        "Resource loader should have 0 plugin children.", 0, registry.getResourceLoaders().size());

    // also assert that the reloader no longer has a reference to the environment
    assertEquals(
        "Reloader should no longer have reference to environment.",
        0,
        reloader.getReloadables().size());
  }
Example #12
0
  @Test
  public void testReloader() throws Exception {
    // Grab the ServerPluginRegistry
    PluginRegistry theRegistry = PluginUtils.getPluginRegistry();
    assertNotNull("PluginRegistry should exist.", theRegistry);
    assertTrue(theRegistry instanceof ServerPluginRegistry);
    ServerPluginRegistry registry = (ServerPluginRegistry) theRegistry;

    // Let's shut down the asynchronous reloader and hot deployer because we want to do this
    // synchronously.
    HotDeployer hotDeployer = registry.getHotDeployer();
    Reloader reloader = registry.getReloader();
    registry.stopHotDeployer();
    registry.stopReloader();

    // Assert that there are currently no plugins
    assertEquals("There should be no plugins.", 0, registry.getPluginEnvironments().size());
    assertEquals(
        "Resource loader should have no children.", 0, registry.getResourceLoaders().size());

    // now let's copy a plugin over and run the hot deployer
    String pluginZipFileLocation =
        getBaseDir() + "/src/test/resources/org/kuali/rice/kew/plugin/ziptest.zip";
    File pluginZipFile = new File(pluginZipFileLocation);
    assertTrue("Plugin file '" + pluginZipFileLocation + "' should exist", pluginZipFile.exists());
    assertTrue(
        "Plugin file '" + pluginZipFileLocation + "' should be a file", pluginZipFile.isFile());
    FileUtils.copyFileToDirectory(pluginZipFile, pluginDir);

    // update pluginZipFile to point to the copy
    pluginZipFile = new File(pluginDir, pluginZipFile.getName());
    assertTrue(pluginZipFile.exists());

    // execute a hot deploy
    hotDeployer.run();

    // the plugin should have been hot deployed
    assertEquals(
        "Plugin should have been hot deployed.", 1, registry.getPluginEnvironments().size());
    assertEquals(
        "Resource loader should have 1 plugin child.", 1, registry.getResourceLoaders().size());
    PluginEnvironment environment = registry.getPluginEnvironments().get(0);
    Plugin plugin = environment.getPlugin();
    assertTrue(environment.isReloadable());
    assertFalse(environment.isReloadNeeded());

    // let's attempt to execute a Reload
    reloader.run();

    // a reload should not have occurred here since nothing was updated
    assertTrue("Original plugin should still be running.", plugin.isStarted());
    assertEquals(
        "Plugin should not have changed.",
        plugin,
        registry.getPluginEnvironments().get(0).getPlugin());

    // touch the plugin file and then reload
    FileUtils.touch(pluginZipFile);
    assertTrue("A reload should be needed now.", environment.isReloadNeeded());
    reloader.run();

    // the original plugin should now be stopped
    assertTrue("original plugin should be stopped.", !plugin.isStarted());
    assertEquals("There should only be one Plugin.", 1, registry.getResourceLoaders().size());

    PluginEnvironment newPluginEnvironment = registry.getPluginEnvironments().get(0);
    Plugin newPlugin = newPluginEnvironment.getPlugin();
    assertEquals(
        "There should still only be one environment.", 1, registry.getPluginEnvironments().size());
    assertEquals(
        "The plugin environments should still be the same.",
        environment,
        registry.getPluginEnvironments().get(0));

    assertFalse("The old and new plugins should be different.", newPlugin.equals(plugin));

    // verify that the resource loader was updated
    assertEquals(
        "The resource loaders should have been updated with the new plugin.",
        newPlugin,
        registry.getResourceLoaders().get(0));
  }
 /**
  * Return the helper, making sure its anonymous while Jenkins is still initializing.
  *
  * @return helper
  */
 HistoryDao getHistoryDao(JobConfigHistory plugin) {
   return (COMPLETED == Hudson.getInstance().getInitLevel())
       ? PluginUtils.getHistoryDao(plugin)
       : PluginUtils.getAnonymousHistoryDao(plugin);
 }
 /**
  * For tests only.
  *
  * @return helper.
  */
 @Deprecated
 HistoryDao getHistoryDao() {
   return getHistoryDao(PluginUtils.getPlugin());
 }
 @Override
 public void exportChat(long threadId) {
   PluginUtils.initiateExportChat(threadId);
 }
 /**
  * For tests only.
  *
  * @return plugin
  */
 JobConfigHistory getPlugin() {
   return PluginUtils.getPlugin();
 }
 @Override
 public CallableStatus sampleStatus(SampleStratification sampleStratification) {
   return PluginUtils.genericSampleStatus(sampleStratification, CALL, threshold);
 }