+ //
+
+ /**
+ * Return the meta of the given story or a list of all known metas if the
+ * luid is "*".
+ * <p>
+ * Will not get the covers.
+ *
+ * @param luid
+ * the luid of the story or *
+ * @param pg
+ * the optional progress
+ *
+ * @return the metas
+ *
+ * @throws IOException
+ * in case of I/O error or bad key (SSLException)
+ */
+ private List<MetaData> getMetasList(final String luid, Progress pg)
+ throws IOException {
+ final Progress pgF = pg;
+ final List<MetaData> metas = new ArrayList<MetaData>();
+
+ connectRemoteAction(new RemoteAction() {
+ @Override
+ public void action(ConnectActionClientObject action)
+ throws Exception {
+ Progress pg = pgF;
+ if (pg == null) {
+ pg = new Progress();
+ }
+
+ Object rep = action
+ .send(new Object[] { subkey, "GET_METADATA", luid });
+
+ while (true) {
+ if (!RemoteLibraryServer.updateProgress(pg, rep)) {
+ break;
+ }
+
+ rep = action.send(null);
+ }
+
+ if (rep instanceof MetaData[]) {
+ for (MetaData meta : (MetaData[]) rep) {
+ metas.add(meta);
+ }
+ } else if (rep != null) {
+ metas.add((MetaData) rep);
+ }
+ }
+ });
+
+ return metas;
+ }
+
+ private void connectRemoteAction(final RemoteAction runAction)
+ throws IOException {
+ final IOException[] err = new IOException[1];
+ try {
+ final RemoteConnectAction[] array = new RemoteConnectAction[1];
+ RemoteConnectAction ra = new RemoteConnectAction() {
+ @Override
+ public void action(Version serverVersion) throws Exception {
+ runAction.action(array[0]);
+ }
+
+ @Override
+ protected void onError(Exception e) {
+ if (!(e instanceof IOException)) {
+ Instance.getInstance().getTraceHandler().error(e);
+ return;
+ }
+
+ err[0] = (IOException) e;
+ }
+ };
+ array[0] = ra;
+ ra.connect();
+ } catch (Exception e) {
+ err[0] = (IOException) e;
+ }
+
+ if (err[0] != null) {
+ throw err[0];
+ }