Changeset 5495 in josm for trunk/src/org/openstreetmap/josm/data
- Timestamp:
- 2012-09-02T14:20:28+02:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/User.java
r4602 r5495 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.io.BufferedReader;7 import java.io.InputStreamReader;8 import java.io.IOException;9 10 6 import java.util.ArrayList; 11 import java.util.concurrent.atomic.AtomicLong;12 7 import java.util.HashMap; 13 8 import java.util.HashSet; 14 9 import java.util.List; 15 16 import org.openstreetmap.josm.Main; 17 import org.openstreetmap.josm.io.MirroredInputStream; 10 import java.util.concurrent.atomic.AtomicLong; 11 18 12 import org.openstreetmap.josm.tools.Utils; 19 13 … … 35 29 */ 36 30 private static HashMap<Long,User> userMap = new HashMap<Long,User>(); 37 private static HashSet<Long> relicensingUsers = null;38 private static HashSet<Long> nonRelicensingUsers = null;39 31 private final static User anonymous = createLocalUser(tr("<anonymous>")); 40 32 … … 119 111 } 120 112 121 public static void initRelicensingInformation() {122 if (relicensingUsers == null) {123 loadRelicensingInformation(false);124 }125 }126 127 public static void loadRelicensingInformation(boolean clean) {128 relicensingUsers = new HashSet<Long>();129 nonRelicensingUsers = new HashSet<Long>();130 try {131 MirroredInputStream stream = new MirroredInputStream(132 Main.pref.get("url.licensechange",133 "http://planet.openstreetmap.org/users_agreed/users_agreed.txt"),134 clean ? 1 : 7200);135 try {136 InputStreamReader r;137 r = new InputStreamReader(stream);138 BufferedReader reader = new BufferedReader(r);139 String line;140 while ((line = reader.readLine()) != null) {141 if (line.startsWith("#")) continue;142 try {143 Long id = new Long(Long.parseLong(line.trim()));144 relicensingUsers.add(id);145 } catch (java.lang.NumberFormatException ex) {146 }147 }148 }149 finally {150 stream.close();151 }152 } catch (IOException ex) {153 }154 155 try {156 MirroredInputStream stream = new MirroredInputStream(157 Main.pref.get("url.licensechange_reject",158 "http://planet.openstreetmap.org/users_agreed/users_disagreed.txt"),159 clean ? 1 : 7200);160 try {161 InputStreamReader r;162 r = new InputStreamReader(stream);163 BufferedReader reader = new BufferedReader(r);164 String line;165 while ((line = reader.readLine()) != null) {166 if (line.startsWith("#")) continue;167 try {168 Long id = new Long(Long.parseLong(line.trim()));169 nonRelicensingUsers.add(id);170 } catch (java.lang.NumberFormatException ex) {171 }172 }173 }174 finally {175 stream.close();176 }177 } catch (IOException ex) {178 }179 }180 181 113 /** the user name */ 182 114 private final HashSet<String> names = new HashSet<String>(); 183 115 /** the user id */ 184 116 private final long uid; 185 private int relicensingStatus = STATUS_UNKNOWN;186 187 public static final int STATUS_UNKNOWN = -1;188 public static final int STATUS_UNDECIDED = 0;189 public static final int STATUS_AGREED = 1;190 public static final int STATUS_NOT_AGREED = 2;191 public static final int STATUS_AUTO_AGREED = 3;192 public static final int STATUS_ANONYMOUS = 4;193 194 /**195 * Finds out this user's relicensing status and saves it for quicker196 * access.197 */198 public int getRelicensingStatus() {199 if (relicensingStatus != STATUS_UNKNOWN) return relicensingStatus;200 if (uid >= 286582) return (relicensingStatus = STATUS_AUTO_AGREED);201 if (relicensingUsers == null) return STATUS_UNKNOWN;202 Long id = new Long(uid);203 if (relicensingUsers.contains(id)) return (relicensingStatus = STATUS_AGREED);204 if (nonRelicensingUsers == null) return STATUS_UNKNOWN;205 if (nonRelicensingUsers.contains(id)) return (relicensingStatus = STATUS_NOT_AGREED);206 return STATUS_UNDECIDED;207 }208 209 /**210 * Sets this user's relicensing status. This can be used if relicensing211 * information is available from another source so that directly looking212 * at the users_agreed/users_not_agreed files it not required.213 */214 public void setRelicensingStatus(int status) {215 relicensingStatus = status;216 }217 117 218 118 /**
Note:
See TracChangeset
for help on using the changeset viewer.