Examples of FreenetURI


Examples of freenet.keys.FreenetURI

    public BookmarkItem(String line, UserAlertManager uam) throws MalformedURLException {
        String[] result = line.split("###");
        this.name = result[0];
        this.desc = result[1];
        this.hasAnActivelink = Fields.stringToBool(result[2], false);
        this.key = new FreenetURI(result[3]);
        this.alerts = uam;
        this.alert = new BookmarkUpdatedUserAlert();
        assert(name != null);
        assert(key != null);
    }
View Full Code Here

Examples of freenet.keys.FreenetURI

        this.desc = sfs.get("Description");
        if(desc == null) desc = "";
        this.shortDescription = sfs.get("ShortDescription");
        if(shortDescription == null) shortDescription = "";
        this.hasAnActivelink = sfs.getBoolean("hasAnActivelink");
        this.key = new FreenetURI(sfs.get("URI"));
        this.alerts = uam;
        this.alert = new BookmarkUpdatedUserAlert();
    }
View Full Code Here

Examples of freenet.keys.FreenetURI

          runningInserts++;
          //started = true;
          System.out.println("Starting insert: running "+runningInserts);
        }
        long t1 = 0, t2 = 0;
        FreenetURI thisURI = null;
        InsertException f = null;
        try {
          t1 = System.currentTimeMillis();
          thisURI = client.insert(block, false, null);
          t2 = System.currentTimeMillis();
View Full Code Here

Examples of freenet.keys.FreenetURI

       
      long t2 = System.currentTimeMillis();
      System.out.println("SEED-TIME:" + (t2 - t1));
      csvLine.add(String.valueOf(t2 - t1));
     
      FreenetURI todaysInsert = null;

      // PUSH N+1 BLOCKS
      for (int i = 0; i <= MAX_N; i++) {
          RandomAccessBucket data = randomData(node);
        HighLevelSimpleClient client = node.clientCore.makeClient((short) 0, false, false);
        System.out.println("PUSHING " + i);

        try {
          InsertBlock block = new InsertBlock(data, new ClientMetadata(), FreenetURI.EMPTY_CHK_URI);
          t1 = System.currentTimeMillis();
          FreenetURI uri = client.insert(block, false, null);
          if(i == 0) todaysInsert = uri;
          t2 = System.currentTimeMillis();

          System.out.println("PUSH-TIME-" + i + ":" + (t2 - t1)+" for "+uri);
          csvLine.add(String.valueOf(t2 - t1));
          csvLine.add(uri.toASCIIString());
        } catch (InsertException e) {
          e.printStackTrace();
          csvLine.add("N/A");
          csvLine.add("N/A");
        }

        data.free();
      }

      node.park();

      // Node 2
      File innerDir2 = new File(dir, Integer.toString(DARKNET_PORT2));
      innerDir2.mkdir();
      fis = new FileInputStream(seednodes);
      FileUtil.writeTo(fis, new File(innerDir2, "seednodes.fref"));
      fis.close();
      node2 = NodeStarter.createTestNode(DARKNET_PORT2, OPENNET_PORT2, dir.getPath(), false,
              Node.DEFAULT_MAX_HTL, 0, random, new PooledExecutor(), 1000, 5 * 1024 * 1024, true, true, true,
              true, true, true, true, 12 * 1024, false, true, false, false, null);
      node2.start(true);

      t1 = System.currentTimeMillis();
      if (!TestUtil.waitForNodes(node2)) {
        exitCode = EXIT_FAILED_TARGET;
        return;
      }
      t2 = System.currentTimeMillis();
      System.out.println("SEED-TIME:" + (t2 - t1));
      csvLine.add(String.valueOf(t2 - t1));

      // PULL N+1 BLOCKS
      for (int i = 0; i <= MAX_N; i++) {
        HighLevelSimpleClient client = node2.clientCore.makeClient((short) 0, false, false);
        Calendar targetDate = (Calendar) today.clone();
        targetDate.add(Calendar.DAY_OF_MONTH, -((1 << i) - 1));

        FreenetURI uri = null;
       
        if(i == 0) uri = todaysInsert;
        else {
          uri = getHistoricURI(uid, i, targetDate);
        }
View Full Code Here

Examples of freenet.keys.FreenetURI

        String[] split = line.split("!");
        if(split.length == 0) continue;
        if(!dateString.equals(split[0])) continue;
        int fieldnum = 3 + i * 2;
        if(line.length() >= fieldnum) continue; // Possible ran twice???
        return new FreenetURI(split[fieldnum]);
      }
      return null;
    } finally {
      fis.close();
    }
View Full Code Here

