Permalink
Browse files

more work on meeting management

  • Loading branch information...
1 parent 5cfe642 commit f668af4e6492e386684ae8e00a10e4b7996bdb7f @jthomerson committed Apr 30, 2010
View
2 src/main/java/com/genericconf/bbbgateway/services/IMeetingService.java
@@ -25,5 +25,7 @@
public void createMeeting(Meeting meeting);
public Collection<Meeting> getMeetings();
+
+ public Meeting findByMeetingID(String meetingID);
}
View
11 src/main/java/com/genericconf/bbbgateway/services/MeetingService.java
@@ -49,13 +49,18 @@ public void createMeeting(Meeting meeting) {
meetings.put(meeting.getMeetingID(), meeting);
}
}
+
+ @Override
+ public Meeting findByMeetingID(String meetingID) {
+ synchronized (meetings) {
+ return meetings.get(meetingID);
+ }
+ }
public Collection<Meeting> getMeetings() {
- Collection<Meeting> vals = null;
synchronized (meetings) {
- vals = meetings.values();
+ return Collections.unmodifiableCollection(meetings.values());
}
- return Collections.unmodifiableCollection(vals);
}
// IoC Methods
View
2 src/main/java/com/genericconf/bbbgateway/web/pages/CreateMeeting.java
@@ -39,7 +39,7 @@ public CreateMeeting() {
protected void onSubmit() {
super.onSubmit();
meetingService.createMeeting(getModelObject());
- setResponsePage(HomePage.class);
+ setResponsePage(ManageMeeting.class, ManageMeeting.createParams(getModelObject()));
}
};
View
89 src/main/java/com/genericconf/bbbgateway/web/pages/ManageMeeting.java
@@ -0,0 +1,89 @@
+/**
+ * Copyright 2010 Generic Conferencing, LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.genericconf.bbbgateway.web.pages;
+
+import java.util.UUID;
+
+import org.apache.commons.codec.digest.DigestUtils;
+import org.apache.wicket.PageParameters;
+import org.apache.wicket.RestartResponseAtInterceptPageException;
+import org.apache.wicket.model.AbstractReadOnlyModel;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.LoadableDetachableModel;
+import org.apache.wicket.spring.injection.annot.SpringBean;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.genericconf.bbbgateway.domain.Meeting;
+import com.genericconf.bbbgateway.services.IMeetingService;
+
+public class ManageMeeting extends BasePage {
+
+ private static final Logger logger = LoggerFactory.getLogger(ManageMeeting.class);
+ private static final String SALT = UUID.randomUUID().toString();
+
+ @SpringBean
+ private IMeetingService meetingService;
+
+ public ManageMeeting(PageParameters params) {
+ final String meetingID = params.getString("0");
+ String check = params.getString("1");
+ boolean okay = createCheck(meetingID).equals(check);
+ logger.info("meeting ID: " + meetingID + "; check: " + check + "; okay: " + okay);
+ if (!okay) {
+ getSession().error("You are not authorized to manage that meeting");
+ throw new RestartResponseAtInterceptPageException(HomePage.class);
+ }
+ IModel<Meeting> model = new LoadableDetachableModel<Meeting>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected Meeting load() {
+ return meetingService.findByMeetingID(meetingID);
+ }
+ };
+ setDefaultModel(model);
+ }
+
+ @Override
+ protected IModel<String> createContentHeaderLabelModel() {
+ return new AbstractReadOnlyModel<String>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String getObject() {
+ return "Manage meeting: " + ManageMeeting.this.getModel().getObject().getName();
+ }
+ };
+ }
+
+ @SuppressWarnings("unchecked")
+ protected IModel<Meeting> getModel() {
+ return (IModel<Meeting>) getDefaultModel();
+ }
+
+ public static PageParameters createParams(Meeting meeting) {
+ PageParameters pp = new PageParameters();
+ pp.put("0", meeting.getMeetingID());
+ pp.put("1", createCheck(meeting.getMeetingID()));
+ return pp;
+ }
+
+ private static String createCheck(String meetingID) {
+ return DigestUtils.md5Hex(SALT + meetingID);
+ }
+}
View
3 src/main/java/com/genericconf/bbbgateway/wicket/GatewayApplication.java
@@ -18,10 +18,12 @@
import org.apache.wicket.protocol.http.WebApplication;
import org.apache.wicket.request.target.coding.HybridUrlCodingStrategy;
+import org.apache.wicket.request.target.coding.IndexedHybridUrlCodingStrategy;
import org.apache.wicket.spring.injection.annot.SpringComponentInjector;
import com.genericconf.bbbgateway.web.pages.CreateMeeting;
import com.genericconf.bbbgateway.web.pages.HomePage;
+import com.genericconf.bbbgateway.web.pages.ManageMeeting;
public class GatewayApplication extends WebApplication {
public GatewayApplication() {
@@ -37,5 +39,6 @@ protected void init() {
mount(new HybridUrlCodingStrategy("home", HomePage.class));
mount(new HybridUrlCodingStrategy("create", CreateMeeting.class));
+ mount(new IndexedHybridUrlCodingStrategy("manage", ManageMeeting.class));
}
}

0 comments on commit f668af4

Please sign in to comment.