Delete some old stuff that was never fully implemented or needed.
This commit is contained in:
parent
270b590ec7
commit
ac48ea044c
|
@ -1,61 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2012, Andy Janata
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
* provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||
* and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
|
||||
* WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.socialgamer.cah.handlers;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import net.socialgamer.cah.Constants;
|
||||
import net.socialgamer.cah.Constants.ErrorCode;
|
||||
import net.socialgamer.cah.Constants.ReturnableData;
|
||||
import net.socialgamer.cah.RequestWrapper;
|
||||
|
||||
|
||||
/**
|
||||
* Superclass of handlers for administrative actions. Ensures that the client is allowed to make
|
||||
* admin requests.
|
||||
*
|
||||
* @author Andy Janata (ajanata@socialgamer.net)
|
||||
*/
|
||||
public abstract class AdminHandler extends Handler {
|
||||
|
||||
@Override
|
||||
public Map<ReturnableData, Object> handle(final RequestWrapper request, final HttpSession session) {
|
||||
if (!Constants.ADMIN_IP_ADDRESSES.contains(request.getRemoteAddr())) {
|
||||
return error(ErrorCode.ACCESS_DENIED);
|
||||
}
|
||||
|
||||
return handle(request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle a request.
|
||||
*
|
||||
* @param request
|
||||
* Request data from the client.
|
||||
* @return Response data.
|
||||
*/
|
||||
public abstract Map<ReturnableData, Object> handle(RequestWrapper request);
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2012, Andy Janata
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
* provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||
* and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
|
||||
* WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.socialgamer.cah.handlers;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import net.socialgamer.cah.Constants.AjaxOperation;
|
||||
import net.socialgamer.cah.Constants.ReturnableData;
|
||||
import net.socialgamer.cah.RequestWrapper;
|
||||
|
||||
|
||||
/**
|
||||
* Admin handler for turning verbose logging on and off. This has been temporarily abandoned as
|
||||
* using this ajax framework for administration purposes would take a while to set up.
|
||||
*
|
||||
* @author Andy Janata (ajanata@socialgamer.net)
|
||||
*/
|
||||
public class AdminSetVerboseLog extends AdminHandler {
|
||||
|
||||
public static final String OP = AjaxOperation.ADMIN_SET_VERBOSE_LOG.toString();
|
||||
|
||||
@Override
|
||||
public Map<ReturnableData, Object> handle(final RequestWrapper request) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Copyright (c) 2012, Andy Janata
|
||||
* Copyright (c) 2012-2018, Andy Janata
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
|
@ -80,36 +80,4 @@ public abstract class Handler {
|
|||
data.putAll(extraData);
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up after this Handler. Currently, this means using reflection to see if the concrete
|
||||
* Handler implementation had a field of type Session (Hibernate), and closing it if it does and
|
||||
* did not already close it.
|
||||
*/
|
||||
public final void cleanUp() {
|
||||
// this actually breaks stuff, I'll have to think it through later.
|
||||
// for (final Field field : this.getClass().getDeclaredFields()) {
|
||||
// if (field.getType() == Session.class) {
|
||||
// try {
|
||||
// // This Handler had a Hibernate Session. Try to close it if it wasn't already closed.
|
||||
// // This is extremely dirty but also extremely awesome to not have problems if it is
|
||||
// // forgotten.
|
||||
// field.setAccessible(true);
|
||||
// final Session session = (Session) field.get(this);
|
||||
// if (session.isOpen()) {
|
||||
// session.close();
|
||||
// logger.log(Level.INFO, "Closing unclosed Hibernate Session in "
|
||||
// + this.getClass().getName());
|
||||
// }
|
||||
// } catch (final Exception e) {
|
||||
// // Something prevented us from ignoring access control check, so we can't close the
|
||||
// // session. Log about it and continue.
|
||||
// e.printStackTrace();
|
||||
// logger.log(Level.SEVERE, "Unable to reflect and get Hibernate Session from "
|
||||
// + this.getClass().getName());
|
||||
// logger.log(Level.SEVERE, e.toString());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@ public class Handlers {
|
|||
|
||||
static {
|
||||
LIST = new HashMap<String, Class<? extends Handler>>();
|
||||
LIST.put(AdminSetVerboseLog.OP, AdminSetVerboseLog.class);
|
||||
LIST.put(BanHandler.OP, BanHandler.class);
|
||||
LIST.put(CardcastAddCardsetHandler.OP, CardcastAddCardsetHandler.class);
|
||||
LIST.put(CardcastListCardsetsHandler.OP, CardcastListCardsetsHandler.class);
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
/**
|
||||
* Copyright (c) 2012, Andy Janata
|
||||
* Copyright (c) 2012-2018, Andy Janata
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
* provided that the following conditions are met:
|
||||
*
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||
* and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
|
@ -46,9 +46,9 @@ import net.socialgamer.cah.handlers.Handlers;
|
|||
|
||||
/**
|
||||
* Servlet implementation class AjaxServlet.
|
||||
*
|
||||
*
|
||||
* This servlet is only used for client actions, not for long-polling.
|
||||
*
|
||||
*
|
||||
* @author Andy Janata (ajanata@socialgamer.net)
|
||||
*/
|
||||
@WebServlet("/AjaxServlet")
|
||||
|
@ -94,7 +94,6 @@ public class AjaxServlet extends CahServlet {
|
|||
return;
|
||||
}
|
||||
final Map<ReturnableData, Object> data = handler.handle(new RequestWrapper(request), hSession);
|
||||
handler.cleanUp();
|
||||
data.put(AjaxResponse.SERIAL, serial);
|
||||
returnData(user, out, data);
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue