Package freenet.keys

Examples of freenet.keys.FreenetURI


          File filename = null;
          String s = props.getProperty(fileBase+".filename");
          if(s == null) break;
          filename = new File(s);
          // Key.
          final FreenetURI key;
          s = props.getProperty(fileBase+".key");
          if(s == null) {
              Logger.error(MainJarDependencies.class, "dependencies.properties broken? missing "+fileBase+".key in atomic multi-files list");
                atomicDeployer.cleanup();
              return false;
          }
          try {
              key = new FreenetURI(s);
          } catch (MalformedURLException e) {
              Logger.error(MainJarDependencies.class, "Unable to parse CHK for multi-files replace for "+fileBase+": \""+s+"\": "+e, e);
                atomicDeployer.cleanup();
              return false;
          }
View Full Code Here


   * @return The downloaded Sone, or {@code null} if the Sone could not be
   *         downloaded
   */
  public Sone fetchSone(Sone sone, FreenetURI soneUri, boolean fetchOnly) {
    logger.log(Level.FINE, String.format("Starting fetch for Sone “%s” from %s…", sone, soneUri));
    FreenetURI requestUri = soneUri.setMetaString(new String[] { "sone.xml" });
    sone.setStatus(SoneStatus.downloading);
    try {
      Fetched fetchResults = freenetInterface.fetchUri(requestUri);
      if (fetchResults == null) {
        /* TODO - mark Sone as bad. */
 
View Full Code Here

    }

    String soneRequestUri = soneXml.getValue("request-uri", null);
    if (soneRequestUri != null) {
      try {
        sone.setRequestUri(new FreenetURI(soneRequestUri));
      } catch (MalformedURLException mue1) {
        /* TODO - mark Sone as bad. */
        logger.log(Level.WARNING, String.format("Downloaded Sone %s has invalid request URI: %s", sone, soneRequestUri), mue1);
        return null;
      }
View Full Code Here

   *            The URI to derive the Sone URI from
   * @return The derived URI
   */
  public static FreenetURI create(String uri) {
    try {
      return new FreenetURI(uri).setDocName("Sone").setMetaString(new String[0]);
    } catch (MalformedURLException mue1) {
      /* this should never happen. */
      logger.log(Level.WARNING, String.format("Could not create Sone URI from URI: %s", uri), mue1);
      return null;
    }
View Full Code Here

   *            The URI to fetch
   * @return The result of the fetch, or {@code null} if an error occured
   */
  public Fetched fetchUri(FreenetURI uri) {
    FetchResult fetchResult = null;
    FreenetURI currentUri = new FreenetURI(uri);
    while (true) {
      try {
        fetchResult = client.fetch(currentUri);
        return new Fetched(currentUri, fetchResult);
      } catch (FetchException fe1) {
View Full Code Here

   *             if the insert could not be started
   */
  public void insertImage(TemporaryImage temporaryImage, Image image, InsertToken insertToken) throws SoneException {
    String filenameHint = image.getId() + "." + temporaryImage.getMimeType().substring(temporaryImage.getMimeType().lastIndexOf("/") + 1);
    InsertableClientSSK key = InsertableClientSSK.createRandom(node.random, "");
    FreenetURI targetUri = key.getInsertURI().setDocName(filenameHint);
    InsertContext insertContext = client.getInsertContext(true);
    Bucket bucket = new ArrayBucket(temporaryImage.getImageData());
    ClientMetadata metadata = new ClientMetadata(temporaryImage.getMimeType());
    InsertBlock insertBlock = new InsertBlock(bucket, metadata, targetUri);
    try {
View Full Code Here

          try {
            sone.setStatus(SoneStatus.inserting);
            long insertTime = System.currentTimeMillis();
            insertInformation.setTime(insertTime);
            eventBus.post(new SoneInsertingEvent(sone));
            FreenetURI finalUri = freenetInterface.insertDirectory(insertInformation.getInsertUri(), insertInformation.generateManifestEntries(), "index.html");
            eventBus.post(new SoneInsertedEvent(sone, System.currentTimeMillis() - insertTime));
            /* at this point we might already be stopped. */
            if (shouldStop()) {
              /* if so, bail out, don’t change anything. */
              break;
            }
            sone.setTime(insertTime);
            sone.setLatestEdition(finalUri.getEdition());
            core.touchConfiguration();
            success = true;
            logger.log(Level.INFO, String.format("Inserted Sone “%s” at %s.", sone.getName(), finalUri));
          } catch (SoneException se1) {
            eventBus.post(new SoneInsertAbortedEvent(sone, se1));
View Full Code Here

            }
            continue;
          }

          if ((linkType == LinkType.KSK) || (linkType == LinkType.CHK) || (linkType == LinkType.SSK) || (linkType == LinkType.USK)) {
            FreenetURI uri;
            if (name.indexOf('?') > -1) {
              name = name.substring(0, name.indexOf('?'));
            }
            if (name.endsWith("/")) {
              name = name.substring(0, name.length() - 1);
            }
            try {
              uri = new FreenetURI(name);
              name = uri.lastMetaString();
              if (name == null) {
                name = uri.getDocName();
              }
              if (name == null) {
                name = link.substring(0, Math.min(9, link.length()));
              }
              boolean fromPostingSone = ((linkType == LinkType.SSK) || (linkType == LinkType.USK)) && (context != null) && (context.getPostingSone() != null) && link.substring(4, Math.min(link.length(), 47)).equals(context.getPostingSone().getId());
View Full Code Here

    }
    logger.info(String.format("Adding Sone from OwnIdentity: %s", ownIdentity));
    synchronized (sones) {
      final Sone sone;
      try {
        sone = getLocalSone(ownIdentity.getId(), true).setIdentity(ownIdentity).setInsertUri(new FreenetURI(ownIdentity.getInsertUri())).setRequestUri(new FreenetURI(ownIdentity.getRequestUri()));
      } catch (MalformedURLException mue1) {
        logger.log(Level.SEVERE, String.format("Could not convert the Identity’s URIs to Freenet URIs: %s, %s", ownIdentity.getInsertUri(), ownIdentity.getRequestUri()), mue1);
        return null;
      }
      sone.setLatestEdition(Numbers.safeParseLong(ownIdentity.getProperty("Sone.LatestEdition"), (long) 0));
View Full Code Here

      while (!shouldStop() && !fetching) {
        sleep();
      }
      if (fetching) {
        core.lockSone(sone);
        FreenetURI soneUri = sone.getRequestUri().setKeyType("SSK").setDocName("Sone-" + currentEdition).setMetaString(new String[] { "sone.xml" });
        System.out.println("URI: " + soneUri);
        Sone fetchedSone = soneDownloader.fetchSone(sone, soneUri, true);
        System.out.println("Sone: " + fetchedSone);
        lastFetchSuccessful = (fetchedSone != null);
        if (lastFetchSuccessful) {
View Full Code Here

TOP

Related Classes of freenet.keys.FreenetURI

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.