Examples of freenet.keys.FreenetURI

  }

    @Override
  protected Hashtable<String, String> persistenceFields (Hashtable<String, String> set) {
    Hashtable<String, String> fieldPairs = new Hashtable<String, String>();
    FreenetURI furi = null;
    String key = set.get("key");
    if (key != null) {
      try {
        furi = new FreenetURI(key);
      } catch (MalformedURLException e) {
        furi = null;
      }
    }

    String element = set.get("compress");
    if (element != null && Boolean.valueOf(element)) {
      fieldPairs.put("compress", element);
    }

    element = set.get("compatibilityMode");
    if (element != null) {
      fieldPairs.put("compatibilityMode", element);
    }

    if (furi != null) {
      fieldPairs.put("key", furi.toASCIIString());
    }

    element = set.get("overrideSplitfileKey");
    if (element != null) fieldPairs.put("overrideSplitfileKey", element);
    return fieldPairs;
View Full Code Here

Examples of freenet.keys.FreenetURI

        continue;
      if(!"USK".equals(item.getKeyType()))
        continue;

      try {
        FreenetURI furi = new FreenetURI(item.getKey());
        USK usk = USK.create(furi);

        if(usk.equals(u, false)) return true;
      } catch(MalformedURLException mue) {
      }
View Full Code Here

Examples of freenet.keys.FreenetURI

  private class USKUpdatedCallback implements USKCallback {

    @Override
    public void onFoundEdition(long edition, USK key, ClientContext context, boolean wasMetadata, short codec, byte[] data, boolean newKnownGood, boolean newSlotToo) {
      if(!newKnownGood) {
        FreenetURI uri = key.copy(edition).getURI();
        node.makeClient(PRIORITY_PROGRESS, false, false).prefetch(uri, MINUTES.toMillis(60), FProxyToadlet.MAX_LENGTH_WITH_PROGRESS, null, PRIORITY_PROGRESS);
        return;
      }
      List<BookmarkItem> items = MAIN_CATEGORY.getAllItems();
      boolean matched = false;
      boolean updated = false;
      for(int i = 0; i < items.size(); i++) {
        if(!"USK".equals(items.get(i).getKeyType()))
          continue;

        try {
          FreenetURI furi = new FreenetURI(items.get(i).getKey());
          USK usk = USK.create(furi);

          if(usk.equals(key, false)) {
            if(logMINOR) Logger.minor(this, "Updating bookmark for "+furi+" to edition "+edition);
            matched = true;
View Full Code Here

Examples of freenet.keys.FreenetURI

  }

  /** Called when we know the final URI of the insert. */
  @Override
  public void onEncode(BaseClientKey key, ClientPutState state, ClientContext context) {
    FreenetURI u;
    synchronized(this) {
        u = key.getURI();
      if(gotFinalMetadata) {
        Logger.error(this, "Generated URI *and* sent final metadata??? on "+this+" from "+state);
      }
      if(targetFilename != null)
        u = u.pushMetaString(targetFilename);
      if(this.uri != null) {
          if(!this.uri.equals(u)) {
              Logger.error(this, "onEncode() called twice with different URIs: "+this.uri+" -> "+u+" for "+this, new Exception("error"));
          }
          return;
View Full Code Here

Examples of freenet.keys.FreenetURI

            return;
        } else if (request.isPartSet("key") && request.isPartSet("filename")) {
          if(!ctx.checkFormPassword(request)) return;
          // FIXME do we still use this? where?
          // FIXME If we support it from freesites we need a confirmation page with the formPassword.
            FreenetURI key = new FreenetURI(request.getPartAsStringFailsafe("key", 128));
            String type = request.getPartAsStringFailsafe("content-type", 128);
            if (type == null) {
                type = "text/plain";
            }
            ClientMetadata contentType = new ClientMetadata(type);

            RandomAccessBucket bucket = request.getPart("filename");

            PageNode page = ctx.getPageMaker().getPageNode(l10n("insertedTitle"), ctx);
            HTMLNode pageNode = page.outer;
            HTMLNode contentNode = page.content;
            HTMLNode content;
            String filenameHint = null;
            if (key.getKeyType().equals("CHK")) {
                String[] metas = key.getAllMetaStrings();
                if ((metas != null) && (metas.length > 1)) {
                    filenameHint = metas[0];
                }
            }
            InsertBlock block = new InsertBlock(bucket, contentType, key);
            try {
                key = this.insert(block, filenameHint, false);
                content = ctx.getPageMaker().getInfobox("infobox-success", l10n("insertSucceededTitle"), contentNode, "successful-insert", false);
                String u = key.toString();
                NodeL10n.getBase().addL10nSubstitution(content, "WelcomeToadlet.keyInsertedSuccessfullyWithKeyAndName",
                        new String[]{"link", "name"},
                        new HTMLNode[] { HTMLNode.link("/"+u), HTMLNode.text(u) });
            } catch (InsertException e) {
              content = ctx.getPageMaker().getInfobox("infobox-error", l10n("insertFailedTitle"), contentNode, "failed-insert", false);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.