*/
public void addLocalSone(Sone sone) {
if (localSones.add(sone)) {
- SoneInserter soneInserter = new SoneInserter(freenetInterface, sone);
+ SoneInserter soneInserter = new SoneInserter(this, freenetInterface, sone);
soneInserter.start();
soneInserters.put(sone, soneInserter);
}
* if a Sone error occurs
*/
public Sone createSone(String name) throws SoneException {
- return createSone(name, null, null);
+ return createSone(name, "Sone-" + name, null, null);
}
/**
*
* @param name
* The name of the Sone
+ * @param documentName
+ * The document name in the SSK
* @param requestUri
* The request URI of the Sone, or {@link NullPointerException}
* to create a Sone at a random location
* @throws SoneException
* if a Sone error occurs
*/
- public Sone createSone(String name, String requestUri, String insertUri) throws SoneException {
+ public Sone createSone(String name, String documentName, String requestUri, String insertUri) throws SoneException {
if ((name == null) || (name.trim().length() == 0)) {
throw new SoneException(Type.INVALID_SONE_NAME);
}
Sone sone;
try {
logger.log(Level.FINEST, "Creating new Sone “%s” at %s (%s)…", new Object[] { name, finalRequestUri, finalInsertUri });
- sone = getSone(UUID.randomUUID().toString()).setName(name).setRequestUri(new FreenetURI(finalRequestUri).setKeyType("USK").setDocName("Sone-" + name)).setInsertUri(new FreenetURI(finalInsertUri).setKeyType("USK").setDocName("Sone-" + name));
+ sone = getSone(UUID.randomUUID().toString()).setName(name).setRequestUri(new FreenetURI(finalRequestUri).setKeyType("USK").setDocName(documentName)).setInsertUri(new FreenetURI(finalInsertUri).setKeyType("USK").setDocName(documentName));
sone.setProfile(new Profile());
/* set modification counter to 1 so it is inserted immediately. */
sone.setModificationCounter(1);
break;
}
String name = configuration.getStringValue(sonePrefix + "/Name").getValue(null);
+ long time = configuration.getLongValue(sonePrefix + "/Time").getValue((long) 0);
String insertUri = configuration.getStringValue(sonePrefix + "/InsertURI").getValue(null);
String requestUri = configuration.getStringValue(sonePrefix + "/RequestURI").getValue(null);
long modificationCounter = configuration.getLongValue(sonePrefix + "/ModificationCounter").getValue((long) 0);
profile.setFirstName(firstName);
profile.setMiddleName(middleName);
profile.setLastName(lastName);
- Sone sone = getSone(id).setName(name).setRequestUri(new FreenetURI(requestUri)).setInsertUri(new FreenetURI(insertUri));
+ Sone sone = getSone(id).setName(name).setTime(time).setRequestUri(new FreenetURI(requestUri)).setInsertUri(new FreenetURI(insertUri));
sone.setProfile(profile);
int postId = 0;
do {
if (id == null) {
break;
}
- long time = configuration.getLongValue(postPrefix + "/Time").getValue(null);
+ time = configuration.getLongValue(postPrefix + "/Time").getValue((long) 0);
String text = configuration.getStringValue(postPrefix + "/Text").getValue(null);
Post post = getPost(id).setSone(sone).setTime(time).setText(text);
sone.addPost(post);
String sonePrefix = "Sone/Sone." + soneId++;
configuration.getStringValue(sonePrefix + "/ID").setValue(sone.getId());
configuration.getStringValue(sonePrefix + "/Name").setValue(sone.getName());
+ configuration.getLongValue(sonePrefix + "/Time").setValue(sone.getTime());
configuration.getStringValue(sonePrefix + "/RequestURI").setValue(sone.getRequestUri().toString());
configuration.getStringValue(sonePrefix + "/InsertURI").setValue(sone.getInsertUri().toString());
configuration.getLongValue(sonePrefix + "/ModificationCounter").setValue(sone.getModificationCounter());