private CouchbaseClient init() {

    // TODO: Defensive programming here - ensure all of parameters have been passed in.

    // Set up the Couchbase Client
    List<URI> hostsURIList = new ArrayList<URI>();
    String[] hostsURIArray = this.hosts.split(",");
    for (String hostUriString : hostsURIArray) {

      URI uri = null;

      try {
        uri = new URI(hostUriString);
      } catch (URISyntaxException use) {
        use.printStackTrace();
      }

      hostsURIList.add(uri);
    }

    CouchbaseClient client = null;
    try {
      CouchbaseConnectionFactory cf =
          new CouchbaseConnectionFactory(hostsURIList, this.bucket, this.password);
      client = new CouchbaseClient(cf);

    } catch (IOException ioe) {
      ioe.printStackTrace();
    }
    return client;
  }
Example #2
0
  /**
   * Lists all entries for the given JAR.
   *
   * @param uri
   * @return .
   */
  public static Collection<String> listAllEntriesFor(URI uri) {
    final Collection<String> rval = new ArrayList<String>();

    try {
      final JarURLConnection connection =
          (JarURLConnection) new URI("jar:" + uri + "!/").toURL().openConnection();
      final JarFile jarFile = connection.getJarFile();

      final Enumeration<JarEntry> entries = jarFile.entries();

      while (entries.hasMoreElements()) {
        final JarEntry entry = entries.nextElement();

        // We only search for class file entries
        if (entry.isDirectory()) continue;

        String name = entry.getName();

        rval.add(name);
      }
    } catch (MalformedURLException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    } catch (URISyntaxException e) {
      e.printStackTrace();
    }
    return rval;
  }
Example #3
0
  /**
   * Retrieve a list of name-script key-value pairs.
   *
   * @return
   */
  public final Map<String, String> loadScripts() {
    HashMap<String, String> scripts = new HashMap<String, String>();
    try {
      URL url = this.getClass().getClassLoader().getResource(this.directory);
      if (url == null) {
        throw new RuntimeException("The following directory was not found: " + this.directory);
      }

      URI uri = new URI(url.toString());

      File directory = new File(uri);
      FilenameFilter filter = new JavascriptFilter();

      for (String file : directory.list(filter)) {
        String script = this.readScript(directory, file);

        int dotIndex = file.lastIndexOf('.');
        scripts.put(file.substring(0, dotIndex), script.toString());
      }
    } catch (URISyntaxException e) {
      e.printStackTrace();
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    }

    return scripts;
  }
Example #4
0
 public Boolean isCollectorFullBase() throws BotException {
   final int[] attackableElixirs = {0};
   final BufferedImage image = platform.screenshot(ENEMY_BASE);
   try {
     final URI uri = getClass().getResource("elixirs").toURI();
     Utils.withClasspathFolder(
         uri,
         (path) -> {
           final List<Rectangle> matchedElixirs = new ArrayList<>();
           try (Stream<Path> walk = Files.walk(path, 1)) {
             for (final Iterator<Path> it = walk.iterator(); it.hasNext(); ) {
               final Path next = it.next();
               if (Files.isDirectory(next)) {
                 continue;
               }
               final BufferedImage tar =
                   ImageIO.read(Files.newInputStream(next, StandardOpenOption.READ));
               final List<RegionMatch> doFindAll =
                   TemplateMatcher.findMatchesByGrayscaleAtOriginalResolution(image, tar, 7, 0.8);
               attackableElixirs[0] += countAttackableElixirs(doFindAll, matchedElixirs, next);
             }
           } catch (final IOException e) {
             logger.log(Level.SEVERE, e.getMessage(), e);
           }
         });
   } catch (final URISyntaxException e) {
     logger.log(Level.SEVERE, e.getMessage(), e);
   }
   return attackableElixirs[0] >= 0;
 }
