* @return The Sone with the given ID, or {@code null} if there is no such
* Sone
*/
- public Sone getSone(String id) {
- return getSone(id, true);
- }
-
- /**
- * Returns the Sone with the given ID, regardless whether it’s local or
- * remote.
- *
- * @param id
- * The ID of the Sone to get
- * @param create
- * {@code true} to create a new Sone if none exists,
- * {@code false} to return {@code null} if a Sone with the given
- * ID does not exist
- * @return The Sone with the given ID, or {@code null} if there is no such
- * Sone
- */
@Override
- public Sone getSone(String id, boolean create) {
+ public Sone getSone(String id) {
synchronized (sones) {
- if (!sones.containsKey(id) && create) {
- Sone sone = new Sone(id, false);
- sones.put(id, sone);
- }
return sones.get(id);
}
}
/* some local identity still trusts this identity, don’t remove. */
return;
}
- Sone sone = getSone(identity.getId(), false);
+ Sone sone = getSone(identity.getId());
if (sone == null) {
/* TODO - we don’t have the Sone anymore. should this happen? */
return;
public interface SoneProvider {
/**
- * Returns the Sone with the given ID, if it exists. If it does not exist
- * and {@code create} is {@code false}, {@code null} is returned; otherwise,
- * a new Sone with the given ID is created and returned.
+ * Returns the Sone with the given ID, if it exists.
*
* @param soneId
* The ID of the Sone to return
- * @param create
- * {@code true} to create a new Sone if no Sone with the given ID
- * exists, {@code false} to return {@code null} instead
* @return The Sone with the given ID, or {@code null}
*/
- public Sone getSone(String soneId, boolean create);
+ public Sone getSone(String soneId);
}
*/
@Override
public Sone getSone() {
- return soneProvider.getSone(soneId, false);
+ return soneProvider.getSone(soneId);
}
/**
*/
@Override
public Sone getRecipient() {
- return soneProvider.getSone(recipientId, false);
+ return soneProvider.getSone(recipientId);
}
/**
*/
@Override
public Sone getSone() {
- return soneProvider.getSone(soneId, false);
+ return soneProvider.getSone(soneId);
}
/**
if (mandatory && (soneId == null)) {
throw new FcpException("Could not load Sone ID from “" + parameterName + "”.");
}
- Sone sone = localOnly ? core.getLocalSone(soneId, false) : core.getSone(soneId, false);
+ Sone sone = localOnly ? core.getLocalSone(soneId, false) : core.getSone(soneId);
if (mandatory && (sone == null)) {
throw new FcpException("Could not load Sone from “" + soneId + "”.");
}
if (!getCore().hasSone(friendSoneId)) {
continue;
}
- allPosts.addAll(getCore().getSone(friendSoneId, false).getPosts());
+ allPosts.addAll(getCore().getSone(friendSoneId).getPosts());
}
allPosts.addAll(getCore().getDirectedPosts(sone));
allPosts = Collections2.filter(allPosts, Post.FUTURE_POSTS_FILTER);
int cutOffLength = Numbers.safeParseInteger(parameters.get("cut-off-length"), Numbers.safeParseInteger(templateContext.get(String.valueOf(parameters.get("cut-off-length"))), length));
Object sone = parameters.get("sone");
if (sone instanceof String) {
- sone = core.getSone((String) sone, false);
+ sone = core.getSone((String) sone);
}
FreenetRequest request = (FreenetRequest) templateContext.get("request");
SoneTextParserContext context = new SoneTextParserContext(request, (Sone) sone);
if (linkType == LinkType.SONE) {
if (line.length() >= (7 + 43)) {
String soneId = line.substring(7, 50);
- Sone sone = soneProvider.getSone(soneId, false);
+ Sone sone = soneProvider.getSone(soneId);
if (sone == null) {
/*
* don’t use create=true above, we don’t want
if (sender == null) {
sender = currentSone;
}
- Sone recipient = webInterface.getCore().getSone(recipientId, false);
+ Sone recipient = webInterface.getCore().getSone(recipientId);
text = TextFilter.filter(request.getHttpRequest().getHeader("host"), text);
webInterface.getCore().createPost(sender, recipient, System.currentTimeMillis(), text);
throw new RedirectException(returnPage);
String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
String identity = request.getHttpRequest().getPartAsStringFailsafe("sone", 44);
Sone currentSone = getCurrentSone(request.getToadletContext());
- Sone sone = webInterface.getCore().getSone(identity, false);
+ Sone sone = webInterface.getCore().getSone(identity);
if (sone != null) {
webInterface.getCore().distrustSone(currentSone, sone);
}
}
String soneId = request.getHttpRequest().getParam("sone", null);
if (soneId != null) {
- Sone sone = webInterface.getCore().getSone(soneId, false);
+ Sone sone = webInterface.getCore().getSone(soneId);
templateContext.set("soneRequested", true);
templateContext.set("sone", sone);
return;
}
webInterface.getCore().markReplyKnown(reply);
} else if (type.equals("sone")) {
- Sone sone = webInterface.getCore().getSone(id, false);
+ Sone sone = webInterface.getCore().getSone(id);
if (sone == null) {
continue;
}
*/
private String getSoneId(String phrase) {
String soneId = phrase.startsWith("sone://") ? phrase.substring(7) : phrase;
- return (webInterface.getCore().getSone(soneId, false) != null) ? soneId : null;
+ return (webInterface.getCore().getSone(soneId) != null) ? soneId : null;
}
/**
String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
String identity = request.getHttpRequest().getPartAsStringFailsafe("sone", 44);
Sone currentSone = getCurrentSone(request.getToadletContext());
- Sone sone = webInterface.getCore().getSone(identity, false);
+ Sone sone = webInterface.getCore().getSone(identity);
if (sone != null) {
webInterface.getCore().trustSone(currentSone, sone);
}
String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
String identity = request.getHttpRequest().getPartAsStringFailsafe("sone", 44);
Sone currentSone = getCurrentSone(request.getToadletContext());
- Sone sone = webInterface.getCore().getSone(identity, false);
+ Sone sone = webInterface.getCore().getSone(identity);
if (sone != null) {
webInterface.getCore().untrustSone(currentSone, sone);
}
@Override
protected String getPageTitle(FreenetRequest request) {
String soneId = request.getHttpRequest().getParam("sone");
- Sone sone = webInterface.getCore().getSone(soneId, false);
+ Sone sone = webInterface.getCore().getSone(soneId);
if ((sone != null) && (sone.getTime() > 0)) {
String soneName = SoneAccessor.getNiceName(sone);
return soneName + " - " + webInterface.getL10n().getString("Page.ViewSone.Title");
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
String soneId = request.getHttpRequest().getParam("sone");
- Sone sone = webInterface.getCore().getSone(soneId, false);
+ Sone sone = webInterface.getCore().getSone(soneId);
templateContext.set("sone", sone);
templateContext.set("soneId", soneId);
if (sone == null) {
return createErrorJsonObject("auth-required");
}
String recipientId = request.getHttpRequest().getParam("recipient");
- Sone recipient = webInterface.getCore().getSone(recipientId, false);
+ Sone recipient = webInterface.getCore().getSone(recipientId);
String senderId = request.getHttpRequest().getParam("sender");
Sone sender = webInterface.getCore().getLocalSone(senderId, false);
if (sender == null) {
return createErrorJsonObject("auth-required");
}
String soneId = request.getHttpRequest().getParam("sone");
- Sone sone = webInterface.getCore().getSone(soneId, false);
+ Sone sone = webInterface.getCore().getSone(soneId);
if (sone == null) {
return createErrorJsonObject("invalid-sone-id");
}
String[] soneIds = loadSoneIds.split(",");
for (String soneId : soneIds) {
/* just add it, we skip null further down. */
- sones.add(webInterface.getCore().getSone(soneId, false));
+ sones.add(webInterface.getCore().getSone(soneId));
}
}
JsonArray jsonSones = new JsonArray();
}
core.markReplyKnown(reply);
} else if (type.equals("sone")) {
- Sone sone = core.getSone(id, false);
+ Sone sone = core.getSone(id);
if (sone == null) {
continue;
}
return createErrorJsonObject("auth-required");
}
String soneId = request.getHttpRequest().getParam("sone");
- Sone sone = webInterface.getCore().getSone(soneId, false);
+ Sone sone = webInterface.getCore().getSone(soneId);
if (sone == null) {
return createErrorJsonObject("invalid-sone-id");
}
return createErrorJsonObject("auth-required");
}
String soneId = request.getHttpRequest().getParam("sone");
- Sone sone = webInterface.getCore().getSone(soneId, false);
+ Sone sone = webInterface.getCore().getSone(soneId);
if (sone == null) {
return createErrorJsonObject("invalid-sone-id");
}
* {@inheritDoc}
*/
@Override
- public Sone getSone(final String soneId, boolean create) {
+ public Sone getSone(final String soneId) {
return new Sone(soneId, false) {
/**