summaryrefslogtreecommitdiff
path: root/src/org/noreply/fancydress/directory/Server.java
diff options
context:
space:
mode:
authorPeter Palfrader <peter@palfrader.org>2003-10-12 03:24:56 +0000
committerPeter Palfrader <peter@palfrader.org>2003-10-12 03:24:56 +0000
commit2f848cd91f899fe3de2701085ee720b96ba317c0 (patch)
treed64da47fed0404faa5f21b13eb9ce5eac58618b0 /src/org/noreply/fancydress/directory/Server.java
parent85eccff05dc687bab86363aa40b61b0d6ed9f6be (diff)
Allow passing a path to the Path class constructor.
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;
}
}