Project: * Clean-up (Eclipse cruft, unused files, etc...) * Git-specific changes * Maven POMs clean-up and changes for the build system * Version set to 1.0.0-0 in the development branches * Maven plug-ins updated to latest versions * Very partial dev. documentation added
This commit is contained in:
parent
c74e30d5ba
commit
0665a760de
1439 changed files with 1020 additions and 1649 deletions
legacyworlds-web-beans/src
main
java/com/deepclone/lw/web
beans
intercept
IEContentTypeBean.javaLanguageInterceptorBean.javaSessionInterceptorBean.javaSessionRequirement.java
msgs
session
ClientSessionReference.javaMaintenanceStatus.javaMaintenanceStatusBean.javaSession.javaSessionClient.javaSessionClientBean.javaSessionMaintenanceException.javaSessionServerException.javaSessionType.java
view
csess
resources
test
|
@ -0,0 +1,26 @@
|
|||
package com.deepclone.lw.web.beans.intercept;
|
||||
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
||||
|
||||
|
||||
|
||||
public class IEContentTypeBean
|
||||
extends HandlerInterceptorAdapter
|
||||
{
|
||||
|
||||
@Override
|
||||
public void postHandle( HttpServletRequest request , HttpServletResponse response , Object handler ,
|
||||
ModelAndView modelAndView )
|
||||
{
|
||||
String userAgent = request.getHeader( "User-Agent" );
|
||||
if ( userAgent.contains( "MSIE" )
|
||||
&& ( response.getContentType( ) == null || response.getContentType( ).startsWith( "application/xhtml+xml" ) ) ) {
|
||||
response.setHeader( "Content-Type" , "text/html" );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,159 @@
|
|||
package com.deepclone.lw.web.beans.intercept;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
||||
|
||||
import com.deepclone.lw.cmd.MaintenanceResponse;
|
||||
import com.deepclone.lw.cmd.ext.ListLanguagesResponse;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.session.SessionException;
|
||||
import com.deepclone.lw.web.beans.session.ClientSessionReference;
|
||||
import com.deepclone.lw.web.beans.session.SessionClient;
|
||||
import com.deepclone.lw.web.beans.session.SessionMaintenanceException;
|
||||
import com.deepclone.lw.web.beans.session.SessionServerException;
|
||||
import com.deepclone.lw.web.csess.ExternalSession;
|
||||
|
||||
|
||||
|
||||
public class LanguageInterceptorBean
|
||||
extends HandlerInterceptorAdapter
|
||||
|
||||
{
|
||||
|
||||
private final Logger logger = Logger.getLogger( SessionInterceptorBean.class );
|
||||
private SessionClient client;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setSessionClient( SessionClient client )
|
||||
{
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean preHandle( HttpServletRequest request , HttpServletResponse response , Object handler )
|
||||
throws IOException
|
||||
{
|
||||
HttpSession session = request.getSession( );
|
||||
String language = (String) session.getAttribute( "language" );
|
||||
|
||||
if ( language != null ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
this.logger.debug( "no language configured, trying to look it up" );
|
||||
|
||||
ExternalSession eSession;
|
||||
CommandResponse cResponse;
|
||||
ClientSessionReference sReference = new ClientSessionReference( null );
|
||||
try {
|
||||
InetAddress addr = InetAddress.getByName( request.getRemoteAddr( ) );
|
||||
eSession = this.client.getSession( sReference , ExternalSession.class , addr );
|
||||
cResponse = eSession.listLanguages( );
|
||||
} catch ( SessionException e ) {
|
||||
this.logger.error( "session error while initialising session language" );
|
||||
throw new RuntimeException( e );
|
||||
} catch ( SessionServerException e ) {
|
||||
this.logger.warn( "server offline while initialising session language, defaulting" );
|
||||
session.setAttribute( "language" , "en" );
|
||||
return true;
|
||||
} catch ( SessionMaintenanceException e ) {
|
||||
this.logger.warn( "server under maintenance while initialising session language, defaulting" );
|
||||
session.setAttribute( "language" , "en" );
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( cResponse instanceof MaintenanceResponse ) {
|
||||
this.logger.warn( "server under maintenance while initialising session language, defaulting" );
|
||||
session.setAttribute( "language" , "en" );
|
||||
return true;
|
||||
}
|
||||
|
||||
ListLanguagesResponse languages = (ListLanguagesResponse) cResponse;
|
||||
String accept = request.getHeader( "Accept-Language" );
|
||||
if ( accept == null ) {
|
||||
this.logger.info( "Accept-Language not found, defaulting" );
|
||||
session.setAttribute( "language" , "en" );
|
||||
return true;
|
||||
}
|
||||
|
||||
Set< String > supported = new HashSet< String >( );
|
||||
for ( ListLanguagesResponse.Language l : languages.getLanguages( ) ) {
|
||||
supported.add( l.getId( ).toLowerCase( ) );
|
||||
this.logger.trace( "supported language code '" + l.getId( ) + "'" );
|
||||
}
|
||||
|
||||
List< String > lAccept = this.makeLangList( accept.replaceAll( "\\s+" , "" ) );
|
||||
for ( String lId : lAccept ) {
|
||||
this.logger.debug( "accepted language code '" + lId + "'" );
|
||||
if ( supported.contains( lId.toLowerCase( ) ) ) {
|
||||
this.logger.info( "using language " + lId );
|
||||
session.setAttribute( "language" , lId );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
this.logger.info( "no language found in Accept-Language, defaulting" );
|
||||
session.setAttribute( "language" , "en" );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private List< String > makeLangList( String acceptString )
|
||||
{
|
||||
List< Double > qValues = new ArrayList< Double >( );
|
||||
Map< Double , Set< String > > found = new HashMap< Double , Set< String > >( );
|
||||
|
||||
for ( String part : acceptString.split( "," ) ) {
|
||||
|
||||
Double qValue;
|
||||
String language;
|
||||
if ( part.contains( ";q=" ) ) {
|
||||
try {
|
||||
String r[] = part.split( ";q=" );
|
||||
language = r[ 0 ];
|
||||
qValue = Double.parseDouble( r[ 1 ] );
|
||||
} catch ( NumberFormatException e ) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
qValue = 1.0;
|
||||
language = part;
|
||||
}
|
||||
|
||||
Set< String > accepts = found.get( qValue );
|
||||
if ( accepts == null ) {
|
||||
accepts = new HashSet< String >( );
|
||||
qValues.add( qValue );
|
||||
found.put( qValue , accepts );
|
||||
}
|
||||
accepts.add( language );
|
||||
}
|
||||
|
||||
Collections.sort( qValues );
|
||||
Collections.reverse( qValues );
|
||||
List< String > result = new LinkedList< String >( );
|
||||
for ( Double v : qValues ) {
|
||||
result.addAll( found.get( v ) );
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
package com.deepclone.lw.web.beans.intercept;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
||||
|
||||
import com.deepclone.lw.web.beans.session.ClientSessionReference;
|
||||
|
||||
|
||||
|
||||
public class SessionInterceptorBean
|
||||
extends HandlerInterceptorAdapter
|
||||
{
|
||||
|
||||
private final Logger logger = Logger.getLogger( SessionInterceptorBean.class );
|
||||
|
||||
|
||||
@Override
|
||||
public boolean preHandle( HttpServletRequest request , HttpServletResponse response , Object handler )
|
||||
throws IOException
|
||||
{
|
||||
HttpSession session = request.getSession( );
|
||||
ClientSessionReference sReference = (ClientSessionReference) session.getAttribute( "sReference" );
|
||||
if ( sReference == null ) {
|
||||
sReference = new ClientSessionReference( null );
|
||||
session.setAttribute( "sReference" , sReference );
|
||||
}
|
||||
|
||||
Class< ? > handlerType = handler.getClass( );
|
||||
SessionRequirement requirement = handlerType.getAnnotation( SessionRequirement.class );
|
||||
if ( requirement == null ) {
|
||||
this.logger.debug( "no session requirement" );
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( ( requirement.value( ) && sReference.isNull( ) ) || ( !requirement.value( ) && !sReference.isNull( ) ) ) {
|
||||
this.logger.debug( "requirement fail, redirecting to /" + requirement.redirectTo( ) );
|
||||
response.sendRedirect( requirement.redirectTo( ) );
|
||||
return false;
|
||||
}
|
||||
if ( requirement.value( ) && requirement.subType( ).length == 1 ) {
|
||||
String rType = requirement.subType( )[ 0 ];
|
||||
if ( !rType.equals( sReference.getReference( ).extra ) ) {
|
||||
this.logger.debug( "sub-type requirement fail, redirecting to /" + requirement.redirectTo( ) );
|
||||
response.sendRedirect( requirement.redirectTo( ) );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
this.logger.debug( "session requirement satisfied" );
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.deepclone.lw.web.beans.intercept;
|
||||
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
|
||||
|
||||
@Retention( RetentionPolicy.RUNTIME )
|
||||
@Target( ElementType.TYPE )
|
||||
public @interface SessionRequirement
|
||||
{
|
||||
|
||||
public boolean value( );
|
||||
|
||||
|
||||
public String[] subType( ) default { };
|
||||
|
||||
|
||||
public String redirectTo( );
|
||||
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package com.deepclone.lw.web.beans.msgs;
|
||||
|
||||
|
||||
public interface MessageFormatter
|
||||
{
|
||||
public String cleanMessage( String message );
|
||||
|
||||
public String formatMessage( String message , boolean internal );
|
||||
|
||||
}
|
|
@ -0,0 +1,129 @@
|
|||
package com.deepclone.lw.web.beans.msgs;
|
||||
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
||||
|
||||
public class MessageFormatterBean
|
||||
implements MessageFormatter
|
||||
{
|
||||
private final Pattern planet = Pattern.compile( "\\{\\{planet:(\\d+) ([^\\}]+)\\}\\}" );
|
||||
private final Pattern empire = Pattern.compile( "\\{\\{empire:(\\d+) ([^\\}]+)\\}\\}" );
|
||||
private final Pattern battle = Pattern.compile( "\\{\\{battle:(\\d+) ([^\\}]+)\\}\\}" );
|
||||
private final Pattern bug = Pattern.compile( "\\{\\{bug:(\\d+)\\}\\}" );
|
||||
|
||||
|
||||
public String cleanMessage( String message )
|
||||
{
|
||||
message = message.trim( );
|
||||
|
||||
StringBuilder repLine = new StringBuilder( );
|
||||
for ( Character c : message.toCharArray( ) ) {
|
||||
int nVal = Character.codePointAt( new char[] {
|
||||
c
|
||||
} , 0 );
|
||||
if ( Character.isISOControl( nVal ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
switch ( c ) {
|
||||
case '<':
|
||||
repLine.append( "<" );
|
||||
continue;
|
||||
case '>':
|
||||
repLine.append( ">" );
|
||||
continue;
|
||||
case '&':
|
||||
repLine.append( "&" );
|
||||
continue;
|
||||
case '\'':
|
||||
repLine.append( "'" );
|
||||
continue;
|
||||
case '"':
|
||||
repLine.append( """ );
|
||||
continue;
|
||||
}
|
||||
if ( nVal < 128 ) {
|
||||
repLine.append( c );
|
||||
} else {
|
||||
repLine.append( "&#" ).append( nVal ).append( ";" );
|
||||
}
|
||||
}
|
||||
message = repLine.toString( );
|
||||
return message;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String formatMessage( String message , boolean internal )
|
||||
{
|
||||
StringBuilder result = new StringBuilder( );
|
||||
boolean inList = false;
|
||||
boolean prevEmpty = true;
|
||||
for ( String line : message.split( "\\n" ) ) {
|
||||
line = this.cleanMessage( line );
|
||||
|
||||
if ( line.equals( "" ) ) {
|
||||
if ( prevEmpty ) {
|
||||
continue;
|
||||
}
|
||||
if ( inList ) {
|
||||
result.append( "</ul>" );
|
||||
} else {
|
||||
result.append( "</p>" );
|
||||
}
|
||||
result.append( "<p> </p>" );
|
||||
prevEmpty = true;
|
||||
inList = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( line.charAt( 0 ) == '*' ) {
|
||||
if ( !inList ) {
|
||||
if ( !prevEmpty ) {
|
||||
result.append( "</p>" );
|
||||
}
|
||||
result.append( "<ul>" );
|
||||
inList = true;
|
||||
}
|
||||
result.append( "<li>" ).append( line.substring( 1 ) ).append( "</li>" );
|
||||
} else {
|
||||
if ( prevEmpty ) {
|
||||
result.append( "<p>" );
|
||||
} else if ( inList ) {
|
||||
result.append( "</ul><p>" );
|
||||
inList = false;
|
||||
} else {
|
||||
result.append( "<br/>" );
|
||||
}
|
||||
result.append( line );
|
||||
}
|
||||
prevEmpty = false;
|
||||
}
|
||||
|
||||
if ( !prevEmpty ) {
|
||||
if ( inList ) {
|
||||
result.append( "</ul>" );
|
||||
} else {
|
||||
result.append( "</p>" );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !internal ) {
|
||||
return result.toString( );
|
||||
}
|
||||
return this.applyInternals( result.toString( ) );
|
||||
}
|
||||
|
||||
|
||||
private String applyInternals( String message )
|
||||
{
|
||||
message = planet.matcher( message ).replaceAll( "<a href=\"planet-$1\">$2</a>" );
|
||||
message = empire.matcher( message ).replaceAll( "<a href=\"msg-empire-$1\">$2</a>" );
|
||||
message = battle.matcher( message ).replaceAll( "<a href=\"battle-$1-latest\">$2</a>" );
|
||||
message = bug.matcher( message ).replaceAll( "<a href=\"bug-$1\">#$1</a>" );
|
||||
return message;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package com.deepclone.lw.web.beans.session;
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.deepclone.lw.session.SessionReference;
|
||||
|
||||
|
||||
|
||||
public class ClientSessionReference
|
||||
implements Serializable
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private SessionReference reference;
|
||||
|
||||
|
||||
public ClientSessionReference( SessionReference reference )
|
||||
{
|
||||
this.setReference( reference );
|
||||
}
|
||||
|
||||
|
||||
public void setReference( SessionReference reference )
|
||||
{
|
||||
this.reference = reference;
|
||||
}
|
||||
|
||||
|
||||
public SessionReference getReference( )
|
||||
{
|
||||
return this.reference;
|
||||
}
|
||||
|
||||
|
||||
public boolean isNull( )
|
||||
{
|
||||
return this.reference == null;
|
||||
}
|
||||
|
||||
|
||||
public void clear( )
|
||||
{
|
||||
this.reference = null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.deepclone.lw.web.beans.session;
|
||||
|
||||
|
||||
import com.deepclone.lw.cmd.MaintenanceResponse;
|
||||
|
||||
|
||||
|
||||
public interface MaintenanceStatus
|
||||
{
|
||||
|
||||
public void storeStatus( MaintenanceResponse response );
|
||||
|
||||
public MaintenanceResponse getStatus( );
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package com.deepclone.lw.web.beans.session;
|
||||
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.deepclone.lw.cmd.MaintenanceResponse;
|
||||
|
||||
|
||||
|
||||
public class MaintenanceStatusBean
|
||||
implements MaintenanceStatus
|
||||
{
|
||||
private final Logger logger = Logger.getLogger( MaintenanceStatusBean.class );
|
||||
private MaintenanceResponse maintenance = null;
|
||||
|
||||
|
||||
@Override
|
||||
synchronized public void storeStatus( MaintenanceResponse response )
|
||||
{
|
||||
this.logger.debug( "Setting maintenance status response: " + response );
|
||||
this.maintenance = response;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
synchronized public MaintenanceResponse getStatus( )
|
||||
{
|
||||
this.logger.debug( "Reading latest maintenance status response: " + this.maintenance );
|
||||
return this.maintenance;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
package com.deepclone.lw.web.beans.session;
|
||||
|
||||
|
||||
import com.deepclone.lw.cmd.MaintenanceResponse;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.session.SessionException;
|
||||
|
||||
|
||||
|
||||
public abstract class Session
|
||||
{
|
||||
|
||||
private ClientSessionReference reference;
|
||||
private SessionClient sClient;
|
||||
|
||||
|
||||
void initialise( SessionClient client , ClientSessionReference ref )
|
||||
{
|
||||
this.sClient = client;
|
||||
this.reference = ref;
|
||||
}
|
||||
|
||||
|
||||
public final boolean isActive( )
|
||||
{
|
||||
return !this.reference.isNull( );
|
||||
}
|
||||
|
||||
|
||||
public boolean authenticate( String identifier , String secret )
|
||||
throws SessionException , SessionServerException
|
||||
{
|
||||
try {
|
||||
this.sClient.authenticate( this.reference , identifier , secret );
|
||||
} catch ( SessionException e ) {
|
||||
this.handleSessionException( e );
|
||||
} catch ( SessionServerException e ) {
|
||||
this.reference.clear( );
|
||||
throw e;
|
||||
}
|
||||
|
||||
if ( this.reference.isNull( ) ) {
|
||||
return false;
|
||||
}
|
||||
return this.reference.getReference( ).authenticated;
|
||||
}
|
||||
|
||||
|
||||
public void terminate( )
|
||||
throws SessionServerException , SessionException
|
||||
{
|
||||
try {
|
||||
this.sClient.terminate( this.reference );
|
||||
} catch ( SessionServerException e ) {
|
||||
throw e;
|
||||
} catch ( SessionException e ) {
|
||||
this.handleSessionException( e );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public final String getSessionSubType( )
|
||||
{
|
||||
try {
|
||||
return this.reference.getReference( ).extra;
|
||||
} catch ( NullPointerException e ) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected CommandResponse execute( Command command )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
CommandResponse response = null;
|
||||
try {
|
||||
response = this.sClient.execute( this.reference , command );
|
||||
} catch ( SessionServerException e ) {
|
||||
this.reference.clear( );
|
||||
throw e;
|
||||
} catch ( SessionException e ) {
|
||||
this.handleSessionException( e );
|
||||
}
|
||||
|
||||
if ( response instanceof MaintenanceResponse ) {
|
||||
throw new SessionMaintenanceException( (MaintenanceResponse) response );
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
protected void handleSessionException( SessionException e )
|
||||
throws SessionException
|
||||
{
|
||||
if ( !e.isSessionKept( ) ) {
|
||||
this.reference.clear( );
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package com.deepclone.lw.web.beans.session;
|
||||
|
||||
|
||||
import java.net.InetAddress;
|
||||
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.session.SessionException;
|
||||
|
||||
|
||||
|
||||
public interface SessionClient
|
||||
{
|
||||
|
||||
public < T extends Session > T getSession( ClientSessionReference reference , Class< T > type , InetAddress ip )
|
||||
throws SessionException , SessionServerException;
|
||||
|
||||
|
||||
public < T extends Session > T restoreSession( ClientSessionReference session , Class< T > type );
|
||||
|
||||
|
||||
public void authenticate( ClientSessionReference session , String identifier , String secret )
|
||||
throws SessionException , SessionServerException;
|
||||
|
||||
|
||||
public CommandResponse execute( ClientSessionReference reference , Command command )
|
||||
throws SessionServerException , SessionException;
|
||||
|
||||
|
||||
public void terminate( ClientSessionReference reference )
|
||||
throws SessionServerException , SessionException;
|
||||
|
||||
}
|
|
@ -0,0 +1,165 @@
|
|||
package com.deepclone.lw.web.beans.session;
|
||||
|
||||
|
||||
import java.net.InetAddress;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.remoting.RemoteAccessException;
|
||||
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.session.SessionAccessor;
|
||||
import com.deepclone.lw.session.SessionException;
|
||||
import com.deepclone.lw.session.SessionReference;
|
||||
import com.deepclone.lw.session.SessionResponse;
|
||||
import com.deepclone.lw.utils.DigestHelper;
|
||||
|
||||
|
||||
|
||||
public class SessionClientBean
|
||||
implements SessionClient , ApplicationContextAware
|
||||
{
|
||||
private Logger logger = Logger.getLogger( SessionClient.class );
|
||||
private String sessionService = "sessionSrv";
|
||||
private ApplicationContext appContext;
|
||||
|
||||
|
||||
public void setSessionService( String name )
|
||||
{
|
||||
this.sessionService = name;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setApplicationContext( ApplicationContext applicationContext )
|
||||
throws BeansException
|
||||
{
|
||||
this.appContext = applicationContext;
|
||||
}
|
||||
|
||||
|
||||
private SessionAccessor getSessionService( )
|
||||
throws SessionServerException
|
||||
{
|
||||
try {
|
||||
return (SessionAccessor) this.appContext.getBean( this.sessionService );
|
||||
} catch ( BeanCreationException e ) {
|
||||
this.logger.error( "Could not connect to session manager" , e.getCause( ) );
|
||||
throw new SessionServerException( e.getCause( ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private < T extends Session > T makeSession( ClientSessionReference sRef , Class< T > type )
|
||||
{
|
||||
T session;
|
||||
try {
|
||||
session = type.newInstance( );
|
||||
} catch ( Exception e ) {
|
||||
this.logger.error( "Session creation failed" , e );
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
session.initialise( this , sRef );
|
||||
return session;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public < T extends Session > T getSession( ClientSessionReference session , Class< T > type , InetAddress ip )
|
||||
throws SessionException , SessionServerException
|
||||
{
|
||||
if ( !type.isAnnotationPresent( SessionType.class ) ) {
|
||||
throw new RuntimeException( "missing SessionType annotation on " + type );
|
||||
}
|
||||
|
||||
SessionType t = type.getAnnotation( SessionType.class );
|
||||
SessionAccessor sAcc = this.getSessionService( );
|
||||
SessionReference sRef;
|
||||
try {
|
||||
sRef = sAcc.create( t.value( ) , "web" , ip );
|
||||
} catch ( RemoteAccessException e ) {
|
||||
this.logger.error( "Could not create session" , e );
|
||||
throw new SessionServerException( e );
|
||||
}
|
||||
|
||||
session.setReference( sRef );
|
||||
return this.makeSession( session , type );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public < T extends Session > T restoreSession( ClientSessionReference session , Class< T > type )
|
||||
{
|
||||
if ( session.isNull( ) ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ( !type.isAnnotationPresent( SessionType.class ) ) {
|
||||
throw new RuntimeException( "missing SessionType annotation on " + type );
|
||||
}
|
||||
|
||||
SessionType t = type.getAnnotation( SessionType.class );
|
||||
if ( !t.value( ).equals( session.getReference( ).type ) ) {
|
||||
throw new RuntimeException( "session type mismatch" );
|
||||
}
|
||||
|
||||
return this.makeSession( session , type );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void authenticate( ClientSessionReference session , String identifier , String secret )
|
||||
throws SessionException , SessionServerException
|
||||
{
|
||||
String challenge = session.getReference( ).extra;
|
||||
String sha1 = DigestHelper.digest( "sha-1" , challenge + " " + DigestHelper.digest( "sha-1" , secret ) );
|
||||
String md5 = DigestHelper.digest( "md5" , challenge + " " + DigestHelper.digest( "md5" , secret ) );
|
||||
|
||||
SessionAccessor sAcc = this.getSessionService( );
|
||||
SessionReference ref;
|
||||
try {
|
||||
ref = sAcc.authenticate( session.getReference( ).identifier , identifier , sha1 , md5 );
|
||||
} catch ( RemoteAccessException e ) {
|
||||
this.logger.error( "Could not authenticate session" , e );
|
||||
throw new SessionServerException( e );
|
||||
}
|
||||
session.setReference( ref );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandResponse execute( ClientSessionReference reference , Command command )
|
||||
throws SessionServerException , SessionException
|
||||
{
|
||||
SessionAccessor sAcc = this.getSessionService( );
|
||||
SessionResponse sRep;
|
||||
try {
|
||||
sRep = sAcc.executeCommand( reference.getReference( ).identifier , command );
|
||||
} catch ( RemoteAccessException e ) {
|
||||
this.logger.error( "Could not execute command" , e );
|
||||
throw new SessionServerException( e );
|
||||
}
|
||||
reference.setReference( sRep.session );
|
||||
return sRep.data;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void terminate( ClientSessionReference reference )
|
||||
throws SessionServerException , SessionException
|
||||
{
|
||||
try {
|
||||
this.getSessionService( ).terminate( reference.getReference( ).identifier );
|
||||
} catch ( RemoteAccessException e ) {
|
||||
this.logger.error( "Could not terminate session" , e );
|
||||
throw new SessionServerException( e );
|
||||
} finally {
|
||||
reference.clear( );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package com.deepclone.lw.web.beans.session;
|
||||
|
||||
|
||||
import com.deepclone.lw.cmd.MaintenanceResponse;
|
||||
|
||||
|
||||
|
||||
public class SessionMaintenanceException
|
||||
extends Exception
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final MaintenanceResponse maintenance;
|
||||
|
||||
|
||||
public SessionMaintenanceException( MaintenanceResponse data )
|
||||
{
|
||||
this.maintenance = data;
|
||||
}
|
||||
|
||||
|
||||
public MaintenanceResponse getMaintenance( )
|
||||
{
|
||||
return maintenance;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.deepclone.lw.web.beans.session;
|
||||
|
||||
|
||||
public class SessionServerException
|
||||
extends Exception
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
public SessionServerException( Throwable cause )
|
||||
{
|
||||
super( "could not reach session server" , cause );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.deepclone.lw.web.beans.session;
|
||||
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
|
||||
|
||||
@Retention( RetentionPolicy.RUNTIME )
|
||||
@Target( ElementType.TYPE )
|
||||
public @interface SessionType
|
||||
{
|
||||
|
||||
public String value( );
|
||||
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
package com.deepclone.lw.web.beans.view;
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.deepclone.lw.cmd.bt.data.BugStatus;
|
||||
|
||||
|
||||
|
||||
public abstract class BugTrackerBase
|
||||
extends PageControllerBase
|
||||
{
|
||||
|
||||
@SuppressWarnings( "serial" )
|
||||
public static class BugQuery
|
||||
implements Serializable
|
||||
{
|
||||
public final BugStatus status;
|
||||
public final boolean ownOnly;
|
||||
public final long first;
|
||||
|
||||
|
||||
BugQuery( BugStatus status , boolean ownOnly , long first )
|
||||
{
|
||||
this.status = status;
|
||||
this.ownOnly = ownOnly;
|
||||
this.first = first;
|
||||
}
|
||||
|
||||
|
||||
public BugStatus getStatus( )
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
public boolean isOwnOnly( )
|
||||
{
|
||||
return ownOnly;
|
||||
}
|
||||
|
||||
|
||||
public long getFirst( )
|
||||
{
|
||||
return first;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected final BugQuery getBugQuery( String sStatus , String sOwn , String sFirst )
|
||||
{
|
||||
BugQuery query;
|
||||
|
||||
// Get status
|
||||
BugStatus status;
|
||||
if ( sStatus == null ) {
|
||||
status = null;
|
||||
} else {
|
||||
try {
|
||||
status = BugStatus.valueOf( sStatus );
|
||||
} catch ( IllegalArgumentException e ) {
|
||||
status = null;
|
||||
}
|
||||
}
|
||||
|
||||
// Own reports only?
|
||||
boolean ownOnly = ( sOwn != null && "1".equals( sOwn ) );
|
||||
|
||||
// First report displayed
|
||||
long first;
|
||||
if ( sFirst == null ) {
|
||||
first = 0;
|
||||
} else {
|
||||
try {
|
||||
first = Long.parseLong( sFirst );
|
||||
} catch ( NumberFormatException e ) {
|
||||
first = 0;
|
||||
}
|
||||
}
|
||||
|
||||
query = new BugQuery( status , ownOnly , first );
|
||||
return query;
|
||||
}
|
||||
|
||||
|
||||
protected String makeGetParams( BugQuery query )
|
||||
{
|
||||
String rTo = "?status=";
|
||||
if ( query.status == null ) {
|
||||
rTo += "x";
|
||||
} else {
|
||||
rTo += query.status.toString( );
|
||||
}
|
||||
rTo += "&own=" + ( query.ownOnly ? "1" : "0" ) + "&first=" + query.first;
|
||||
return rTo;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
package com.deepclone.lw.web.beans.view;
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
|
||||
public class Page
|
||||
implements Serializable
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String type;
|
||||
|
||||
private String language;
|
||||
|
||||
private Serializable data;
|
||||
|
||||
|
||||
public Page( String name , String language )
|
||||
{
|
||||
this.type = name;
|
||||
this.language = language;
|
||||
}
|
||||
|
||||
|
||||
public Page( String name , String language , Serializable data )
|
||||
{
|
||||
this.type = name;
|
||||
this.language = language;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
|
||||
public String getDataType( )
|
||||
{
|
||||
if ( this.data == null ) {
|
||||
return "null";
|
||||
}
|
||||
return this.data.getClass( ).getSimpleName( );
|
||||
}
|
||||
|
||||
|
||||
public String getLanguage( )
|
||||
{
|
||||
return this.language;
|
||||
}
|
||||
|
||||
|
||||
public Object getData( )
|
||||
{
|
||||
return this.data;
|
||||
}
|
||||
|
||||
|
||||
public String getType( )
|
||||
{
|
||||
return this.type;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,163 @@
|
|||
package com.deepclone.lw.web.beans.view;
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.ui.Model;
|
||||
|
||||
import com.deepclone.lw.cmd.player.gdata.GameResponseBase;
|
||||
import com.deepclone.lw.session.CommandResponse;
|
||||
import com.deepclone.lw.session.SessionException;
|
||||
import com.deepclone.lw.web.beans.session.ClientSessionReference;
|
||||
import com.deepclone.lw.web.beans.session.Session;
|
||||
import com.deepclone.lw.web.beans.session.SessionClient;
|
||||
import com.deepclone.lw.web.beans.session.SessionServerException;
|
||||
|
||||
|
||||
|
||||
public abstract class PageControllerBase
|
||||
{
|
||||
|
||||
protected SessionClient client;
|
||||
|
||||
|
||||
@Autowired( required = true )
|
||||
public void setSessionClient( SessionClient client )
|
||||
{
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
|
||||
protected String render( Model model , String template , String language )
|
||||
{
|
||||
return this.render( model , template , new Page( null , language ) );
|
||||
}
|
||||
|
||||
|
||||
protected String render( Model model , String template , String language , String subPage )
|
||||
{
|
||||
return this.render( model , template , new Page( subPage , language ) );
|
||||
}
|
||||
|
||||
|
||||
protected String render( Model model , String template , String language , CommandResponse data )
|
||||
{
|
||||
return this.render( model , template , new Page( null , language , data ) );
|
||||
}
|
||||
|
||||
|
||||
protected String render( Model model , String template , String language , String subPage , CommandResponse data )
|
||||
{
|
||||
return this.render( model , template , new Page( subPage , language , data ) );
|
||||
}
|
||||
|
||||
|
||||
protected String renderMap( Model model , String template , String language , String subPage , Object... data )
|
||||
{
|
||||
HashMap< String , Serializable > map = new HashMap< String , Serializable >( );
|
||||
for ( int i = 0 ; i < data.length / 2 ; i++ ) {
|
||||
map.put( (String) data[ i * 2 ] , (Serializable) data[ i * 2 + 1 ] );
|
||||
}
|
||||
return this.render( model , template , new Page( subPage , language , map ) );
|
||||
}
|
||||
|
||||
|
||||
protected String renderStatic( Model model , String template , String language , String name )
|
||||
{
|
||||
return this.render( model , template , new Page( "static" , language , name ) );
|
||||
}
|
||||
|
||||
|
||||
protected String renderStatic( Model model , String template , String language , GameResponseBase gameData ,
|
||||
String name )
|
||||
{
|
||||
return this.renderMap( model , template , language , "static" , "page" , gameData.getPage( ) , "name" , name );
|
||||
}
|
||||
|
||||
|
||||
protected String render( Model model , String template , Page page )
|
||||
{
|
||||
model.addAttribute( "container" , template );
|
||||
model.addAttribute( "language" , page.getLanguage( ) );
|
||||
model.addAttribute( "type" , page.getType( ) );
|
||||
model.addAttribute( "data" , page.getData( ) );
|
||||
model.addAttribute( "dataType" , page.getDataType( ) );
|
||||
return "ROOT";
|
||||
}
|
||||
|
||||
|
||||
protected String render( Model model , String template , String language , String type , Map< String , Object > data )
|
||||
{
|
||||
model.addAttribute( "container" , template );
|
||||
model.addAttribute( "language" , language );
|
||||
model.addAttribute( "type" , type );
|
||||
model.addAttribute( "data" , data );
|
||||
model.addAttribute( "dataType" , "map" );
|
||||
return "ROOT";
|
||||
}
|
||||
|
||||
|
||||
protected String redirect( String to )
|
||||
{
|
||||
return "redirect:" + to;
|
||||
}
|
||||
|
||||
|
||||
protected final InetAddress getAddress( HttpServletRequest request )
|
||||
{
|
||||
InetAddress address;
|
||||
try {
|
||||
address = InetAddress.getByName( request.getRemoteAddr( ) );
|
||||
} catch ( UnknownHostException e ) {
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
return address;
|
||||
}
|
||||
|
||||
|
||||
protected final ClientSessionReference getSessionReference( HttpServletRequest request )
|
||||
{
|
||||
return (ClientSessionReference) request.getSession( ).getAttribute( "sReference" );
|
||||
}
|
||||
|
||||
|
||||
protected < T extends Session > T createTemporarySession( Class< T > type , HttpServletRequest request )
|
||||
throws SessionException , SessionServerException
|
||||
{
|
||||
return this.client.getSession( new ClientSessionReference( null ) , type , this.getAddress( request ) );
|
||||
}
|
||||
|
||||
|
||||
protected < T extends Session > T initSession( Class< T > type , HttpServletRequest request )
|
||||
throws SessionException , SessionServerException
|
||||
{
|
||||
return this.client.getSession( this.getSessionReference( request ) , type , this.getAddress( request ) );
|
||||
}
|
||||
|
||||
|
||||
protected < T extends Session > T getSession( Class< T > type , HttpServletRequest request )
|
||||
{
|
||||
return this.client.restoreSession( this.getSessionReference( request ) , type );
|
||||
}
|
||||
|
||||
|
||||
protected void clearSession( HttpServletRequest request )
|
||||
{
|
||||
this.getSessionReference( request ).clear( );
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings( "unchecked" )
|
||||
protected Map< String , Object > getInput( HttpServletRequest request )
|
||||
{
|
||||
return (Map< String , Object >) request.getParameterMap( );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,542 @@
|
|||
package com.deepclone.lw.web.csess;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.deepclone.lw.cmd.CreateAuthChallengeCommand;
|
||||
import com.deepclone.lw.cmd.CreateAuthChallengeResponse;
|
||||
import com.deepclone.lw.cmd.admin.*;
|
||||
import com.deepclone.lw.cmd.admin.adata.*;
|
||||
import com.deepclone.lw.cmd.admin.bans.*;
|
||||
import com.deepclone.lw.cmd.admin.bt.*;
|
||||
import com.deepclone.lw.cmd.admin.constants.*;
|
||||
import com.deepclone.lw.cmd.admin.i18n.*;
|
||||
import com.deepclone.lw.cmd.admin.logs.*;
|
||||
import com.deepclone.lw.cmd.admin.mntm.*;
|
||||
import com.deepclone.lw.cmd.admin.msg.*;
|
||||
import com.deepclone.lw.cmd.admin.naming.*;
|
||||
import com.deepclone.lw.cmd.admin.prefs.*;
|
||||
import com.deepclone.lw.cmd.admin.su.*;
|
||||
import com.deepclone.lw.cmd.admin.tick.*;
|
||||
import com.deepclone.lw.cmd.admin.users.*;
|
||||
import com.deepclone.lw.cmd.bt.*;
|
||||
import com.deepclone.lw.cmd.bt.data.BugStatus;
|
||||
import com.deepclone.lw.cmd.msgdata.MessageType;
|
||||
import com.deepclone.lw.session.SessionException;
|
||||
import com.deepclone.lw.utils.DigestHelper;
|
||||
import com.deepclone.lw.web.beans.session.Session;
|
||||
import com.deepclone.lw.web.beans.session.SessionMaintenanceException;
|
||||
import com.deepclone.lw.web.beans.session.SessionServerException;
|
||||
import com.deepclone.lw.web.beans.session.SessionType;
|
||||
|
||||
|
||||
|
||||
@SessionType( "admin" )
|
||||
public class AdminSession
|
||||
extends Session
|
||||
{
|
||||
|
||||
/* Common commands */
|
||||
|
||||
public AdminOverviewResponse getOverview( )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (AdminOverviewResponse) this.execute( new AdminOverviewCommand( ) );
|
||||
}
|
||||
|
||||
|
||||
public AdminResponse noOp( )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (AdminResponse) this.execute( new NoOperationCommand( ) );
|
||||
}
|
||||
|
||||
|
||||
public AdminResponse noOp( Privileges privilege )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (AdminResponse) this.execute( new NoOperationCommand( privilege ) );
|
||||
}
|
||||
|
||||
|
||||
public SetPasswordResponse changePassword( String current , String password , String passwordConfirm )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
String challenge = ( (CreateAuthChallengeResponse) this.execute( new CreateAuthChallengeCommand( ) ) )
|
||||
.getChallenge( );
|
||||
|
||||
String sha1 , md5;
|
||||
sha1 = DigestHelper.digest( "sha-1" , challenge + " " + DigestHelper.digest( "sha-1" , current ) );
|
||||
md5 = DigestHelper.digest( "md5" , challenge + " " + DigestHelper.digest( "md5" , current ) );
|
||||
|
||||
return (SetPasswordResponse) this.execute( new SetPasswordCommand( sha1 , md5 , password , passwordConfirm ) );
|
||||
}
|
||||
|
||||
|
||||
/* Constants administration */
|
||||
|
||||
public GetConstantsResponse getConstants( )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (GetConstantsResponse) this.execute( new GetConstantsCommand( ) );
|
||||
}
|
||||
|
||||
|
||||
public SetConstantResponse setConstant( String name , double value )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (SetConstantResponse) this.execute( new SetConstantCommand( name , value ) );
|
||||
}
|
||||
|
||||
|
||||
/* Administrators administration */
|
||||
|
||||
public ListAdministratorsResponse listAdmins( )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (ListAdministratorsResponse) this.execute( new ListAdministratorsCommand( ) );
|
||||
}
|
||||
|
||||
|
||||
public AddAdministratorResponse addAdmin( String address , String name , List< Privileges > privs )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (AddAdministratorResponse) this.execute( new AddAdministratorCommand( address , name , privs ) );
|
||||
}
|
||||
|
||||
|
||||
public ViewAdministratorResponse viewAdministrator( int id )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (ViewAdministratorResponse) this.execute( new ViewAdministratorCommand( id ) );
|
||||
}
|
||||
|
||||
|
||||
public ViewAdministratorResponse resetAdministrator( int id )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (ViewAdministratorResponse) this.execute( new ResetAdminPasswordCommand( id ) );
|
||||
}
|
||||
|
||||
|
||||
public ViewAdministratorResponse setAdminPrivileges( int id , List< Privileges > privs )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (ViewAdministratorResponse) this.execute( new SetPrivilegesCommand( id , privs ) );
|
||||
}
|
||||
|
||||
|
||||
/* I18N administration */
|
||||
|
||||
public ViewLanguagesResponse listLanguages( )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (ViewLanguagesResponse) this.execute( new ViewLanguagesCommand( ) );
|
||||
}
|
||||
|
||||
|
||||
public GetLanguageResponse getLanguage( String language )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (GetLanguageResponse) this.execute( new GetLanguageCommand( language ) );
|
||||
}
|
||||
|
||||
|
||||
public ChangeLanguageResponse setLanguageName( String language , String name )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (ChangeLanguageResponse) this.execute( new ChangeLanguageCommand( language , name ) );
|
||||
}
|
||||
|
||||
|
||||
public SetStringResponse setTranslation( String language , String string , String value )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (SetStringResponse) this.execute( new SetStringCommand( language , string , value ) );
|
||||
}
|
||||
|
||||
|
||||
/* Names */
|
||||
|
||||
public NamesSummaryResponse getNameSummary( )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (NamesSummaryResponse) this.execute( new NamesSummaryCommand( ) );
|
||||
}
|
||||
|
||||
|
||||
public GetNamesResponse getNames( NameType type )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (GetNamesResponse) this.execute( new GetNamesCommand( type ) );
|
||||
}
|
||||
|
||||
|
||||
public void namesAction( NameType type , NameAction action , int[] ids )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
this.execute( new NamesActionCommand( type , action , ids ) );
|
||||
}
|
||||
|
||||
|
||||
/* Banhammer */
|
||||
|
||||
public BansSummaryResponse getBansSummary( )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (BansSummaryResponse) this.execute( new BansSummaryCommand( ) );
|
||||
}
|
||||
|
||||
|
||||
public ListBansResponse getBans( BanType type )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (ListBansResponse) this.execute( new ListBansCommand( type ) );
|
||||
}
|
||||
|
||||
|
||||
public RequestBanResponse requestBan( String user , boolean empire , String reason )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (RequestBanResponse) this.execute( new RequestBanCommand( user , empire , reason ) );
|
||||
}
|
||||
|
||||
|
||||
public RejectBanResponse rejectBan( int id , String reason )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (RejectBanResponse) this.execute( new RejectBanCommand( id , reason ) );
|
||||
}
|
||||
|
||||
|
||||
public void confirmBan( int id )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
this.execute( new ConfirmBanCommand( id ) );
|
||||
}
|
||||
|
||||
|
||||
public void liftBan( int id )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
this.execute( new LiftBanCommand( id ) );
|
||||
}
|
||||
|
||||
|
||||
/* Ticker */
|
||||
|
||||
public TickerStatusResponse getTickerStatus( )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (TickerStatusResponse) this.execute( new TickerStatusCommand( ) );
|
||||
}
|
||||
|
||||
|
||||
public void toggleTicker( )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
this.execute( new ToggleTickerCommand( ) );
|
||||
}
|
||||
|
||||
|
||||
public void setTickerTaskStatus( int task , boolean run )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
this.execute( new SetTaskStatusCommand( task , run ) );
|
||||
}
|
||||
|
||||
|
||||
public void setTickerTaskStatus( int task , long delay )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
this.execute( new SetTaskStatusCommand( task , delay ) );
|
||||
}
|
||||
|
||||
|
||||
/* Logs */
|
||||
|
||||
public ViewLogResponse viewLog( LogType logType , int first , int pageSize , LogLevel logLevel , String component ,
|
||||
boolean excOnly )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (ViewLogResponse) this.execute( new ViewLogCommand( logType , first , pageSize , logLevel , component ,
|
||||
excOnly ) );
|
||||
}
|
||||
|
||||
|
||||
public GetEntryResponse getLogEntry( long id )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (GetEntryResponse) this.execute( new GetEntryCommand( id ) );
|
||||
}
|
||||
|
||||
|
||||
/* Spam! */
|
||||
|
||||
public AdminResponse sendSpam( String title , String body )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (AdminResponse) this.execute( new SendSpamCommand( title , body ) );
|
||||
}
|
||||
|
||||
|
||||
/* Messages */
|
||||
|
||||
public GetMessagesResponse getMessages( boolean inbox )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (GetMessagesResponse) this.execute( new GetMessagesCommand( inbox ) );
|
||||
}
|
||||
|
||||
|
||||
public ReadMessageResponse readMessage( boolean inbox , long id )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (ReadMessageResponse) this.execute( new ReadMessageCommand( inbox , id ) );
|
||||
}
|
||||
|
||||
|
||||
public void deleteMessages( boolean inbox , long[] selection )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
this.execute( new MessageBoxCommand( inbox , selection ) );
|
||||
}
|
||||
|
||||
|
||||
public void markRead( long[] selection )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
this.execute( new MessageBoxCommand( selection , true ) );
|
||||
}
|
||||
|
||||
|
||||
public void markUnread( long[] selection )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
this.execute( new MessageBoxCommand( selection , false ) );
|
||||
}
|
||||
|
||||
|
||||
public ComposeMessageResponse initNewMessage( )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (ComposeMessageResponse) this.execute( PrepareMessageCommand.newMessage( ) );
|
||||
}
|
||||
|
||||
|
||||
public ComposeMessageResponse replyTo( boolean inbox , long id )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (ComposeMessageResponse) this.execute( new PrepareMessageCommand( id , inbox ) );
|
||||
}
|
||||
|
||||
|
||||
public ComposeMessageResponse messageTo( MessageType type , int id )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (ComposeMessageResponse) this.execute( PrepareMessageCommand.newMessageTo( type , id ) );
|
||||
}
|
||||
|
||||
|
||||
public ComposeMessageResponse sendMessage( MessageType type , String toName , String title , String contents )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
ComposeMessageCommand command = new ComposeMessageCommand( );
|
||||
command.setType( type );
|
||||
command.setTarget( toName );
|
||||
command.setSubject( title );
|
||||
command.setContents( contents );
|
||||
return (ComposeMessageResponse) this.execute( command );
|
||||
}
|
||||
|
||||
|
||||
public ComposeMessageResponse sendReply( boolean inbox , long rtId , MessageType type , String toName ,
|
||||
String title , String contents )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
ComposeMessageCommand command = new ComposeMessageCommand( inbox , rtId );
|
||||
command.setType( type );
|
||||
command.setTarget( toName );
|
||||
command.setSubject( title );
|
||||
command.setContents( contents );
|
||||
return (ComposeMessageResponse) this.execute( command );
|
||||
}
|
||||
|
||||
|
||||
/* Users */
|
||||
|
||||
public ListAccountsResponse listUsers( )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (ListAccountsResponse) this.execute( new ListAccountsCommand( ) );
|
||||
}
|
||||
|
||||
|
||||
public ListAccountsResponse listOnlineUsers( )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (ListAccountsResponse) this.execute( new ListAccountsCommand( null , true ) );
|
||||
}
|
||||
|
||||
|
||||
public ListAccountsResponse listUsers( AccountStatus status )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (ListAccountsResponse) this.execute( new ListAccountsCommand( status ) );
|
||||
}
|
||||
|
||||
|
||||
public ListAccountsResponse listOnlineUsers( AccountStatus status )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (ListAccountsResponse) this.execute( new ListAccountsCommand( status , true ) );
|
||||
}
|
||||
|
||||
|
||||
public ViewAccountResponse viewUser( int id )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (ViewAccountResponse) this.execute( new ViewAccountCommand( id ) );
|
||||
}
|
||||
|
||||
|
||||
public ListSessionsResponse viewUserSessions( int id )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (ListSessionsResponse) this.execute( new ListSessionsCommand( id ) );
|
||||
}
|
||||
|
||||
|
||||
public void giveCredits( int id , int credits )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
this.execute( new GiveCreditsCommand( id , credits ) );
|
||||
}
|
||||
|
||||
|
||||
/* Default preferences */
|
||||
|
||||
public PrefDefaultsResponse getPrefDefaults( )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (PrefDefaultsResponse) this.execute( new GetPrefDefaultsCommand( ) );
|
||||
}
|
||||
|
||||
|
||||
public void setPrefDefault( String pref , String value )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
this.execute( new SetPrefDefaultCommand( pref , value ) );
|
||||
}
|
||||
|
||||
|
||||
/* Bug tracking system */
|
||||
|
||||
public BugsSummaryResponse getBugsSummary( )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (BugsSummaryResponse) this.execute( new BugsSummaryCommand( ) );
|
||||
}
|
||||
|
||||
|
||||
public ListBugsResponse listBugs( BugStatus status , boolean ownOnly , long first , int count )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (ListBugsResponse) this.execute( new ListBugsCommand( status , ownOnly , first , count ) );
|
||||
}
|
||||
|
||||
|
||||
public ReportBugResponse reportBug( String title , String description , boolean publicReport )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (ReportBugResponse) this.execute( new ReportBugCommand( title , description , publicReport ) );
|
||||
}
|
||||
|
||||
|
||||
public ViewBugResponse getBugReport( long bugId )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (ViewBugResponse) this.execute( new ViewBugCommand( bugId ) );
|
||||
}
|
||||
|
||||
|
||||
public PostCommentResponse postBugComment( long bugId , String comment , boolean publicComment )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (PostCommentResponse) this.execute( new PostCommentCommand( bugId , comment , publicComment ) );
|
||||
}
|
||||
|
||||
|
||||
public void moderateBugComment( long commentId , boolean validate )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
this.execute( new ModerateCommentCommand( commentId , validate ) );
|
||||
}
|
||||
|
||||
|
||||
public void validateReport( long bugId , BugStatus newStatus , boolean visible , int grantCredits , boolean snapshot )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
this.execute( new ValidateReportCommand( bugId , newStatus , visible , grantCredits , snapshot ) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void setReportStatus( long bugId , BugStatus newStatus )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
this.execute( new ReportStatusCommand( bugId , newStatus ) );
|
||||
}
|
||||
|
||||
|
||||
public void toggleReportVisibility( long bugId )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
this.execute( new ReportVisibilityCommand( bugId ) );
|
||||
}
|
||||
|
||||
|
||||
public MergeReportsResponse mergeReports( long bugId , long mergeId )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (MergeReportsResponse) this.execute( new MergeReportsCommand( bugId , mergeId ) );
|
||||
}
|
||||
|
||||
|
||||
public GetSnapshotResponse getSnapshot( long bugId )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (GetSnapshotResponse) this.execute( new GetSnapshotCommand( bugId ) );
|
||||
}
|
||||
|
||||
|
||||
/* Maintenance mode */
|
||||
|
||||
public MaintenanceStatusResponse getMaintenanceStatus( )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (MaintenanceStatusResponse) this.execute( new MaintenanceStatusCommand( ) );
|
||||
}
|
||||
|
||||
|
||||
public MaintenanceChangeResponse enableMaintenance( String reason , int duration )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (MaintenanceChangeResponse) this.execute( new EnableMaintenanceCommand( reason , duration ) );
|
||||
}
|
||||
|
||||
|
||||
public void extendMaintenance( int duration )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
this.execute( new ExtendMaintenanceCommand( duration ) );
|
||||
}
|
||||
|
||||
|
||||
public void endMaintenance( )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
this.execute( new EndMaintenanceCommand( ) );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package com.deepclone.lw.web.csess;
|
||||
|
||||
|
||||
import com.deepclone.lw.cmd.ext.*;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.SessionException;
|
||||
import com.deepclone.lw.web.beans.session.Session;
|
||||
import com.deepclone.lw.web.beans.session.SessionMaintenanceException;
|
||||
import com.deepclone.lw.web.beans.session.SessionServerException;
|
||||
import com.deepclone.lw.web.beans.session.SessionType;
|
||||
|
||||
|
||||
|
||||
@SessionType( "ext" )
|
||||
public class ExternalSession
|
||||
extends Session
|
||||
{
|
||||
|
||||
public ListLanguagesResponse listLanguages( )
|
||||
throws SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
Command ll = new ListLanguagesCommand( );
|
||||
try {
|
||||
return (ListLanguagesResponse) this.execute( ll );
|
||||
} catch ( SessionException se ) {
|
||||
throw new RuntimeException( se );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public CreateAccountResponse createAccount( String mail , String mailConfirm , String password ,
|
||||
String passwordConfirm , String language )
|
||||
throws SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
Command command = new CreateAccountCommand( mail , mailConfirm , password , passwordConfirm , language );
|
||||
try {
|
||||
return (CreateAccountResponse) this.execute( command );
|
||||
} catch ( SessionException se ) {
|
||||
throw new RuntimeException( se );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public RequestPasswordRecoveryResponse requestPasswordRecovery( String mail )
|
||||
throws SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
Command command = new RequestPasswordRecoveryCommand( mail );
|
||||
try {
|
||||
return (RequestPasswordRecoveryResponse) this.execute( command );
|
||||
} catch ( SessionException se ) {
|
||||
throw new RuntimeException( se );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public ConfirmPasswordRecoveryResponse confirmPasswordRecovery( String mail , String token , String password ,
|
||||
String passwordConfirm )
|
||||
throws SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
Command command = new ConfirmPasswordRecoveryCommand( mail , token , password , passwordConfirm );
|
||||
try {
|
||||
return (ConfirmPasswordRecoveryResponse) this.execute( command );
|
||||
} catch ( SessionException se ) {
|
||||
throw new RuntimeException( se );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,578 @@
|
|||
package com.deepclone.lw.web.csess;
|
||||
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.deepclone.lw.cmd.CreateAuthChallengeCommand;
|
||||
import com.deepclone.lw.cmd.CreateAuthChallengeResponse;
|
||||
import com.deepclone.lw.cmd.bt.*;
|
||||
import com.deepclone.lw.cmd.bt.data.BugStatus;
|
||||
import com.deepclone.lw.cmd.msgdata.MessageType;
|
||||
import com.deepclone.lw.cmd.player.*;
|
||||
import com.deepclone.lw.cmd.player.account.*;
|
||||
import com.deepclone.lw.cmd.player.alliances.*;
|
||||
import com.deepclone.lw.cmd.player.battles.*;
|
||||
import com.deepclone.lw.cmd.player.bt.*;
|
||||
import com.deepclone.lw.cmd.player.elist.*;
|
||||
import com.deepclone.lw.cmd.player.fleets.*;
|
||||
import com.deepclone.lw.cmd.player.gdata.*;
|
||||
import com.deepclone.lw.cmd.player.planets.*;
|
||||
import com.deepclone.lw.cmd.player.msgs.*;
|
||||
import com.deepclone.lw.session.Command;
|
||||
import com.deepclone.lw.session.SessionException;
|
||||
import com.deepclone.lw.utils.DigestHelper;
|
||||
import com.deepclone.lw.web.beans.session.*;
|
||||
|
||||
|
||||
|
||||
@SessionType( "player" )
|
||||
public class PlayerSession
|
||||
extends Session
|
||||
{
|
||||
|
||||
/* General & account management commands */
|
||||
|
||||
public String getLanguage( )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
Command command = new GetLanguageCommand( );
|
||||
return ( (GetLanguageResponse) this.execute( command ) ).getLanguage( );
|
||||
}
|
||||
|
||||
|
||||
public AccountValidationResponse startValidation( )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (AccountValidationResponse) this.execute( new AccountValidationCommand( ) );
|
||||
}
|
||||
|
||||
|
||||
public AccountValidationResponse validate( String token , String empire , String planet )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
Command command = new AccountValidationCommand( token , empire , planet );
|
||||
return (AccountValidationResponse) this.execute( command );
|
||||
}
|
||||
|
||||
|
||||
public AccountReactivationResponse reactivate( )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (AccountReactivationResponse) this.execute( new AccountReactivationCommand( ) );
|
||||
}
|
||||
|
||||
|
||||
public BanDetailsResponse getBanDetails( )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (BanDetailsResponse) this.execute( new BanDetailsCommand( ) );
|
||||
}
|
||||
|
||||
|
||||
/* Empire commands */
|
||||
|
||||
public EmpireResponse getOverview( )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (EmpireResponse) this.execute( new OverviewCommand( ) );
|
||||
}
|
||||
|
||||
|
||||
public EmpireResponse implementTechnology( int technology )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (EmpireResponse) this.execute( new ImplementTechCommand( technology ) );
|
||||
}
|
||||
|
||||
|
||||
/* Planet list */
|
||||
|
||||
public ListPlanetsResponse listPlanets( )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (ListPlanetsResponse) this.execute( new ListPlanetsCommand( ) );
|
||||
}
|
||||
|
||||
|
||||
/* Map */
|
||||
|
||||
public ViewMapResponse viewMap( )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (ViewMapResponse) this.execute( new ViewMapCommand( ) );
|
||||
}
|
||||
|
||||
|
||||
public ViewMapResponse viewMap( int x , int y , MapSize size )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (ViewMapResponse) this.execute( new ViewMapCommand( x , y , size ) );
|
||||
}
|
||||
|
||||
|
||||
/* Planet commands */
|
||||
|
||||
public ViewPlanetResponse getPlanetView( int id )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (ViewPlanetResponse) this.execute( new ViewPlanetCommand( id ) );
|
||||
}
|
||||
|
||||
|
||||
public ViewPlanetResponse constructBuildings( int planetId , int type , int amount )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
Command cmd = new BuildingActionCommand( planetId , type , amount , false );
|
||||
return (ViewPlanetResponse) this.execute( cmd );
|
||||
}
|
||||
|
||||
|
||||
public ViewPlanetResponse destroyBuildings( int planetId , int type , int amount )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
Command cmd = new BuildingActionCommand( planetId , type , amount , true );
|
||||
return (ViewPlanetResponse) this.execute( cmd );
|
||||
}
|
||||
|
||||
|
||||
public ViewPlanetResponse buildShips( int planetId , int type , int amount )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
Command cmd = new BuildShipsCommand( planetId , type , amount );
|
||||
return (ViewPlanetResponse) this.execute( cmd );
|
||||
}
|
||||
|
||||
|
||||
public ViewPlanetResponse flushQueue( int planetId , boolean military )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
Command cmd = new FlushQueueCommand( planetId , military );
|
||||
return (ViewPlanetResponse) this.execute( cmd );
|
||||
}
|
||||
|
||||
|
||||
public ViewPlanetResponse rename( int planetId , String name )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (ViewPlanetResponse) this.execute( new RenamePlanetCommand( planetId , name ) );
|
||||
}
|
||||
|
||||
|
||||
public ViewPlanetResponse abandon( int planetId )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (ViewPlanetResponse) this.execute( new AbandonPlanetCommand( planetId , false ) );
|
||||
}
|
||||
|
||||
|
||||
public ViewPlanetResponse cancelAbandon( int planetId )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (ViewPlanetResponse) this.execute( new AbandonPlanetCommand( planetId , true ) );
|
||||
}
|
||||
|
||||
|
||||
/* Alliance commands */
|
||||
|
||||
public AllianceStatusResponse getAllianceStatus( )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (AllianceStatusResponse) this.execute( new AllianceStatusCommand( ) );
|
||||
}
|
||||
|
||||
|
||||
public AllianceStatusResponse viewAlliance( String tag )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (AllianceStatusResponse) this.execute( new ViewAllianceCommand( tag ) );
|
||||
}
|
||||
|
||||
|
||||
public AllianceStatusResponse joinAlliance( String tag )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (AllianceStatusResponse) this.execute( new JoinAllianceCommand( tag ) );
|
||||
}
|
||||
|
||||
|
||||
public AllianceStatusResponse cancelJoinAlliance( )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (AllianceStatusResponse) this.execute( new CancelJoinCommand( ) );
|
||||
}
|
||||
|
||||
|
||||
public AllianceStatusResponse createAlliance( String tag , String name )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (AllianceStatusResponse) this.execute( new CreateAllianceCommand( tag , name ) );
|
||||
}
|
||||
|
||||
|
||||
public AllianceStatusResponse manageRequests( boolean accept , int[] members )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (AllianceStatusResponse) this.execute( new ManageRequestsCommand( members , accept ) );
|
||||
}
|
||||
|
||||
|
||||
public AllianceStatusResponse kickMembers( int[] members )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (AllianceStatusResponse) this.execute( new KickMembersCommand( members ) );
|
||||
}
|
||||
|
||||
|
||||
public AllianceStatusResponse transferLeadership( int to )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (AllianceStatusResponse) this.execute( new TransferLeadershipCommand( to ) );
|
||||
}
|
||||
|
||||
|
||||
public AllianceStatusResponse leaveAlliance( )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (AllianceStatusResponse) this.execute( new LeaveAllianceCommand( ) );
|
||||
}
|
||||
|
||||
|
||||
/* Enemy list */
|
||||
|
||||
public EnemyListResponse getEnemyList( )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (EnemyListResponse) this.execute( new EnemyListCommand( ) );
|
||||
}
|
||||
|
||||
|
||||
public EnemyListResponse addEnemy( boolean alliance , String name )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (EnemyListResponse) this.execute( new AddEnemyCommand( alliance , name ) );
|
||||
}
|
||||
|
||||
|
||||
public EnemyListResponse removeEnemies( boolean alliance , int[] ids )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (EnemyListResponse) this.execute( new RemoveEnemiesCommand( alliance , ids ) );
|
||||
}
|
||||
|
||||
|
||||
/* Fleets */
|
||||
|
||||
public ViewFleetsResponse getFleets( )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (ViewFleetsResponse) this.execute( new ViewFleetsCommand( ) );
|
||||
}
|
||||
|
||||
|
||||
public MoveFleetsResponse moveFleets( long[] ids )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (MoveFleetsResponse) this.execute( new MoveFleetsCommand( ids ) );
|
||||
}
|
||||
|
||||
|
||||
public MoveFleetsResponse moveFleets( long[] ids , String destination , boolean attack )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (MoveFleetsResponse) this.execute( new MoveFleetsCommand( ids , destination , attack ) );
|
||||
}
|
||||
|
||||
|
||||
public SetFleetsModeResponse setFleetsMode( long[] ids , boolean attack , boolean forReal )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (SetFleetsModeResponse) this.execute( new SetFleetsModeCommand( ids , attack , forReal ) );
|
||||
}
|
||||
|
||||
|
||||
public RenameFleetsResponse renameFleets( long[] ids )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (RenameFleetsResponse) this.execute( new RenameFleetsCommand( ids ) );
|
||||
}
|
||||
|
||||
|
||||
public RenameFleetsResponse renameFleets( long[] ids , String name )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (RenameFleetsResponse) this.execute( new RenameFleetsCommand( ids , name ) );
|
||||
}
|
||||
|
||||
|
||||
public SplitFleetResponse splitFleet( long id )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (SplitFleetResponse) this.execute( new SplitFleetCommand( id ) );
|
||||
}
|
||||
|
||||
|
||||
public SplitFleetResponse splitFleet( long id , Map< Integer , Integer > ships , int nFleets , String name )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (SplitFleetResponse) this.execute( new SplitFleetCommand( id , ships , nFleets , name ) );
|
||||
}
|
||||
|
||||
|
||||
public DisbandFleetsResponse disbandFleets( long[] ids , boolean confirm )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (DisbandFleetsResponse) this.execute( new DisbandFleetsCommand( ids , confirm ) );
|
||||
}
|
||||
|
||||
|
||||
public MergeFleetsResponse mergeFleets( long[] ids )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (MergeFleetsResponse) this.execute( new MergeFleetsCommand( ids ) );
|
||||
}
|
||||
|
||||
|
||||
/* Account management */
|
||||
|
||||
public GetAccountResponse getAccount( )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (GetAccountResponse) this.execute( new GetAccountCommand( ) );
|
||||
}
|
||||
|
||||
|
||||
public void setLanguage( String language )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
this.execute( new SetLanguageCommand( language ) );
|
||||
}
|
||||
|
||||
|
||||
public String createAuthenticationChallenge( )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return ( (CreateAuthChallengeResponse) this.execute( new CreateAuthChallengeCommand( ) ) ).getChallenge( );
|
||||
}
|
||||
|
||||
|
||||
public SetPasswordResponse setPassword( String currentPassword , String challenge , String newPass1 ,
|
||||
String newPass2 )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
String sha1 , md5;
|
||||
sha1 = DigestHelper.digest( "sha-1" , challenge + " " + DigestHelper.digest( "sha-1" , currentPassword ) );
|
||||
md5 = DigestHelper.digest( "md5" , challenge + " " + DigestHelper.digest( "md5" , currentPassword ) );
|
||||
|
||||
return (SetPasswordResponse) this.execute( new SetPasswordCommand( sha1 , md5 , newPass1 , newPass2 ) );
|
||||
}
|
||||
|
||||
|
||||
public SetAddressResponse setAddress( String currentPassword , String challenge , String newAddr1 , String newAddr2 )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
String sha1 , md5;
|
||||
sha1 = DigestHelper.digest( "sha-1" , challenge + " " + DigestHelper.digest( "sha-1" , currentPassword ) );
|
||||
md5 = DigestHelper.digest( "md5" , challenge + " " + DigestHelper.digest( "md5" , currentPassword ) );
|
||||
|
||||
return (SetAddressResponse) this.execute( new SetAddressCommand( sha1 , md5 , newAddr1 , newAddr2 ) );
|
||||
}
|
||||
|
||||
|
||||
public ValidateSetAddressResponse cancelAddressChange( )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (ValidateSetAddressResponse) this.execute( new ValidateSetAddressCommand( ) );
|
||||
}
|
||||
|
||||
|
||||
public ValidateSetAddressResponse confirmAddressChange( String code )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (ValidateSetAddressResponse) this.execute( new ValidateSetAddressCommand( code ) );
|
||||
}
|
||||
|
||||
|
||||
public void loadDefaultPreferences( )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
this.execute( new SetPreferencesCommand( ) );
|
||||
}
|
||||
|
||||
|
||||
public void setPreferences( Map< String , String > prefs )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
this.execute( new SetPreferencesCommand( prefs ) );
|
||||
}
|
||||
|
||||
|
||||
public void setQuit( String reason )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
this.execute( new QuitGameCommand( reason ) );
|
||||
}
|
||||
|
||||
|
||||
public void cancelQuit( )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
this.execute( new CancelQuitCommand( ) );
|
||||
}
|
||||
|
||||
|
||||
public void toggleVacation( )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
this.execute( new ToggleVacationCommand( ) );
|
||||
}
|
||||
|
||||
|
||||
/* Battles */
|
||||
|
||||
public GetBattleResponse getBattle( long battle )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (GetBattleResponse) this.execute( new GetBattleCommand( battle ) );
|
||||
}
|
||||
|
||||
|
||||
public GetBattleResponse getBattle( long battle , long tick )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (GetBattleResponse) this.execute( new GetBattleCommand( battle , tick ) );
|
||||
}
|
||||
|
||||
|
||||
public ListBattlesResponse getBattles( int page )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (ListBattlesResponse) this.execute( new ListBattlesCommand( page ) );
|
||||
}
|
||||
|
||||
|
||||
public GetNewPlanetResponse getNewPlanet( String name )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (GetNewPlanetResponse) this.execute( new GetNewPlanetCommand( name ) );
|
||||
}
|
||||
|
||||
|
||||
/* Messages */
|
||||
|
||||
public GetMessagesResponse getMessages( boolean inbox )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (GetMessagesResponse) this.execute( new GetMessagesCommand( inbox ) );
|
||||
}
|
||||
|
||||
|
||||
public ReadMessageResponse readMessage( boolean inbox , long id )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (ReadMessageResponse) this.execute( new ReadMessageCommand( inbox , id ) );
|
||||
}
|
||||
|
||||
|
||||
public void deleteMessages( boolean inbox , long[] selection )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
this.execute( new MessageBoxCommand( inbox , selection ) );
|
||||
}
|
||||
|
||||
|
||||
public void markRead( long[] selection )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
this.execute( new MessageBoxCommand( selection , true ) );
|
||||
}
|
||||
|
||||
|
||||
public void markUnread( long[] selection )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
this.execute( new MessageBoxCommand( selection , false ) );
|
||||
}
|
||||
|
||||
|
||||
public ComposeMessageResponse initNewMessage( )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (ComposeMessageResponse) this.execute( PrepareMessageCommand.newMessage( ) );
|
||||
}
|
||||
|
||||
|
||||
public ComposeMessageResponse messageTo( MessageType messageType , int id )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (ComposeMessageResponse) this.execute( PrepareMessageCommand.newMessageTo( messageType , id ) );
|
||||
}
|
||||
|
||||
|
||||
public ComposeMessageResponse sendMessage( MessageType type , String toName , String title , String contents )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
ComposeMessageCommand command = new ComposeMessageCommand( );
|
||||
command.setType( type );
|
||||
command.setTarget( toName );
|
||||
command.setSubject( title );
|
||||
command.setContents( contents );
|
||||
return (ComposeMessageResponse) this.execute( command );
|
||||
}
|
||||
|
||||
|
||||
public ComposeMessageResponse sendReply( boolean inbox , long rtId , MessageType type , String toName ,
|
||||
String title , String contents )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
ComposeMessageCommand command = new ComposeMessageCommand( inbox , rtId );
|
||||
command.setType( type );
|
||||
command.setTarget( toName );
|
||||
command.setSubject( title );
|
||||
command.setContents( contents );
|
||||
return (ComposeMessageResponse) this.execute( command );
|
||||
}
|
||||
|
||||
|
||||
public ComposeMessageResponse replyTo( boolean inbox , long id )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (ComposeMessageResponse) this.execute( new PrepareMessageCommand( id , inbox ) );
|
||||
}
|
||||
|
||||
|
||||
public ListTargetsResponse listMessageTargets( )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (ListTargetsResponse) this.execute( new ListTargetsCommand( ) );
|
||||
}
|
||||
|
||||
|
||||
/* Bug tracking system */
|
||||
|
||||
public ListBugsResponse listBugs( BugStatus status , boolean ownOnly , long first , int count )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (ListBugsResponse) this.execute( new ListBugsCommand( status , ownOnly , first , count ) );
|
||||
}
|
||||
|
||||
|
||||
public ReportBugResponse reportBug( String title , String description )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (ReportBugResponse) this.execute( new ReportBugCommand( title , description ) );
|
||||
}
|
||||
|
||||
|
||||
public ViewBugResponse getBugReport( long bugId )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (ViewBugResponse) this.execute( new ViewBugCommand( bugId ) );
|
||||
}
|
||||
|
||||
|
||||
public PostCommentResponse postBugComment( long bugId , String comment )
|
||||
throws SessionException , SessionServerException , SessionMaintenanceException
|
||||
{
|
||||
return (PostCommentResponse) this.execute( new PostCommentCommand( bugId , comment ) );
|
||||
}
|
||||
}
|
0
legacyworlds-web-beans/src/main/resources/.empty
Normal file
0
legacyworlds-web-beans/src/main/resources/.empty
Normal file
0
legacyworlds-web-beans/src/test/java/.empty
Normal file
0
legacyworlds-web-beans/src/test/java/.empty
Normal file
0
legacyworlds-web-beans/src/test/resources/.empty
Normal file
0
legacyworlds-web-beans/src/test/resources/.empty
Normal file
Reference in a new issue