- if ("GET_METADATA".equals(command)) {
- if (args[0].equals("*")) {
- List<MetaData> metas = Instance.getLibrary().getMetas(
- createPgForwarder(action));
- return metas.toArray(new MetaData[] {});
+ return mode;
+ }
+
+ @Override
+ protected void onRequestDone(long id, long bytesReceived, long bytesSent) {
+ boolean whitelist = wls.get(id);
+ boolean rw = rws.get(id);
+ wls.remove(id);
+ rws.remove(id);
+
+ String rec = StringUtils.formatNumber(bytesReceived) + "b";
+ String sent = StringUtils.formatNumber(bytesSent) + "b";
+ long now = System.currentTimeMillis();
+ System.out.println(StringUtils.fromTime(now)
+ + ": "
+ + String.format("%s[>%s]: (%s sent, %s rec) in %d ms",
+ display(whitelist, rw), commands.get(id), sent, rec,
+ times.get(id)));
+
+ commands.remove(id);
+ times.remove(id);
+ }
+
+ private Object doRequest(ConnectActionServerObject action, String command,
+ Object[] args, boolean rw, List<String> whitelist)
+ throws NoSuchFieldException, NoSuchMethodException,
+ ClassNotFoundException, IOException {
+ if ("PING".equals(command)) {
+ return rw ? "r/w" : "r/o";
+ } else if ("GET_METADATA".equals(command)) {
+ List<MetaData> metas = new ArrayList<MetaData>();
+
+ if ("*".equals(args[0])) {
+ Progress pg = createPgForwarder(action);
+
+ for (MetaData meta : Instance.getInstance().getLibrary().getMetas(pg)) {
+ metas.add(removeCover(meta));
+ }
+
+ forcePgDoneSent(pg);
+ } else {
+ MetaData meta = Instance.getInstance().getLibrary().getInfo((String) args[0]);
+ MetaData light;
+ if (meta.getCover() == null) {
+ light = meta;
+ } else {
+ light = meta.clone();
+ light.setCover(null);
+ }
+
+ metas.add(light);