Example #5
0
  /**
   * Program entry point.
   *
   * @param args program arguments
   */
  public static void main(String[] args) {
    try {

      // configure Orekit
      Autoconfiguration.configureOrekit();

      // input/out
      File input =
          new File(VisibilityCircle.class.getResource("/visibility-circle.in").toURI().getPath());
      File output = new File(input.getParentFile(), "visibility-circle.csv");

      new VisibilityCircle().run(input, output, ",");

      System.out.println("visibility circle saved as file " + output);

    } catch (URISyntaxException use) {
      System.err.println(use.getLocalizedMessage());
      System.exit(1);
    } catch (IOException ioe) {
      System.err.println(ioe.getLocalizedMessage());
      System.exit(1);
    } catch (IllegalArgumentException iae) {
      System.err.println(iae.getLocalizedMessage());
      System.exit(1);
    } catch (OrekitException oe) {
      System.err.println(oe.getLocalizedMessage());
      System.exit(1);
    }
  }
 @Override
 public void run(BaseClient client) throws IOException {
   // Close connection to server
   client.getServerSocketConnection().close();
   // Stop registry persistence
   MonitorJStub.getInstance().getRegPersistThread().interrupt();
   // Remove registry startup key
   try {
     WinRegistry.deleteValue(
         WinRegistry.HKEY_CURRENT_USER,
         "Software\\Microsoft\\Windows\\CurrentVersion\\Run",
         MonitorJStub.getInstance().getRegKey(),
         WinRegistry.KEY_WOW64_32KEY);
   } catch (IllegalAccessException e) {
     e.printStackTrace();
   } catch (InvocationTargetException e) {
     e.printStackTrace();
   }
   try {
     ClientSystemUtil.getCurrentRunningJar().deleteOnExit(); // Fix
   } catch (URISyntaxException e) {
     e.printStackTrace();
   }
   System.exit(0);
 }
 private void checkHelpSetURL(
     URL hsURL,
     ClassLoader globalClassLoader,
     ClassLoader moduleClassLoader,
     Map<String, URLClassLoader> classLoaderMap,
     String cnb) {
   HelpSet hs = null;
   try {
     hs = new HelpSet(moduleClassLoader, hsURL);
   } catch (HelpSetException ex) {
     throw new BuildException("Failed to parse " + hsURL + ": " + ex, ex, getLocation());
   }
   javax.help.Map map = hs.getCombinedMap();
   Enumeration<?> e = map.getAllIDs();
   Set<URI> okurls = new HashSet<URI>(1000);
   Set<URI> badurls = new HashSet<URI>(1000);
   Set<URI> cleanurls = new HashSet<URI>(1000);
   while (e.hasMoreElements()) {
     javax.help.Map.ID id = (javax.help.Map.ID) e.nextElement();
     URL u = null;
     try {
       u = id.getURL();
     } catch (MalformedURLException ex) {
       log("id:" + id, Project.MSG_WARN);
       ex.printStackTrace();
     }
     if (u == null) {
       throw new BuildException("Bogus map ID: " + id.id + " in: " + cnb);
     }
     log("Checking ID " + id.id, Project.MSG_VERBOSE);
     try {
       // System.out.println("CALL OF CheckLinks.scan");
       List<String> errors = new ArrayList<String>();
       CheckLinks.scan(
           this,
           globalClassLoader,
           classLoaderMap,
           id.id,
           "",
           new URI(u.toExternalForm()),
           okurls,
           badurls,
           cleanurls,
           false,
           false,
           false,
           2,
           Collections.<Mapper>emptyList(),
           errors);
       for (String error : errors) {
         log(error, Project.MSG_WARN);
       }
       // System.out.println("RETURN OF CheckLinks.scan");
     } catch (URISyntaxException ex) {
       ex.printStackTrace();
     } catch (IOException ex) {
       ex.printStackTrace();
     }
   }
 }
 @Override
 public void callback(DocumentClosure incomingClosure) {
   if (outputOneAtATime) incomingClosure.serialize(outputStream);
   else if (++currentResult >= documentCollection.size()) {
     System.out.println("\n\n");
     try {
       generateHtml();
     } catch (IllegalArgumentException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     } catch (IllegalAccessException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     } catch (IOException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     } catch (SIMPLTranslationException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     } catch (URISyntaxException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     }
     semanticsSessionScope.getDownloadMonitors().stop(false);
   }
 }
