projects
/
Sone.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Increase test coverage.
[Sone.git]
/
src
/
main
/
java
/
net
/
pterodactylus
/
sone
/
template
/
IdentityAccessor.java
diff --git
a/src/main/java/net/pterodactylus/sone/template/IdentityAccessor.java
b/src/main/java/net/pterodactylus/sone/template/IdentityAccessor.java
index
4ea956d
..
efb4d16
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/template/IdentityAccessor.java
+++ b/
src/main/java/net/pterodactylus/sone/template/IdentityAccessor.java
@@
-1,5
+1,5
@@
/*
/*
- * Sone - IdentityAccessor.java - Copyright © 2010 David Roden
+ * Sone - IdentityAccessor.java - Copyright © 2010
–2013
David Roden
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@
-17,16
+17,14
@@
package net.pterodactylus.sone.template;
package net.pterodactylus.sone.template;
-import java.util.Collections;
import java.util.Set;
import net.pterodactylus.sone.core.Core;
import net.pterodactylus.sone.freenet.wot.Identity;
import net.pterodactylus.sone.freenet.wot.OwnIdentity;
import java.util.Set;
import net.pterodactylus.sone.core.Core;
import net.pterodactylus.sone.freenet.wot.Identity;
import net.pterodactylus.sone.freenet.wot.OwnIdentity;
-import net.pterodactylus.sone.freenet.wot.PluginException;
import net.pterodactylus.util.template.Accessor;
import net.pterodactylus.util.template.Accessor;
-import net.pterodactylus.util.template.DataProvider;
import net.pterodactylus.util.template.ReflectionAccessor;
import net.pterodactylus.util.template.ReflectionAccessor;
+import net.pterodactylus.util.template.TemplateContext;
/**
* {@link Accessor} implementation that adds a “uniqueNickname” member to an
/**
* {@link Accessor} implementation that adds a “uniqueNickname” member to an
@@
-53,17
+51,12
@@
public class IdentityAccessor extends ReflectionAccessor {
* {@inheritDoc}
*/
@Override
* {@inheritDoc}
*/
@Override
- public Object get(
DataProvider dataProvider
, Object object, String member) {
+ public Object get(
TemplateContext templateContext
, Object object, String member) {
Identity identity = (Identity) object;
if ("uniqueNickname".equals(member)) {
int minLength = -1;
Identity identity = (Identity) object;
if ("uniqueNickname".equals(member)) {
int minLength = -1;
- boolean found = false;
- Set<OwnIdentity> ownIdentities = null;
- try {
- ownIdentities = core.getWebOfTrustConnector().loadAllOwnIdentities();
- } catch (PluginException e) {
- ownIdentities = Collections.emptySet();
- }
+ boolean found;
+ Set<OwnIdentity> ownIdentities = core.getIdentityManager().getAllOwnIdentities();
do {
boolean unique = true;
String abbreviatedWantedNickname = getAbbreviatedNickname(identity, ++minLength);
do {
boolean unique = true;
String abbreviatedWantedNickname = getAbbreviatedNickname(identity, ++minLength);
@@
-81,7
+74,7
@@
public class IdentityAccessor extends ReflectionAccessor {
} while (!found && (minLength < 43));
return getAbbreviatedNickname(identity, minLength);
}
} while (!found && (minLength < 43));
return getAbbreviatedNickname(identity, minLength);
}
- return super.get(
dataProvider
, object, member);
+ return super.get(
templateContext
, object, member);
}
//
}
//
@@
-99,7
+92,7
@@
public class IdentityAccessor extends ReflectionAccessor {
* append to the nickname
* @return The nickname with optional ID appendage
*/
* append to the nickname
* @return The nickname with optional ID appendage
*/
- private String getAbbreviatedNickname(Identity identity, int length) {
+ private
static
String getAbbreviatedNickname(Identity identity, int length) {
return identity.getNickname() + ((length > 0) ? "@" + identity.getId().substring(0, length) : "");
}
return identity.getNickname() + ((length > 0) ? "@" + identity.getId().substring(0, length) : "");
}