Esempio n. 1
0
 public void loadSecondStage(Dictionary dictionaries) {
   Dictionary laneDictionary = (Dictionary) (dictionaries.get("lane")),
       nodeDictionary = (Dictionary) (dictionaries.get("node"));
   tl = ((Drivelane) (laneDictionary.get(new Integer(loadData.oldTlId)))).getSign();
   tl_new = ((Drivelane) (laneDictionary.get(new Integer(loadData.newTlId)))).getSign();
   destination = (Node) (nodeDictionary.get(new Integer(loadData.destNodeId)));
 }
  protected void validate() {
    try {
      Dictionary<String, Object> fileSystemDictionary =
          getConfigurationDictionary(FileSystemStoreConfiguration.class);

      Dictionary<String, Object> advancedFileSystemDictionary =
          getConfigurationDictionary(AdvancedFileSystemStoreConfiguration.class);

      if ((fileSystemDictionary != null) && (advancedFileSystemDictionary != null)) {

        String fileSystemRootDir = (String) fileSystemDictionary.get("rootdir");

        String advancedFileSystemRootDir = (String) advancedFileSystemDictionary.get("rootdir");

        if (Validator.equals(fileSystemRootDir, advancedFileSystemRootDir)) {

          throw new IllegalArgumentException(
              "File system root directory and advanced file "
                  + "system root directory are identical",
              new FileSystemStoreRootDirException());
        }
      }
    } catch (IOException ioe) {
      throw new IllegalArgumentException(ioe);
    }
  }
Esempio n. 3
0
  public void update(final Dictionary<String, ?> properties) {
    dispose();

    final String keyring = (String) properties.get("keyring");
    final String keyId = (String) properties.get("key.id");
    final String passphrase = (String) properties.get("key.passphrase");
    final Object description = properties.get("description");

    PgpSigningService service;
    try {
      service = PgpSigningService.create(new File(keyring), keyId, passphrase);
    } catch (IOException | PGPException e) {
      logger.warn("Failed to register signing service", e);
      return;
    }

    // register new service

    final Dictionary<String, Object> serviceProperties = new Hashtable<>();

    serviceProperties.put(Constants.SERVICE_PID, this.pid);
    serviceProperties.put(Constants.SERVICE_DESCRIPTION, description);

    this.handle = this.context.registerService(SigningService.class, service, serviceProperties);
  }
  public static int getScrollY(AbsListView lv) {
    View c = lv.getChildAt(0);
    if (c == null) {
      return 0;
    }

    int firstVisiblePosition = lv.getFirstVisiblePosition();
    int scrollY = -(c.getTop());
    //        int scrollY = 0;

    sListViewItemHeights.put(lv.getFirstVisiblePosition(), c.getHeight());

    //        if(scrollY>0)
    //            Log.d("QuickReturnUtils", "getScrollY() : -(c.getTop()) - "+ -(c.getTop()));
    //        else
    //            Log.i("QuickReturnUtils", "getScrollY() : -(c.getTop()) - "+ -(c.getTop()));

    if (scrollY < 0) scrollY = 0;

    for (int i = 0; i < firstVisiblePosition; ++i) {
      //            Log.d("QuickReturnUtils", "getScrollY() : i - "+i);

      //            Log.d("QuickReturnUtils", "getScrollY() : sListViewItemHeights.get(i) -
      // "+sListViewItemHeights.get(i));

      if (sListViewItemHeights.get(i) != null) // (this is a sanity check)
      scrollY += sListViewItemHeights.get(i); // add all heights of the views that are gone
    }

    //        Log.d("QuickReturnUtils", "getScrollY() : scrollY - "+scrollY);

    return scrollY;
  }
  @Activate
  protected void activate(ComponentContext componentContext) throws Exception {
    LOG.info("Starting Activation of AMQ Broker ");
    try {
      Dictionary<?, ?> properties = componentContext.getProperties();
      BundleContext bundleContext = componentContext.getBundleContext();
      String brokerUrl = (String) properties.get(ACTIVEMQ_BROKER_URL);

      broker = new BrokerService();

      // generate a full path
      String slingHome = bundleContext.getProperty("sling.home");
      String dataPath = slingHome + "/activemq-data";
      LOG.info("Setting Data Path to  [{}] [{}] ", new Object[] {slingHome, dataPath});
      broker.setDataDirectory(dataPath);

      String federatedBrokerUrl = (String) properties.get(ACTIVEMQ_FEDERATED_BROKER_URL);

      if (federatedBrokerUrl != null && federatedBrokerUrl.length() > 0) {
        LOG.info("Federating ActiveMQ  [" + federatedBrokerUrl + "]");
        NetworkConnector connector = broker.addNetworkConnector(federatedBrokerUrl);
        connector.setDuplex(true);
      }

      // configure the broker
      LOG.info("Adding ActiveMQ connector [" + brokerUrl + "]");
      broker.addConnector(brokerUrl);

      broker.start();
    } catch (Exception e) {
      LOG.info(e.getMessage(), e);
      throw e;
    }
  }
  public void updated(String pid, Dictionary<String, ?> configuration)
      throws ConfigurationException {
    synchronized (m_updateLock) {
      if (m_log.doDebug()) {
        m_log.debug("Updated pid=" + pid);
      }

      if (!PID.equals(pid) && (null != m_services.get(PID))) {
        if (m_log.doDebug()) {
          m_log.debug("Overriding default instance with new pid " + pid);
        }

        deleted(PID);
      }

      SslServiceWrapper service = m_services.get(pid);
      if (service == null) {
        if (m_log.doDebug()) {
          m_log.debug("create pid=" + pid);
        }

        service = new SslServiceWrapper(m_bc, m_log);
        m_services.put(pid, service);
      }

      service.update(configuration);
    }
  }