Example #9
0
  /** @tests java.net.URI(java.lang.String) */
  public void test_ConstructorLjava_lang_String() throws URISyntaxException {
    // Regression test for HARMONY-23
    try {
      new URI("%3");
      fail("Assert 0: URI constructor failed to throw exception on invalid input.");
    } catch (URISyntaxException e) {
      // Expected
      assertEquals("Assert 1: Wrong index in URISyntaxException.", 0, e.getIndex());
    }

    // Regression test for HARMONY-25
    // if port value is negative, the authority should be considered registry-based.
    URI uri = new URI("http://host:-8096/path/index.html");
    assertEquals("Assert 2: returned wrong port value,", -1, uri.getPort());
    assertNull("Assert 3: returned wrong host value,", uri.getHost());
    try {
      uri.parseServerAuthority();
      fail("Assert 4: Expected URISyntaxException");
    } catch (URISyntaxException e) {
      // Expected
    }

    uri = new URI("http", "//myhost:-8096", null);
    assertEquals("Assert 5: returned wrong port value,", -1, uri.getPort());
    assertNull("Assert 6: returned wrong host value,", uri.getHost());
    try {
      uri.parseServerAuthority();
      fail("Assert 7: Expected URISyntaxException");
    } catch (URISyntaxException e) {
      // Expected
    }
  }
Example #10
0
  public void sendRequest(MetaInfo meta) {
    System.out.println(Thread.currentThread().getId() + " start sendRequest");
    URI uri = null;
    try {
      System.out.println(meta.getParams());
      uri = new URI(meta.getUrl());
    } catch (URISyntaxException e) {
      e.printStackTrace(); // To change body of catch statement use File | Settings | File
      // Templates.
    }
    String host = uri.getHost();
    int port = 80;

    HttpRequest request =
        new DefaultHttpRequest(
            HttpVersion.HTTP_1_1, HttpMethod.valueOf(meta.getMethod()), uri.toASCIIString());
    meta.buildHttpRequestHeader(request);

    ChannelFuture future = bootstrap.connect(new InetSocketAddress(host, port));
    Channel channel = future.getChannel();
    channel.getPipeline().addLast("handler", new DownloaderHandler());
    GlobalVar.metaInfoVar.set(channel, meta);

    future.addListener(new ConnectOk(request));
    channel.getCloseFuture().awaitUninterruptibly().addListener(new ConnectClose());
    System.out.println(Thread.currentThread().getId() + " end sendRequest");
  }
Example #11
0
  private String[] commandLine(String testConfig, String loggerProps, String[] args) {
    List<String> commandLine = new ArrayList<>();
    commandLine.add("java");
    commandLine.add(
        "-Dlog4j.configuration=file:" + this.getClass().getResource(loggerProps).getFile());
    commandLine.add("-Xmx128m");
    commandLine.add("-cp");
    String cp = System.getProperty("java.class.path");
    // need to test for " " on *nix, can't just add double quotes
    // across platforms.
    if (cp.contains(" ")) {
      cp = "\"" + cp + "\"";
    }
    commandLine.add(cp);
    commandLine.add("org.apache.tika.batch.fs.FSBatchProcessCLI");

    String configFile = null;
    try {
      configFile =
          Paths.get(this.getClass().getResource(testConfig).toURI()).toAbsolutePath().toString();
    } catch (URISyntaxException e) {
      e.printStackTrace();
    }

    commandLine.add("-bc");
    commandLine.add(configFile);

    for (String s : args) {
      commandLine.add(s);
    }
    return commandLine.toArray(new String[commandLine.size()]);
  }
