public SimpleFieldSet exportFieldSet(Config.RequestType configRequestType, boolean withDefaults) { SimpleFieldSet fs = new SimpleFieldSet(true); @SuppressWarnings("unchecked") Map.Entry<String, Option<?>>[] entries = new Map.Entry[map.size()]; // FIXME is any locking at all necessary here? After it has finished init, it's constant... synchronized (this) { entries = map.entrySet().toArray(entries); } if (logMINOR) Logger.minor(this, "Prefix=" + prefix); for (Map.Entry<String, Option<?>> entry : entries) { String key = entry.getKey(); Option<?> o = entry.getValue(); if (logMINOR) Logger.minor( this, "Key=" + key + " value=" + o.getValueString() + " default=" + o.isDefault()); if (configRequestType == Config.RequestType.CURRENT_SETTINGS && (!withDefaults) && o.isDefault() && (!o.forceWrite)) { if (logMINOR) Logger.minor(this, "Skipping " + key + " - " + o.isDefault()); continue; } switch (configRequestType) { case CURRENT_SETTINGS: fs.putSingle(key, o.getValueString()); break; case DEFAULT_SETTINGS: fs.putSingle(key, o.getDefault()); break; case SORT_ORDER: fs.put(key, o.getSortOrder()); break; case EXPERT_FLAG: fs.put(key, o.isExpert()); break; case FORCE_WRITE_FLAG: fs.put(key, o.isForcedWrite()); break; case SHORT_DESCRIPTION: fs.putSingle(key, o.getLocalisedShortDesc()); break; case LONG_DESCRIPTION: fs.putSingle(key, o.getLocalisedLongDesc()); break; case DATA_TYPE: fs.putSingle(key, o.getDataTypeStr()); break; default: Logger.error(this, "Unknown config request type value: " + configRequestType); break; } if (logMINOR) Logger.minor(this, "Key=" + prefix + '.' + key + " value=" + o.getValueString()); } return fs; }
public void onGeneratedURI(FreenetURI uri, BaseClientPutter state, ObjectContainer container) { if (logMINOR) Logger.minor(this, "Generated URI for " + darknetOpennetString + " ARK: " + uri); long l = uri.getSuggestedEdition(); if (l < crypto.myARKNumber) { Logger.error( this, "Inserted " + darknetOpennetString + " ARK edition # lower than attempted: " + l + " expected " + crypto.myARKNumber); } else if (l > crypto.myARKNumber) { if (logMINOR) Logger.minor( this, darknetOpennetString + " ARK number moving from " + crypto.myARKNumber + " to " + l); crypto.myARKNumber = l; if (crypto.isOpennet) node.writeOpennetFile(); else node.writeNodeFile(); // We'll broadcast the new ARK edition to our connected peers via a differential node // reference SimpleFieldSet fs = new SimpleFieldSet(true); fs.putSingle("ark.number", Long.toString(crypto.myARKNumber)); node.peers.locallyBroadcastDiffNodeRef(fs, !crypto.isOpennet, crypto.isOpennet); } }
public SimpleFieldSet toFieldSet() { if (freed) { Logger.error(this, "Cannot serialize because already freed: " + this); return null; } SimpleFieldSet fs = new SimpleFieldSet(false); fs.putSingle("Type", "DelayedFreeBucket"); if (bucket instanceof SerializableToFieldSetBucket) { fs.put("Underlying", ((SerializableToFieldSetBucket) bucket).toFieldSet()); } else { Logger.error(this, "Cannot serialize underlying bucket: " + bucket); return null; } return fs; }
// This is distinct from the ClientGetMessage code, as later on it will be radically // different (it can store detailed state). @Override public synchronized SimpleFieldSet getFieldSet() { SimpleFieldSet fs = new SimpleFieldSet(false); // we will need multi-level later... fs.putSingle("Type", "GET"); fs.putSingle("URI", uri.toString(false, false)); fs.putSingle("Identifier", identifier); fs.putSingle("Verbosity", Integer.toString(verbosity)); fs.putSingle("PriorityClass", Short.toString(priorityClass)); fs.putSingle("ReturnType", ClientGetMessage.returnTypeString(returnType)); fs.putSingle("Persistence", persistenceTypeString(persistenceType)); fs.putSingle("ClientName", client.name); if (targetFile != null) fs.putSingle("Filename", targetFile.getPath()); if (tempFile != null) fs.putSingle("TempFilename", tempFile.getPath()); if (clientToken != null) fs.putSingle("ClientToken", clientToken); fs.putSingle("IgnoreDS", Boolean.toString(fctx.ignoreStore)); fs.putSingle("DSOnly", Boolean.toString(fctx.localRequestOnly)); fs.putSingle("MaxRetries", Integer.toString(fctx.maxNonSplitfileRetries)); fs.putSingle("Finished", Boolean.toString(finished)); fs.putSingle("Succeeded", Boolean.toString(succeeded)); if (fctx.allowedMIMETypes != null) fs.putOverwrite( "AllowedMIMETypes", (String[]) fctx.allowedMIMETypes.toArray(new String[fctx.allowedMIMETypes.size()])); if (finished) { if (succeeded) { fs.putSingle("FoundDataLength", Long.toString(foundDataLength)); fs.putSingle("FoundDataMimeType", foundDataMimeType); if (postFetchProtocolErrorMessage != null) { fs.put("PostFetchProtocolError", postFetchProtocolErrorMessage.getFieldSet()); } } else { if (getFailedMessage != null) { fs.put("GetFailed", getFailedMessage.getFieldSet(false)); } } } // Return bucket if (returnType == ClientGetMessage.RETURN_TYPE_DIRECT && !(succeeded == false && returnBucket == null)) { bucketToFS(fs, "ReturnBucket", false, returnBucket); } fs.putSingle("Global", Boolean.toString(client.isGlobalQueue)); fs.put("BinaryBlob", binaryBlob); fs.put("StartupTime", startupTime); if (finished) fs.put("CompletionTime", completionTime); return fs; }