summaryrefslogtreecommitdiff
path: root/src/org/noreply/fancydress/directory/Server.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/noreply/fancydress/directory/Server.java')
-rw-r--r--src/org/noreply/fancydress/directory/Server.java20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/org/noreply/fancydress/directory/Server.java b/src/org/noreply/fancydress/directory/Server.java
index 53455f4..c4052d9 100644
--- a/src/org/noreply/fancydress/directory/Server.java
+++ b/src/org/noreply/fancydress/directory/Server.java
@@ -77,11 +77,23 @@ public class Server {
}
/**
- * get the first server descriptor (needs fixing).
+ * get the the currently valid server descriptor.
*
- * @return first server descriptor
+ * @return current server descriptor
*/
- public ServerDescriptor getDescriptor() { /* FIXME */
- return (ServerDescriptor) descriptors.get(0);
+ public ServerDescriptor getDescriptor() throws Mix3Exception {
+ ServerDescriptor result = null;
+ Date now = new Date();
+
+ for (int i=0; i<descriptors.size(); i++) {
+ ServerDescriptor desc = (ServerDescriptor) descriptors.get(i);
+ if (now.after( desc.getValidAfter() ) &&
+ now.before( desc.getValidUntil() ) &&
+ ((result == null) || desc.getPublished().after( result.getPublished())))
+ result = desc;
+ }
+ if (result == null)
+ throw new Mix3Exception("No valid server descriptor found.");
+ return result;
}
}