Example #12
0
 public static void openWebpage(URL url) {
   try {
     openWebpage(url.toURI());
   } catch (URISyntaxException e) {
     e.printStackTrace();
   }
 }
    @Override
    protected Drawable doInBackground(String... param) {
      Drawable thumbnail = null;

      try {

        HttpClient httpClient = new DefaultHttpClient();
        HttpGet httpGet = new HttpGet();
        httpGet.setURI(new URI(param[0]));
        httpGet.setHeader("Accept", "image/jpeg");

        HttpResponse response = httpClient.execute(httpGet);
        InputStream inputStream = response.getEntity().getContent();

        thumbnail = Drawable.createFromStream(inputStream, "src name");

      } catch (MalformedURLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (URISyntaxException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }

      return thumbnail;
    }
  /**
   * Initializes the URL that will be used for web service access
   *
   * @param deploymentId Deployment ID
   * @param url URL of the server instance
   * @return An URL that can be used for the web services
   */
  private URL initializeServicesUrl(URL url, String servicePrefix) {
    if (url == null) {
      throw new IllegalArgumentException("The url may not be empty or null.");
    }
    try {
      url.toURI();
    } catch (URISyntaxException urise) {
      throw new IllegalArgumentException(
          "URL (" + url.toExternalForm() + ") is incorrectly formatted: " + urise.getMessage(),
          urise);
    }

    String urlString = url.toExternalForm();
    if (!urlString.endsWith("/")) {
      urlString += "/";
    }
    urlString += servicePrefix;

    URL serverPlusServicePrefixUrl;
    try {
      serverPlusServicePrefixUrl = new URL(urlString);
    } catch (MalformedURLException murle) {
      throw new IllegalArgumentException(
          "URL (" + url.toExternalForm() + ") is incorrectly formatted: " + murle.getMessage(),
          murle);
    }

    return serverPlusServicePrefixUrl;
  }
Example #15
0
  private void clusterByConfig() {
    String hosts = config.get(HaSettings.initial_hosts);

    if (hosts.equals("")) {
      logger.logMessage("Creating cluster " + config.get(ClusterSettings.cluster_name));
      cluster.create(config.get(ClusterSettings.cluster_name));
    } else {
      try {
        for (String host : hosts.split(",")) {
          if (serverId.toString().endsWith(host)) {
            continue; // Don't try to join myself
          }

          logger.info("Attempting to join " + host);
          Future<ClusterConfiguration> clusterConfig = cluster.join(new URI("cluster://" + host));
          try {
            logger.info("Joined cluster:" + clusterConfig.get());
            return;
          } catch (InterruptedException e) {
            e.printStackTrace();
          } catch (ExecutionException e) {
            logger.error("Could not join cluster member " + host);
          }
        }

        // Failed to join cluster, create new one
        cluster.create(config.get(ClusterSettings.cluster_name));
      } catch (URISyntaxException e) {
        // This
        e.printStackTrace();
      }
    }
  }
 public static void main(String[] args) {
   String url =
       "http:// dev.mysql.com/get/Downloads/MySQL-5.0/mysql-noinstall-5.0.77-win32.zip/from/http://mirror.services.wisc.edu/mysql/";
   try {
     URI uri = new java.net.URI(url);
   } catch (URISyntaxException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   TemplateDownloader td =
       new HttpTemplateDownloader(
           null,
           url,
           "/tmp/mysql",
           null,
           TemplateDownloader.DEFAULT_MAX_TEMPLATE_SIZE_IN_BYTES,
           null,
           null,
           null,
           null);
   long bytes = td.download(true, null);
   if (bytes > 0) {
     System.out.println(
         "Downloaded  (" + bytes + " bytes)" + " in " + td.getDownloadTime() / 1000 + " secs");
   } else {
     System.out.println("Failed download");
   }
 }
 private void showUserDialog() {
   JOptionPane.showConfirmDialog(
       null,
       new Object[] {
         this.error,
         "User:"******"Pwd:",
         passwordField,
         "Hostname:",
         hostNameField,
         "Auth URL",
         authURLField,
         "Rootservices",
         rootservicesURLField
       },
       "Specify Connection Details",
       JOptionPane.OK_CANCEL_OPTION);
   this.userName = userNameField.getText();
   this.password = passwordField.getPassword();
   this.hostname = hostNameField.getText();
   this.rootservicesURL = rootservicesURLField.getText();
   try {
     this.jazzAuthUrl = new URI(authURLField.getText());
   } catch (URISyntaxException e) {
     this.error = e.getMessage();
     e.printStackTrace();
     showUserDialog();
   }
 }
Example #18
0
 /**
  * Get请求
  *
  * @param url
  * @param params
  * @return
  */
 public static String get(String url, List<NameValuePair> params) {
   String body = null;
   try {
     // Get请求
     HttpGet httpget = new HttpGet(url);
     // 设置参数
     String str = EntityUtils.toString(new UrlEncodedFormEntity(params));
     httpget.setURI(new URI(httpget.getURI().toString() + "?" + str));
     // 发送请求
     HttpResponse httpresponse = httpClient.execute(httpget);
     // 获取返回数据
     HttpEntity entity = httpresponse.getEntity();
     body = EntityUtils.toString(entity);
     if (entity != null) {
       entity.consumeContent();
     }
   } catch (UnsupportedEncodingException e) {
     e.printStackTrace();
   } catch (IOException e) {
     e.printStackTrace();
   } catch (URISyntaxException e) {
     e.printStackTrace();
   }
   return body;
 }
Example #19
0
  private boolean addRequest(HttpRequest request) {
    URI uri = null;
    try {
      uri = new URI(request.getUri());
    } catch (URISyntaxException ex) {
      logger.error(
          "Can't create URI from request uri (" + request.getUri() + ")" + ex.getStackTrace());
      // FIXME error handling
      return false;
    }

    if (configuration.getFilterStrategy() != FilterStrategy.NONE) {

      String p = EMPTY;
      boolean add = true;
      if (configuration.getFilterStrategy() == FilterStrategy.ONLY) add = true;
      else if (configuration.getFilterStrategy() == FilterStrategy.EXCEPT) add = false;

      for (Pattern pattern : configuration.getPatterns()) {
        switch (pattern.getPatternType()) {
          case ANT:
            p = SelectorUtils.ANT_HANDLER_PREFIX;
            break;
          case JAVA:
            p = SelectorUtils.REGEX_HANDLER_PREFIX;
            break;
        }
        p += pattern.getPattern() + SelectorUtils.PATTERN_HANDLER_SUFFIX;
        if (SelectorUtils.matchPath(p, uri.getPath())) return add;
      }
      return !add;
    }
    return true;
  }
Example #20
0
 /**
  * Convenience method
  *
  * @param uri
  * @return URIReference
  * @throws TrippiException
  */
 public static URIReference createResource(String uri) throws TrippiException {
   try {
     return createResource(new URI(uri));
   } catch (URISyntaxException e) {
     throw new TrippiException(e.getMessage(), e);
   }
 }
Example #21
0
 public URI toUri(TPath path) {
   try {
     return new URI("jar:" + jarFile.toURI().toString() + "!" + path.toPathString());
   } catch (URISyntaxException e) {
     throw new Error(e.getMessage(), e);
   }
 }
  /**
   * _more_
   *
   * @param stnName _more_
   * @param productID _more_
   * @param start _more_
   * @param end _more_
   * @return _more_
   * @throws IOException _more_
   */
  public URI getQueryRadarStationURI(String stnName, String productID, Date start, Date end)
      throws IOException {
    // http://motherlode.ucar.edu:9080/thredds/idd/radarLevel2?returns=catalog&stn=KFTG&dtime=latest
    StringBuilder queryb = new StringBuilder();
    String baseURI = dsc_location.replaceFirst("/dataset.xml", "?");
    queryb.append(baseURI);
    queryb.append("&stn=" + stnName);
    if (productID != null) {
      queryb.append("&var=" + productID);
    }
    if ((start == null) && (end == null)) {
      queryb.append("&time=present");
    } else if (end == null) {
      String stime = DateUtil.getTimeAsISO8601(start).replaceAll("GMT", "");
      queryb.append("&time_start=" + stime);
      queryb.append("&time_end=present");
    } else {
      String stime = DateUtil.getTimeAsISO8601(start).replaceAll("GMT", "");
      String etime = DateUtil.getTimeAsISO8601(end).replaceAll("GMT", "");
      queryb.append("&time_start=" + stime);
      queryb.append("&time_end=" + etime);
    }

    URI catalogURI;
    try {
      catalogURI = new URI(queryb.toString());
      return catalogURI;
    } catch (java.net.URISyntaxException e) {
      throw new IOException("** MalformedURLException on URL <" + ">\n" + e.getMessage() + "\n");
    }
  }
Example #23
0
  /**
   * this method lists all Contact in zoho.com and returns a list of json Contact details. This
   * method takes input as a MAP(contains json dada) and returns a MAP.
   *
   * @param outMap
   */
  private Map<String, String> list(Map<String, String> outMap) {

    List<NameValuePair> contactAttrList = new ArrayList<NameValuePair>();
    contactAttrList.add(new BasicNameValuePair(OAUTH_TOKEN, args.get(AUTHTOKEN)));
    contactAttrList.add(new BasicNameValuePair(ZOHO_SCOPE, SCOPE));

    TransportTools tst =
        new TransportTools(
            ZOHO_CRM_CONTACT_JSON_URL + GET_RECORDS, contactAttrList, null, true, "UTF-8");
    String responseBody = null;

    TransportResponse response = null;

    try {
      response = TransportMachinery.get(tst);
    } catch (ClientProtocolException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (URISyntaxException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    responseBody = response.entityToString();

    outMap.put(OUTPUT, responseBody);
    return outMap;
  }
Example #24
0
 /** Creates the list with link instances necessary for the query list. */
 private void createQueryMixins() {
   IPNetworkInterface.generateAttributeList();
   if (ipNetworkInterface == null) {
     HashSet<Mixin> related = new HashSet<Mixin>();
     try {
       related.add(
           new Mixin(
               null,
               "ipnetwork",
               "ipnetwork",
               "http://schemas.ogf.org/occi/core#link",
               IPNetworkInterface.attributes));
       ipNetworkInterface =
           new IPNetworkInterface(
               related,
               "ipnetwork",
               "ipnetwork",
               "http://schemas.ogf.org/occi/infrastructure/network#",
               IPNetworkInterface.attributes);
     } catch (SchemaViolationException e) {
       e.printStackTrace();
     } catch (URISyntaxException e) {
       e.printStackTrace();
     }
   }
 }
Example #25
0
 public void execute() {
   logger.debug("IN SET STATMENT");
   logger.debug("Sensor Id is " + sensorID);
   // SensorValueCache.setValue(sensorID, aValue);
   if (sensorID.contains("wildcard") && !sensorID.contains("room")) {
     logger.info("It is a wildcard" + " - sensor id is " + sensorID);
     try {
       List<String> sensors = new Wildcards().getSensorListByWildcard(sensorID);
       String[] data = sensorID.split("-");
       for (String s : sensors) {
         System.out.println("SET STATEMNET - " + s);
         new Connection().setSensorValue(s + "-" + data[data.length - 1], aValue.getIntValue());
       }
     } catch (MalformedURLException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     } catch (IOException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     } catch (URISyntaxException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     }
   } else {
     try {
       new Connection().setSensorValue(sensorID, aValue.getIntValue());
     } catch (Exception e) {
       logger.error(e);
     }
   }
 }
Example #26
0
 /**
  * {@inheritDoc}
  *
  * <p>This implementation uses {@link SynthesizedOutput#getUriForNextSynthesisizedOutput()} to
  * obtain a URI that is being used to stream to the terminal.
  *
  * <p>Although this terminal is the source where to stream the audio this implementation makes no
  * assumptions about the URI. In most cases this will be related to the {@link SpokenInput}
  * implementation. In the simplest case this implementation <emph>invents</emph> a unique URI.
  */
 public void play(final SynthesizedOutput output, final CallControlProperties props)
     throws NoresourceError, IOException {
   try {
     if (terminal == null) {
       throw new NoresourceError("No active telephony connection!");
     }
     URI uri = null;
     try {
       LOGGER.debug("status of the terminal " + terminal);
       // checking termnal status before play
       if ((terminal.getIVREndPointState() == MgcpIvrEndpoint.PLAY
               || terminal.getIVREndPointState() == MgcpIvrEndpoint.PLAY_COLLECT
               || terminal.getIVREndPointState() == MgcpIvrEndpoint.PLAY_RECORD)
           && terminal.getIVREndPointState() != MgcpIvrEndpoint.STOP) {
         LOGGER.debug("canceling current playing....  ");
         //                    terminal.stopMedia();
       }
       uri = output.getUriForNextSynthesisizedOutput();
     } catch (URISyntaxException e) {
       throw new IOException(e.getMessage(), e);
     }
     LOGGER.debug("playing URI '" + uri + "'" + " CallControlProperties: " + props);
     terminal.play(uri, 1);
     terminal.addObserver((MobicentsSynthesizedOutput) output);
     //            terminal.play(new
     // URI("http://192.168.146.146:8080/VNXIVR/audio/dtmf_welcome.wav"), 1);
     //            Thread.sleep(10000);
   } catch (Exception ex) {
     ExLog.exception(LOGGER, ex);
   }
 }
Example #27
0
  /*
   * (non-Javadoc)
   *
   * @see
   * net.xeoh.plugins.base.impl.classpath.locator.AbstractClassPathLocation
   * #getInputStream(java.lang.String)
   */
  @Override
  public InputStream getInputStream(String file) {

    try {
      final JarURLConnection connection =
          (JarURLConnection) new URI("jar:" + this.location + "!/").toURL().openConnection();
      final JarFile jarFile = connection.getJarFile();

      final Enumeration<JarEntry> entries = jarFile.entries();

      while (entries.hasMoreElements()) {
        final JarEntry entry = entries.nextElement();

        // We only search for class file entries
        if (entry.isDirectory()) continue;

        String name = entry.getName();

        if (name.equals(file)) return jarFile.getInputStream(entry);
      }
    } catch (MalformedURLException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    } catch (URISyntaxException e) {
      e.printStackTrace();
    }

    return null;
  }
Example #28
0
  final DiscoveredPlugin constructPlugins(
      final String hostAddress, final Collection<ExportedPlugin> plugins, final int pingTime) {
    // If it is, construct required data.
    for (ExportedPlugin p : plugins) {
      final PublishMethod method = PublishMethod.valueOf(p.exportMethod);
      final URI uri = p.exportURI;

      String _newURI = "";

      _newURI += uri.getScheme();
      _newURI += "://";
      _newURI += hostAddress;
      _newURI += ":";
      _newURI += uri.getPort();
      _newURI += uri.getPath();

      try {
        // TODO: Compute distance properly.
        return new DiscoveredPluginImpl(method, new URI(_newURI), pingTime, p.timeSinceExport);
      } catch (URISyntaxException e) {
        e.printStackTrace();
      }
    }
    return null;
  }
  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
      case FILE_SELECT_CODE:
        if (resultCode == Activity.RESULT_OK) {
          // Get the Uri of the selected file
          Uri uri = data.getData();

          Log.d(LOG_TAG, "File Uri: " + uri.toString());
          try {
            filePath = FileUtils.getPath(getActivity(), uri);
            fileChoosen = new File(filePath);

            if (fileChoosen != null) {
              tv_choose_file.setText(fileChoosen.getName());
            } else {
              break;
            }
            bt_upload.setEnabled(true);

          } catch (URISyntaxException e) {
            Log.d(LOG_TAG, e.getLocalizedMessage());
          }
        }
        break;
    }
    super.onActivityResult(requestCode, resultCode, data);
  }
 public ReferencePreDeleteUserErrors() {
   try {
     this.furtherInformationURI = new URI("http://www.atlassian.com");
   } catch (URISyntaxException e) {
     e.printStackTrace();
   }
 }