Esempio n. 7
0
  /** {@inheritDoc} */
  @Override
  public void updated(Dictionary<String, ?> config) throws ConfigurationException {

    if (omniWorker != null) {
      omniWorker.setRunning(false);
    }

    if (config != null) {

      String host = (String) config.get("host");
      int port = Integer.parseInt((String) config.get("port"));
      String key1 = (String) config.get("key1");
      String key2 = (String) config.get("key2");

      boolean generateItems = Boolean.parseBoolean((String) config.get("generateItems"));

      if (StringUtils.isEmpty(host) || StringUtils.isEmpty(key1) || StringUtils.isEmpty(key2)) {
        throw new ConfigurationException("omnilink", "host, key1 or key2 was not found");
      }

      logger.debug("Starting update");

      omniWorker = new OmniConnectionThread(host, port, key1 + ":" + key2, generateItems, this);
      omniWorker.start();
    }
  }
  /**
   * Implements the <tt>ListCellRenderer</tt> method. Returns this panel that has been configured to
   * display bundle name, version and description.
   *
   * @param table the parent table
   * @param value the value of the rendered cell
   * @param isSelected indicates if the rendered cell is selected
   * @param hasFocus indicates if the rendered cell has the focus
   * @param rowIndex the row index of the rendered cell
   * @param vColIndex the column index of the rendered cell
   * @return the rendering component
   */
  public Component getTableCellRendererComponent(
      JTable table,
      Object value,
      boolean isSelected,
      boolean hasFocus,
      int rowIndex,
      int vColIndex) {
    Bundle bundle = (Bundle) value;

    Dictionary<?, ?> headers = bundle.getHeaders();
    Object bundleName = headers.get(Constants.BUNDLE_NAME);
    Object bundleVersion = headers.get(Constants.BUNDLE_VERSION);
    Object bundleDescription = headers.get(Constants.BUNDLE_DESCRIPTION);

    Icon stateIcon = getStateIcon(bundle.getState());

    if (bundleName != null) this.nameLabel.setText(bundleName.toString());
    else this.nameLabel.setText("unknown");

    if (bundleVersion != null) this.versionLabel.setText(bundleVersion.toString());
    else this.versionLabel.setText("");

    if (bundleDescription != null) this.descriptionLabel.setText(bundleDescription.toString());
    else this.descriptionLabel.setText("");

    if (stateIcon != null) this.stateLabel.setIcon(stateIcon);

    this.nameVersionPanel.remove(systemLabel);

    if (PluginManagerActivator.isSystemBundle(bundle)) this.nameVersionPanel.add(systemLabel);

    this.isSelected = isSelected;

    return this;
  }
Esempio n. 9
0
  AD localize(Dictionary<?, ?> dict) {
    final AD localized = (AD) this.clone();

    if (name != null && name.startsWith("%")) {
      String sub;
      if ((sub = (String) dict.get(name.substring(1))) != null) {
        localized.name = sub;
      }
    }

    if (desc != null && desc.startsWith("%")) {
      String sub;
      if ((sub = (String) dict.get(desc.substring(1))) != null) {
        localized.desc = sub;
      }
    }

    if (optLabels != null) {
      for (int i = 0; i < optLabels.length; i++) {
        if (optLabels[i].startsWith("%")) {
          String sub;
          if ((sub = (String) dict.get(optLabels[i].substring(1))) != null) {
            localized.optLabels[i] = sub;
          }
        }
      }
    }

    return localized;
  }
  @SuppressWarnings("rawtypes")
  public void updated(String pid, Dictionary properties) throws ConfigurationException {
    DataSourceEntry dsEntry = dataSources.get(pid);
    if (dsEntry != null) {
      dsEntry.getServiceRegistration().unregister();
      dataSources.remove(pid);
    }

    try {

      Properties dsProperties = filterDataSourceProperties(properties);
      DataSource ds = datasourceFactory.createDataSource(dsProperties);

      Dictionary<String, String> registrationProperties = new Hashtable<String, String>();
      String databaseName = (String) properties.get(DataSourceFactory.JDBC_DATABASE_NAME);
      String datasourceName = (String) properties.get(DataSourceFactory.JDBC_DATASOURCE_NAME);
      if (datasourceName != null)
        registrationProperties.put(DataSourceFactory.JDBC_DATASOURCE_NAME, datasourceName);
      registrationProperties.put(DataSourceFactory.JDBC_SERVER_NAME, databaseName);
      ServiceRegistration serviceRegistration =
          bundleContext.registerService(DataSource.class.getName(), ds, registrationProperties);
      dsEntry = new DataSourceEntry(ds, serviceRegistration);
      dataSources.put(pid, dsEntry);
    } catch (SQLException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
  /**
   * @param bundle
   * @return
   */
  private static String getHeader(final Bundle bundle, String... keys) {
    // Look in the bundle...
    Dictionary headers = bundle.getHeaders();
    for (String key : keys) {
      String value = (String) headers.get(key);
      if (value != null) {
        return value;
      }
    }

    // Next, look in the bundle's fragments.
    Bundle[] bundles = bundle.getBundleContext().getBundles();
    for (Bundle fragment : bundles) {
      // only fragments are in resolved state
      if (fragment.getState() != bundle.RESOLVED) continue;

      // A fragment must also have the FRAGMENT_HOST header and the FRAGMENT_HOST header
      // must be equal to the bundle symbolic name
      String fragmentHost = (String) fragment.getHeaders().get(Constants.FRAGMENT_HOST);
      if ((fragmentHost == null) || (!fragmentHost.equals(bundle.getSymbolicName()))) {
        continue;
      }
      headers = fragment.getHeaders();
      for (String key : keys) {
        String value = (String) headers.get(key);
        if (value != null) {
          return value;
        }
      }
    }
    return null;
  }
Esempio n. 12
0
  /** @{inheritDoc */
  @Override
  public void updated(Dictionary<String, ?> config) throws ConfigurationException {
    // logger.debug("updated() is called!");

    setProperlyConfigured(false);

    if (config != null) {

      String refreshIntervalString = (String) config.get("refresh");
      if (StringUtils.isNotBlank(refreshIntervalString)) {
        refreshInterval = Long.parseLong(refreshIntervalString);
      }

      String ip = (String) config.get("ip"); // $NON-NLS-1$
      if (StringUtils.isBlank(ip)) {
        throw new ConfigurationException("ip", "The ip address must not be empty.");
      }
      this.ip = ip;

      String username = (String) config.get("username"); // $NON-NLS-1$
      if (StringUtils.isBlank(username)) {
        throw new ConfigurationException("username", "The username must not be empty.");
      }
      this.username = username;

      String password = (String) config.get("password"); // $NON-NLS-1$
      if (StringUtils.isBlank(password)) {
        throw new ConfigurationException("password", "The password must not be empty.");
      }
      this.password = password;

      setProperlyConfigured(true);
    }
  }
 @SuppressWarnings("unchecked")
 @Activate
 protected void activate(ComponentContext context) {
   Dictionary properties = context.getProperties();
   casServerUrl = (String) properties.get(serverName);
   casServerLoginUrl = (String) properties.get(loginUrl);
   casServerLogoutUrl = (String) properties.get(logoutUrl);
 }
Esempio n. 14
0
 public void sendMailToSupervisor(String subject, String textbody)
     throws AddressException, MessagingException {
   TreeMap<String, Object> msg = new TreeMap<String, Object>();
   msg.put("from", properties.get("sendMailFrom"));
   msg.put("recipient", properties.get("supervisorEMail"));
   msg.put("subject", subject);
   msg.put("messageText", textbody);
   send(msg);
 }
 @Override
 public String apply(String remainder) {
   if (m_properties != null) {
     return (m_properties.get(remainder) != null) ? m_properties.get(remainder).toString() : null;
   } else if (m_dictonnary != null) {
     return (m_dictonnary.get(remainder) != null) ? m_dictonnary.get(remainder).toString() : null;
   }
   return null;
 }
Esempio n. 16
0
  /**
   * Internal match routine. Dictionary parameter must support case-insensitive get.
   *
   * @param properties A dictionary whose keys are used in the match.
   * @return If the Dictionary's keys match the filter, return <code>true</code>. Otherwise, return
   *     <code>false</code>.
   */
  private boolean match0(Dictionary properties) {
    switch (op) {
      case AND:
        {
          FilterImpl[] filters = (FilterImpl[]) value;
          for (int i = 0, size = filters.length; i < size; i++) {
            if (!filters[i].match0(properties)) {
              return false;
            }
          }

          return true;
        }

      case OR:
        {
          FilterImpl[] filters = (FilterImpl[]) value;
          for (int i = 0, size = filters.length; i < size; i++) {
            if (filters[i].match0(properties)) {
              return true;
            }
          }

          return false;
        }

      case NOT:
        {
          FilterImpl filter = (FilterImpl) value;

          return !filter.match0(properties);
        }

      case SUBSTRING:
      case EQUAL:
      case GREATER:
      case LESS:
      case APPROX:
      case SUBSET:
      case SUPERSET:
        {
          Object prop = (properties == null) ? null : properties.get(attr);

          return compare(op, prop, value);
        }

      case PRESENT:
        {
          Object prop = (properties == null) ? null : properties.get(attr);

          return prop != null;
        }
    }

    return false;
  }
  @Activate
  public void activate(ComponentContext ctx) {
    final Dictionary<String, Object> properties = ctx.getProperties();

    _problemTitle = (String) properties.get("problem.title");
    _problemSummary = (String) properties.get("problem.summary");
    _problemType = (String) properties.get("file.extensions");
    _problemTickets = (String) properties.get("problem.tickets");
    _sectionKey = (String) properties.get("problem.section");
  }
 private int getScroll() {
   View c = leftView.getChildAt(0); // this is the first visible row
   int scrollY = -c.getTop();
   listViewItemHeights.put(leftView.getFirstVisiblePosition(), c.getHeight());
   for (int i = 0; i < leftView.getFirstVisiblePosition(); ++i) {
     if (listViewItemHeights.get(i) != null) // (this is a sanity check)
     scrollY += listViewItemHeights.get(i); // add all heights of the views that are gone
   }
   return scrollY;
 }
Esempio n. 19
0
  @SuppressWarnings("rawtypes")
  @Override
  public void updated(Dictionary config) throws ConfigurationException {

    super.updated(config);

    if (config != null) {

      String timeOutString = (String) config.get("buffersize");
      if (StringUtils.isNotBlank(timeOutString)) {
        timeOut = Integer.parseInt((timeOutString));
      } else {
        logger.info(
            "The maximum time out for blocking write operations will be set to the default vaulue of {}",
            timeOut);
      }

      String blockingString = (String) config.get("retryinterval");
      if (StringUtils.isNotBlank(blockingString)) {
        blocking = Boolean.parseBoolean((blockingString));
      } else {
        logger.info(
            "The blocking nature of read/write operations will be set to the default vaulue of {}",
            blocking);
      }

      String preambleString = (String) config.get("preamble");
      if (StringUtils.isNotBlank(preambleString)) {
        preAmble = preambleString.replaceAll("\\\\", "\\");
      } else {
        logger.info(
            "The preamble for all write operations will be set to the default vaulue of {}",
            preAmble);
      }

      String postambleString = (String) config.get("postamble");
      if (StringUtils.isNotBlank(postambleString)) {
        postAmble = postambleString.replaceAll("\\\\", "\\");
        ;
      } else {
        logger.info(
            "The postamble for all write operations will be set to the default vaulue of {}",
            postAmble);
      }

      String updatewithresponseString = (String) config.get("updatewithresponse");
      if (StringUtils.isNotBlank(updatewithresponseString)) {
        updateWithResponse = Boolean.parseBoolean((updatewithresponseString));
      } else {
        logger.info(
            "Updating states with returned values will be set to the default vaulue of {}",
            updateWithResponse);
      }
    }
  }
Esempio n. 20
0
  @Test
  public void testPersistTimeoutSystemProperty() throws Exception {
    System.setProperty(PluginUtils.MAERA_PLUGINS_ENABLE_WAIT, "300");
    try {
      final File propertiesFile = new File(cacheDir, ".properties");

      assertFalse(propertiesFile.exists());

      final PluginJarBuilder firstBuilder = new PluginJarBuilder("first");

      final File jar =
          firstBuilder
              .addPluginInformation("first", "Some name", "1.0")
              .addFormattedJava(
                  "first.MyInterface", "package first;", "public interface MyInterface {}")
              .addFormattedResource(
                  "META-INF/MANIFEST.MF",
                  "Manifest-Version: 1.0",
                  "Bundle-SymbolicName: first",
                  "Bundle-Version: 1.0",
                  "Export-Package: first",
                  "")
              .build();
      initPluginManager();

      pluginManager.installPlugin(new JarPluginArtifact(jar));

      Bundle bundle = findBundleByName("first");
      Dictionary headers = bundle.getHeaders();
      assertEquals("*;timeout:=300", headers.get("Spring-Context"));

      assertTrue(propertiesFile.exists());

      Properties properties = new Properties();
      properties.load(new FileInputStream(propertiesFile));
      assertEquals("300", properties.getProperty("spring.timeout"));

      final File testFile = new File(new File(cacheDir, "transformed-plugins"), ".test");
      assertTrue(testFile.createNewFile());
      assertTrue(testFile.exists());

      initPluginManager();
      pluginManager.installPlugin(new JarPluginArtifact(jar));

      bundle = findBundleByName("first");
      headers = bundle.getHeaders();
      assertEquals("*;timeout:=300", headers.get("Spring-Context"));

      assertTrue(propertiesFile.exists());
      assertTrue(testFile.exists());
    } finally {
      System.clearProperty(PluginUtils.MAERA_PLUGINS_ENABLE_WAIT);
    }
  }
 private Map<String, Object> getLegacyProperties() {
   Map<String, Object> map = new HashMap<String, Object>();
   map.put(LaunchLiveActionBase.PROP_RANK, props.get(LaunchLiveActionBase.PROP_RANK));
   map.put(
       LaunchLiveActionBase.PROP_PROPS,
       PropertiesUtil.toStringArray(props.get(LaunchLiveActionBase.PROP_PROPS)));
   map.put(LaunchLiveActionBase.PROP_PARAMETER, props.get(LaunchLiveActionBase.PROP_PARAMETER));
   map.put(LaunchLiveActionBase.PROP_TITLE, props.get(LaunchLiveActionBase.PROP_TITLE));
   map.put(LaunchLiveActionBase.ACTION_TYPE, props.get(LaunchLiveActionBase.ACTION_TYPE));
   return map;
 }
 public void updated(Dictionary<String, ?> config) throws ConfigurationException {
   if (config != null) {
     Integer filterPriority = (Integer) config.get(FILTER_PRIORITY);
     String applicationName = (String) config.get(APPLICATION_NAME);
     setPriority(filterPriority);
     setApplicationName(applicationName);
   }
   synchronized (this) {
     filterFactoryServiceRegistration.setProperties(config);
   }
 }
Esempio n. 23
0
  public DuplicateNodeDetectorAlgorithm(
      Data[] data, Dictionary parameters, CIShellContext context) {
    this.data = data;
    this.parameters = parameters;
    this.context = context;

    // unpack parameters
    this.compareAttributeName = ((String) parameters.get("compareAttribute"));
    this.mergeOnSimilarity = ((Float) parameters.get("mergeOnSimilarity")).floatValue();
    this.makeNoteOnSimilarity = ((Float) parameters.get("makeNoteOnSimilarity")).floatValue();
    this.numPrefixLetters = ((Integer) parameters.get("numPrefixLetters")).intValue();
  }
Esempio n. 24
0
  public void getClassPathForCompileTarget() {
    Dictionary<String, Classpath> classpaths = module.getClassPathsFor(new BuildTarget("compile"));
    assertEquals(true, classpaths.get(ClasspathNames.SOURCE).contains("production", "bar"));

    assertEquals(true, classpaths.get(ClasspathNames.SUCCOR).contains("succor", "bar"));
    assertEquals(true, classpaths.get(ClasspathNames.SUCCOR).contains("production", "bar"));

    assertEquals(true, classpaths.get(ClasspathNames.TEST).contains("succor", "bar"));
    assertEquals(true, classpaths.get(ClasspathNames.TEST).contains("production", "baz"));
    assertEquals(true, classpaths.get(ClasspathNames.TEST).contains("test", "foo"));
    assertEquals(false, classpaths.get(ClasspathNames.TEST).contains("test", "bar"));
  }
  public void startup() {

    //        Dictionary<?, ?> dict = cmPropertyPlaceholder.getConfigAdmin()
    //                .getConfiguration(cmPropertyPlaceholder.getPersistentId()).getProperties();
    Dictionary<?, ?> dict = properties;
    // System.out.println("### ZOOKEEPER :: dictionary : " + dict);

    LOG.info("Staring up ZooKeeper server");

    if (dict == null) {
      LOG.info("Ignoring configuration update because updated configuration is empty.");
      shutdown();
      return;
    }

    if (main != null) {
      // stop the current instance
      shutdown();
      // then reconfigure and start again.
    }

    if (dict.get("clientPort") == null) {
      LOG.info("Ignoring configuration update because required property 'clientPort' isn't set.");
      return;
    }

    Properties props = new Properties();
    for (Enumeration<?> e = dict.keys(); e.hasMoreElements(); ) {
      Object key = e.nextElement();
      props.put(key, dict.get(key));
    }

    try {
      main = ZookeeperServerImpl.getZookeeperServer(props);

      zkMainThread =
          new Thread(
              new Runnable() {
                public void run() {
                  try {
                    main.startup();
                  } catch (IOException e) {
                    LOG.log(Level.SEVERE, "Problem running ZooKeeper server.", e);
                  }
                }
              });
      zkMainThread.start();

      LOG.info("Applied configuration update :" + props);
    } catch (Exception th) {
      LOG.log(Level.SEVERE, "Problem applying configuration update: " + props, th);
    }
  }
  public Data[] execute() throws AlgorithmExecutionException {

    File inputData = (File) data[0].getData();

    try {
      validateInputFile(inputData);
    } catch (ParsingException e) {
      throw new AlgorithmExecutionException("Inappropriate NWB File provided.", e);
    }

    if (isUndirectedNetwork && numberOfEdges > 1 && numberOfNodes > 1) {
      try {

        String edgeWeightColumnName = (String) parameters.get("weightcolumn");
        String edgeWeightType = (String) parameters.get("weighttypecolumn");

        /*
         * Used to process the provided file for Pathfinder Network Scaling.
         * */
        NWBFileParser parser = new NWBFileParser(inputData);
        MSTPathfinderNetworkScalingComputation networkScalingComputation =
            new MSTPathfinderNetworkScalingComputation(
                edgeWeightColumnName, edgeWeightType, logger);
        parser.parse(networkScalingComputation);

        /*
         * Used to generate the output file containing the scaled network.
         */
        File outputNWBFile = File.createTempFile("nwb-", ".nwb");
        NWBFileParser outputParser = new NWBFileParser(inputData);
        outputParser.parse(
            new MSTPathfinderNetworkScalingOutputGenerator(
                networkScalingComputation, outputNWBFile));

        Data outNWBData = new BasicData(outputNWBFile, "file:text/nwb");
        prepareOutputMetadata(edgeWeightType, networkScalingComputation, outNWBData);

        return new Data[] {outNWBData};

      } catch (FileNotFoundException e) {
        throw new AlgorithmExecutionException(
            "NWB File'" + inputData.getAbsolutePath() + "' not found.");
      } catch (IOException e) {
        throw new AlgorithmExecutionException(e);
      } catch (ParsingException e) {
        throw new AlgorithmExecutionException(e);
      }
    } else {
      throw new AlgorithmExecutionException(
          "Input network should be Undirected " + "with more than 1 edge & 1 node.");
    }
  }
 private void sendHeaders(URLConnection connection, Dictionary headers) {
   for (Enumeration e = headers.keys(); e.hasMoreElements(); ) {
     String key = (String) e.nextElement();
     connection.setRequestProperty(key, (String) headers.get(key));
     if (HttpUnitOptions.isLoggingHttpHeaders()) {
       if (key.equalsIgnoreCase("authorization") || key.equalsIgnoreCase("proxy-authorization")) {
         System.out.println("Sending:: " + key + ": " + headers.get(key));
       } else {
         System.out.println("Sending:: " + key + ": " + connection.getRequestProperty(key));
       }
     }
   }
 }
Esempio n. 28
0
    /**
     * Filter using a {@code Dictionary}. This {@code Filter} is executed using the specified {@code
     * Dictionary}'s keys and values. The keys are looked up in a normal manner respecting case.
     *
     * @param dictionary The {@code Dictionary} whose key/value pairs are used in the match.
     * @return {@code true} if the {@code Dictionary}'s values match this filter; {@code false}
     *     otherwise.
     * @since 1.3
     */
    @Override
    public boolean matchCase(Dictionary<String, ?> dictionary) {
      switch (op) {
        case AND:
          {
            FilterImpl[] filters = (FilterImpl[]) value;
            for (FilterImpl f : filters) {
              if (!f.matchCase(dictionary)) {
                return false;
              }
            }
            return true;
          }

        case OR:
          {
            FilterImpl[] filters = (FilterImpl[]) value;
            for (FilterImpl f : filters) {
              if (f.matchCase(dictionary)) {
                return true;
              }
            }
            return false;
          }

        case NOT:
          {
            FilterImpl filter = (FilterImpl) value;
            return !filter.matchCase(dictionary);
          }

        case SUBSTRING:
        case EQUAL:
        case GREATER:
        case LESS:
        case APPROX:
          {
            Object prop = (dictionary == null) ? null : dictionary.get(attr);
            return compare(op, prop, value);
          }

        case PRESENT:
          {
            Object prop = (dictionary == null) ? null : dictionary.get(attr);
            return prop != null;
          }
      }

      return false;
    }
  /**
   * {@inheritDoc}
   *
   * @see org.osgi.service.cm.ManagedServiceFactory#updated(java.lang.String, java.util.Dictionary)
   */
  @Override
  public void updated(String pid, Dictionary properties) throws ConfigurationException {

    // Get the agent properties
    String nameConfig = (String) properties.get("id");
    if (isEmpty(nameConfig)) {
      throw new ConfigurationException("id", "must be specified");
    }
    nameConfig = nameConfig.trim();

    String urlConfig = (String) properties.get("url");
    if (isEmpty(urlConfig)) {
      throw new ConfigurationException("url", "must be specified");
    }
    urlConfig = urlConfig.trim();

    String orgConfig = (String) properties.get("organization");
    if (isEmpty(orgConfig)) {
      throw new ConfigurationException("organization", "must be specified");
    }
    orgConfig = orgConfig.trim();

    String schedulerRolesConfig = (String) properties.get("schedulerRoles");
    if (isEmpty(schedulerRolesConfig)) {
      throw new ConfigurationException("schedulerRoles", "must be specified");
    }
    schedulerRolesConfig = schedulerRolesConfig.trim();

    // If we don't already have a mapping for this PID, create one
    if (!pidMap.containsKey(pid)) {
      pidMap.put(pid, nameConfig);
    }

    AgentImpl agent = getAgent(nameConfig, orgConfig);
    if (agent == null) {
      agent = new AgentImpl(nameConfig, orgConfig, UNKNOWN, urlConfig, new Properties());
    } else {
      agent.url = urlConfig.trim();
      agent.organization = orgConfig.trim();
      agent.state = UNKNOWN;
      String[] schedulerRoles = schedulerRolesConfig.split(",");
      for (String role : schedulerRoles) {
        agent.schedulerRoles.add(role.trim());
      }
    }

    // Update the database
    logger.info("Roles '{}' may schedule '{}'", schedulerRolesConfig, agent.name);
    updateAgentInDatabase(agent);
  }
Esempio n. 30
0
  /** @{inheritDoc} */
  @Override
  public void updated(Dictionary<String, ?> config) throws ConfigurationException {
    if (config != null) {
      // to override the mode (gpio or http) one has to add a
      // parameter to openhab.cfg like openSprinkler:mode=[gpio|http]
      String modeString = (String) config.get("mode");
      if (StringUtils.isNotBlank(modeString)) {
        try {
          mode = OpenSprinklerMode.valueOf(modeString.toUpperCase());
        } catch (IllegalArgumentException iae) {
          throw new ConfigurationException(
              "openSprinkler:mode",
              "Unknown OpenSprinkler mode "
                  + mode
                  + "! Valid modes are 'gpio' and 'http'. Please fix your openhab.cfg.");
        }
      }

      // to specify the http url one has to add a
      // parameter to openhab.cfg like openSprinkler:httpUrl=<url>
      url = (String) config.get("httpUrl");

      // to specify the http password one has to add a
      // parameter to openhab.cfg like openSprinkler:httpPassword=<password>
      password = (String) config.get("httpPassword");

      // to override the refresh rate of the rain sensor check one has to add a
      // parameter to openhab.cfg like openSprinkler:rsRefresh
      String rsRefreshRate = (String) config.get("refreshInterval");
      if (StringUtils.isNotBlank(rsRefreshRate)) {
        refreshInterval = Long.parseLong(rsRefreshRate);
      }

      // to override the number of stations one has to add a
      // parameter to openhab.cfg like openSprinkler:numberOfStations=<count>
      String numberOfStationsString = (String) config.get("numberOfStations");
      if (StringUtils.isNotBlank(numberOfStationsString)) {
        numberOfStations = Integer.parseInt(numberOfStationsString);
        openSprinkler.setNumberOfStations(numberOfStations);
      }

      // read further config parameters here ...

      setProperlyConfigured(true);

      // then update the binding
      updateBinding();
    }
  }