code
stringlengths
1
2.01M
repo_name
stringlengths
3
62
path
stringlengths
1
267
language
stringclasses
231 values
license
stringclasses
13 values
size
int64
1
2.01M
package net.sourceforge.jsocks; import java.io.IOException; import java.io.InputStream; import java.net.InetAddress; import java.net.UnknownHostException; /** Proxy which describes SOCKS4 proxy. */ public class Socks4Proxy extends Proxy implements Cloneable{ //Data members String user; //Public Constructors //==================== /** Creates the SOCKS4 proxy @param p Proxy to use to connect to this proxy, allows proxy chaining. @param proxyHost Address of the proxy server. @param proxyPort Port of the proxy server @param user User name to use for identification purposes. @throws UnknownHostException If proxyHost can't be resolved. */ public Socks4Proxy(String proxyHost,int proxyPort,String user) throws UnknownHostException{ super(proxyHost,proxyPort); this.user = new String(user); version = 4; } /** Creates the SOCKS4 proxy @param p Proxy to use to connect to this proxy, allows proxy chaining. @param proxyIP Address of the proxy server. @param proxyPort Port of the proxy server @param user User name to use for identification purposes. */ public Socks4Proxy(Proxy p,InetAddress proxyIP,int proxyPort,String user){ super(p,proxyIP,proxyPort); this.user = new String(user); version = 4; } /** Creates the SOCKS4 proxy @param proxyIP Address of the proxy server. @param proxyPort Port of the proxy server @param user User name to use for identification purposes. */ public Socks4Proxy(InetAddress proxyIP,int proxyPort,String user){ this(null,proxyIP,proxyPort,user); } //Public instance methods //======================== /** * Creates a clone of this proxy. Changes made to the clone should not * affect this object. */ public Object clone(){ Socks4Proxy newProxy = new Socks4Proxy(proxyIP,proxyPort,user); newProxy.chainProxy = chainProxy; return newProxy; } //Public Static(Class) Methods //============================== //Protected Methods //================= protected Proxy copy(){ Socks4Proxy copy = new Socks4Proxy(proxyIP,proxyPort,user); copy.chainProxy = chainProxy; return copy; } protected ProxyMessage formMessage(int cmd,InetAddress ip,int port){ switch(cmd){ case SOCKS_CMD_CONNECT: cmd = Socks4Message.REQUEST_CONNECT; break; case SOCKS_CMD_BIND: cmd = Socks4Message.REQUEST_BIND; break; default: return null; } return new Socks4Message(cmd,ip,port,user); } protected ProxyMessage formMessage(int cmd,String host,int port) throws UnknownHostException{ return formMessage(cmd,InetAddress.getByName(host),port); } protected ProxyMessage formMessage(InputStream in) throws SocksException, IOException{ return new Socks4Message(in,true); } }
zzsuper001-linuxshell
src/net/sourceforge/jsocks/Socks4Proxy.java
Java
asf20
3,109
package net.sourceforge.jsocks; import java.net.*; import java.io.*; /** * SocksSocket tryies to look very similar to normal Socket, * while allowing connections through the SOCKS4 or 5 proxy. * To use this class you will have to identify proxy you need * to use, Proxy class allows you to set default proxy, which * will be used by all Socks aware sockets. You can also create * either Socks4Proxy or Socks5Proxy, and use them by passing to the * appropriate constructors. * <P> * Using Socks package can be as easy as that: * * <pre><tt> * * import Socks.*; * .... * * try{ * //Specify SOCKS5 proxy * Proxy.setDefaultProxy("socks-proxy",1080); * * //OR you still use SOCKS4 * //Code below uses SOCKS4 proxy * //Proxy.setDefaultProxy("socks-proxy",1080,userName); * * Socket s = SocksSocket("some.host.of.mine",13); * readTimeFromSock(s); * }catch(SocksException sock_ex){ * //Usually it will turn in more or less meaningfull message * System.err.println("SocksException:"+sock_ex); * } * * </tt></pre> *<P> * However if the need exist for more control, like resolving addresses * remotely, or using some non-trivial authentication schemes, it can be done. */ public class SocksSocket extends Socket{ //Data members protected Proxy proxy; protected String localHost, remoteHost; protected InetAddress localIP, remoteIP; protected int localPort,remotePort; private Socket directSock = null; /** * Tryies to connect to given host and port * using default proxy. If no default proxy speciefied * it throws SocksException with error code SOCKS_NO_PROXY. @param host Machine to connect to. @param port Port to which to connect. * @see SocksSocket#SocksSocket(Proxy,String,int) * @see Socks5Proxy#resolveAddrLocally */ public SocksSocket(String host,int port) throws SocksException,UnknownHostException{ this(Proxy.defaultProxy,host,port); } /** * Connects to host port using given proxy server. @param p Proxy to use. @param host Machine to connect to. @param port Port to which to connect. @throws UnknownHostException If one of the following happens: <ol> <li> Proxy settings say that address should be resolved locally, but this fails. <li> Proxy settings say that the host should be contacted directly but host name can't be resolved. </ol> @throws SocksException If one of the following happens: <ul> <li> Proxy is is null. <li> Proxy settings say that the host should be contacted directly but this fails. <li> Socks Server can't be contacted. <li> Authentication fails. <li> Connection is not allowed by the SOCKS proxy. <li> SOCKS proxy can't establish the connection. <li> Any IO error occured. <li> Any protocol error occured. </ul> @throws IOexception if anything is wrong with I/O. @see Socks5Proxy#resolveAddrLocally */ public SocksSocket(Proxy p, String host, int port) throws SocksException, UnknownHostException { remoteHost = host; remotePort = port; remoteIP = InetAddress.getByName(host); doDirect(); } /** Connects to given ip and port using given Proxy server. @param p Proxy to use. @param ip Machine to connect to. @param port Port to which to connect. */ public SocksSocket(InetAddress ip, int port) throws SocksException{ this.remoteIP = ip; this.remotePort = port; this.remoteHost = ip.getHostName(); doDirect(); } /** * These 2 constructors are used by the SocksServerSocket. * This socket simply overrides remoteHost, remotePort */ protected SocksSocket(String host,int port,Proxy proxy){ this.remotePort = port; this.proxy = proxy; this.localIP = proxy.proxySocket.getLocalAddress(); this.localPort = proxy.proxySocket.getLocalPort(); this.remoteHost = host; } protected SocksSocket(InetAddress ip,int port,Proxy proxy){ remoteIP = ip; remotePort = port; this.proxy = proxy; this.localIP = proxy.proxySocket.getLocalAddress(); this.localPort = proxy.proxySocket.getLocalPort(); remoteHost = remoteIP.getHostName(); } /** * Same as Socket */ public void close() throws IOException{ if(proxy!= null)proxy.endSession(); proxy = null; } /** * Same as Socket */ public InputStream getInputStream(){ return proxy.in; } /** * Same as Socket */ public OutputStream getOutputStream(){ return proxy.out; } /** * Same as Socket */ public int getPort(){ return remotePort; } /** * Returns remote host name, it is usefull in cases when addresses * are resolved by proxy, and we can't create InetAddress object. @return The name of the host this socket is connected to. */ public String getHost(){ return remoteHost; } /** * Get remote host as InetAddress object, might return null if * addresses are resolved by proxy, and it is not possible to resolve * it locally @return Ip address of the host this socket is connected to, or null if address was returned by the proxy as DOMAINNAME and can't be resolved locally. */ public InetAddress getInetAddress(){ if(remoteIP == null){ try{ remoteIP = InetAddress.getByName(remoteHost); }catch(UnknownHostException e){ return null; } } return remoteIP; } /** * Get the port assigned by the proxy for the socket, not * the port on locall machine as in Socket. @return Port of the socket used on the proxy server. */ public int getLocalPort(){ return localPort; } /** * Get address assigned by proxy to make a remote connection, * it might be different from the host specified for the proxy. * Can return null if socks server returned this address as hostname * and it can't be resolved locally, use getLocalHost() then. @return Address proxy is using to make a connection. */ public InetAddress getLocalAddress(){ if(localIP == null){ try{ localIP = InetAddress.getByName(localHost); }catch(UnknownHostException e){ return null; } } return localIP; } /** Get name of the host, proxy has assigned to make a remote connection for this socket. This method is usefull when proxy have returned address as hostname, and we can't resolve it on this machine. @return The name of the host proxy is using to make a connection. */ public String getLocalHost(){ return localHost; } /** Same as socket. */ public void setSoLinger(boolean on,int val) throws SocketException{ proxy.proxySocket.setSoLinger(on,val); } /** Same as socket. */ public int getSoLinger(int timeout) throws SocketException{ return proxy.proxySocket.getSoLinger(); } /** Same as socket. */ public void setSoTimeout(int timeout) throws SocketException{ proxy.proxySocket.setSoTimeout(timeout); } /** Same as socket. */ public int getSoTimeout(int timeout) throws SocketException{ return proxy.proxySocket.getSoTimeout(); } /** Same as socket. */ public void setTcpNoDelay(boolean on) throws SocketException{ proxy.proxySocket.setTcpNoDelay(on); } /** Same as socket. */ public boolean getTcpNoDelay() throws SocketException{ return proxy.proxySocket.getTcpNoDelay(); } /** Get string representation of the socket. */ public String toString(){ if(directSock!=null) return "Direct connection:"+directSock; return ("Proxy:"+proxy+";"+"addr:"+remoteHost+",port:"+remotePort +",localport:"+localPort); } //Private Methods ////////////////// private void doDirect()throws SocksException{ try{ //System.out.println("IP:"+remoteIP+":"+remotePort); directSock = new Socket(remoteIP,remotePort); proxy.out = directSock.getOutputStream(); proxy.in = directSock.getInputStream(); proxy.proxySocket = directSock; localIP = directSock.getLocalAddress(); localPort = directSock.getLocalPort(); }catch(IOException io_ex){ throw new SocksException(Proxy.SOCKS_DIRECT_FAILED, "Direct connect failed:"+io_ex); } } }
zzsuper001-linuxshell
src/net/sourceforge/jsocks/SocksSocket.java
Java
asf20
8,953
package net.sourceforge.jsocks; /** SOCKS5 none authentication. Dummy class does almost nothing. */ public class AuthenticationNone implements Authentication{ public Object[] doSocksAuthentication(int methodId, java.net.Socket proxySocket) throws java.io.IOException{ if(methodId!=0) return null; return new Object[] { proxySocket.getInputStream(), proxySocket.getOutputStream()}; } }
zzsuper001-linuxshell
src/net/sourceforge/jsocks/AuthenticationNone.java
Java
asf20
511
package net.sourceforge.jsocks; import net.sourceforge.jsocks.server.*; import java.net.*; import java.io.*; /** UDP Relay server, used by ProxyServer to perform udp forwarding. */ class UDPRelayServer implements Runnable{ DatagramSocket client_sock; DatagramSocket remote_sock; Socket controlConnection; int relayPort; InetAddress relayIP; Thread pipe_thread1,pipe_thread2; Thread master_thread; ServerAuthenticator auth; long lastReadTime; static PrintStream log = null; static Proxy proxy = null; static int datagramSize = 0xFFFF;//64K, a bit more than max udp size static int iddleTimeout = 180000;//3 minutes /** Constructs UDP relay server to communicate with client on given ip and port. @param clientIP Address of the client from whom datagrams will be recieved and to whom they will be forwarded. @param clientPort Clients port. @param master_thread Thread which will be interrupted, when UDP relay server stoppes for some reason. @param controlConnection Socket which will be closed, before interrupting the master thread, it is introduced due to a bug in windows JVM which does not throw InterruptedIOException in threads which block in I/O operation. */ public UDPRelayServer(InetAddress clientIP,int clientPort, Thread master_thread, Socket controlConnection, ServerAuthenticator auth) throws IOException{ this.master_thread = master_thread; this.controlConnection = controlConnection; this.auth = auth; client_sock = new Socks5DatagramSocket(true,auth.getUdpEncapsulation(), clientIP,clientPort); relayPort = client_sock.getLocalPort(); relayIP = client_sock.getLocalAddress(); if(relayIP.getHostAddress().equals("0.0.0.0")) relayIP = InetAddress.getLocalHost(); if(proxy == null) remote_sock = new DatagramSocket(); else remote_sock = new Socks5DatagramSocket(proxy,0,null); } //Public methods ///////////////// /** Sets the timeout for UDPRelay server.<br> Zero timeout implies infinity.<br> Default timeout is 3 minutes. */ static public void setTimeout(int timeout){ iddleTimeout = timeout; } /** Sets the size of the datagrams used in the UDPRelayServer.<br> Default size is 64K, a bit more than maximum possible size of the datagram. */ static public void setDatagramSize(int size){ datagramSize = size; } /** Port to which client should send datagram for association. */ public int getRelayPort(){ return relayPort; } /** IP address to which client should send datagrams for association. */ public InetAddress getRelayIP(){ return relayIP; } /** Starts udp relay server. Spawns two threads of execution and returns. */ public void start() throws IOException{ remote_sock.setSoTimeout(iddleTimeout); client_sock.setSoTimeout(iddleTimeout); log("Starting UDP relay server on "+relayIP+":"+relayPort); log("Remote socket "+remote_sock.getLocalAddress()+":"+ remote_sock.getLocalPort()); pipe_thread1 = new Thread(this,"pipe1"); pipe_thread2 = new Thread(this,"pipe2"); lastReadTime = System.currentTimeMillis(); pipe_thread1.start(); pipe_thread2.start(); } /** Stops Relay server. <p> Does not close control connection, does not interrupt master_thread. */ public synchronized void stop(){ master_thread = null; controlConnection = null; abort(); } //Runnable interface //////////////////// public void run(){ try{ if(Thread.currentThread().getName().equals("pipe1")) pipe(remote_sock,client_sock,false); else pipe(client_sock,remote_sock,true); }catch(IOException ioe){ }finally{ abort(); log("UDP Pipe thread "+Thread.currentThread().getName()+" stopped."); } } //Private methods ///////////////// private synchronized void abort(){ if(pipe_thread1 == null) return; log("Aborting UDP Relay Server"); remote_sock.close(); client_sock.close(); if(controlConnection != null) try{ controlConnection.close();} catch(IOException ioe){} if(master_thread!=null) master_thread.interrupt(); pipe_thread1.interrupt(); pipe_thread2.interrupt(); pipe_thread1 = null; } static private void log(String s){ if(log != null){ log.println(s); log.flush(); } } private void pipe(DatagramSocket from,DatagramSocket to,boolean out) throws IOException{ byte[] data = new byte[datagramSize]; DatagramPacket dp = new DatagramPacket(data,data.length); while(true){ try{ from.receive(dp); lastReadTime = System.currentTimeMillis(); if(auth.checkRequest(dp,out)) to.send(dp); }catch(UnknownHostException uhe){ log("Dropping datagram for unknown host"); }catch(InterruptedIOException iioe){ //log("Interrupted: "+iioe); //If we were interrupted by other thread. if(iddleTimeout == 0) return; //If last datagram was received, long time ago, return. long timeSinceRead = System.currentTimeMillis() - lastReadTime; if(timeSinceRead >= iddleTimeout -100) //-100 for adjustment return; } dp.setLength(data.length); } } }
zzsuper001-linuxshell
src/net/sourceforge/jsocks/UDPRelayServer.java
Java
asf20
6,128
package net.sourceforge.jsocks; import java.net.*; import java.io.*; /** Datagram socket to interract through the firewall.<BR> Can be used same way as the normal DatagramSocket. One should be carefull though with the datagram sizes used, as additional data is present in both incomming and outgoing datagrams. <p> SOCKS5 protocol allows to send host address as either: <ul> <li> IPV4, normal 4 byte address. (10 bytes header size) <li> IPV6, version 6 ip address (not supported by Java as for now). 22 bytes header size. <li> Host name,(7+length of the host name bytes header size). </ul> As with other Socks equivalents, direct addresses are handled transparently, that is data will be send directly when required by the proxy settings. <p> <b>NOTE:</b><br> Unlike other SOCKS Sockets, it <b>does not</b> support proxy chaining, and will throw an exception if proxy has a chain proxy attached. The reason for that is not my laziness, but rather the restrictions of the SOCKSv5 protocol. Basicaly SOCKSv5 proxy server, needs to know from which host:port datagrams will be send for association, and returns address to which datagrams should be send by the client, but it does not inform client from which host:port it is going to send datagrams, in fact there is even no guarantee they will be send at all and from the same address each time. */ public class Socks5DatagramSocket extends DatagramSocket{ InetAddress relayIP; int relayPort; Socks5Proxy proxy; private boolean server_mode = false; UDPEncapsulation encapsulation; /** Construct Datagram socket for communication over SOCKS5 proxy server. This constructor uses default proxy, the one set with Proxy.setDefaultProxy() method. If default proxy is not set or it is set to version4 proxy, which does not support datagram forwarding, throws SocksException. */ public Socks5DatagramSocket() throws SocksException, IOException{ this(Proxy.defaultProxy,0,null); } /** Construct Datagram socket for communication over SOCKS5 proxy server. And binds it to the specified local port. This constructor uses default proxy, the one set with Proxy.setDefaultProxy() method. If default proxy is not set or it is set to version4 proxy, which does not support datagram forwarding, throws SocksException. */ public Socks5DatagramSocket(int port) throws SocksException, IOException{ this(Proxy.defaultProxy,port,null); } /** Construct Datagram socket for communication over SOCKS5 proxy server. And binds it to the specified local port and address. This constructor uses default proxy, the one set with Proxy.setDefaultProxy() method. If default proxy is not set or it is set to version4 proxy, which does not support datagram forwarding, throws SocksException. */ public Socks5DatagramSocket(int port,InetAddress ip) throws SocksException, IOException{ this(Proxy.defaultProxy,port,ip); } /** Constructs datagram socket for communication over specified proxy. And binds it to the given local address and port. Address of null and port of 0, signify any availabale port/address. Might throw SocksException, if: <ol> <li> Given version of proxy does not support UDP_ASSOCIATE. <li> Proxy can't be reached. <li> Authorization fails. <li> Proxy does not want to perform udp forwarding, for any reason. </ol> Might throw IOException if binding dtagram socket to given address/port fails. See java.net.DatagramSocket for more details. */ public Socks5DatagramSocket(Proxy p,int port,InetAddress ip) throws SocksException, IOException{ super(port,ip); if(p == null) throw new SocksException(Proxy.SOCKS_NO_PROXY); if(!(p instanceof Socks5Proxy)) throw new SocksException(-1,"Datagram Socket needs Proxy version 5"); if(p.chainProxy != null) throw new SocksException(Proxy.SOCKS_JUST_ERROR, "Datagram Sockets do not support proxy chaining."); proxy =(Socks5Proxy) p.copy(); ProxyMessage msg = proxy.udpAssociate(super.getLocalAddress(), super.getLocalPort()); relayIP = msg.ip; if(relayIP.getHostAddress().equals("0.0.0.0")) relayIP = proxy.proxyIP; relayPort = msg.port; encapsulation = proxy.udp_encapsulation; //debug("Datagram Socket:"+getLocalAddress()+":"+getLocalPort()+"\n"); //debug("Socks5Datagram: "+relayIP+":"+relayPort+"\n"); } /** Used by UDPRelayServer. */ Socks5DatagramSocket(boolean server_mode,UDPEncapsulation encapsulation, InetAddress relayIP,int relayPort) throws IOException{ super(); this.server_mode = server_mode; this.relayIP = relayIP; this.relayPort = relayPort; this.encapsulation = encapsulation; this.proxy = null; } /** Sends the Datagram either through the proxy or directly depending on current proxy settings and destination address. <BR> <B> NOTE: </B> DatagramPacket size should be at least 10 bytes less than the systems limit. <P> See documentation on java.net.DatagramSocket for full details on how to use this method. @param dp Datagram to send. @throws IOException If error happens with I/O. */ public void send(DatagramPacket dp) throws IOException{ //If the host should be accessed directly, send it as is. if(!server_mode){ super.send(dp); //debug("Sending directly:"); return; } byte[] head = formHeader(dp.getAddress(),dp.getPort()); byte[] buf = new byte[head.length + dp.getLength()]; byte[] data = dp.getData(); //Merge head and data System.arraycopy(head,0,buf,0,head.length); //System.arraycopy(data,dp.getOffset(),buf,head.length,dp.getLength()); System.arraycopy(data,0,buf,head.length,dp.getLength()); if(encapsulation != null) buf = encapsulation.udpEncapsulate(buf,true); super.send(new DatagramPacket(buf,buf.length,relayIP,relayPort)); } /** This method allows to send datagram packets with address type DOMAINNAME. SOCKS5 allows to specify host as names rather than ip addresses.Using this method one can send udp datagrams through the proxy, without having to know the ip address of the destination host. <p> If proxy specified for that socket has an option resolveAddrLocally set to true host will be resolved, and the datagram will be send with address type IPV4, if resolve fails, UnknownHostException is thrown. @param dp Datagram to send, it should contain valid port and data @param host Host name to which datagram should be send. @throws IOException If error happens with I/O, or the host can't be resolved when proxy settings say that hosts should be resolved locally. @see Socks5Proxy#resolveAddrLocally(boolean) */ public void send(DatagramPacket dp, String host) throws IOException { dp.setAddress(InetAddress.getByName(host)); super.send(dp); } /** * Receives udp packet. If packet have arrived from the proxy relay server, * it is processed and address and port of the packet are set to the * address and port of sending host.<BR> * If the packet arrived from anywhere else it is not changed.<br> * <B> NOTE: </B> DatagramPacket size should be at least 10 bytes bigger * than the largest packet you expect (this is for IPV4 addresses). * For hostnames and IPV6 it is even more. @param dp Datagram in which all relevent information will be copied. */ public void receive(DatagramPacket dp) throws IOException{ super.receive(dp); if(server_mode){ //Drop all datagrams not from relayIP/relayPort int init_length = dp.getLength(); int initTimeout = getSoTimeout(); long startTime = System.currentTimeMillis(); while(!relayIP.equals(dp.getAddress()) || relayPort != dp.getPort()){ //Restore datagram size dp.setLength(init_length); //If there is a non-infinit timeout on this socket //Make sure that it happens no matter how often unexpected //packets arrive. if(initTimeout != 0){ int newTimeout = initTimeout - (int)(System.currentTimeMillis() - startTime); if(newTimeout <= 0) throw new InterruptedIOException( "In Socks5DatagramSocket->receive()"); setSoTimeout(newTimeout); } super.receive(dp); } //Restore timeout settings if(initTimeout != 0) setSoTimeout(initTimeout); }else if(!relayIP.equals(dp.getAddress()) || relayPort != dp.getPort()) return; // Recieved direct packet //If the datagram is not from the relay server, return it it as is. byte[] data; data = dp.getData(); if(encapsulation != null) data = encapsulation.udpEncapsulate(data,false); int offset = 0; //Java 1.1 //int offset = dp.getOffset(); //Java 1.2 ByteArrayInputStream bIn = new ByteArrayInputStream(data,offset, dp.getLength()); ProxyMessage msg = new Socks5Message(bIn); dp.setPort(msg.port); dp.setAddress(msg.getInetAddress()); //what wasn't read by the Message is the data int data_length = bIn.available(); //Shift data to the left System.arraycopy(data,offset+dp.getLength()-data_length, data,offset,data_length); dp.setLength(data_length); } /** * Returns port assigned by the proxy, to which datagrams are relayed. * It is not the same port to which other party should send datagrams. @return Port assigned by socks server to which datagrams are send for association. */ public int getLocalPort(){ if(server_mode) return super.getLocalPort(); return relayPort; } /** * Address assigned by the proxy, to which datagrams are send for relay. * It is not necesseraly the same address, to which other party should send * datagrams. @return Address to which datagrams are send for association. */ public InetAddress getLocalAddress(){ if(server_mode) return super.getLocalAddress(); return relayIP; } /** * Closes datagram socket, and proxy connection. */ public void close(){ if(!server_mode) proxy.endSession(); super.close(); } /** This method checks wether proxy still runs udp forwarding service for this socket. <p> This methods checks wether the primary connection to proxy server is active. If it is, chances are that proxy continues to forward datagrams being send from this socket. If it was closed, most likely datagrams are no longer being forwarded by the server. <p> Proxy might decide to stop forwarding datagrams, in which case it should close primary connection. This method allows to check, wether this have been done. <p> You can specify timeout for which we should be checking EOF condition on the primary connection. Timeout is in milliseconds. Specifying 0 as timeout implies infinity, in which case method will block, until connection to proxy is closed or an error happens, and then return false. <p> One possible scenario is to call isProxyactive(0) in separate thread, and once it returned notify other threads about this event. @param timeout For how long this method should block, before returning. @return true if connection to proxy is active, false if eof or error condition have been encountered on the connection. */ public boolean isProxyAlive(int timeout){ if(server_mode) return false; if(proxy != null){ try{ proxy.proxySocket.setSoTimeout(timeout); int eof = proxy.in.read(); if(eof < 0) return false; // EOF encountered. else return true; // This really should not happen }catch(InterruptedIOException iioe){ return true; // read timed out. }catch(IOException ioe){ return false; } } return false; } //PRIVATE METHODS ////////////////// private byte[] formHeader(InetAddress ip, int port){ Socks5Message request = new Socks5Message(0,ip,port); request.data[0] = 0; return request.data; } /*====================================================================== //Mainly Test functions ////////////////////// private String bytes2String(byte[] b){ String s=""; char[] hex_digit = { '0','1','2','3','4','5','6','7','8','9', 'A','B','C','D','E','F'}; for(int i=0;i<b.length;++i){ int i1 = (b[i] & 0xF0) >> 4; int i2 = b[i] & 0xF; s+=hex_digit[i1]; s+=hex_digit[i2]; s+=" "; } return s; } private static final void debug(String s){ if(DEBUG) System.out.print(s); } private static final boolean DEBUG = true; public static void usage(){ System.err.print( "Usage: java Socks.SocksDatagramSocket host port [socksHost socksPort]\n"); } static final int defaultProxyPort = 1080; //Default Port static final String defaultProxyHost = "www-proxy"; //Default proxy public static void main(String args[]){ int port; String host; int proxyPort; String proxyHost; InetAddress ip; if(args.length > 1 && args.length < 5){ try{ host = args[0]; port = Integer.parseInt(args[1]); proxyPort =(args.length > 3)? Integer.parseInt(args[3]) : defaultProxyPort; host = args[0]; ip = InetAddress.getByName(host); proxyHost =(args.length > 2)? args[2] : defaultProxyHost; Proxy.setDefaultProxy(proxyHost,proxyPort); Proxy p = Proxy.getDefaultProxy(); p.addDirect("lux"); DatagramSocket ds = new Socks5DatagramSocket(); BufferedReader in = new BufferedReader( new InputStreamReader(System.in)); String s; System.out.print("Enter line:"); s = in.readLine(); while(s != null){ byte[] data = (s+"\r\n").getBytes(); DatagramPacket dp = new DatagramPacket(data,0,data.length, ip,port); System.out.println("Sending to: "+ip+":"+port); ds.send(dp); dp = new DatagramPacket(new byte[1024],1024); System.out.println("Trying to recieve on port:"+ ds.getLocalPort()); ds.receive(dp); System.out.print("Recieved:\n"+ "From:"+dp.getAddress()+":"+dp.getPort()+ "\n\n"+ new String(dp.getData(),dp.getOffset(),dp.getLength())+"\n" ); System.out.print("Enter line:"); s = in.readLine(); } ds.close(); System.exit(1); }catch(SocksException s_ex){ System.err.println("SocksException:"+s_ex); s_ex.printStackTrace(); System.exit(1); }catch(IOException io_ex){ io_ex.printStackTrace(); System.exit(1); }catch(NumberFormatException num_ex){ usage(); num_ex.printStackTrace(); System.exit(1); } }else{ usage(); } } */ }
zzsuper001-linuxshell
src/net/sourceforge/jsocks/Socks5DatagramSocket.java
Java
asf20
16,661
package net.sourceforge.jsocks; /** The Authentication interface provides for performing method specific authentication for SOCKS5 connections. */ public interface Authentication{ /** This method is called when SOCKS5 server have selected a particular authentication method, for whch an implementaion have been registered. <p> This method should return an array {inputstream,outputstream [,UDPEncapsulation]}. The reason for that is that SOCKS5 protocol allows to have method specific encapsulation of data on the socket for purposes of integrity or security. And this encapsulation should be performed by those streams returned from the method. It is also possible to encapsulate datagrams. If authentication method supports such encapsulation an instance of the UDPEncapsulation interface should be returned as third element of the array, otherwise either null should be returned as third element, or array should contain only 2 elements. @param methodId Authentication method selected by the server. @param proxySocket Socket used to conect to the proxy. @return Two or three element array containing Input/Output streams which should be used on this connection. Third argument is optional and should contain an instance of UDPEncapsulation. It should be provided if the authentication method used requires any encapsulation to be done on the datagrams. */ Object[] doSocksAuthentication(int methodId,java.net.Socket proxySocket) throws java.io.IOException; }
zzsuper001-linuxshell
src/net/sourceforge/jsocks/Authentication.java
Java
asf20
1,667
package net.sourceforge.jsocks; /** Exception thrown by various socks classes to indicate errors with protocol or unsuccessful server responses. */ public class SocksException extends java.io.IOException{ private static final long serialVersionUID = 6141184566248512277L; /** Construct a SocksException with given error code. <p> Tries to look up message which corresponds to this error code. @param errCode Error code for this exception. */ public SocksException(int errCode){ this.errCode = errCode; if((errCode >> 16) == 0){ //Server reply error message errString = errCode <= serverReplyMessage.length ? serverReplyMessage[errCode] : UNASSIGNED_ERROR_MESSAGE; }else{ //Local error errCode = (errCode >> 16) -1; errString = errCode <= localErrorMessage.length ? localErrorMessage[errCode] : UNASSIGNED_ERROR_MESSAGE; } } /** Constructs a SocksException with given error code and message. @param errCode Error code. @param errString Error Message. */ public SocksException(int errCode,String errString){ this.errCode = errCode; this.errString = errString; } /** Get the error code associated with this exception. @return Error code associated with this exception. */ public int getErrorCode(){ return errCode; } /** Get human readable representation of this exception. @return String represntation of this exception. */ public String toString(){ return errString; } static final String UNASSIGNED_ERROR_MESSAGE = "Unknown error message"; static final String serverReplyMessage[] = { "Succeeded", "General SOCKS server failure", "Connection not allowed by ruleset", "Network unreachable", "Host unreachable", "Connection refused", "TTL expired", "Command not supported", "Address type not supported" }; static final String localErrorMessage[] ={ "SOCKS server not specified", "Unable to contact SOCKS server", "IO error", "None of Authentication methods are supported", "Authentication failed", "General SOCKS fault" }; String errString; public int errCode; }//End of SocksException class
zzsuper001-linuxshell
src/net/sourceforge/jsocks/SocksException.java
Java
asf20
2,670
package net.sourceforge.jsocks; import java.io.EOFException; import java.io.IOException; import java.io.InputStream; import java.io.InterruptedIOException; import java.io.OutputStream; import java.io.PrintStream; import java.io.PushbackInputStream; import java.net.ConnectException; import java.net.InetAddress; import java.net.NoRouteToHostException; import java.net.ServerSocket; import java.net.Socket; import net.sourceforge.jsocks.server.ServerAuthenticator; /** SOCKS4 and SOCKS5 proxy, handles both protocols simultaniously. Implements all SOCKS commands, including UDP relaying. <p> In order to use it you will need to implement ServerAuthenticator interface. There is an implementation of this interface which does no authentication ServerAuthenticatorNone, but it is very dangerous to use, as it will give access to your local network to anybody in the world. One should never use this authentication scheme unless one have pretty good reason to do so. There is a couple of other authentication schemes in socks.server package. @see socks.server.ServerAuthenticator */ public class ProxyServer implements Runnable{ ServerAuthenticator auth; ProxyMessage msg = null; Socket sock=null,remote_sock=null; ServerSocket ss=null; UDPRelayServer relayServer = null; InputStream in,remote_in; OutputStream out,remote_out; int mode; static final int START_MODE = 0; static final int ACCEPT_MODE = 1; static final int PIPE_MODE = 2; static final int ABORT_MODE = 3; static final int BUF_SIZE = 8192; Thread pipe_thread1,pipe_thread2; long lastReadTime; protected static int iddleTimeout = 180000; //3 minutes static int acceptTimeout = 180000; //3 minutes static PrintStream log = null; static Proxy proxy; //Public Constructors ///////////////////// /** Creates a proxy server with given Authentication scheme. @param auth Authentication scheme to be used. */ public ProxyServer(ServerAuthenticator auth){ this.auth = auth; } //Other constructors //////////////////// protected ProxyServer(ServerAuthenticator auth,Socket s){ this.auth = auth; this.sock = s; mode = START_MODE; } //Public methods ///////////////// /** Set the logging stream. Specifying null disables logging. */ public static void setLog(OutputStream out){ if(out == null){ log = null; }else{ log = new PrintStream(out,true); } UDPRelayServer.log = log; } /** Set proxy. <p> Allows Proxy chaining so that one Proxy server is connected to another and so on. If proxy supports SOCKSv4, then only some SOCKSv5 requests can be handled, UDP would not work, however CONNECT and BIND will be translated. @param p Proxy which should be used to handle user requests. */ public static void setProxy(Proxy p){ proxy =p; UDPRelayServer.proxy = proxy; } /** Get proxy. @return Proxy wich is used to handle user requests. */ public static Proxy getProxy(){ return proxy; } /** Sets the timeout for connections, how long shoud server wait for data to arrive before dropping the connection.<br> Zero timeout implies infinity.<br> Default timeout is 3 minutes. */ public static void setIddleTimeout(int timeout){ iddleTimeout = timeout; } /** Sets the timeout for BIND command, how long the server should wait for the incoming connection.<br> Zero timeout implies infinity.<br> Default timeout is 3 minutes. */ public static void setAcceptTimeout(int timeout){ acceptTimeout = timeout; } /** Sets the timeout for UDPRelay server.<br> Zero timeout implies infinity.<br> Default timeout is 3 minutes. */ public static void setUDPTimeout(int timeout){ UDPRelayServer.setTimeout(timeout); } /** Sets the size of the datagrams used in the UDPRelayServer.<br> Default size is 64K, a bit more than maximum possible size of the datagram. */ public static void setDatagramSize(int size){ UDPRelayServer.setDatagramSize(size); } /** Start the Proxy server at given port.<br> This methods blocks. */ public void start(int port){ start(port,5,null); } /** Create a server with the specified port, listen backlog, and local IP address to bind to. The localIP argument can be used on a multi-homed host for a ServerSocket that will only accept connect requests to one of its addresses. If localIP is null, it will default accepting connections on any/all local addresses. The port must be between 0 and 65535, inclusive. <br> This methods blocks. */ public void start(int port,int backlog,InetAddress localIP){ try{ ss = new ServerSocket(port,backlog,localIP); log("Starting SOCKS Proxy on:"+ss.getInetAddress().getHostAddress()+":" +ss.getLocalPort()); while(true){ Socket s = ss.accept(); log("Accepted from:"+s.getInetAddress().getHostName()+":" +s.getPort()); ProxyServer ps = new ProxyServer(auth,s); (new Thread(ps)).start(); } }catch(IOException ioe){ ioe.printStackTrace(); }finally{ } } /** Stop server operation.It would be wise to interrupt thread running the server afterwards. */ public void stop(){ try{ if(ss != null) ss.close(); }catch(IOException ioe){ } } //Runnable interface //////////////////// public void run(){ switch(mode){ case START_MODE: try{ startSession(); }catch(IOException ioe){ handleException(ioe); //ioe.printStackTrace(); }finally{ abort(); if(auth!=null) auth.endSession(); log("Main thread(client->remote)stopped."); } break; case ACCEPT_MODE: try{ doAccept(); mode = PIPE_MODE; pipe_thread1.interrupt(); //Tell other thread that connection have //been accepted. pipe(remote_in,out); }catch(IOException ioe){ //log("Accept exception:"+ioe); handleException(ioe); }finally{ abort(); log("Accept thread(remote->client) stopped"); } break; case PIPE_MODE: try{ pipe(remote_in,out); }catch(IOException ioe){ }finally{ abort(); log("Support thread(remote->client) stopped"); } break; case ABORT_MODE: break; default: log("Unexpected MODE "+mode); } } //Private methods ///////////////// private void startSession() throws IOException{ sock.setSoTimeout(iddleTimeout); try{ auth = auth.startSession(sock); }catch(IOException ioe){ log("Auth throwed exception:"+ioe); auth = null; return; } if(auth == null){ //Authentication failed log("Authentication failed"); return; } in = auth.getInputStream(); out = auth.getOutputStream(); msg = readMsg(in); handleRequest(msg); } protected void handleRequest(ProxyMessage msg) throws IOException{ if(!auth.checkRequest(msg)) throw new SocksException(Proxy.SOCKS_FAILURE); if(msg.ip == null){ if(msg instanceof Socks5Message){ msg.ip = InetAddress.getByName(msg.host); }else throw new SocksException(Proxy.SOCKS_FAILURE); } log(msg); switch(msg.command){ case Proxy.SOCKS_CMD_CONNECT: onConnect(msg); break; case Proxy.SOCKS_CMD_BIND: onBind(msg); break; case Proxy.SOCKS_CMD_UDP_ASSOCIATE: onUDP(msg); break; default: throw new SocksException(Proxy.SOCKS_CMD_NOT_SUPPORTED); } } private void handleException(IOException ioe){ //If we couldn't read the request, return; if(msg == null) return; //If have been aborted by other thread if(mode == ABORT_MODE) return; //If the request was successfully completed, but exception happened later if(mode == PIPE_MODE) return; int error_code = Proxy.SOCKS_FAILURE; if(ioe instanceof SocksException) error_code = ((SocksException)ioe).errCode; else if(ioe instanceof NoRouteToHostException) error_code = Proxy.SOCKS_HOST_UNREACHABLE; else if(ioe instanceof ConnectException) error_code = Proxy.SOCKS_CONNECTION_REFUSED; else if(ioe instanceof InterruptedIOException) error_code = Proxy.SOCKS_TTL_EXPIRE; if(error_code > Proxy.SOCKS_ADDR_NOT_SUPPORTED || error_code < 0){ error_code = Proxy.SOCKS_FAILURE; } sendErrorMessage(error_code); } private void onConnect(ProxyMessage msg) throws IOException{ Socket s; ProxyMessage response = null; s = new Socket(msg.ip,msg.port); log("Connected to "+s.getInetAddress()+":"+s.getPort()); if(msg instanceof Socks5Message){ response = new Socks5Message(Proxy.SOCKS_SUCCESS, s.getLocalAddress(), s.getLocalPort()); }else{ response = new Socks4Message(Socks4Message.REPLY_OK, s.getLocalAddress(),s.getLocalPort()); } response.write(out); startPipe(s); } private void onBind(ProxyMessage msg) throws IOException{ ProxyMessage response = null; if(proxy == null) ss = new ServerSocket(0); else ss = new SocksServerSocket(proxy, msg.ip, msg.port); ss.setSoTimeout(acceptTimeout); log("Trying accept on "+ss.getInetAddress()+":"+ss.getLocalPort()); if(msg.version == 5) response = new Socks5Message(Proxy.SOCKS_SUCCESS,ss.getInetAddress(), ss.getLocalPort()); else response = new Socks4Message(Socks4Message.REPLY_OK, ss.getInetAddress(), ss.getLocalPort()); response.write(out); mode = ACCEPT_MODE; pipe_thread1 = Thread.currentThread(); pipe_thread2 = new Thread(this); pipe_thread2.start(); //Make timeout infinit. sock.setSoTimeout(0); int eof=0; try{ while((eof=in.read())>=0){ if(mode != ACCEPT_MODE){ if(mode != PIPE_MODE) return;//Accept failed remote_out.write(eof); break; } } }catch(EOFException eofe){ //System.out.println("EOF exception"); return;//Connection closed while we were trying to accept. }catch(InterruptedIOException iioe){ //Accept thread interrupted us. //System.out.println("Interrupted"); if(mode != PIPE_MODE) return;//If accept thread was not successfull return. }finally{ //System.out.println("Finnaly!"); } if(eof < 0)//Connection closed while we were trying to accept; return; //Do not restore timeout, instead timeout is set on the //remote socket. It does not make any difference. pipe(in,remote_out); } private void onUDP(ProxyMessage msg) throws IOException{ if(msg.ip.getHostAddress().equals("0.0.0.0")) msg.ip = sock.getInetAddress(); log("Creating UDP relay server for "+msg.ip+":"+msg.port); relayServer = new UDPRelayServer(msg.ip,msg.port, Thread.currentThread(),sock,auth); ProxyMessage response; response = new Socks5Message(Proxy.SOCKS_SUCCESS, relayServer.relayIP,relayServer.relayPort); response.write(out); relayServer.start(); //Make timeout infinit. sock.setSoTimeout(0); try{ while(in.read()>=0) /*do nothing*/; }catch(EOFException eofe){ } } //Private methods ////////////////// private void doAccept() throws IOException{ Socket s; long startTime = System.currentTimeMillis(); while(true){ s = ss.accept(); if(s.getInetAddress().equals(msg.ip)){ //got the connection from the right host //Close listenning socket. ss.close(); break; }else if(ss instanceof SocksServerSocket){ //We can't accept more then one connection s.close(); ss.close(); throw new SocksException(Proxy.SOCKS_FAILURE); }else{ if(acceptTimeout!=0){ //If timeout is not infinit int newTimeout = acceptTimeout-(int)(System.currentTimeMillis()- startTime); if(newTimeout <= 0) throw new InterruptedIOException( "In doAccept()"); ss.setSoTimeout(newTimeout); } s.close(); //Drop all connections from other hosts } } //Accepted connection remote_sock = s; remote_in = s.getInputStream(); remote_out = s.getOutputStream(); //Set timeout remote_sock.setSoTimeout(iddleTimeout); log("Accepted from "+s.getInetAddress()+":"+s.getPort()); ProxyMessage response; if(msg.version == 5) response = new Socks5Message(Proxy.SOCKS_SUCCESS, s.getInetAddress(), s.getPort()); else response = new Socks4Message(Socks4Message.REPLY_OK, s.getInetAddress(), s.getPort()); response.write(out); } protected ProxyMessage readMsg(InputStream in) throws IOException{ PushbackInputStream push_in; if(in instanceof PushbackInputStream) push_in = (PushbackInputStream) in; else push_in = new PushbackInputStream(in); int version = push_in.read(); push_in.unread(version); ProxyMessage msg; if(version == 5){ msg = new Socks5Message(push_in,false); }else if(version == 4){ msg = new Socks4Message(push_in,false); }else{ throw new SocksException(Proxy.SOCKS_FAILURE); } return msg; } private void startPipe(Socket s){ mode = PIPE_MODE; remote_sock = s; try{ remote_in = s.getInputStream(); remote_out = s.getOutputStream(); pipe_thread1 = Thread.currentThread(); pipe_thread2 = new Thread(this); pipe_thread2.start(); pipe(in,remote_out); }catch(IOException ioe){ } } private void sendErrorMessage(int error_code){ ProxyMessage err_msg; if(msg instanceof Socks4Message) err_msg = new Socks4Message(Socks4Message.REPLY_REJECTED); else err_msg = new Socks5Message(error_code); try{ err_msg.write(out); }catch(IOException ioe){} } private synchronized void abort(){ if(mode == ABORT_MODE) return; mode = ABORT_MODE; try{ log("Aborting operation"); if(remote_sock != null) remote_sock.close(); if(sock != null) sock.close(); if(relayServer!=null) relayServer.stop(); if(ss!=null) ss.close(); if(pipe_thread1 != null) pipe_thread1.interrupt(); if(pipe_thread2 != null) pipe_thread2.interrupt(); }catch(IOException ioe){} } static final void log(String s){ if(log != null){ log.println(s); log.flush(); } } static final void log(ProxyMessage msg){ log("Request version:"+msg.version+ "\tCommand: "+command2String(msg.command)); log("IP:"+msg.ip +"\tPort:"+msg.port+ (msg.version==4?"\tUser:"+msg.user:"")); } private void pipe(InputStream in,OutputStream out) throws IOException{ lastReadTime = System.currentTimeMillis(); byte[] buf = new byte[BUF_SIZE]; int len = 0; while(len >= 0){ try{ if(len!=0){ out.write(buf,0,len); out.flush(); } len= in.read(buf); lastReadTime = System.currentTimeMillis(); }catch(InterruptedIOException iioe){ if(iddleTimeout == 0) return;//Other thread interrupted us. long timeSinceRead = System.currentTimeMillis() - lastReadTime; if(timeSinceRead >= iddleTimeout - 1000) //-1s for adjustment. return; len = 0; } } } static final String command_names[] = {"CONNECT","BIND","UDP_ASSOCIATE"}; static final String command2String(int cmd){ if(cmd > 0 && cmd < 4) return command_names[cmd-1]; else return "Unknown Command "+cmd; } }
zzsuper001-linuxshell
src/net/sourceforge/jsocks/ProxyServer.java
Java
asf20
17,822
package net.sourceforge.jsocks; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.InetAddress; import java.net.Socket; import java.net.SocketException; import java.net.UnknownHostException; import java.util.Enumeration; import java.util.Hashtable; /** SOCKS5 Proxy. */ public class Socks5Proxy extends Proxy implements Cloneable{ //Data members private Hashtable<Integer, Authentication> authMethods = new Hashtable<Integer, Authentication>(); private int selectedMethod; boolean resolveAddrLocally = true; UDPEncapsulation udp_encapsulation=null; //Public Constructors //==================== /** Creates SOCKS5 proxy. @param proxyHost Host on which a Proxy server runs. @param proxyPort Port on which a Proxy server listens for connections. @throws UnknownHostException If proxyHost can't be resolved. */ public Socks5Proxy(String proxyHost,int proxyPort) throws UnknownHostException{ super(proxyHost,proxyPort); version = 5; setAuthenticationMethod(0,new AuthenticationNone()); } /** Creates SOCKS5 proxy. @param proxyIP Host on which a Proxy server runs. @param proxyPort Port on which a Proxy server listens for connections. */ public Socks5Proxy(InetAddress proxyIP,int proxyPort){ super(proxyIP,proxyPort); version = 5; setAuthenticationMethod(0,new AuthenticationNone()); } //Public instance methods //======================== /** * Wether to resolve address locally or to let proxy do so. <p> SOCKS5 protocol allows to send host names rather then IPs in the requests, this option controls wether the hostnames should be send to the proxy server as names, or should they be resolved locally. @param doResolve Wether to perform resolution locally. @return Previous settings. */ public boolean resolveAddrLocally(boolean doResolve){ boolean old = resolveAddrLocally; resolveAddrLocally = doResolve; return old; } /** Get current setting on how the addresses should be handled. @return Current setting for address resolution. @see Socks5Proxy#resolveAddrLocally(boolean doResolve) */ public boolean resolveAddrLocally(){ return resolveAddrLocally; } /** Adds another authentication method. @param methodId Authentication method id, see rfc1928 @param method Implementation of Authentication @see Authentication */ public boolean setAuthenticationMethod(int methodId, Authentication method){ if(methodId<0 || methodId > 255) return false; if(method == null){ //Want to remove a particular method return (authMethods.remove(new Integer(methodId)) != null); }else{//Add the method, or rewrite old one authMethods.put(new Integer(methodId),method); } return true; } /** Get authentication method, which corresponds to given method id @param methodId Authentication method id. @return Implementation for given method or null, if one was not set. */ public Authentication getAuthenticationMethod(int methodId){ Object method = authMethods.get(new Integer(methodId)); if(method == null) return null; return (Authentication)method; } /** Creates a clone of this Proxy. */ @SuppressWarnings("unchecked") public Object clone(){ Socks5Proxy newProxy = new Socks5Proxy(proxyIP,proxyPort); newProxy.authMethods = (Hashtable<Integer, Authentication>) this.authMethods.clone(); newProxy.resolveAddrLocally = resolveAddrLocally; newProxy.chainProxy = chainProxy; return newProxy; } //Public Static(Class) Methods //============================== //Protected Methods //================= protected Proxy copy(){ Socks5Proxy copy = new Socks5Proxy(proxyIP,proxyPort); copy.authMethods = this.authMethods; //same Hash, no copy copy.chainProxy = this.chainProxy; copy.resolveAddrLocally = this.resolveAddrLocally; return copy; } /** * * */ protected void startSession()throws SocksException{ super.startSession(); Authentication auth; Socket ps = proxySocket; //The name is too long try{ byte nMethods = (byte) authMethods.size(); //Number of methods byte[] buf = new byte[2+nMethods]; //2 is for VER,NMETHODS buf[0] = (byte) version; buf[1] = nMethods; //Number of methods int i=2; Enumeration<Integer> ids = authMethods.keys(); while(ids.hasMoreElements()) buf[i++] = (byte)((Integer)ids.nextElement()).intValue(); out.write(buf); out.flush(); int versionNumber = in.read(); selectedMethod = in.read(); if(versionNumber < 0 || selectedMethod < 0){ //EOF condition was reached endSession(); throw(new SocksException(SOCKS_PROXY_IO_ERROR, "Connection to proxy lost.")); } if(versionNumber < version){ //What should we do?? } if(selectedMethod == 0xFF){ //No method selected ps.close(); throw ( new SocksException(SOCKS_AUTH_NOT_SUPPORTED)); } auth = getAuthenticationMethod(selectedMethod); if(auth == null){ //This shouldn't happen, unless method was removed by other //thread, or the server stuffed up throw(new SocksException(SOCKS_JUST_ERROR, "Speciefied Authentication not found!")); } Object[] in_out = auth.doSocksAuthentication(selectedMethod,ps); if(in_out == null){ //Authentication failed by some reason throw(new SocksException(SOCKS_AUTH_FAILURE)); } //Most authentication methods are expected to return //simply the input/output streams associated with //the socket. However if the auth. method requires //some kind of encryption/decryption being done on the //connection it should provide classes to handle I/O. in = (InputStream) in_out[0]; out = (OutputStream) in_out[1]; if(in_out.length > 2) udp_encapsulation = (UDPEncapsulation) in_out[2]; }catch(SocksException s_ex){ throw s_ex; }catch(UnknownHostException uh_ex){ throw(new SocksException(SOCKS_PROXY_NO_CONNECT)); }catch(SocketException so_ex){ throw(new SocksException(SOCKS_PROXY_NO_CONNECT)); }catch(IOException io_ex){ //System.err.println(io_ex); throw(new SocksException(SOCKS_PROXY_IO_ERROR,""+io_ex)); } } protected ProxyMessage formMessage(int cmd,InetAddress ip,int port){ return new Socks5Message(cmd,ip,port); } protected ProxyMessage formMessage(int cmd,String host,int port) throws UnknownHostException{ if(resolveAddrLocally) return formMessage(cmd,InetAddress.getByName(host),port); else return new Socks5Message(cmd,host,port); } protected ProxyMessage formMessage(InputStream in) throws SocksException, IOException{ return new Socks5Message(in); } }
zzsuper001-linuxshell
src/net/sourceforge/jsocks/Socks5Proxy.java
Java
asf20
7,632
/** * Originally from http://www.cornetdesign.com/files/BeanTestCase.java.txt */ package org.connectbot.mock; import junit.framework.TestCase; import java.lang.reflect.Field; public class BeanTestCase extends TestCase { private static final String TEST_STRING_VAL1 = "Some Value"; private static final String TEST_STRING_VAL2 = "Some Other Value"; public static void assertMeetsEqualsContract(Class<?> classUnderTest, String[] fieldNames) { Object o1; Object o2; try { // Get Instances o1 = classUnderTest.newInstance(); o2 = classUnderTest.newInstance(); assertTrue( "Instances with default constructor not equal (o1.equals(o2))", o1.equals(o2)); assertTrue( "Instances with default constructor not equal (o2.equals(o1))", o2.equals(o1)); Field[] fields = getFieldsByNameOrAll(classUnderTest, fieldNames); for (int i = 0; i < fields.length; i++) { // Reset the instances o1 = classUnderTest.newInstance(); o2 = classUnderTest.newInstance(); Field field = fields[i]; field.setAccessible(true); if (field.getType() == String.class) { field.set(o1, TEST_STRING_VAL1); } else if (field.getType() == boolean.class) { field.setBoolean(o1, true); } else if (field.getType() == short.class) { field.setShort(o1, (short) 1); } else if (field.getType() == long.class) { field.setLong(o1, (long) 1); } else if (field.getType() == float.class) { field.setFloat(o1, (float) 1); } else if (field.getType() == int.class) { field.setInt(o1, 1); } else if (field.getType() == byte.class) { field.setByte(o1, (byte) 1); } else if (field.getType() == char.class) { field.setChar(o1, (char) 1); } else if (field.getType() == double.class) { field.setDouble(o1, (double) 1); } else if (field.getType().isEnum()) { field.set(o1, field.getType().getEnumConstants()[0]); } else if (Object.class.isAssignableFrom(field.getType())) { field.set(o1, field.getType().newInstance()); } else { fail("Don't know how to set a " + field.getType().getName()); } assertFalse("Instances with o1 having " + field.getName() + " set and o2 having it not set are equal", o1 .equals(o2)); field.set(o2, field.get(o1)); assertTrue( "After setting o2 with the value of the object in o1, the two objects in the field are not equal", field.get(o1).equals(field.get(o2))); assertTrue( "Instances with o1 having " + field.getName() + " set and o2 having it set to the same object of type " + field.get(o2).getClass().getName() + " are not equal", o1.equals(o2)); if (field.getType() == String.class) { field.set(o2, TEST_STRING_VAL2); } else if (field.getType() == boolean.class) { field.setBoolean(o2, false); } else if (field.getType() == short.class) { field.setShort(o2, (short) 0); } else if (field.getType() == long.class) { field.setLong(o2, (long) 0); } else if (field.getType() == float.class) { field.setFloat(o2, (float) 0); } else if (field.getType() == int.class) { field.setInt(o2, 0); } else if (field.getType() == byte.class) { field.setByte(o2, (byte) 0); } else if (field.getType() == char.class) { field.setChar(o2, (char) 0); } else if (field.getType() == double.class) { field.setDouble(o2, (double) 1); } else if (field.getType().isEnum()) { field.set(o2, field.getType().getEnumConstants()[1]); } else if (Object.class.isAssignableFrom(field.getType())) { field.set(o2, field.getType().newInstance()); } else { fail("Don't know how to set a " + field.getType().getName()); } if (field.get(o1).equals(field.get(o2))) { // Even though we have different instances, they are equal. // Let's walk one of them // to see if we can find a field to set Field[] paramFields = field.get(o1).getClass() .getDeclaredFields(); for (int j = 0; j < paramFields.length; j++) { paramFields[j].setAccessible(true); if (paramFields[j].getType() == String.class) { paramFields[j].set(field.get(o1), TEST_STRING_VAL1); } } } assertFalse( "After setting o2 with a different object than what is in o1, the two objects in the field are equal. " + "This is after an attempt to walk the fields to make them different", field.get(o1).equals(field.get(o2))); assertFalse( "Instances with o1 having " + field.getName() + " set and o2 having it set to a different object are equal", o1.equals(o2)); } } catch (InstantiationException e) { e.printStackTrace(); throw new AssertionError( "Unable to construct an instance of the class under test"); } catch (IllegalAccessException e) { e.printStackTrace(); throw new AssertionError( "Unable to construct an instance of the class under test"); } catch (SecurityException e) { e.printStackTrace(); throw new AssertionError( "Unable to read the field from the class under test"); } catch (NoSuchFieldException e) { e.printStackTrace(); throw new AssertionError( "Unable to find field in the class under test"); } } /** * @param classUnderTest * @param fieldNames * @return * @throws NoSuchFieldException */ private static Field[] getFieldsByNameOrAll(Class<?> classUnderTest, String[] fieldNames) throws NoSuchFieldException { Field fields[]; if (fieldNames == null) { fields = classUnderTest.getDeclaredFields(); } else { fields = new Field[fieldNames.length]; for (int i = 0; i < fieldNames.length; i++) fields[i] = classUnderTest.getDeclaredField(fieldNames[i]); } return fields; } public static void assertMeetsHashCodeContract(Class<?> classUnderTest, String[] fieldNames) { try { Field[] fields = getFieldsByNameOrAll(classUnderTest, fieldNames); for (int i = 0; i < fields.length; i++) { Object o1 = classUnderTest.newInstance(); int initialHashCode = o1.hashCode(); Field field = fields[i]; field.setAccessible(true); if (field.getType() == String.class) { field.set(o1, TEST_STRING_VAL1); } else if (field.getType() == boolean.class) { field.setBoolean(o1, true); } else if (field.getType() == short.class) { field.setShort(o1, (short) 1); } else if (field.getType() == long.class) { field.setLong(o1, (long) 1); } else if (field.getType() == float.class) { field.setFloat(o1, (float) 1); } else if (field.getType() == int.class) { field.setInt(o1, 1); } else if (field.getType() == byte.class) { field.setByte(o1, (byte) 1); } else if (field.getType() == char.class) { field.setChar(o1, (char) 1); } else if (field.getType() == double.class) { field.setDouble(o1, (double) 1); } else if (field.getType().isEnum()) { field.set(o1, field.getType().getEnumConstants()[0]); } else if (Object.class.isAssignableFrom(field.getType())) { field.set(o1, field.getType().newInstance()); } else { fail("Don't know how to set a " + field.getType().getName()); } int updatedHashCode = o1.hashCode(); assertFalse( "The field " + field.getName() + " was not taken into account for the hashCode contract ", initialHashCode == updatedHashCode); } } catch (InstantiationException e) { e.printStackTrace(); throw new AssertionError( "Unable to construct an instance of the class under test"); } catch (IllegalAccessException e) { e.printStackTrace(); throw new AssertionError( "Unable to construct an instance of the class under test"); } catch (NoSuchFieldException e) { e.printStackTrace(); throw new AssertionError( "Unable to find field in the class under test"); } } }
zzsuper001-linuxshell
tests/src/org/connectbot/mock/BeanTestCase.java
Java
asf20
7,895
/* * ConnectBot: simple, powerful, open-source SSH client for Android * Copyright 2007 Kenny Root, Jeffrey Sharkey * * 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 org.connectbot.mock; import java.io.IOException; import java.util.Map; import org.connectbot.bean.HostBean; import org.connectbot.service.TerminalBridge; import org.connectbot.service.TerminalManager; import org.connectbot.transport.AbsTransport; import android.net.Uri; /** * @author kenny * */ public class NullTransport extends AbsTransport { /** * */ public NullTransport() { // TODO Auto-generated constructor stub } /** * @param host * @param bridge * @param manager */ public NullTransport(HostBean host, TerminalBridge bridge, TerminalManager manager) { super(host, bridge, manager); // TODO Auto-generated constructor stub } @Override public void close() { // TODO Auto-generated method stub } @Override public void connect() { // TODO Auto-generated method stub } @Override public HostBean createHost(Uri uri) { // TODO Auto-generated method stub return null; } @Override public void flush() throws IOException { // TODO Auto-generated method stub } @Override public String getDefaultNickname(String username, String hostname, int port) { // TODO Auto-generated method stub return null; } @Override public int getDefaultPort() { // TODO Auto-generated method stub return 0; } @Override public void getSelectionArgs(Uri uri, Map<String, String> selection) { // TODO Auto-generated method stub } @Override public boolean isConnected() { // TODO Auto-generated method stub return false; } @Override public boolean isSessionOpen() { // TODO Auto-generated method stub return false; } @Override public int read(byte[] buffer, int offset, int length) throws IOException { // TODO Auto-generated method stub return 0; } @Override public void setDimensions(int columns, int rows, int width, int height) { // TODO Auto-generated method stub } @Override public void write(byte[] buffer) throws IOException { // TODO Auto-generated method stub } @Override public void write(int c) throws IOException { // TODO Auto-generated method stub } @Override public boolean usesNetwork() { // TODO Auto-generated method stub return false; } }
zzsuper001-linuxshell
tests/src/org/connectbot/mock/NullTransport.java
Java
asf20
2,862
/* * ConnectBot: simple, powerful, open-source SSH client for Android * Copyright 2007 Kenny Root, Jeffrey Sharkey * * 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 org.connectbot.mock; import java.io.IOException; import java.io.OutputStream; /** * @author Kenny Root * */ public class NullOutputStream extends OutputStream { @Override public void write(int arg0) throws IOException { // do nothing } }
zzsuper001-linuxshell
tests/src/org/connectbot/mock/NullOutputStream.java
Java
asf20
937
/* * ConnectBot: simple, powerful, open-source SSH client for Android * Copyright 2007 Kenny Root, Jeffrey Sharkey * * 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 org.connectbot; import android.test.ActivityInstrumentationTestCase2; /** * This is a simple framework for a test of an Application. See * {@link android.test.ApplicationTestCase ApplicationTestCase} for more * information on how to write and extend Application tests. * <p/> * To run this test, you can type: * adb shell am instrument -w \ * -e class org.connectbot.HostListActivityTest \ * org.connectbot.tests/android.test.InstrumentationTestRunner */ public class SettingsActivityTest extends ActivityInstrumentationTestCase2<SettingsActivity> { public SettingsActivityTest() { super("org.connectbot", SettingsActivity.class); } public void testOpenMenu() { SettingsActivity a = getActivity(); a.openOptionsMenu(); a.closeOptionsMenu(); } }
zzsuper001-linuxshell
tests/src/org/connectbot/SettingsActivityTest.java
Java
asf20
1,463
/* * ConnectBot: simple, powerful, open-source SSH client for Android * Copyright 2007 Kenny Root, Jeffrey Sharkey * * 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 org.connectbot.util; import java.util.Arrays; import android.test.AndroidTestCase; /** * @author Kenny Root * */ public class PubkeyUtilsTest extends AndroidTestCase { public void testEncodeHex_Null_Failure() throws Exception { try { PubkeyUtils.encodeHex(null); fail("Should throw null pointer exception when argument is null"); } catch (NullPointerException e) { // success } } public void testEncodeHex_Success() throws Exception { byte[] input = {(byte) 0xFF, 0x00, (byte) 0xA5, 0x5A, 0x12, 0x23}; String expected = "ff00a55a1223"; assertEquals("Encoded hex should match expected", PubkeyUtils.encodeHex(input), expected); } public void testSha256_Empty_Success() throws Exception { byte[] empty_hashed = new byte[] { (byte) 0xe3, (byte) 0xb0, (byte) 0xc4, (byte) 0x42, (byte) 0x98, (byte) 0xfc, (byte) 0x1c, (byte) 0x14, (byte) 0x9a, (byte) 0xfb, (byte) 0xf4, (byte) 0xc8, (byte) 0x99, (byte) 0x6f, (byte) 0xb9, (byte) 0x24, (byte) 0x27, (byte) 0xae, (byte) 0x41, (byte) 0xe4, (byte) 0x64, (byte) 0x9b, (byte) 0x93, (byte) 0x4c, (byte) 0xa4, (byte) 0x95, (byte) 0x99, (byte) 0x1b, (byte) 0x78, (byte) 0x52, (byte) 0xb8, (byte) 0x55, }; final byte[] empty = new byte[] {}; assertTrue("Empty string should be equal to known test vector", Arrays.equals(empty_hashed, PubkeyUtils.sha256(empty))); } }
zzsuper001-linuxshell
tests/src/org/connectbot/util/PubkeyUtilsTest.java
Java
asf20
2,075
/* * ConnectBot: simple, powerful, open-source SSH client for Android * Copyright 2007 Kenny Root, Jeffrey Sharkey * * 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 org.connectbot; import org.connectbot.bean.HostBean; import org.connectbot.mock.BeanTestCase; import android.test.AndroidTestCase; /** * @author Kenny Root * */ public class HostBeanTest extends AndroidTestCase { private static final String[] FIELDS = { "nickname", "username", "hostname", "port" }; HostBean host1; HostBean host2; @Override protected void setUp() throws Exception { super.setUp(); host1 = new HostBean(); host1.setNickname("Home"); host1.setUsername("bob"); host1.setHostname("server.example.com"); host1.setPort(22); host2 = new HostBean(); host2.setNickname("Home"); host2.setUsername("bob"); host2.setHostname("server.example.com"); host2.setPort(22); } @Override protected void tearDown() throws Exception { super.tearDown(); } public void testIdEquality() { host1.setId(1); host2.setId(1); assertTrue(host1.equals(host2)); assertTrue(host1.hashCode() == host2.hashCode()); } public void testIdInequality() { host1.setId(1); host2.setId(2); // HostBeans shouldn't be equal when their IDs are not the same assertFalse("HostBeans are equal when their ID is different", host1 .equals(host2)); assertFalse("HostBean hash codes are equal when their ID is different", host1.hashCode() == host2.hashCode()); } public void testIdEquality2() { host1.setId(1); host2.setId(1); host2.setNickname("Work"); host2.setUsername("alice"); host2.setHostname("client.example.com"); assertTrue( "HostBeans are not equal when their ID is the same but other fields are different!", host1.equals(host2)); assertTrue( "HostBeans hashCodes are not equal when their ID is the same but other fields are different!", host1.hashCode() == host2.hashCode()); } public void testBeanMeetsEqualsContract() { BeanTestCase.assertMeetsEqualsContract(HostBean.class, FIELDS); } public void testBeanMeetsHashCodeContract() { BeanTestCase.assertMeetsHashCodeContract(HostBean.class, FIELDS); } }
zzsuper001-linuxshell
tests/src/org/connectbot/HostBeanTest.java
Java
asf20
2,689
/* * ConnectBot: simple, powerful, open-source SSH client for Android * Copyright 2007 Kenny Root, Jeffrey Sharkey * * 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 org.connectbot; import org.connectbot.bean.SelectionArea; import android.test.AndroidTestCase; /** * @author Kenny Root * */ public class SelectionAreaTest extends AndroidTestCase { private static final int WIDTH = 80; private static final int HEIGHT = 24; public void testCreate() { SelectionArea sa = new SelectionArea(); assertTrue(sa.getLeft() == 0); assertTrue(sa.getRight() == 0); assertTrue(sa.getTop() == 0); assertTrue(sa.getBottom() == 0); assertTrue(sa.isSelectingOrigin()); } public void testCheckMovement() { SelectionArea sa = new SelectionArea(); sa.setBounds(WIDTH, HEIGHT); sa.incrementColumn(); // Should be (1,0) to (1,0) assertTrue(sa.getLeft() == 1); assertTrue(sa.getTop() == 0); assertTrue(sa.getRight() == 1); assertTrue(sa.getBottom() == 0); sa.finishSelectingOrigin(); assertFalse(sa.isSelectingOrigin()); sa.incrementColumn(); sa.incrementColumn(); // Should be (1,0) to (3,0) assertTrue(sa.getLeft() == 1); assertTrue(sa.getTop() == 0); assertTrue(sa.getRight() == 3); assertTrue(sa.getBottom() == 0); } public void testBounds() { SelectionArea sa = new SelectionArea(); sa.setBounds(WIDTH, HEIGHT); for (int i = 0; i <= WIDTH; i++) sa.decrementColumn(); assertTrue("Left bound should be 0, but instead is " + sa.getLeft(), sa.getLeft() == 0); for (int i = 0; i <= HEIGHT; i++) sa.decrementRow(); assertTrue("Top bound should be 0, but instead is " + sa.getLeft(), sa.getTop() == 0); sa.finishSelectingOrigin(); for (int i = 0; i <= WIDTH * 2; i++) sa.incrementColumn(); assertTrue("Left bound should be 0, but instead is " + sa.getLeft(), sa.getLeft() == 0); assertTrue("Right bound should be " + (WIDTH - 1) + ", but instead is " + sa.getRight(), sa.getRight() == (WIDTH - 1)); for (int i = 0; i <= HEIGHT * 2; i++) sa.incrementRow(); assertTrue("Bottom bound should be " + (HEIGHT - 1) + ", but instead is " + sa.getBottom(), sa.getBottom() == (HEIGHT - 1)); assertTrue("Top bound should be 0, but instead is " + sa.getTop(), sa.getTop() == 0); } public void testSetThenMove() { SelectionArea sa = new SelectionArea(); sa.setBounds(WIDTH, HEIGHT); int targetColumn = WIDTH / 2; int targetRow = HEIGHT / 2; sa.setColumn(targetColumn); sa.setRow(targetRow); sa.incrementRow(); assertTrue("Row should be " + (targetRow + 1) + ", but instead is " + sa.getTop(), sa.getTop() == (targetRow + 1)); sa.decrementColumn(); assertTrue("Column shold be " + (targetColumn - 1) + ", but instead is " + sa.getLeft(), sa.getLeft() == (targetColumn - 1)); sa.finishSelectingOrigin(); sa.setRow(0); sa.setColumn(0); sa.incrementRow(); sa.decrementColumn(); assertTrue("Top row should be 1, but instead is " + sa.getTop(), sa.getTop() == 1); assertTrue("Left column shold be 0, but instead is " + sa.getLeft(), sa.getLeft() == 0); assertTrue("Bottom row should be " + (targetRow + 1) + ", but instead is " + sa.getBottom(), sa.getBottom() == (targetRow + 1)); assertTrue("Right column shold be " + (targetColumn - 1) + ", but instead is " + sa.getRight(), sa.getRight() == (targetColumn - 1)); } }
zzsuper001-linuxshell
tests/src/org/connectbot/SelectionAreaTest.java
Java
asf20
3,919
/* * ConnectBot: simple, powerful, open-source SSH client for Android * Copyright 2007 Kenny Root, Jeffrey Sharkey * * 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 org.connectbot; import android.app.Activity; import android.test.ActivityInstrumentationTestCase2; /** * This is a simple framework for a test of an Application. See * {@link android.test.ApplicationTestCase ApplicationTestCase} for more * information on how to write and extend Application tests. * <p/> * To run this test, you can type: adb shell am instrument -w \ -e class * org.connectbot.HostListActivityTest \ * org.connectbot.tests/android.test.InstrumentationTestRunner */ public class HostListActivityTest extends ActivityInstrumentationTestCase2<HostListActivity> { private Activity mActivity; public HostListActivityTest() { super("org.connectbot", HostListActivity.class); } @Override protected void setUp() throws Exception { super.setUp(); setActivityInitialTouchMode(false); mActivity = getActivity(); } }
zzsuper001-linuxshell
tests/src/org/connectbot/HostListActivityTest.java
Java
asf20
1,538
/* * ConnectBot: simple, powerful, open-source SSH client for Android * Copyright 2007 Kenny Root, Jeffrey Sharkey * * 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 org.connectbot; import android.test.AndroidTestCase; /** * @author Kenny Root * */ public class TerminalBridgeTest extends AndroidTestCase { public void testShiftLock() throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException { // TerminalBridge bridge = new TerminalBridge(); // AbsTransport nullTransport = new NullTransport(); // // // Make sure onKey will work when we call it // Field disconnected = TerminalBridge.class // .getDeclaredField("disconnected"); // Field keymode = TerminalBridge.class.getDeclaredField("keymode"); // Field transport = TerminalBridge.class.getDeclaredField("transport"); // // disconnected.setAccessible(true); // keymode.setAccessible(true); // transport.setAccessible(true); // // disconnected.setBoolean(bridge, false); // keymode.set(bridge, PreferenceConstants.KEYMODE_RIGHT); // transport.set(bridge, nullTransport); // // // Begin tests // assertTrue("Meta state is " + bridge.getMetaState() // + " when it should be 0", bridge.getMetaState() == 0); // // KeyEvent shiftDown = new KeyEvent(KeyEvent.ACTION_DOWN, // KeyEvent.KEYCODE_SHIFT_LEFT); // bridge.onKey(null, shiftDown.getKeyCode(), shiftDown); // // assertTrue("Shift test: after shift press, meta state is " // + bridge.getMetaState() + " when it should be " // + TerminalBridge.META_SHIFT_ON, // bridge.getMetaState() == TerminalBridge.META_SHIFT_ON); // // KeyEvent shiftUp = KeyEvent.changeAction(shiftDown, KeyEvent.ACTION_UP); // bridge.onKey(null, shiftUp.getKeyCode(), shiftUp); // // assertTrue("Shift test: after shift release, meta state is " // + bridge.getMetaState() + " when it should be " // + TerminalBridge.META_SHIFT_ON, // bridge.getMetaState() == TerminalBridge.META_SHIFT_ON); // // KeyEvent letterAdown = new KeyEvent(KeyEvent.ACTION_DOWN, // KeyEvent.KEYCODE_A); // KeyEvent letterAup = KeyEvent.changeAction(letterAdown, // KeyEvent.ACTION_UP); // // bridge.onKey(null, letterAdown.getKeyCode(), letterAdown); // bridge.onKey(null, letterAup.getKeyCode(), letterAup); // // assertTrue("Shift test: after letter press and release, meta state is " // + bridge.getMetaState() + " when it should be 0", bridge // .getMetaState() == 0); // // bridge.onKey(null, shiftDown.getKeyCode(), shiftDown); // bridge.onKey(null, shiftUp.getKeyCode(), shiftUp); // bridge.onKey(null, shiftDown.getKeyCode(), shiftDown); // bridge.onKey(null, shiftUp.getKeyCode(), shiftUp); // // assertTrue("Shift lock test: after two shift presses, meta state is " // + bridge.getMetaState() + " when it should be " // + TerminalBridge.META_SHIFT_LOCK, // bridge.getMetaState() == TerminalBridge.META_SHIFT_LOCK); // // bridge.onKey(null, letterAdown.getKeyCode(), letterAdown); // // assertTrue( // "Shift lock test: after letter press, meta state is " // + bridge.getMetaState() + " when it should be " // + TerminalBridge.META_SHIFT_LOCK, // bridge.getMetaState() == TerminalBridge.META_SHIFT_LOCK); // // bridge.onKey(null, letterAup.getKeyCode(), letterAup); // // assertTrue( // "Shift lock test: after letter press and release, meta state is " // + bridge.getMetaState() + " when it should be " // + TerminalBridge.META_SHIFT_LOCK, // bridge.getMetaState() == TerminalBridge.META_SHIFT_LOCK); } }
zzsuper001-linuxshell
tests/src/org/connectbot/TerminalBridgeTest.java
Java
asf20
4,044
/* * Copyright (C) 2007 The Android Open Source Project * * 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. */ #include "com_google_ase_Exec.h" #include <errno.h> #include <fcntl.h> #include <stdlib.h> #include <sys/ioctl.h> #include <sys/types.h> #include <sys/wait.h> #include <termios.h> #include <unistd.h> #include "android/log.h" #define LOG_TAG "Exec" #define LOG(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__) void JNU_ThrowByName(JNIEnv* env, const char* name, const char* msg) { jclass clazz = env->FindClass(name); if (clazz != NULL) { env->ThrowNew(clazz, msg); } env->DeleteLocalRef(clazz); } char* JNU_GetStringNativeChars(JNIEnv* env, jstring jstr) { if (jstr == NULL) { return NULL; } jbyteArray bytes = 0; jthrowable exc; char* result = 0; if (env->EnsureLocalCapacity(2) < 0) { return 0; /* out of memory error */ } jclass Class_java_lang_String = env->FindClass("java/lang/String"); jmethodID MID_String_getBytes = env->GetMethodID( Class_java_lang_String, "getBytes", "()[B"); bytes = (jbyteArray) env->CallObjectMethod(jstr, MID_String_getBytes); exc = env->ExceptionOccurred(); if (!exc) { jint len = env->GetArrayLength(bytes); result = (char*) malloc(len + 1); if (result == 0) { JNU_ThrowByName(env, "java/lang/OutOfMemoryError", 0); env->DeleteLocalRef(bytes); return 0; } env->GetByteArrayRegion(bytes, 0, len, (jbyte*) result); result[len] = 0; /* NULL-terminate */ } else { env->DeleteLocalRef(exc); } env->DeleteLocalRef(bytes); return result; } int jniGetFDFromFileDescriptor(JNIEnv* env, jobject fileDescriptor) { jclass Class_java_io_FileDescriptor = env->FindClass("java/io/FileDescriptor"); jfieldID descriptor = env->GetFieldID(Class_java_io_FileDescriptor, "descriptor", "I"); return env->GetIntField(fileDescriptor, descriptor); } static int create_subprocess( const char* cmd, const char* arg0, const char* arg1, int* pProcessId) { char* devname; int ptm; pid_t pid; ptm = open("/dev/ptmx", O_RDWR); // | O_NOCTTY); if(ptm < 0){ LOG("[ cannot open /dev/ptmx - %s ]\n", strerror(errno)); return -1; } fcntl(ptm, F_SETFD, FD_CLOEXEC); if(grantpt(ptm) || unlockpt(ptm) || ((devname = (char*) ptsname(ptm)) == 0)){ LOG("[ trouble with /dev/ptmx - %s ]\n", strerror(errno)); return -1; } pid = fork(); if(pid < 0) { LOG("- fork failed: %s -\n", strerror(errno)); return -1; } if(pid == 0){ int pts; setsid(); pts = open(devname, O_RDWR); if(pts < 0) exit(-1); dup2(pts, 0); dup2(pts, 1); dup2(pts, 2); close(ptm); execl(cmd, cmd, arg0, arg1, NULL); exit(-1); } else { *pProcessId = (int) pid; return ptm; } } JNIEXPORT jobject JNICALL Java_com_google_ase_Exec_createSubprocess( JNIEnv* env, jclass clazz, jstring cmd, jstring arg0, jstring arg1, jintArray processIdArray) { char* cmd_8 = JNU_GetStringNativeChars(env, cmd); char* arg0_8 = JNU_GetStringNativeChars(env, arg0); char* arg1_8 = JNU_GetStringNativeChars(env, arg1); int procId; int ptm = create_subprocess(cmd_8, arg0_8, arg1_8, &procId); if (processIdArray) { int procIdLen = env->GetArrayLength(processIdArray); if (procIdLen > 0) { jboolean isCopy; int* pProcId = (int*) env->GetPrimitiveArrayCritical(processIdArray, &isCopy); if (pProcId) { *pProcId = procId; env->ReleasePrimitiveArrayCritical(processIdArray, pProcId, 0); } } } jclass Class_java_io_FileDescriptor = env->FindClass("java/io/FileDescriptor"); jmethodID init = env->GetMethodID(Class_java_io_FileDescriptor, "<init>", "()V"); jobject result = env->NewObject(Class_java_io_FileDescriptor, init); if (!result) { LOG("Couldn't create a FileDescriptor."); } else { jfieldID descriptor = env->GetFieldID(Class_java_io_FileDescriptor, "descriptor", "I"); env->SetIntField(result, descriptor, ptm); } return result; } JNIEXPORT void Java_com_google_ase_Exec_setPtyWindowSize( JNIEnv* env, jclass clazz, jobject fileDescriptor, jint row, jint col, jint xpixel, jint ypixel) { int fd; struct winsize sz; fd = jniGetFDFromFileDescriptor(env, fileDescriptor); if (env->ExceptionOccurred() != NULL) { return; } sz.ws_row = row; sz.ws_col = col; sz.ws_xpixel = xpixel; sz.ws_ypixel = ypixel; ioctl(fd, TIOCSWINSZ, &sz); } JNIEXPORT jint Java_com_google_ase_Exec_waitFor(JNIEnv* env, jclass clazz, jint procId) { int status; waitpid(procId, &status, 0); int result = 0; if (WIFEXITED(status)) { result = WEXITSTATUS(status); } return result; }
zzsuper001-linuxshell
jni/Exec/com_google_ase_Exec.cpp
C++
asf20
5,383
LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := com_google_ase_Exec LOCAL_CFLAGS := -Werror LOCAL_SRC_FILES := com_google_ase_Exec.cpp LOCAL_LDLIBS := -llog include $(BUILD_SHARED_LIBRARY)
zzsuper001-linuxshell
jni/Exec/Android.mk
Makefile
asf20
220
# Build both ARMv5TE and x86-32 machine code. APP_ABI := armeabi x86
zzsuper001-linuxshell
jni/Application.mk
Makefile
asf20
69
include $(call all-subdir-makefiles)
zzsuper001-linuxshell
jni/Android.mk
Makefile
asf20
37
package cn.nju.zyy.samples; import javax.sql.DataSource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.jdbc.core.JdbcTemplate; @Configuration public class CustomerConfiguration { @Autowired private DataSource dataSource; @Bean public JdbcTemplate jdbcTemplate() { return new JdbcTemplate(this.dataSource); } }
zyy-spring-blog-guide
trunk/src/cn/nju/zyy/samples/CustomerConfiguration.java
Java
asf20
500
package cn.nju.zyy.samples; public class Customer { private long id; private String firstName; private String lastName; private String email; public Customer() { } public Customer(long id, String firstName, String lastName, String email) { this.id = id; this.firstName = firstName; this.lastName = lastName; this.email = email; } public long getId() { return id; } public void setId(long id) { this.id = id; } public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } @Override public String toString() { return "First name: " + getFirstName() + " | Last name: " + getLastName() + " | Email: " + getEmail(); } }
zyy-spring-blog-guide
trunk/src/cn/nju/zyy/samples/Customer.java
Java
asf20
1,031
package cn.nju.zyy.samples; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component public class CustomerClient { private CustomerService customerService; @Autowired public void setCustomerService(CustomerService customerService) { this.customerService = customerService; } public void printCustomerInformation(long customerId) { Customer customer = customerService.getCustomerById(customerId); System.out.println(customer); } }
zyy-spring-blog-guide
trunk/src/cn/nju/zyy/samples/CustomerClient.java
Java
asf20
537
package cn.nju.zyy.samples; public interface CustomerService { public Customer getCustomerById(long id); }
zyy-spring-blog-guide
trunk/src/cn/nju/zyy/samples/CustomerService.java
Java
asf20
116
package cn.nju.zyy.samples; import java.sql.ResultSet; import java.sql.SQLException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.RowMapper; import org.springframework.stereotype.Component; @Component public class DatabaseCustomerService implements CustomerService { private JdbcTemplate jdbcTemplate; private RowMapper<Customer> customerRowMapper = new CustomerRowMapper(); @Override public Customer getCustomerById(long id) { return jdbcTemplate.queryForObject( "select * from CUSTOMERS where ID = ?", this.customerRowMapper, id); } @Autowired public void setJdbcTemplate(JdbcTemplate jdbcTemplatee) { this.jdbcTemplate = jdbcTemplatee; } class CustomerRowMapper implements RowMapper<Customer> { @Override public Customer mapRow(ResultSet resultSet, int i) throws SQLException { String fn = resultSet.getString("FIRST_NAME"); String ln = resultSet.getString("LAST_NAME"); String email = resultSet.getString("EMAIL"); long id = resultSet.getInt("ID"); return new Customer(id, fn, ln, email); } } }
zyy-spring-blog-guide
trunk/src/cn/nju/zyy/samples/DatabaseCustomerService.java
Java
asf20
1,194
<html> <head> </head> <body> <div id="results">zhizhangming</div> </body> </html>
zzm-calender-gadgets
trunk/myTest.html
HTML
asf20
99
/*! * Ext JS Library 3.4.0 * Copyright(c) 2006-2011 Sencha Inc. * licensing@sencha.com * http://www.sencha.com/license */ html,body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,p,blockquote,th,td{margin:0;padding:0;}img,body,html{border:0;}address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal;}ol,ul {list-style:none;}caption,th {text-align:left;}h1,h2,h3,h4,h5,h6{font-size:100%;}q:before,q:after{content:'';} .ext-forced-border-box, .ext-forced-border-box * { -moz-box-sizing: border-box; -ms-box-sizing: border-box; -webkit-box-sizing: border-box; } .ext-el-mask { z-index: 100; position: absolute; top:0; left:0; -moz-opacity: 0.5; opacity: .50; filter: alpha(opacity=50); width: 100%; height: 100%; zoom: 1; } .ext-el-mask-msg { z-index: 20001; position: absolute; top: 0; left: 0; border:1px solid; background:repeat-x 0 -16px; padding:2px; } .ext-el-mask-msg div { padding:5px 10px 5px 10px; border:1px solid; cursor:wait; } .ext-shim { position:absolute; visibility:hidden; left:0; top:0; overflow:hidden; } .ext-ie .ext-shim { filter: alpha(opacity=0); } .ext-ie6 .ext-shim { margin-left: 5px; margin-top: 3px; } .x-mask-loading div { padding:5px 10px 5px 25px; background:no-repeat 5px 5px; line-height:16px; } /* class for hiding elements without using display:none */ .x-hidden, .x-hide-offsets { position:absolute !important; left:-10000px; top:-10000px; visibility:hidden; } .x-hide-display { display:none !important; } .x-hide-nosize, .x-hide-nosize * /* Emulate display:none for children */ { height:0px!important; width:0px!important; visibility:hidden!important; border:none!important; zoom:1; } .x-hide-visibility { visibility:hidden !important; } .x-masked { overflow: hidden !important; } .x-masked-relative { position: relative !important; } .x-masked select, .x-masked object, .x-masked embed { visibility: hidden; } .x-layer { visibility: hidden; } .x-unselectable, .x-unselectable * { -moz-user-select: none; -khtml-user-select: none; -webkit-user-select:ignore; } .x-repaint { zoom: 1; background-color: transparent; -moz-outline: none; outline: none; } .x-item-disabled { cursor: default; opacity: .6; -moz-opacity: .6; filter: alpha(opacity=60); } .x-item-disabled * { cursor: default !important; } .x-form-radio-group .x-item-disabled { filter: none; } .x-splitbar-proxy { position: absolute; visibility: hidden; z-index: 20001; zoom: 1; line-height: 1px; font-size: 1px; overflow: hidden; } .x-splitbar-h, .x-splitbar-proxy-h { cursor: e-resize; cursor: col-resize; } .x-splitbar-v, .x-splitbar-proxy-v { cursor: s-resize; cursor: row-resize; } .x-color-palette { width: 150px; height: 92px; cursor: pointer; } .x-color-palette a { border: 1px solid; float: left; padding: 2px; text-decoration: none; -moz-outline: 0 none; outline: 0 none; cursor: pointer; } .x-color-palette a:hover, .x-color-palette a.x-color-palette-sel { border: 1px solid; } .x-color-palette em { display: block; border: 1px solid; } .x-color-palette em span { cursor: pointer; display: block; height: 10px; line-height: 10px; width: 10px; } .x-ie-shadow { display: none; position: absolute; overflow: hidden; left:0; top:0; zoom:1; } .x-shadow { display: none; position: absolute; overflow: hidden; left:0; top:0; } .x-shadow * { overflow: hidden; } .x-shadow * { padding: 0; border: 0; margin: 0; clear: none; zoom: 1; } /* top bottom */ .x-shadow .xstc, .x-shadow .xsbc { height: 6px; float: left; } /* corners */ .x-shadow .xstl, .x-shadow .xstr, .x-shadow .xsbl, .x-shadow .xsbr { width: 6px; height: 6px; float: left; } /* sides */ .x-shadow .xsc { width: 100%; } .x-shadow .xsml, .x-shadow .xsmr { width: 6px; float: left; height: 100%; } .x-shadow .xsmc { float: left; height: 100%; background-color: transparent; } .x-shadow .xst, .x-shadow .xsb { height: 6px; overflow: hidden; width: 100%; } .x-shadow .xsml { background: transparent repeat-y 0 0; } .x-shadow .xsmr { background: transparent repeat-y -6px 0; } .x-shadow .xstl { background: transparent no-repeat 0 0; } .x-shadow .xstc { background: transparent repeat-x 0 -30px; } .x-shadow .xstr { background: transparent repeat-x 0 -18px; } .x-shadow .xsbl { background: transparent no-repeat 0 -12px; } .x-shadow .xsbc { background: transparent repeat-x 0 -36px; } .x-shadow .xsbr { background: transparent repeat-x 0 -6px; } .loading-indicator { background: no-repeat left; padding-left: 20px; line-height: 16px; margin: 3px; } .x-text-resize { position: absolute; left: -1000px; top: -1000px; visibility: hidden; zoom: 1; } .x-drag-overlay { width: 100%; height: 100%; display: none; position: absolute; left: 0; top: 0; background-image:url(../images/default/s.gif); z-index: 20000; } .x-clear { clear:both; height:0; overflow:hidden; line-height:0; font-size:0; } .x-spotlight { z-index: 8999; position: absolute; top:0; left:0; -moz-opacity: 0.5; opacity: .50; filter: alpha(opacity=50); width:0; height:0; zoom: 1; } #x-history-frame { position:absolute; top:-1px; left:0; width:1px; height:1px; visibility:hidden; } #x-history-field { position:absolute; top:0; left:-1px; width:1px; height:1px; visibility:hidden; } .x-resizable-handle { position:absolute; z-index:100; /* ie needs these */ font-size:1px; line-height:6px; overflow:hidden; filter:alpha(opacity=0); opacity:0; zoom:1; } .x-resizable-handle-east{ width:6px; cursor:e-resize; right:0; top:0; height:100%; } .ext-ie .x-resizable-handle-east { margin-right:-1px; /*IE rounding error*/ } .x-resizable-handle-south{ width:100%; cursor:s-resize; left:0; bottom:0; height:6px; } .ext-ie .x-resizable-handle-south { margin-bottom:-1px; /*IE rounding error*/ } .x-resizable-handle-west{ width:6px; cursor:w-resize; left:0; top:0; height:100%; } .x-resizable-handle-north{ width:100%; cursor:n-resize; left:0; top:0; height:6px; } .x-resizable-handle-southeast{ width:6px; cursor:se-resize; right:0; bottom:0; height:6px; z-index:101; } .x-resizable-handle-northwest{ width:6px; cursor:nw-resize; left:0; top:0; height:6px; z-index:101; } .x-resizable-handle-northeast{ width:6px; cursor:ne-resize; right:0; top:0; height:6px; z-index:101; } .x-resizable-handle-southwest{ width:6px; cursor:sw-resize; left:0; bottom:0; height:6px; z-index:101; } .x-resizable-over .x-resizable-handle, .x-resizable-pinned .x-resizable-handle{ filter:alpha(opacity=100); opacity:1; } .x-resizable-over .x-resizable-handle-east, .x-resizable-pinned .x-resizable-handle-east, .x-resizable-over .x-resizable-handle-west, .x-resizable-pinned .x-resizable-handle-west { background-position: left; } .x-resizable-over .x-resizable-handle-south, .x-resizable-pinned .x-resizable-handle-south, .x-resizable-over .x-resizable-handle-north, .x-resizable-pinned .x-resizable-handle-north { background-position: top; } .x-resizable-over .x-resizable-handle-southeast, .x-resizable-pinned .x-resizable-handle-southeast{ background-position: top left; } .x-resizable-over .x-resizable-handle-northwest, .x-resizable-pinned .x-resizable-handle-northwest{ background-position:bottom right; } .x-resizable-over .x-resizable-handle-northeast, .x-resizable-pinned .x-resizable-handle-northeast{ background-position: bottom left; } .x-resizable-over .x-resizable-handle-southwest, .x-resizable-pinned .x-resizable-handle-southwest{ background-position: top right; } .x-resizable-proxy{ border: 1px dashed; position:absolute; overflow:hidden; display:none; left:0; top:0; z-index:50000; } .x-resizable-overlay{ width:100%; height:100%; display:none; position:absolute; left:0; top:0; z-index:200000; -moz-opacity: 0; opacity:0; filter: alpha(opacity=0); } .x-tab-panel { overflow:hidden; } .x-tab-panel-header, .x-tab-panel-footer { border: 1px solid; overflow:hidden; zoom:1; } .x-tab-panel-header { border: 1px solid; padding-bottom: 2px; } .x-tab-panel-footer { border: 1px solid; padding-top: 2px; } .x-tab-strip-wrap { width:100%; overflow:hidden; position:relative; zoom:1; } ul.x-tab-strip { display:block; width:5000px; zoom:1; } ul.x-tab-strip-top{ padding-top: 1px; background: repeat-x bottom; border-bottom: 1px solid; } ul.x-tab-strip-bottom{ padding-bottom: 1px; background: repeat-x top; border-top: 1px solid; border-bottom: 0 none; } .x-tab-panel-header-plain .x-tab-strip-top { background:transparent !important; padding-top:0 !important; } .x-tab-panel-header-plain { background:transparent !important; border-width:0 !important; padding-bottom:0 !important; } .x-tab-panel-header-plain .x-tab-strip-spacer, .x-tab-panel-footer-plain .x-tab-strip-spacer { border:1px solid; height:2px; font-size:1px; line-height:1px; } .x-tab-panel-header-plain .x-tab-strip-spacer { border-top: 0 none; } .x-tab-panel-footer-plain .x-tab-strip-spacer { border-bottom: 0 none; } .x-tab-panel-footer-plain .x-tab-strip-bottom { background:transparent !important; padding-bottom:0 !important; } .x-tab-panel-footer-plain { background:transparent !important; border-width:0 !important; padding-top:0 !important; } .ext-border-box .x-tab-panel-header-plain .x-tab-strip-spacer, .ext-border-box .x-tab-panel-footer-plain .x-tab-strip-spacer { height:3px; } ul.x-tab-strip li { float:left; margin-left:2px; } ul.x-tab-strip li.x-tab-edge { float:left; margin:0 !important; padding:0 !important; border:0 none !important; font-size:1px !important; line-height:1px !important; overflow:hidden; zoom:1; background:transparent !important; width:1px; } .x-tab-strip a, .x-tab-strip span, .x-tab-strip em { display:block; } .x-tab-strip a { text-decoration:none !important; -moz-outline: none; outline: none; cursor:pointer; } .x-tab-strip-inner { overflow:hidden; text-overflow: ellipsis; } .x-tab-strip span.x-tab-strip-text { white-space: nowrap; cursor:pointer; padding:4px 0; } .x-tab-strip-top .x-tab-with-icon .x-tab-right { padding-left:6px; } .x-tab-strip .x-tab-with-icon span.x-tab-strip-text { padding-left:20px; background-position: 0 3px; background-repeat: no-repeat; } .x-tab-strip-active, .x-tab-strip-active a.x-tab-right { cursor:default; } .x-tab-strip-active span.x-tab-strip-text { cursor:default; } .x-tab-strip-disabled .x-tabs-text { cursor:default; } .x-tab-panel-body { overflow:hidden; } .x-tab-panel-bwrap { overflow:hidden; } .ext-ie .x-tab-strip .x-tab-right { position:relative; } .x-tab-strip-top .x-tab-strip-active .x-tab-right { margin-bottom:-1px; } /* * Horrible hack for IE8 in quirks mode */ .ext-ie8 .x-tab-strip li { position: relative; } .ext-border-box .ext-ie8 .x-tab-strip-top .x-tab-right { top: 1px; } .ext-ie8 .x-tab-strip-top { padding-top: 1; } .ext-border-box .ext-ie8 .x-tab-strip-top { padding-top: 0; } .ext-ie8 .x-tab-strip .x-tab-strip-closable a.x-tab-strip-close { top:3px; } .ext-border-box .ext-ie8 .x-tab-strip .x-tab-strip-closable a.x-tab-strip-close { top:4px; } .ext-ie8 .x-tab-strip-bottom .x-tab-right{ top:0; } .x-tab-strip-top .x-tab-strip-active .x-tab-right span.x-tab-strip-text { padding-bottom:5px; } .x-tab-strip-bottom .x-tab-strip-active .x-tab-right { margin-top:-1px; } .x-tab-strip-bottom .x-tab-strip-active .x-tab-right span.x-tab-strip-text { padding-top:5px; } .x-tab-strip-top .x-tab-right { background: transparent no-repeat 0 -51px; padding-left:10px; } .x-tab-strip-top .x-tab-left { background: transparent no-repeat right -351px; padding-right:10px; } .x-tab-strip-top .x-tab-strip-inner { background: transparent repeat-x 0 -201px; } .x-tab-strip-top .x-tab-strip-over .x-tab-right { background-position:0 -101px; } .x-tab-strip-top .x-tab-strip-over .x-tab-left { background-position:right -401px; } .x-tab-strip-top .x-tab-strip-over .x-tab-strip-inner { background-position:0 -251px; } .x-tab-strip-top .x-tab-strip-active .x-tab-right { background-position: 0 0; } .x-tab-strip-top .x-tab-strip-active .x-tab-left { background-position: right -301px; } .x-tab-strip-top .x-tab-strip-active .x-tab-strip-inner { background-position: 0 -151px; } .x-tab-strip-bottom .x-tab-right { background: no-repeat bottom right; } .x-tab-strip-bottom .x-tab-left { background: no-repeat bottom left; } .x-tab-strip-bottom .x-tab-strip-active .x-tab-right { background: no-repeat bottom right; } .x-tab-strip-bottom .x-tab-strip-active .x-tab-left { background: no-repeat bottom left; } .x-tab-strip-bottom .x-tab-left { margin-right: 3px; padding:0 10px; } .x-tab-strip-bottom .x-tab-right { padding:0; } .x-tab-strip .x-tab-strip-close { display:none; } .x-tab-strip-closable { position:relative; } .x-tab-strip-closable .x-tab-left { padding-right:19px; } .x-tab-strip .x-tab-strip-closable a.x-tab-strip-close { opacity:.6; -moz-opacity:.6; background-repeat:no-repeat; display:block; width:11px; height:11px; position:absolute; top:3px; right:3px; cursor:pointer; z-index:2; } .x-tab-strip .x-tab-strip-active a.x-tab-strip-close { opacity:.8; -moz-opacity:.8; } .x-tab-strip .x-tab-strip-closable a.x-tab-strip-close:hover{ opacity:1; -moz-opacity:1; } .x-tab-panel-body { border: 1px solid; } .x-tab-panel-body-top { border-top: 0 none; } .x-tab-panel-body-bottom { border-bottom: 0 none; } .x-tab-scroller-left { background: transparent no-repeat -18px 0; border-bottom: 1px solid; width:18px; position:absolute; left:0; top:0; z-index:10; cursor:pointer; } .x-tab-scroller-left-over { background-position: 0 0; } .x-tab-scroller-left-disabled { background-position: -18px 0; opacity:.5; -moz-opacity:.5; filter:alpha(opacity=50); cursor:default; } .x-tab-scroller-right { background: transparent no-repeat 0 0; border-bottom: 1px solid; width:18px; position:absolute; right:0; top:0; z-index:10; cursor:pointer; } .x-tab-scroller-right-over { background-position: -18px 0; } .x-tab-scroller-right-disabled { background-position: 0 0; opacity:.5; -moz-opacity:.5; filter:alpha(opacity=50); cursor:default; } .x-tab-scrolling-bottom .x-tab-scroller-left, .x-tab-scrolling-bottom .x-tab-scroller-right{ margin-top: 1px; } .x-tab-scrolling .x-tab-strip-wrap { margin-left:18px; margin-right:18px; } .x-tab-scrolling { position:relative; } .x-tab-panel-bbar .x-toolbar { border:1px solid; border-top:0 none; overflow:hidden; padding:2px; } .x-tab-panel-tbar .x-toolbar { border:1px solid; border-top:0 none; overflow:hidden; padding:2px; }/* all fields */ .x-form-field{ margin: 0 0 0 0; } .ext-webkit *:focus{ outline: none !important; } /* ---- text fields ---- */ .x-form-text, textarea.x-form-field{ padding:1px 3px; background:repeat-x 0 0; border:1px solid; } textarea.x-form-field { padding:2px 3px; } .x-form-text, .ext-ie .x-form-file { height:22px; line-height:18px; vertical-align:middle; } .ext-ie6 .x-form-text, .ext-ie7 .x-form-text { margin:-1px 0; /* ie bogus margin bug */ height:22px; /* ie quirks */ line-height:18px; } .x-quirks .ext-ie9 .x-form-text { height: 22px; padding-top: 3px; padding-bottom: 0px; } /* Ugly hacks for the bogus 1px margin bug in IE9 quirks */ .x-quirks .ext-ie9 .x-input-wrapper .x-form-text, .x-quirks .ext-ie9 .x-form-field-trigger-wrap .x-form-text { margin-top: -1px; margin-bottom: -1px; } .x-quirks .ext-ie9 .x-input-wrapper .x-form-element { margin-bottom: -1px; } .ext-ie6 .x-form-field-wrap .x-form-file-btn, .ext-ie7 .x-form-field-wrap .x-form-file-btn { top: -1px; /* because of all these margin hacks, these buttons are off by one pixel in IE6,7 */ } .ext-ie6 textarea.x-form-field, .ext-ie7 textarea.x-form-field { margin:-1px 0; /* ie bogus margin bug */ } .ext-strict .x-form-text { height:18px; } .ext-safari.ext-mac textarea.x-form-field { margin-bottom:-2px; /* another bogus margin bug, safari/mac only */ } /* .ext-strict .ext-ie8 .x-form-text, .ext-strict .ext-ie8 textarea.x-form-field { margin-bottom: 1px; } */ .ext-gecko .x-form-text , .ext-ie8 .x-form-text { padding-top:2px; /* FF won't center the text vertically */ padding-bottom:0; } .ext-ie6 .x-form-composite .x-form-text.x-box-item, .ext-ie7 .x-form-composite .x-form-text.x-box-item { margin: 0 !important; /* clear ie bogus margin bug fix */ } textarea { resize: none; /* Disable browser resizable textarea */ } /* select boxes */ .x-form-select-one { height:20px; line-height:18px; vertical-align:middle; border: 1px solid; } /* multi select boxes */ /* --- TODO --- */ /* 2.0.2 style */ .x-form-check-wrap { line-height:18px; height: auto; } .ext-ie .x-form-check-wrap input { width:15px; height:15px; } .x-form-check-wrap input{ vertical-align: bottom; } .x-editor .x-form-check-wrap { padding:3px; } .x-editor .x-form-checkbox { height:13px; } .x-form-check-group-label { border-bottom: 1px solid; margin-bottom: 5px; padding-left: 3px !important; float: none !important; } /* wrapped fields and triggers */ .x-form-field-wrap .x-form-trigger{ width:17px; height:21px; border:0; background:transparent no-repeat 0 0; cursor:pointer; border-bottom: 1px solid; position:absolute; top:0; } .x-form-field-wrap .x-form-date-trigger, .x-form-field-wrap .x-form-clear-trigger, .x-form-field-wrap .x-form-search-trigger{ cursor:pointer; } .x-form-field-wrap .x-form-twin-triggers .x-form-trigger{ position:static; top:auto; vertical-align:top; } .x-form-field-wrap { position:relative; left:0;top:0; text-align: left; zoom:1; white-space: nowrap; } .ext-strict .ext-ie8 .x-toolbar-cell .x-form-field-trigger-wrap .x-form-trigger { right: 0; /* IE8 Strict mode trigger bug */ } .x-form-field-wrap .x-form-trigger-over{ background-position:-17px 0; } .x-form-field-wrap .x-form-trigger-click{ background-position:-34px 0; } .x-trigger-wrap-focus .x-form-trigger{ background-position:-51px 0; } .x-trigger-wrap-focus .x-form-trigger-over{ background-position:-68px 0; } .x-trigger-wrap-focus .x-form-trigger-click{ background-position:-85px 0; } .x-trigger-wrap-focus .x-form-trigger{ border-bottom: 1px solid; } .x-item-disabled .x-form-trigger-over{ background-position:0 0 !important; border-bottom: 1px solid; } .x-item-disabled .x-form-trigger-click{ background-position:0 0 !important; border-bottom: 1px solid; } .x-trigger-noedit{ cursor:pointer; } /* field focus style */ .x-form-focus, textarea.x-form-focus{ border: 1px solid; } /* invalid fields */ .x-form-invalid, textarea.x-form-invalid{ background:repeat-x bottom; border: 1px solid; } .x-form-inner-invalid, textarea.x-form-inner-invalid{ background:repeat-x bottom; } /* editors */ .x-editor { visibility:hidden; padding:0; margin:0; } .x-form-grow-sizer { left: -10000px; padding: 8px 3px; position: absolute; visibility:hidden; top: -10000px; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word; zoom:1; } .x-form-grow-sizer p { margin:0 !important; border:0 none !important; padding:0 !important; } /* Form Items CSS */ .x-form-item { display:block; margin-bottom:4px; zoom:1; } .x-form-item label.x-form-item-label { display:block; float:left; width:100px; padding:3px; padding-left:0; clear:left; z-index:2; position:relative; } .x-form-element { padding-left:105px; position:relative; } .x-form-invalid-msg { padding:2px; padding-left:18px; background: transparent no-repeat 0 2px; line-height:16px; width:200px; } .x-form-label-left label.x-form-item-label { text-align:left; } .x-form-label-right label.x-form-item-label { text-align:right; } .x-form-label-top .x-form-item label.x-form-item-label { width:auto; float:none; clear:none; display:inline; margin-bottom:4px; position:static; } .x-form-label-top .x-form-element { padding-left:0; padding-top:4px; } .x-form-label-top .x-form-item { padding-bottom:4px; } /* Editor small font for grid, toolbar and tree */ .x-small-editor .x-form-text { height:20px; line-height:16px; vertical-align:middle; } .ext-ie6 .x-small-editor .x-form-text, .ext-ie7 .x-small-editor .x-form-text { margin-top:-1px !important; /* ie bogus margin bug */ margin-bottom:-1px !important; height:20px !important; /* ie quirks */ line-height:16px !important; } .ext-strict .x-small-editor .x-form-text { height:16px !important; } .ext-ie6 .x-small-editor .x-form-text, .ext-ie7 .x-small-editor .x-form-text { height:20px; line-height:16px; } .ext-border-box .x-small-editor .x-form-text { height:20px; } .x-small-editor .x-form-select-one { height:20px; line-height:16px; vertical-align:middle; } .x-small-editor .x-form-num-field { text-align:right; } .x-small-editor .x-form-field-wrap .x-form-trigger{ height:19px; } .ext-webkit .x-small-editor .x-form-text{padding-top:3px;font-size:100%;} .ext-strict .ext-webkit .x-small-editor .x-form-text{ height:14px !important; } .x-form-clear { clear:both; height:0; overflow:hidden; line-height:0; font-size:0; } .x-form-clear-left { clear:left; height:0; overflow:hidden; line-height:0; font-size:0; } .ext-ie6 .x-form-check-wrap input, .ext-border-box .x-form-check-wrap input{ margin-top: 3px; } .x-form-cb-label { position: relative; margin-left:4px; top: 2px; } .ext-ie .x-form-cb-label{ top: 1px; } .ext-ie6 .x-form-cb-label, .ext-border-box .x-form-cb-label{ top: 3px; } .x-form-display-field{ padding-top: 2px; } .ext-gecko .x-form-display-field, .ext-strict .ext-ie7 .x-form-display-field{ padding-top: 1px; } .ext-ie .x-form-display-field{ padding-top: 3px; } .ext-strict .ext-ie8 .x-form-display-field{ padding-top: 0; } .x-form-column { float:left; padding:0; margin:0; width:48%; overflow:hidden; zoom:1; } /* buttons */ .x-form .x-form-btns-ct .x-btn{ float:right; clear:none; } .x-form .x-form-btns-ct .x-form-btns td { border:0; padding:0; } .x-form .x-form-btns-ct .x-form-btns-right table{ float:right; clear:none; } .x-form .x-form-btns-ct .x-form-btns-left table{ float:left; clear:none; } .x-form .x-form-btns-ct .x-form-btns-center{ text-align:center; /*ie*/ } .x-form .x-form-btns-ct .x-form-btns-center table{ margin:0 auto; /*everyone else*/ } .x-form .x-form-btns-ct table td.x-form-btn-td{ padding:3px; } .x-form .x-form-btns-ct .x-btn-focus .x-btn-left{ background-position:0 -147px; } .x-form .x-form-btns-ct .x-btn-focus .x-btn-right{ background-position:0 -168px; } .x-form .x-form-btns-ct .x-btn-focus .x-btn-center{ background-position:0 -189px; } .x-form .x-form-btns-ct .x-btn-click .x-btn-center{ background-position:0 -126px; } .x-form .x-form-btns-ct .x-btn-click .x-btn-right{ background-position:0 -84px; } .x-form .x-form-btns-ct .x-btn-click .x-btn-left{ background-position:0 -63px; } .x-form-invalid-icon { width:16px; height:18px; visibility:hidden; position:absolute; left:0; top:0; display:block; background:transparent no-repeat 0 2px; } /* fieldsets */ .x-fieldset { border:1px solid; padding:10px; margin-bottom:10px; display:block; /* preserve margins in IE */ } /* make top of checkbox/tools visible in webkit */ .ext-webkit .x-fieldset-header { padding-top: 1px; } .ext-ie .x-fieldset legend { margin-bottom:10px; } .ext-strict .ext-ie9 .x-fieldset legend.x-fieldset-header { padding-top: 1px; } .ext-ie .x-fieldset { padding-top: 0; padding-bottom:10px; } .x-fieldset legend .x-tool-toggle { margin-right:3px; margin-left:0; float:left !important; } .x-fieldset legend input { margin-right:3px; float:left !important; height:13px; width:13px; } fieldset.x-panel-collapsed { padding-bottom:0 !important; border-width: 1px 1px 0 1px !important; border-left-color: transparent; border-right-color: transparent; } .ext-ie6 fieldset.x-panel-collapsed{ padding-bottom:0 !important; border-width: 1px 0 0 0 !important; margin-left: 1px; margin-right: 1px; } fieldset.x-panel-collapsed .x-fieldset-bwrap { visibility:hidden; position:absolute; left:-1000px; top:-1000px; } .ext-ie .x-fieldset-bwrap { zoom:1; } .x-fieldset-noborder { border:0px none transparent; } .x-fieldset-noborder legend { margin-left:-3px; } /* IE legend positioning bug */ .ext-ie .x-fieldset-noborder legend { position: relative; margin-bottom:23px; } .ext-ie .x-fieldset-noborder legend span { position: absolute; left:16px; } .ext-gecko .x-window-body .x-form-item { -moz-outline: none; outline: none; overflow: auto; } .ext-mac.ext-gecko .x-window-body .x-form-item { overflow:hidden; } .ext-gecko .x-form-item { -moz-outline: none; outline: none; } .x-hide-label label.x-form-item-label { display:none; } .x-hide-label .x-form-element { padding-left: 0 !important; } .x-form-label-top .x-hide-label label.x-form-item-label{ display: none; } .x-fieldset { overflow:hidden; } .x-fieldset-bwrap { overflow:hidden; zoom:1; } .x-fieldset-body { overflow:hidden; } .x-btn{ cursor:pointer; white-space: nowrap; } .x-btn button{ border:0 none; background-color:transparent; padding-left:3px; padding-right:3px; cursor:pointer; margin:0; overflow:visible; width:auto; -moz-outline:0 none; outline:0 none; } * html .ext-ie .x-btn button { width:1px; } .ext-gecko .x-btn button, .ext-webkit .x-btn button { padding-left:0; padding-right:0; } .ext-gecko .x-btn button::-moz-focus-inner { padding:0; } .ext-ie .x-btn button { padding-top:2px; } .x-btn td { padding:0 !important; } .x-btn-text { cursor:pointer; white-space: nowrap; padding:0; } /* icon placement and sizing styles */ /* Only text */ .x-btn-noicon .x-btn-small .x-btn-text{ height: 16px; } .x-btn-noicon .x-btn-medium .x-btn-text{ height: 24px; } .x-btn-noicon .x-btn-large .x-btn-text{ height: 32px; } /* Only icons */ .x-btn-icon .x-btn-text{ background-position: center; background-repeat: no-repeat; } .x-btn-icon .x-btn-small .x-btn-text{ height: 16px; width: 16px; } .x-btn-icon .x-btn-medium .x-btn-text{ height: 24px; width: 24px; } .x-btn-icon .x-btn-large .x-btn-text{ height: 32px; width: 32px; } /* Icons and text */ /* left */ .x-btn-text-icon .x-btn-icon-small-left .x-btn-text{ background-position: 0 center; background-repeat: no-repeat; padding-left:18px; height:16px; } .x-btn-text-icon .x-btn-icon-medium-left .x-btn-text{ background-position: 0 center; background-repeat: no-repeat; padding-left:26px; height:24px; } .x-btn-text-icon .x-btn-icon-large-left .x-btn-text{ background-position: 0 center; background-repeat: no-repeat; padding-left:34px; height:32px; } /* top */ .x-btn-text-icon .x-btn-icon-small-top .x-btn-text{ background-position: center 0; background-repeat: no-repeat; padding-top:18px; } .x-btn-text-icon .x-btn-icon-medium-top .x-btn-text{ background-position: center 0; background-repeat: no-repeat; padding-top:26px; } .x-btn-text-icon .x-btn-icon-large-top .x-btn-text{ background-position: center 0; background-repeat: no-repeat; padding-top:34px; } /* right */ .x-btn-text-icon .x-btn-icon-small-right .x-btn-text{ background-position: right center; background-repeat: no-repeat; padding-right:18px; height:16px; } .x-btn-text-icon .x-btn-icon-medium-right .x-btn-text{ background-position: right center; background-repeat: no-repeat; padding-right:26px; height:24px; } .x-btn-text-icon .x-btn-icon-large-right .x-btn-text{ background-position: right center; background-repeat: no-repeat; padding-right:34px; height:32px; } /* bottom */ .x-btn-text-icon .x-btn-icon-small-bottom .x-btn-text{ background-position: center bottom; background-repeat: no-repeat; padding-bottom:18px; } .x-btn-text-icon .x-btn-icon-medium-bottom .x-btn-text{ background-position: center bottom; background-repeat: no-repeat; padding-bottom:26px; } .x-btn-text-icon .x-btn-icon-large-bottom .x-btn-text{ background-position: center bottom; background-repeat: no-repeat; padding-bottom:34px; } /* background positioning */ .x-btn-tr i, .x-btn-tl i, .x-btn-mr i, .x-btn-ml i, .x-btn-br i, .x-btn-bl i{ font-size:1px; line-height:1px; width:3px; display:block; overflow:hidden; } .x-btn-tr i, .x-btn-tl i, .x-btn-br i, .x-btn-bl i{ height:3px; } .x-btn-tl{ width:3px; height:3px; background:no-repeat 0 0; } .x-btn-tr{ width:3px; height:3px; background:no-repeat -3px 0; } .x-btn-tc{ height:3px; background:repeat-x 0 -6px; } .x-btn-ml{ width:3px; background:no-repeat 0 -24px; } .x-btn-mr{ width:3px; background:no-repeat -3px -24px; } .x-btn-mc{ background:repeat-x 0 -1096px; vertical-align: middle; text-align:center; padding:0 5px; cursor:pointer; white-space:nowrap; } /* Fixes an issue with the button height */ .ext-strict .ext-ie6 .x-btn-mc, .ext-strict .ext-ie7 .x-btn-mc { height: 100%; } .x-btn-bl{ width:3px; height:3px; background:no-repeat 0 -3px; } .x-btn-br{ width:3px; height:3px; background:no-repeat -3px -3px; } .x-btn-bc{ height:3px; background:repeat-x 0 -15px; } .x-btn-over .x-btn-tl{ background-position: -6px 0; } .x-btn-over .x-btn-tr{ background-position: -9px 0; } .x-btn-over .x-btn-tc{ background-position: 0 -9px; } .x-btn-over .x-btn-ml{ background-position: -6px -24px; } .x-btn-over .x-btn-mr{ background-position: -9px -24px; } .x-btn-over .x-btn-mc{ background-position: 0 -2168px; } .x-btn-over .x-btn-bl{ background-position: -6px -3px; } .x-btn-over .x-btn-br{ background-position: -9px -3px; } .x-btn-over .x-btn-bc{ background-position: 0 -18px; } .x-btn-click .x-btn-tl, .x-btn-menu-active .x-btn-tl, .x-btn-pressed .x-btn-tl{ background-position: -12px 0; } .x-btn-click .x-btn-tr, .x-btn-menu-active .x-btn-tr, .x-btn-pressed .x-btn-tr{ background-position: -15px 0; } .x-btn-click .x-btn-tc, .x-btn-menu-active .x-btn-tc, .x-btn-pressed .x-btn-tc{ background-position: 0 -12px; } .x-btn-click .x-btn-ml, .x-btn-menu-active .x-btn-ml, .x-btn-pressed .x-btn-ml{ background-position: -12px -24px; } .x-btn-click .x-btn-mr, .x-btn-menu-active .x-btn-mr, .x-btn-pressed .x-btn-mr{ background-position: -15px -24px; } .x-btn-click .x-btn-mc, .x-btn-menu-active .x-btn-mc, .x-btn-pressed .x-btn-mc{ background-position: 0 -3240px; } .x-btn-click .x-btn-bl, .x-btn-menu-active .x-btn-bl, .x-btn-pressed .x-btn-bl{ background-position: -12px -3px; } .x-btn-click .x-btn-br, .x-btn-menu-active .x-btn-br, .x-btn-pressed .x-btn-br{ background-position: -15px -3px; } .x-btn-click .x-btn-bc, .x-btn-menu-active .x-btn-bc, .x-btn-pressed .x-btn-bc{ background-position: 0 -21px; } .x-btn-disabled *{ cursor:default !important; } /* With a menu arrow */ /* right */ .x-btn-mc em.x-btn-arrow { display:block; background:transparent no-repeat right center; padding-right:10px; } .x-btn-mc em.x-btn-split { display:block; background:transparent no-repeat right center; padding-right:14px; } /* bottom */ .x-btn-mc em.x-btn-arrow-bottom { display:block; background:transparent no-repeat center bottom; padding-bottom:14px; } .x-btn-mc em.x-btn-split-bottom { display:block; background:transparent no-repeat center bottom; padding-bottom:14px; } /* height adjustment class */ .x-btn-as-arrow .x-btn-mc em { display:block; background-color:transparent; padding-bottom:14px; } /* groups */ .x-btn-group { padding:1px; } .x-btn-group-header { padding:2px; text-align:center; } .x-btn-group-tc { background: transparent repeat-x 0 0; overflow:hidden; } .x-btn-group-tl { background: transparent no-repeat 0 0; padding-left:3px; zoom:1; } .x-btn-group-tr { background: transparent no-repeat right 0; zoom:1; padding-right:3px; } .x-btn-group-bc { background: transparent repeat-x 0 bottom; zoom:1; } .x-btn-group-bc .x-panel-footer { zoom:1; } .x-btn-group-bl { background: transparent no-repeat 0 bottom; padding-left:3px; zoom:1; } .x-btn-group-br { background: transparent no-repeat right bottom; padding-right:3px; zoom:1; } .x-btn-group-mc { border:0 none; padding:1px 0 0 0; margin:0; } .x-btn-group-mc .x-btn-group-body { background-color:transparent; border: 0 none; } .x-btn-group-ml { background: transparent repeat-y 0 0; padding-left:3px; zoom:1; } .x-btn-group-mr { background: transparent repeat-y right 0; padding-right:3px; zoom:1; } .x-btn-group-bc .x-btn-group-footer { padding-bottom:6px; } .x-panel-nofooter .x-btn-group-bc { height:3px; font-size:0; line-height:0; } .x-btn-group-bwrap { overflow:hidden; zoom:1; } .x-btn-group-body { overflow:hidden; zoom:1; } .x-btn-group-notitle .x-btn-group-tc { background: transparent repeat-x 0 0; overflow:hidden; height:2px; }.x-toolbar{ border-style:solid; border-width:0 0 1px 0; display: block; padding:2px; background:repeat-x top left; position:relative; left:0; top:0; zoom:1; overflow:hidden; } .x-toolbar-left { width: 100%; } .x-toolbar .x-item-disabled .x-btn-icon { opacity: .35; -moz-opacity: .35; filter: alpha(opacity=35); } .x-toolbar td { vertical-align:middle; } .x-toolbar td,.x-toolbar span,.x-toolbar input,.x-toolbar div,.x-toolbar select,.x-toolbar label{ white-space: nowrap; } .x-toolbar .x-item-disabled { cursor:default; opacity:.6; -moz-opacity:.6; filter:alpha(opacity=60); } .x-toolbar .x-item-disabled * { cursor:default; } .x-toolbar .x-toolbar-cell { vertical-align:middle; } .x-toolbar .x-btn-tl, .x-toolbar .x-btn-tr, .x-toolbar .x-btn-tc, .x-toolbar .x-btn-ml, .x-toolbar .x-btn-mr, .x-toolbar .x-btn-mc, .x-toolbar .x-btn-bl, .x-toolbar .x-btn-br, .x-toolbar .x-btn-bc { background-position: 500px 500px; } /* These rules are duplicated from button.css to give priority of x-toolbar rules above */ .x-toolbar .x-btn-over .x-btn-tl{ background-position: -6px 0; } .x-toolbar .x-btn-over .x-btn-tr{ background-position: -9px 0; } .x-toolbar .x-btn-over .x-btn-tc{ background-position: 0 -9px; } .x-toolbar .x-btn-over .x-btn-ml{ background-position: -6px -24px; } .x-toolbar .x-btn-over .x-btn-mr{ background-position: -9px -24px; } .x-toolbar .x-btn-over .x-btn-mc{ background-position: 0 -2168px; } .x-toolbar .x-btn-over .x-btn-bl{ background-position: -6px -3px; } .x-toolbar .x-btn-over .x-btn-br{ background-position: -9px -3px; } .x-toolbar .x-btn-over .x-btn-bc{ background-position: 0 -18px; } .x-toolbar .x-btn-click .x-btn-tl, .x-toolbar .x-btn-menu-active .x-btn-tl, .x-toolbar .x-btn-pressed .x-btn-tl{ background-position: -12px 0; } .x-toolbar .x-btn-click .x-btn-tr, .x-toolbar .x-btn-menu-active .x-btn-tr, .x-toolbar .x-btn-pressed .x-btn-tr{ background-position: -15px 0; } .x-toolbar .x-btn-click .x-btn-tc, .x-toolbar .x-btn-menu-active .x-btn-tc, .x-toolbar .x-btn-pressed .x-btn-tc{ background-position: 0 -12px; } .x-toolbar .x-btn-click .x-btn-ml, .x-toolbar .x-btn-menu-active .x-btn-ml, .x-toolbar .x-btn-pressed .x-btn-ml{ background-position: -12px -24px; } .x-toolbar .x-btn-click .x-btn-mr, .x-toolbar .x-btn-menu-active .x-btn-mr, .x-toolbar .x-btn-pressed .x-btn-mr{ background-position: -15px -24px; } .x-toolbar .x-btn-click .x-btn-mc, .x-toolbar .x-btn-menu-active .x-btn-mc, .x-toolbar .x-btn-pressed .x-btn-mc{ background-position: 0 -3240px; } .x-toolbar .x-btn-click .x-btn-bl, .x-toolbar .x-btn-menu-active .x-btn-bl, .x-toolbar .x-btn-pressed .x-btn-bl{ background-position: -12px -3px; } .x-toolbar .x-btn-click .x-btn-br, .x-toolbar .x-btn-menu-active .x-btn-br, .x-toolbar .x-btn-pressed .x-btn-br{ background-position: -15px -3px; } .x-toolbar .x-btn-click .x-btn-bc, .x-toolbar .x-btn-menu-active .x-btn-bc, .x-toolbar .x-btn-pressed .x-btn-bc{ background-position: 0 -21px; } .x-toolbar div.xtb-text{ padding:2px 2px 0; line-height:16px; display:block; } .x-toolbar .xtb-sep { background-position: center; background-repeat: no-repeat; display: block; font-size: 1px; height: 16px; width:4px; overflow: hidden; cursor:default; margin: 0 2px 0; border:0; } .x-toolbar .xtb-spacer { width:2px; } /* Paging Toolbar */ .x-tbar-page-number{ width:30px; height:14px; } .ext-ie .x-tbar-page-number{ margin-top: 2px; } .x-paging-info { position:absolute; top:5px; right: 8px; } /* floating */ .x-toolbar-ct { width:100%; } .x-toolbar-right td { text-align: center; } .x-panel-tbar, .x-panel-bbar, .x-window-tbar, .x-window-bbar, .x-tab-panel-tbar, .x-tab-panel-bbar, .x-plain-tbar, .x-plain-bbar { overflow:hidden; zoom:1; } .x-toolbar-more .x-btn-small .x-btn-text{ height: 16px; width: 12px; } .x-toolbar-more em.x-btn-arrow { display:inline; background-color:transparent; padding-right:0; } .x-toolbar-more .x-btn-mc em.x-btn-arrow { background-image: none; } div.x-toolbar-no-items { color:gray !important; padding:5px 10px !important; } /* fix ie toolbar form items */ .ext-border-box .x-toolbar-cell .x-form-text { margin-bottom:-1px !important; } .ext-border-box .x-toolbar-cell .x-form-field-wrap .x-form-text { margin:0 !important; } .ext-ie .x-toolbar-cell .x-form-field-wrap { height:21px; } .ext-ie .x-toolbar-cell .x-form-text { position:relative; top:-1px; } .ext-strict .ext-ie8 .x-toolbar-cell .x-form-field-trigger-wrap .x-form-text, .ext-strict .ext-ie .x-toolbar-cell .x-form-text { top: 0px; } .x-toolbar-right td .x-form-field-trigger-wrap{ text-align: left; } .x-toolbar-cell .x-form-checkbox, .x-toolbar-cell .x-form-radio{ margin-top: 5px; } .x-toolbar-cell .x-form-cb-label{ vertical-align: bottom; top: 1px; } .ext-ie .x-toolbar-cell .x-form-checkbox, .ext-ie .x-toolbar-cell .x-form-radio{ margin-top: 4px; } .ext-ie .x-toolbar-cell .x-form-cb-label{ top: 0; } /* Grid3 styles */ .x-grid3 { position:relative; overflow:hidden; } .x-grid-panel .x-panel-body { overflow:hidden !important; } .x-grid-panel .x-panel-mc .x-panel-body { border:1px solid; } .x-grid3 table { table-layout:fixed; } .x-grid3-viewport{ overflow:hidden; } .x-grid3-hd-row td, .x-grid3-row td, .x-grid3-summary-row td{ -moz-outline: none; outline: none; -moz-user-focus: normal; } .x-grid3-row td, .x-grid3-summary-row td { line-height:13px; vertical-align: top; padding-left:1px; padding-right:1px; -moz-user-select: none; -khtml-user-select:none; -webkit-user-select:ignore; } .x-grid3-cell{ -moz-user-select: none; -khtml-user-select:none; -webkit-user-select:ignore; } .x-grid3-hd-row td { line-height:15px; vertical-align:middle; border-left:1px solid; border-right:1px solid; } .x-grid3-hd-row .x-grid3-marker-hd { padding:3px; } .x-grid3-row .x-grid3-marker { padding:3px; } .x-grid3-cell-inner, .x-grid3-hd-inner{ overflow:hidden; -o-text-overflow: ellipsis; text-overflow: ellipsis; padding:3px 3px 3px 5px; white-space: nowrap; } /* ActionColumn, reduce padding to accommodate 16x16 icons in normal row height */ .x-action-col-cell .x-grid3-cell-inner { padding-top: 1px; padding-bottom: 1px; } .x-action-col-icon { cursor: pointer; } .x-grid3-hd-inner { position:relative; cursor:inherit; padding:4px 3px 4px 5px; } .x-grid3-row-body { white-space:normal; } .x-grid3-body-cell { -moz-outline:0 none; outline:0 none; } /* IE Quirks to clip */ .ext-ie .x-grid3-cell-inner, .ext-ie .x-grid3-hd-inner{ width:100%; } /* reverse above in strict mode */ .ext-strict .x-grid3-cell-inner, .ext-strict .x-grid3-hd-inner{ width:auto; } .x-grid-row-loading { background: no-repeat center center; } .x-grid-page { overflow:hidden; } .x-grid3-row { cursor: default; border: 1px solid; width:100%; } .x-grid3-row-over { border:1px solid; background: repeat-x left top; } .x-grid3-resize-proxy { width:1px; left:0; cursor: e-resize; cursor: col-resize; position:absolute; top:0; height:100px; overflow:hidden; visibility:hidden; border:0 none; z-index:7; } .x-grid3-resize-marker { width:1px; left:0; position:absolute; top:0; height:100px; overflow:hidden; visibility:hidden; border:0 none; z-index:7; } .x-grid3-focus { position:absolute; left:0; top:0; width:1px; height:1px; line-height:1px; font-size:1px; -moz-outline:0 none; outline:0 none; -moz-user-select: text; -khtml-user-select: text; -webkit-user-select:ignore; } /* header styles */ .x-grid3-header{ background: repeat-x 0 bottom; cursor:default; zoom:1; padding:1px 0 0 0; } .x-grid3-header-pop { border-left:1px solid; float:right; clear:none; } .x-grid3-header-pop-inner { border-left:1px solid; width:14px; height:19px; background: transparent no-repeat center center; } .ext-ie .x-grid3-header-pop-inner { width:15px; } .ext-strict .x-grid3-header-pop-inner { width:14px; } .x-grid3-header-inner { overflow:hidden; zoom:1; float:left; } .x-grid3-header-offset { padding-left:1px; text-align: left; } td.x-grid3-hd-over, td.sort-desc, td.sort-asc, td.x-grid3-hd-menu-open { border-left:1px solid; border-right:1px solid; } td.x-grid3-hd-over .x-grid3-hd-inner, td.sort-desc .x-grid3-hd-inner, td.sort-asc .x-grid3-hd-inner, td.x-grid3-hd-menu-open .x-grid3-hd-inner { background: repeat-x left bottom; } .x-grid3-sort-icon{ background-repeat: no-repeat; display: none; height: 4px; width: 13px; margin-left:3px; vertical-align: middle; } .sort-asc .x-grid3-sort-icon, .sort-desc .x-grid3-sort-icon { display: inline; } /* Header position fixes for IE strict mode */ .ext-strict .ext-ie .x-grid3-header-inner, .ext-strict .ext-ie6 .x-grid3-hd { position:relative; } .ext-strict .ext-ie6 .x-grid3-hd-inner{ position:static; } /* Body Styles */ .x-grid3-body { zoom:1; } .x-grid3-scroller { overflow:auto; zoom:1; position:relative; } .x-grid3-cell-text, .x-grid3-hd-text { display: block; padding: 3px 5px 3px 5px; -moz-user-select: none; -khtml-user-select: none; -webkit-user-select:ignore; } .x-grid3-split { background-position: center; background-repeat: no-repeat; cursor: e-resize; cursor: col-resize; display: block; font-size: 1px; height: 16px; overflow: hidden; position: absolute; top: 2px; width: 6px; z-index: 3; } /* Column Reorder DD */ .x-dd-drag-proxy .x-grid3-hd-inner{ background: repeat-x left bottom; width:120px; padding:3px; border:1px solid; overflow:hidden; } .col-move-top, .col-move-bottom{ width:9px; height:9px; position:absolute; top:0; line-height:1px; font-size:1px; overflow:hidden; visibility:hidden; z-index:20000; background:transparent no-repeat left top; } /* Selection Styles */ .x-grid3-row-selected { border:1px dotted; } .x-grid3-locked td.x-grid3-row-marker, .x-grid3-locked .x-grid3-row-selected td.x-grid3-row-marker{ background: repeat-x 0 bottom !important; vertical-align:middle !important; padding:0; border-top:1px solid; border-bottom:none !important; border-right:1px solid !important; text-align:center; } .x-grid3-locked td.x-grid3-row-marker div, .x-grid3-locked .x-grid3-row-selected td.x-grid3-row-marker div{ padding:0 4px; text-align:center; } /* dirty cells */ .x-grid3-dirty-cell { background: transparent no-repeat 0 0; } /* Grid Toolbars */ .x-grid3-topbar, .x-grid3-bottombar{ overflow:hidden; display:none; zoom:1; position:relative; } .x-grid3-topbar .x-toolbar{ border-right:0 none; } .x-grid3-bottombar .x-toolbar{ border-right:0 none; border-bottom:0 none; border-top:1px solid; } /* Props Grid Styles */ .x-props-grid .x-grid3-cell{ padding:1px; } .x-props-grid .x-grid3-td-name .x-grid3-cell-inner{ background:transparent repeat-y -16px !important; padding-left:12px; } .x-props-grid .x-grid3-body .x-grid3-td-name{ padding:1px; padding-right:0; border:0 none; border-right:1px solid; } /* dd */ .x-grid3-col-dd { border:0 none; padding:0; background-color:transparent; } .x-dd-drag-ghost .x-grid3-dd-wrap { padding:1px 3px 3px 1px; } .x-grid3-hd { -moz-user-select:none; -khtml-user-select:none; -webkit-user-select:ignore; } .x-grid3-hd-btn { display:none; position:absolute; width:14px; background:no-repeat left center; right:0; top:0; z-index:2; cursor:pointer; } .x-grid3-hd-over .x-grid3-hd-btn, .x-grid3-hd-menu-open .x-grid3-hd-btn { display:block; } a.x-grid3-hd-btn:hover { background-position:-14px center; } /* Expanders */ .x-grid3-body .x-grid3-td-expander { background:transparent repeat-y right; } .x-grid3-body .x-grid3-td-expander .x-grid3-cell-inner { padding:0 !important; height:100%; } .x-grid3-row-expander { width:100%; height:18px; background-position:4px 2px; background-repeat:no-repeat; background-color:transparent; } .x-grid3-row-collapsed .x-grid3-row-expander { background-position:4px 2px; } .x-grid3-row-expanded .x-grid3-row-expander { background-position:-21px 2px; } .x-grid3-row-collapsed .x-grid3-row-body { display:none !important; } .x-grid3-row-expanded .x-grid3-row-body { display:block !important; } /* Checkers */ .x-grid3-body .x-grid3-td-checker { background:transparent repeat-y right; } .x-grid3-body .x-grid3-td-checker .x-grid3-cell-inner, .x-grid3-header .x-grid3-td-checker .x-grid3-hd-inner { padding:0 !important; height:100%; } .x-grid3-row-checker, .x-grid3-hd-checker { width:100%; height:18px; background-position:2px 2px; background-repeat:no-repeat; background-color:transparent; } .x-grid3-row .x-grid3-row-checker { background-position:2px 2px; } .x-grid3-row-selected .x-grid3-row-checker, .x-grid3-hd-checker-on .x-grid3-hd-checker,.x-grid3-row-checked .x-grid3-row-checker { background-position:-23px 2px; } .x-grid3-hd-checker { background-position:2px 1px; } .ext-border-box .x-grid3-hd-checker { background-position:2px 3px; } .x-grid3-hd-checker-on .x-grid3-hd-checker { background-position:-23px 1px; } .ext-border-box .x-grid3-hd-checker-on .x-grid3-hd-checker { background-position:-23px 3px; } /* Numberer */ .x-grid3-body .x-grid3-td-numberer { background:transparent repeat-y right; } .x-grid3-body .x-grid3-td-numberer .x-grid3-cell-inner { padding:3px 5px 0 0 !important; text-align:right; } /* Row Icon */ .x-grid3-body .x-grid3-td-row-icon { background:transparent repeat-y right; vertical-align:top; text-align:center; } .x-grid3-body .x-grid3-td-row-icon .x-grid3-cell-inner { padding:0 !important; background-position:center center; background-repeat:no-repeat; width:16px; height:16px; margin-left:2px; margin-top:3px; } /* All specials */ .x-grid3-body .x-grid3-row-selected .x-grid3-td-numberer, .x-grid3-body .x-grid3-row-selected .x-grid3-td-checker, .x-grid3-body .x-grid3-row-selected .x-grid3-td-expander { background:transparent repeat-y right; } .x-grid3-body .x-grid3-check-col-td .x-grid3-cell-inner { padding: 1px 0 0 0 !important; } .x-grid3-check-col { width:100%; height:16px; background-position:center center; background-repeat:no-repeat; background-color:transparent; } .x-grid3-check-col-on { width:100%; height:16px; background-position:center center; background-repeat:no-repeat; background-color:transparent; } /* Grouping classes */ .x-grid-group, .x-grid-group-body, .x-grid-group-hd { zoom:1; } .x-grid-group-hd { border-bottom: 2px solid; cursor:pointer; padding-top:6px; } .x-grid-group-hd div.x-grid-group-title { background:transparent no-repeat 3px 3px; padding:4px 4px 4px 17px; } .x-grid-group-collapsed .x-grid-group-body { display:none; } .ext-ie6 .x-grid3 .x-editor .x-form-text, .ext-ie7 .x-grid3 .x-editor .x-form-text { position:relative; top:-1px; } .ext-ie .x-props-grid .x-editor .x-form-text { position:static; top:0; } .x-grid-empty { padding:10px; } /* fix floating toolbar issue */ .ext-ie7 .x-grid-panel .x-panel-bbar { position:relative; } /* Reset position to static when Grid Panel has been framed */ /* to resolve 'snapping' from top to bottom behavior. */ /* @forumThread 86656 */ .ext-ie7 .x-grid-panel .x-panel-mc .x-panel-bbar { position: static; } .ext-ie6 .x-grid3-header { position: relative; } /* Fix WebKit bug in Grids */ .ext-webkit .x-grid-panel .x-panel-bwrap{ -webkit-user-select:none; } .ext-webkit .x-tbar-page-number{ -webkit-user-select:ignore; } /* end*/ /* column lines */ .x-grid-with-col-lines .x-grid3-row td.x-grid3-cell { padding-right:0; border-right:1px solid; } .x-pivotgrid .x-grid3-header-offset table { width: 100%; border-collapse: collapse; } .x-pivotgrid .x-grid3-header-offset table td { padding: 4px 3px 4px 5px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 11px; line-height: 13px; font-family: tahoma; } .x-pivotgrid .x-grid3-row-headers { display: block; float: left; } .x-pivotgrid .x-grid3-row-headers table { height: 100%; width: 100%; border-collapse: collapse; } .x-pivotgrid .x-grid3-row-headers table td { height: 18px; padding: 2px 7px 0 0; text-align: right; text-overflow: ellipsis; font-size: 11px; font-family: tahoma; } .ext-gecko .x-pivotgrid .x-grid3-row-headers table td { height: 21px; } .x-grid3-header-title { top: 0%; left: 0%; position: absolute; text-align: center; vertical-align: middle; font-family: tahoma; font-size: 11px; padding: auto 1px; display: table-cell; } .x-grid3-header-title span { position: absolute; top: 50%; left: 0%; width: 100%; margin-top: -6px; }.x-dd-drag-proxy{ position:absolute; left:0; top:0; visibility:hidden; z-index:15000; } .x-dd-drag-ghost{ -moz-opacity: 0.85; opacity:.85; filter: alpha(opacity=85); border: 1px solid; padding:3px; padding-left:20px; white-space:nowrap; } .x-dd-drag-repair .x-dd-drag-ghost{ -moz-opacity: 0.4; opacity:.4; filter: alpha(opacity=40); border:0 none; padding:0; background-color:transparent; } .x-dd-drag-repair .x-dd-drop-icon{ visibility:hidden; } .x-dd-drop-icon{ position:absolute; top:3px; left:3px; display:block; width:16px; height:16px; background-color:transparent; background-position: center; background-repeat: no-repeat; z-index:1; } .x-view-selector { position:absolute; left:0; top:0; width:0; border:1px dotted; opacity: .5; -moz-opacity: .5; filter:alpha(opacity=50); zoom:1; }.ext-strict .ext-ie .x-tree .x-panel-bwrap{ position:relative; overflow:hidden; } .x-tree-icon, .x-tree-ec-icon, .x-tree-elbow-line, .x-tree-elbow, .x-tree-elbow-end, .x-tree-elbow-plus, .x-tree-elbow-minus, .x-tree-elbow-end-plus, .x-tree-elbow-end-minus{ border: 0 none; height: 18px; margin: 0; padding: 0; vertical-align: top; width: 16px; background-repeat: no-repeat; } .x-tree-node-collapsed .x-tree-node-icon, .x-tree-node-expanded .x-tree-node-icon, .x-tree-node-leaf .x-tree-node-icon{ border: 0 none; height: 18px; margin: 0; padding: 0; vertical-align: top; width: 16px; background-position:center; background-repeat: no-repeat; } .ext-ie .x-tree-node-indent img, .ext-ie .x-tree-node-icon, .ext-ie .x-tree-ec-icon { vertical-align: middle !important; } .ext-strict .ext-ie8 .x-tree-node-indent img, .ext-strict .ext-ie8 .x-tree-node-icon, .ext-strict .ext-ie8 .x-tree-ec-icon { vertical-align: top !important; } /* checkboxes */ input.x-tree-node-cb { margin-left:1px; height: 19px; vertical-align: bottom; } .ext-ie input.x-tree-node-cb { margin-left:0; margin-top: 1px; width: 16px; height: 16px; vertical-align: middle; } .ext-strict .ext-ie8 input.x-tree-node-cb{ margin: 1px 1px; height: 14px; vertical-align: bottom; } .ext-strict .ext-ie8 input.x-tree-node-cb + a{ vertical-align: bottom; } .ext-opera input.x-tree-node-cb { height: 14px; vertical-align: middle; } .x-tree-noicon .x-tree-node-icon{ width:0; height:0; } /* No line styles */ .x-tree-no-lines .x-tree-elbow{ background-color:transparent; } .x-tree-no-lines .x-tree-elbow-end{ background-color:transparent; } .x-tree-no-lines .x-tree-elbow-line{ background-color:transparent; } /* Arrows */ .x-tree-arrows .x-tree-elbow{ background-color:transparent; } .x-tree-arrows .x-tree-elbow-plus{ background:transparent no-repeat 0 0; } .x-tree-arrows .x-tree-elbow-minus{ background:transparent no-repeat -16px 0; } .x-tree-arrows .x-tree-elbow-end{ background-color:transparent; } .x-tree-arrows .x-tree-elbow-end-plus{ background:transparent no-repeat 0 0; } .x-tree-arrows .x-tree-elbow-end-minus{ background:transparent no-repeat -16px 0; } .x-tree-arrows .x-tree-elbow-line{ background-color:transparent; } .x-tree-arrows .x-tree-ec-over .x-tree-elbow-plus{ background-position:-32px 0; } .x-tree-arrows .x-tree-ec-over .x-tree-elbow-minus{ background-position:-48px 0; } .x-tree-arrows .x-tree-ec-over .x-tree-elbow-end-plus{ background-position:-32px 0; } .x-tree-arrows .x-tree-ec-over .x-tree-elbow-end-minus{ background-position:-48px 0; } .x-tree-elbow-plus, .x-tree-elbow-minus, .x-tree-elbow-end-plus, .x-tree-elbow-end-minus{ cursor:pointer; } .ext-ie ul.x-tree-node-ct{ font-size:0; line-height:0; zoom:1; } .x-tree-node{ white-space: nowrap; } .x-tree-node-el { line-height:18px; cursor:pointer; } .x-tree-node a, .x-dd-drag-ghost a{ text-decoration:none; -khtml-user-select:none; -moz-user-select:none; -webkit-user-select:ignore; -kthml-user-focus:normal; -moz-user-focus:normal; -moz-outline: 0 none; outline:0 none; } .x-tree-node a span, .x-dd-drag-ghost a span{ text-decoration:none; padding:1px 3px 1px 2px; } .x-tree-node .x-tree-node-disabled .x-tree-node-icon{ -moz-opacity: 0.5; opacity:.5; filter: alpha(opacity=50); } .x-tree-node .x-tree-node-inline-icon{ background-color:transparent; } .x-tree-node a:hover, .x-dd-drag-ghost a:hover{ text-decoration:none; } .x-tree-node div.x-tree-drag-insert-below{ border-bottom:1px dotted; } .x-tree-node div.x-tree-drag-insert-above{ border-top:1px dotted; } .x-tree-dd-underline .x-tree-node div.x-tree-drag-insert-below{ border-bottom:0 none; } .x-tree-dd-underline .x-tree-node div.x-tree-drag-insert-above{ border-top:0 none; } .x-tree-dd-underline .x-tree-node div.x-tree-drag-insert-below a{ border-bottom:2px solid; } .x-tree-dd-underline .x-tree-node div.x-tree-drag-insert-above a{ border-top:2px solid; } .x-tree-node .x-tree-drag-append a span{ border:1px dotted; } .x-dd-drag-ghost .x-tree-node-indent, .x-dd-drag-ghost .x-tree-ec-icon{ display:none !important; } /* Fix for ie rootVisible:false issue */ .x-tree-root-ct { zoom:1; } .x-date-picker { border: 1px solid; border-top:0 none; position:relative; } .x-date-picker a { -moz-outline:0 none; outline:0 none; } .x-date-inner, .x-date-inner td, .x-date-inner th{ border-collapse:separate; } .x-date-middle,.x-date-left,.x-date-right { background: repeat-x 0 -83px; overflow:hidden; } .x-date-middle .x-btn-tc,.x-date-middle .x-btn-tl,.x-date-middle .x-btn-tr, .x-date-middle .x-btn-mc,.x-date-middle .x-btn-ml,.x-date-middle .x-btn-mr, .x-date-middle .x-btn-bc,.x-date-middle .x-btn-bl,.x-date-middle .x-btn-br{ background:transparent !important; vertical-align:middle; } .x-date-middle .x-btn-mc em.x-btn-arrow { background:transparent no-repeat right 0; } .x-date-right, .x-date-left { width:18px; } .x-date-right{ text-align:right; } .x-date-middle { padding-top:2px; padding-bottom:2px; width:130px; /* FF3 */ } .x-date-right a, .x-date-left a{ display:block; width:16px; height:16px; background-position: center; background-repeat: no-repeat; cursor:pointer; -moz-opacity: 0.6; opacity:.6; filter: alpha(opacity=60); } .x-date-right a:hover, .x-date-left a:hover{ -moz-opacity: 1; opacity:1; filter: alpha(opacity=100); } .x-item-disabled .x-date-right a:hover, .x-item-disabled .x-date-left a:hover{ -moz-opacity: 0.6; opacity:.6; filter: alpha(opacity=60); } .x-date-right a { margin-right:2px; text-decoration:none !important; } .x-date-left a{ margin-left:2px; text-decoration:none !important; } table.x-date-inner { width: 100%; table-layout:fixed; } .ext-webkit table.x-date-inner{ /* Fix for webkit browsers */ width: 175px; } .x-date-inner th { width:25px; } .x-date-inner th { background: repeat-x left top; text-align:right !important; border-bottom: 1px solid; cursor:default; padding:0; border-collapse:separate; } .x-date-inner th span { display:block; padding:2px; padding-right:7px; } .x-date-inner td { border: 1px solid; text-align:right; padding:0; } .x-date-inner a { padding:2px 5px; display:block; text-decoration:none; text-align:right; zoom:1; } .x-date-inner .x-date-active{ cursor:pointer; color:black; } .x-date-inner .x-date-selected a{ background: repeat-x left top; border:1px solid; padding:1px 4px; } .x-date-inner .x-date-today a{ border: 1px solid; padding:1px 4px; } .x-date-inner .x-date-prevday a,.x-date-inner .x-date-nextday a { text-decoration:none !important; } .x-date-bottom { padding:4px; border-top: 1px solid; background: repeat-x left top; } .x-date-inner a:hover, .x-date-inner .x-date-disabled a:hover{ text-decoration:none !important; } .x-item-disabled .x-date-inner a:hover{ background: none; } .x-date-inner .x-date-disabled a { cursor:default; } .x-date-menu .x-menu-item { padding:1px 24px 1px 4px; white-space: nowrap; } .x-date-menu .x-menu-item .x-menu-item-icon { width:10px; height:10px; margin-right:5px; background-position:center -4px !important; } .x-date-mp { position:absolute; left:0; top:0; display:none; } .x-date-mp td { padding:2px; font:normal 11px arial, helvetica,tahoma,sans-serif; } td.x-date-mp-month,td.x-date-mp-year,td.x-date-mp-ybtn { border: 0 none; text-align:center; vertical-align: middle; width:25%; } .x-date-mp-ok { margin-right:3px; } .x-date-mp-btns button { text-decoration:none; text-align:center; text-decoration:none !important; border:1px solid; padding:1px 3px 1px; cursor:pointer; } .x-date-mp-btns { background: repeat-x left top; } .x-date-mp-btns td { border-top: 1px solid; text-align:center; } td.x-date-mp-month a,td.x-date-mp-year a { display:block; padding:2px 4px; text-decoration:none; text-align:center; } td.x-date-mp-month a:hover,td.x-date-mp-year a:hover { text-decoration:none; cursor:pointer; } td.x-date-mp-sel a { padding:1px 3px; background: repeat-x left top; border:1px solid; } .x-date-mp-ybtn a { overflow:hidden; width:15px; height:15px; cursor:pointer; background:transparent no-repeat; display:block; margin:0 auto; } .x-date-mp-ybtn a.x-date-mp-next { background-position:0 -120px; } .x-date-mp-ybtn a.x-date-mp-next:hover { background-position:-15px -120px; } .x-date-mp-ybtn a.x-date-mp-prev { background-position:0 -105px; } .x-date-mp-ybtn a.x-date-mp-prev:hover { background-position:-15px -105px; } .x-date-mp-ybtn { text-align:center; } td.x-date-mp-sep { border-right:1px solid; }.x-tip{ position: absolute; top: 0; left:0; visibility: hidden; z-index: 20002; border:0 none; } .x-tip .x-tip-close{ height: 15px; float:right; width: 15px; margin:0 0 2px 2px; cursor:pointer; display:none; } .x-tip .x-tip-tc { background: transparent no-repeat 0 -62px; padding-top:3px; overflow:hidden; zoom:1; } .x-tip .x-tip-tl { background: transparent no-repeat 0 0; padding-left:6px; overflow:hidden; zoom:1; } .x-tip .x-tip-tr { background: transparent no-repeat right 0; padding-right:6px; overflow:hidden; zoom:1; } .x-tip .x-tip-bc { background: transparent no-repeat 0 -121px; height:3px; overflow:hidden; } .x-tip .x-tip-bl { background: transparent no-repeat 0 -59px; padding-left:6px; zoom:1; } .x-tip .x-tip-br { background: transparent no-repeat right -59px; padding-right:6px; zoom:1; } .x-tip .x-tip-mc { border:0 none; } .x-tip .x-tip-ml { background: no-repeat 0 -124px; padding-left:6px; zoom:1; } .x-tip .x-tip-mr { background: transparent no-repeat right -124px; padding-right:6px; zoom:1; } .ext-ie .x-tip .x-tip-header,.ext-ie .x-tip .x-tip-tc { font-size:0; line-height:0; } .ext-border-box .x-tip .x-tip-header, .ext-border-box .x-tip .x-tip-tc{ line-height: 1px; } .x-tip .x-tip-header-text { padding:0; margin:0 0 2px 0; } .x-tip .x-tip-body { margin:0 !important; line-height:14px; padding:0; } .x-tip .x-tip-body .loading-indicator { margin:0; } .x-tip-draggable .x-tip-header,.x-tip-draggable .x-tip-header-text { cursor:move; } .x-form-invalid-tip .x-tip-tc { background: repeat-x 0 -12px; padding-top:6px; } .x-form-invalid-tip .x-tip-bc { background: repeat-x 0 -18px; height:6px; } .x-form-invalid-tip .x-tip-bl { background: no-repeat 0 -6px; } .x-form-invalid-tip .x-tip-br { background: no-repeat right -6px; } .x-form-invalid-tip .x-tip-body { padding:2px; } .x-form-invalid-tip .x-tip-body { padding-left:24px; background:transparent no-repeat 2px 2px; } .x-tip-anchor { position: absolute; width: 9px; height: 10px; overflow:hidden; background: transparent no-repeat 0 0; zoom:1; } .x-tip-anchor-bottom { background-position: -9px 0; } .x-tip-anchor-right { background-position: -18px 0; width: 10px; } .x-tip-anchor-left { background-position: -28px 0; width: 10px; }.x-menu { z-index: 15000; zoom: 1; background: repeat-y; } .x-menu-floating{ border: 1px solid; } .x-menu a { text-decoration: none !important; } .ext-ie .x-menu { zoom:1; overflow:hidden; } .x-menu-list{ padding: 2px; background-color:transparent; border:0 none; overflow:hidden; overflow-y: hidden; } .ext-strict .ext-ie .x-menu-list{ position: relative; } .x-menu li{ line-height:100%; } .x-menu li.x-menu-sep-li{ font-size:1px; line-height:1px; } .x-menu-list-item{ white-space: nowrap; display:block; padding:1px; } .x-menu-item{ -moz-user-select: none; -khtml-user-select:none; -webkit-user-select:ignore; } .x-menu-item-arrow{ background:transparent no-repeat right; } .x-menu-sep { display:block; font-size:1px; line-height:1px; margin: 2px 3px; border-bottom:1px solid; overflow:hidden; } .x-menu-focus { position:absolute; left:-1px; top:-1px; width:1px; height:1px; line-height:1px; font-size:1px; -moz-outline:0 none; outline:0 none; -moz-user-select: none; -khtml-user-select:none; -webkit-user-select:ignore; overflow:hidden; display:block; } a.x-menu-item { cursor: pointer; display: block; line-height: 16px; outline-color: -moz-use-text-color; outline-style: none; outline-width: 0; padding: 3px 21px 3px 27px; position: relative; text-decoration: none; white-space: nowrap; } .x-menu-item-active { background-repeat: repeat-x; background-position: left bottom; border-style:solid; border-width: 1px 0; margin:0 1px; padding: 0; } .x-menu-item-active a.x-menu-item { border-style:solid; border-width:0 1px; margin:0 -1px; } .x-menu-item-icon { border: 0 none; height: 16px; padding: 0; vertical-align: top; width: 16px; position: absolute; left: 3px; top: 3px; margin: 0; background-position:center; } .ext-ie .x-menu-item-icon { left: -24px; } .ext-strict .x-menu-item-icon { left: 3px; } .ext-ie6 .x-menu-item-icon { left: -24px; } .ext-ie .x-menu-item-icon { vertical-align: middle; } .x-menu-check-item .x-menu-item-icon{ background: transparent no-repeat center; } .x-menu-group-item .x-menu-item-icon{ background-color: transparent; } .x-menu-item-checked .x-menu-group-item .x-menu-item-icon{ background: transparent no-repeat center; } .x-date-menu .x-menu-list{ padding: 0; } .x-menu-date-item{ padding:0; } .x-menu .x-color-palette, .x-menu .x-date-picker{ margin-left: 26px; margin-right:4px; } .x-menu .x-date-picker{ border:1px solid; margin-top:2px; margin-bottom:2px; } .x-menu-plain .x-color-palette, .x-menu-plain .x-date-picker{ margin: 0; border: 0 none; } .x-date-menu { padding:0 !important; } /* * fixes separator visibility problem in IE 6 */ .ext-strict .ext-ie6 .x-menu-sep-li { padding: 3px 4px; } .ext-strict .ext-ie6 .x-menu-sep { margin: 0; height: 1px; } /* * Fixes an issue with "fat" separators in webkit */ .ext-webkit .x-menu-sep{ height: 1px; } /* * Ugly mess to remove the white border under the picker */ .ext-ie .x-date-menu{ height: 199px; } .ext-strict .ext-ie .x-date-menu, .ext-border-box .ext-ie8 .x-date-menu{ height: 197px; } .ext-strict .ext-ie7 .x-date-menu{ height: 195px; } .ext-strict .ext-ie8 .x-date-menu{ height: auto; } .x-cycle-menu .x-menu-item-checked { border:1px dotted !important; padding:0; } .x-menu .x-menu-scroller { width: 100%; background-repeat:no-repeat; background-position:center; height:8px; line-height: 8px; cursor:pointer; margin: 0; padding: 0; } .x-menu .x-menu-scroller-active{ height: 6px; line-height: 6px; } .x-menu-list-item-indent{ padding-left: 27px; }/* Creates rounded, raised boxes like on the Ext website - the markup isn't pretty: <div class="x-box-blue"> <div class="x-box-tl"><div class="x-box-tr"><div class="x-box-tc"></div></div></div> <div class="x-box-ml"><div class="x-box-mr"><div class="x-box-mc"> <h3>YOUR TITLE HERE (optional)</h3> <div>YOUR CONTENT HERE</div> </div></div></div> <div class="x-box-bl"><div class="x-box-br"><div class="x-box-bc"></div></div></div> </div> */ .x-box-tl { background: transparent no-repeat 0 0; zoom:1; } .x-box-tc { height: 8px; background: transparent repeat-x 0 0; overflow: hidden; } .x-box-tr { background: transparent no-repeat right -8px; } .x-box-ml { background: transparent repeat-y 0; padding-left: 4px; overflow: hidden; zoom:1; } .x-box-mc { background: repeat-x 0 -16px; padding: 4px 10px; } .x-box-mc h3 { margin: 0 0 4px 0; zoom:1; } .x-box-mr { background: transparent repeat-y right; padding-right: 4px; overflow: hidden; } .x-box-bl { background: transparent no-repeat 0 -16px; zoom:1; } .x-box-bc { background: transparent repeat-x 0 -8px; height: 8px; overflow: hidden; } .x-box-br { background: transparent no-repeat right -24px; } .x-box-tl, .x-box-bl { padding-left: 8px; overflow: hidden; } .x-box-tr, .x-box-br { padding-right: 8px; overflow: hidden; }.x-combo-list { border:1px solid; zoom:1; overflow:hidden; } .x-combo-list-inner { overflow:auto; position:relative; /* for calculating scroll offsets */ zoom:1; overflow-x:hidden; } .x-combo-list-hd { border-bottom:1px solid; padding:3px; } .x-resizable-pinned .x-combo-list-inner { border-bottom:1px solid; } .x-combo-list-item { padding:2px; border:1px solid; white-space: nowrap; overflow:hidden; text-overflow: ellipsis; } .x-combo-list .x-combo-selected{ border:1px dotted !important; cursor:pointer; } .x-combo-list .x-toolbar { border-top:1px solid; border-bottom:0 none; }.x-panel { border-style: solid; border-width:0; } .x-panel-header { overflow:hidden; zoom:1; padding:5px 3px 4px 5px; border:1px solid; line-height: 15px; background: transparent repeat-x 0 -1px; } .x-panel-body { border:1px solid; border-top:0 none; overflow:hidden; position: relative; /* added for item scroll positioning */ } .x-panel-bbar .x-toolbar, .x-panel-tbar .x-toolbar { border:1px solid; border-top:0 none; overflow:hidden; padding:2px; } .x-panel-tbar-noheader .x-toolbar, .x-panel-mc .x-panel-tbar .x-toolbar { border-top:1px solid; border-bottom: 0 none; } .x-panel-body-noheader, .x-panel-mc .x-panel-body { border-top:1px solid; } .x-panel-header { overflow:hidden; zoom:1; } .x-panel-tl .x-panel-header { padding:5px 0 4px 0; border:0 none; background:transparent no-repeat; } .x-panel-tl .x-panel-icon, .x-window-tl .x-panel-icon { padding-left:20px !important; background-repeat:no-repeat; background-position:0 4px; zoom:1; } .x-panel-inline-icon { width:16px; height:16px; background-repeat:no-repeat; background-position:0 0; vertical-align:middle; margin-right:4px; margin-top:-1px; margin-bottom:-1px; } .x-panel-tc { background: transparent repeat-x 0 0; overflow:hidden; } /* fix ie7 strict mode bug */ .ext-strict .ext-ie7 .x-panel-tc { overflow: visible; } .x-panel-tl { background: transparent no-repeat 0 0; padding-left:6px; zoom:1; border-bottom:1px solid; } .x-panel-tr { background: transparent no-repeat right 0; zoom:1; padding-right:6px; } .x-panel-bc { background: transparent repeat-x 0 bottom; zoom:1; } .x-panel-bc .x-panel-footer { zoom:1; } .x-panel-bl { background: transparent no-repeat 0 bottom; padding-left:6px; zoom:1; } .x-panel-br { background: transparent no-repeat right bottom; padding-right:6px; zoom:1; } .x-panel-mc { border:0 none; padding:0; margin:0; padding-top:6px; } .x-panel-mc .x-panel-body { background-color:transparent; border: 0 none; } .x-panel-ml { background: repeat-y 0 0; padding-left:6px; zoom:1; } .x-panel-mr { background: transparent repeat-y right 0; padding-right:6px; zoom:1; } .x-panel-bc .x-panel-footer { padding-bottom:6px; } .x-panel-nofooter .x-panel-bc, .x-panel-nofooter .x-window-bc { height:6px; font-size:0; line-height:0; } .x-panel-bwrap { overflow:hidden; zoom:1; left:0; top:0; } .x-panel-body { overflow:hidden; zoom:1; } .x-panel-collapsed .x-resizable-handle{ display:none; } .ext-gecko .x-panel-animated div { overflow:hidden !important; } /* Plain */ .x-plain-body { overflow:hidden; } .x-plain-bbar .x-toolbar { overflow:hidden; padding:2px; } .x-plain-tbar .x-toolbar { overflow:hidden; padding:2px; } .x-plain-bwrap { overflow:hidden; zoom:1; } .x-plain { overflow:hidden; } /* Tools */ .x-tool { overflow:hidden; width:15px; height:15px; float:right; cursor:pointer; background:transparent no-repeat; margin-left:2px; } /* expand / collapse tools */ .x-tool-toggle { background-position:0 -60px; } .x-tool-toggle-over { background-position:-15px -60px; } .x-panel-collapsed .x-tool-toggle { background-position:0 -75px; } .x-panel-collapsed .x-tool-toggle-over { background-position:-15px -75px; } .x-tool-close { background-position:0 -0; } .x-tool-close-over { background-position:-15px 0; } .x-tool-minimize { background-position:0 -15px; } .x-tool-minimize-over { background-position:-15px -15px; } .x-tool-maximize { background-position:0 -30px; } .x-tool-maximize-over { background-position:-15px -30px; } .x-tool-restore { background-position:0 -45px; } .x-tool-restore-over { background-position:-15px -45px; } .x-tool-gear { background-position:0 -90px; } .x-tool-gear-over { background-position:-15px -90px; } .x-tool-prev { background-position:0 -105px; } .x-tool-prev-over { background-position:-15px -105px; } .x-tool-next { background-position:0 -120px; } .x-tool-next-over { background-position:-15px -120px; } .x-tool-pin { background-position:0 -135px; } .x-tool-pin-over { background-position:-15px -135px; } .x-tool-unpin { background-position:0 -150px; } .x-tool-unpin-over { background-position:-15px -150px; } .x-tool-right { background-position:0 -165px; } .x-tool-right-over { background-position:-15px -165px; } .x-tool-left { background-position:0 -180px; } .x-tool-left-over { background-position:-15px -180px; } .x-tool-down { background-position:0 -195px; } .x-tool-down-over { background-position:-15px -195px; } .x-tool-up { background-position:0 -210px; } .x-tool-up-over { background-position:-15px -210px; } .x-tool-refresh { background-position:0 -225px; } .x-tool-refresh-over { background-position:-15px -225px; } .x-tool-plus { background-position:0 -240px; } .x-tool-plus-over { background-position:-15px -240px; } .x-tool-minus { background-position:0 -255px; } .x-tool-minus-over { background-position:-15px -255px; } .x-tool-search { background-position:0 -270px; } .x-tool-search-over { background-position:-15px -270px; } .x-tool-save { background-position:0 -285px; } .x-tool-save-over { background-position:-15px -285px; } .x-tool-help { background-position:0 -300px; } .x-tool-help-over { background-position:-15px -300px; } .x-tool-print { background-position:0 -315px; } .x-tool-print-over { background-position:-15px -315px; } .x-tool-expand { background-position:0 -330px; } .x-tool-expand-over { background-position:-15px -330px; } .x-tool-collapse { background-position:0 -345px; } .x-tool-collapse-over { background-position:-15px -345px; } .x-tool-resize { background-position:0 -360px; } .x-tool-resize-over { background-position:-15px -360px; } .x-tool-move { background-position:0 -375px; } .x-tool-move-over { background-position:-15px -375px; } /* Ghosting */ .x-panel-ghost { z-index:12000; overflow:hidden; position:absolute; left:0;top:0; opacity:.65; -moz-opacity:.65; filter:alpha(opacity=65); } .x-panel-ghost ul { margin:0; padding:0; overflow:hidden; font-size:0; line-height:0; border:1px solid; border-top:0 none; display:block; } .x-panel-ghost * { cursor:move !important; } .x-panel-dd-spacer { border:2px dashed; } /* Buttons */ .x-panel-btns { padding:5px; overflow:hidden; } .x-panel-btns td.x-toolbar-cell{ padding:3px; } .x-panel-btns .x-btn-focus .x-btn-left{ background-position:0 -147px; } .x-panel-btns .x-btn-focus .x-btn-right{ background-position:0 -168px; } .x-panel-btns .x-btn-focus .x-btn-center{ background-position:0 -189px; } .x-panel-btns .x-btn-over .x-btn-left{ background-position:0 -63px; } .x-panel-btns .x-btn-over .x-btn-right{ background-position:0 -84px; } .x-panel-btns .x-btn-over .x-btn-center{ background-position:0 -105px; } .x-panel-btns .x-btn-click .x-btn-center{ background-position:0 -126px; } .x-panel-btns .x-btn-click .x-btn-right{ background-position:0 -84px; } .x-panel-btns .x-btn-click .x-btn-left{ background-position:0 -63px; } .x-panel-fbar td,.x-panel-fbar span,.x-panel-fbar input,.x-panel-fbar div,.x-panel-fbar select,.x-panel-fbar label{ white-space: nowrap; } /** * W3C Suggested Default style sheet for HTML 4 * http://www.w3.org/TR/CSS21/sample.html * * Resets for Ext.Panel @cfg normal: true */ .x-panel-reset .x-panel-body html, .x-panel-reset .x-panel-body address, .x-panel-reset .x-panel-body blockquote, .x-panel-reset .x-panel-body body, .x-panel-reset .x-panel-body dd, .x-panel-reset .x-panel-body div, .x-panel-reset .x-panel-body dl, .x-panel-reset .x-panel-body dt, .x-panel-reset .x-panel-body fieldset, .x-panel-reset .x-panel-body form, .x-panel-reset .x-panel-body frame, frameset, .x-panel-reset .x-panel-body h1, .x-panel-reset .x-panel-body h2, .x-panel-reset .x-panel-body h3, .x-panel-reset .x-panel-body h4, .x-panel-reset .x-panel-body h5, .x-panel-reset .x-panel-body h6, .x-panel-reset .x-panel-body noframes, .x-panel-reset .x-panel-body ol, .x-panel-reset .x-panel-body p, .x-panel-reset .x-panel-body ul, .x-panel-reset .x-panel-body center, .x-panel-reset .x-panel-body dir, .x-panel-reset .x-panel-body hr, .x-panel-reset .x-panel-body menu, .x-panel-reset .x-panel-body pre { display: block } .x-panel-reset .x-panel-body li { display: list-item } .x-panel-reset .x-panel-body head { display: none } .x-panel-reset .x-panel-body table { display: table } .x-panel-reset .x-panel-body tr { display: table-row } .x-panel-reset .x-panel-body thead { display: table-header-group } .x-panel-reset .x-panel-body tbody { display: table-row-group } .x-panel-reset .x-panel-body tfoot { display: table-footer-group } .x-panel-reset .x-panel-body col { display: table-column } .x-panel-reset .x-panel-body colgroup { display: table-column-group } .x-panel-reset .x-panel-body td, .x-panel-reset .x-panel-body th { display: table-cell } .x-panel-reset .x-panel-body caption { display: table-caption } .x-panel-reset .x-panel-body th { font-weight: bolder; text-align: center } .x-panel-reset .x-panel-body caption { text-align: center } .x-panel-reset .x-panel-body body { margin: 8px } .x-panel-reset .x-panel-body h1 { font-size: 2em; margin: .67em 0 } .x-panel-reset .x-panel-body h2 { font-size: 1.5em; margin: .75em 0 } .x-panel-reset .x-panel-body h3 { font-size: 1.17em; margin: .83em 0 } .x-panel-reset .x-panel-body h4, .x-panel-reset .x-panel-body p, .x-panel-reset .x-panel-body blockquote, .x-panel-reset .x-panel-body ul, .x-panel-reset .x-panel-body fieldset, .x-panel-reset .x-panel-body form, .x-panel-reset .x-panel-body ol, .x-panel-reset .x-panel-body dl, .x-panel-reset .x-panel-body dir, .x-panel-reset .x-panel-body menu { margin: 1.12em 0 } .x-panel-reset .x-panel-body h5 { font-size: .83em; margin: 1.5em 0 } .x-panel-reset .x-panel-body h6 { font-size: .75em; margin: 1.67em 0 } .x-panel-reset .x-panel-body h1, .x-panel-reset .x-panel-body h2, .x-panel-reset .x-panel-body h3, .x-panel-reset .x-panel-body h4, .x-panel-reset .x-panel-body h5, .x-panel-reset .x-panel-body h6, .x-panel-reset .x-panel-body b, .x-panel-reset .x-panel-body strong { font-weight: bolder } .x-panel-reset .x-panel-body blockquote { margin-left: 40px; margin-right: 40px } .x-panel-reset .x-panel-body i, .x-panel-reset .x-panel-body cite, .x-panel-reset .x-panel-body em, .x-panel-reset .x-panel-body var, .x-panel-reset .x-panel-body address { font-style: italic } .x-panel-reset .x-panel-body pre, .x-panel-reset .x-panel-body tt, .x-panel-reset .x-panel-body code, .x-panel-reset .x-panel-body kbd, .x-panel-reset .x-panel-body samp { font-family: monospace } .x-panel-reset .x-panel-body pre { white-space: pre } .x-panel-reset .x-panel-body button, .x-panel-reset .x-panel-body textarea, .x-panel-reset .x-panel-body input, .x-panel-reset .x-panel-body select { display: inline-block } .x-panel-reset .x-panel-body big { font-size: 1.17em } .x-panel-reset .x-panel-body small, .x-panel-reset .x-panel-body sub, .x-panel-reset .x-panel-body sup { font-size: .83em } .x-panel-reset .x-panel-body sub { vertical-align: sub } .x-panel-reset .x-panel-body sup { vertical-align: super } .x-panel-reset .x-panel-body table { border-spacing: 2px; } .x-panel-reset .x-panel-body thead, .x-panel-reset .x-panel-body tbody, .x-panel-reset .x-panel-body tfoot { vertical-align: middle } .x-panel-reset .x-panel-body td, .x-panel-reset .x-panel-body th { vertical-align: inherit } .x-panel-reset .x-panel-body s, .x-panel-reset .x-panel-body strike, .x-panel-reset .x-panel-body del { text-decoration: line-through } .x-panel-reset .x-panel-body hr { border: 1px inset } .x-panel-reset .x-panel-body ol, .x-panel-reset .x-panel-body ul, .x-panel-reset .x-panel-body dir, .x-panel-reset .x-panel-body menu, .x-panel-reset .x-panel-body dd { margin-left: 40px } .x-panel-reset .x-panel-body ul, .x-panel-reset .x-panel-body menu, .x-panel-reset .x-panel-body dir { list-style-type: disc;} .x-panel-reset .x-panel-body ol { list-style-type: decimal } .x-panel-reset .x-panel-body ol ul, .x-panel-reset .x-panel-body ul ol, .x-panel-reset .x-panel-body ul ul, .x-panel-reset .x-panel-body ol ol { margin-top: 0; margin-bottom: 0 } .x-panel-reset .x-panel-body u, .x-panel-reset .x-panel-body ins { text-decoration: underline } .x-panel-reset .x-panel-body br:before { content: "\A" } .x-panel-reset .x-panel-body :before, .x-panel-reset .x-panel-body :after { white-space: pre-line } .x-panel-reset .x-panel-body center { text-align: center } .x-panel-reset .x-panel-body :link, .x-panel-reset .x-panel-body :visited { text-decoration: underline } .x-panel-reset .x-panel-body :focus { outline: invert dotted thin } /* Begin bidirectionality settings (do not change) */ .x-panel-reset .x-panel-body BDO[DIR="ltr"] { direction: ltr; unicode-bidi: bidi-override } .x-panel-reset .x-panel-body BDO[DIR="rtl"] { direction: rtl; unicode-bidi: bidi-override } .x-window { zoom:1; } .x-window .x-window-handle { opacity:0; -moz-opacity:0; filter:alpha(opacity=0); } .x-window-proxy { border:1px solid; z-index:12000; overflow:hidden; position:absolute; left:0;top:0; display:none; opacity:.5; -moz-opacity:.5; filter:alpha(opacity=50); } .x-window-header { overflow:hidden; zoom:1; } .x-window-bwrap { z-index:1; position:relative; zoom:1; left:0;top:0; } .x-window-tl .x-window-header { padding:5px 0 4px 0; } .x-window-header-text { cursor:pointer; } .x-window-tc { background: transparent repeat-x 0 0; overflow:hidden; zoom:1; } .x-window-tl { background: transparent no-repeat 0 0; padding-left:6px; zoom:1; z-index:1; position:relative; } .x-window-tr { background: transparent no-repeat right 0; padding-right:6px; } .x-window-bc { background: transparent repeat-x 0 bottom; zoom:1; } .x-window-bc .x-window-footer { padding-bottom:6px; zoom:1; font-size:0; line-height:0; } .x-window-bl { background: transparent no-repeat 0 bottom; padding-left:6px; zoom:1; } .x-window-br { background: transparent no-repeat right bottom; padding-right:6px; zoom:1; } .x-window-mc { border:1px solid; padding:0; margin:0; } .x-window-ml { background: transparent repeat-y 0 0; padding-left:6px; zoom:1; } .x-window-mr { background: transparent repeat-y right 0; padding-right:6px; zoom:1; } .x-window-body { overflow:hidden; } .x-window-bwrap { overflow:hidden; } .x-window-maximized .x-window-bl, .x-window-maximized .x-window-br, .x-window-maximized .x-window-ml, .x-window-maximized .x-window-mr, .x-window-maximized .x-window-tl, .x-window-maximized .x-window-tr { padding:0; } .x-window-maximized .x-window-footer { padding-bottom:0; } .x-window-maximized .x-window-tc { padding-left:3px; padding-right:3px; } .x-window-maximized .x-window-mc { border-left:0 none; border-right:0 none; } .x-window-tbar .x-toolbar, .x-window-bbar .x-toolbar { border-left:0 none; border-right: 0 none; } .x-window-bbar .x-toolbar { border-top:1px solid; border-bottom:0 none; } .x-window-draggable, .x-window-draggable .x-window-header-text { cursor:move; } .x-window-maximized .x-window-draggable, .x-window-maximized .x-window-draggable .x-window-header-text { cursor:default; } .x-window-body { background-color:transparent; } .x-panel-ghost .x-window-tl { border-bottom:1px solid; } .x-panel-collapsed .x-window-tl { border-bottom:1px solid; } .x-window-maximized-ct { overflow:hidden; } .x-window-maximized .x-window-handle { display:none; } .x-window-sizing-ghost ul { border:0 none !important; } .x-dlg-focus{ -moz-outline:0 none; outline:0 none; width:0; height:0; overflow:hidden; position:absolute; top:0; left:0; } .ext-webkit .x-dlg-focus{ width: 1px; height: 1px; } .x-dlg-mask{ z-index:10000; display:none; position:absolute; top:0; left:0; -moz-opacity: 0.5; opacity:.50; filter: alpha(opacity=50); } body.ext-ie6.x-body-masked select { visibility:hidden; } body.ext-ie6.x-body-masked .x-window select { visibility:visible; } .x-window-plain .x-window-mc { border: 1px solid; } .x-window-plain .x-window-body { border: 1px solid; background:transparent !important; }.x-html-editor-wrap { border:1px solid; } .x-html-editor-tb .x-btn-text { background:transparent no-repeat; } .x-html-editor-tb .x-edit-bold, .x-menu-item img.x-edit-bold { background-position:0 0; background-image:url(../images/default/editor/tb-sprite.gif); } .x-html-editor-tb .x-edit-italic, .x-menu-item img.x-edit-italic { background-position:-16px 0; background-image:url(../images/default/editor/tb-sprite.gif); } .x-html-editor-tb .x-edit-underline, .x-menu-item img.x-edit-underline { background-position:-32px 0; background-image:url(../images/default/editor/tb-sprite.gif); } .x-html-editor-tb .x-edit-forecolor, .x-menu-item img.x-edit-forecolor { background-position:-160px 0; background-image:url(../images/default/editor/tb-sprite.gif); } .x-html-editor-tb .x-edit-backcolor, .x-menu-item img.x-edit-backcolor { background-position:-176px 0; background-image:url(../images/default/editor/tb-sprite.gif); } .x-html-editor-tb .x-edit-justifyleft, .x-menu-item img.x-edit-justifyleft { background-position:-112px 0; background-image:url(../images/default/editor/tb-sprite.gif); } .x-html-editor-tb .x-edit-justifycenter, .x-menu-item img.x-edit-justifycenter { background-position:-128px 0; background-image:url(../images/default/editor/tb-sprite.gif); } .x-html-editor-tb .x-edit-justifyright, .x-menu-item img.x-edit-justifyright { background-position:-144px 0; background-image:url(../images/default/editor/tb-sprite.gif); } .x-html-editor-tb .x-edit-insertorderedlist, .x-menu-item img.x-edit-insertorderedlist { background-position:-80px 0; background-image:url(../images/default/editor/tb-sprite.gif); } .x-html-editor-tb .x-edit-insertunorderedlist, .x-menu-item img.x-edit-insertunorderedlist { background-position:-96px 0; background-image:url(../images/default/editor/tb-sprite.gif); } .x-html-editor-tb .x-edit-increasefontsize, .x-menu-item img.x-edit-increasefontsize { background-position:-48px 0; background-image:url(../images/default/editor/tb-sprite.gif); } .x-html-editor-tb .x-edit-decreasefontsize, .x-menu-item img.x-edit-decreasefontsize { background-position:-64px 0; background-image:url(../images/default/editor/tb-sprite.gif); } .x-html-editor-tb .x-edit-sourceedit, .x-menu-item img.x-edit-sourceedit { background-position:-192px 0; background-image:url(../images/default/editor/tb-sprite.gif); } .x-html-editor-tb .x-edit-createlink, .x-menu-item img.x-edit-createlink { background-position:-208px 0; background-image:url(../images/default/editor/tb-sprite.gif); } .x-html-editor-tip .x-tip-bd .x-tip-bd-inner { padding:5px; padding-bottom:1px; } .x-html-editor-tb .x-toolbar { position:static !important; }.x-panel-noborder .x-panel-body-noborder { border-width:0; } .x-panel-noborder .x-panel-header-noborder { border-width:0 0 1px; border-style:solid; } .x-panel-noborder .x-panel-tbar-noborder .x-toolbar { border-width:0 0 1px; border-style:solid; } .x-panel-noborder .x-panel-bbar-noborder .x-toolbar { border-width:1px 0 0 0; border-style:solid; } .x-window-noborder .x-window-mc { border-width:0; } .x-window-plain .x-window-body-noborder { border-width:0; } .x-tab-panel-noborder .x-tab-panel-body-noborder { border-width:0; } .x-tab-panel-noborder .x-tab-panel-header-noborder { border-width: 0 0 1px 0; } .x-tab-panel-noborder .x-tab-panel-footer-noborder { border-width: 1px 0 0 0; } .x-tab-panel-bbar-noborder .x-toolbar { border-width: 1px 0 0 0; border-style:solid; } .x-tab-panel-tbar-noborder .x-toolbar { border-width:0 0 1px; border-style:solid; }.x-border-layout-ct { position: relative; } .x-border-panel { position:absolute; left:0; top:0; } .x-tool-collapse-south { background-position:0 -195px; } .x-tool-collapse-south-over { background-position:-15px -195px; } .x-tool-collapse-north { background-position:0 -210px; } .x-tool-collapse-north-over { background-position:-15px -210px; } .x-tool-collapse-west { background-position:0 -180px; } .x-tool-collapse-west-over { background-position:-15px -180px; } .x-tool-collapse-east { background-position:0 -165px; } .x-tool-collapse-east-over { background-position:-15px -165px; } .x-tool-expand-south { background-position:0 -210px; } .x-tool-expand-south-over { background-position:-15px -210px; } .x-tool-expand-north { background-position:0 -195px; } .x-tool-expand-north-over { background-position:-15px -195px; } .x-tool-expand-west { background-position:0 -165px; } .x-tool-expand-west-over { background-position:-15px -165px; } .x-tool-expand-east { background-position:0 -180px; } .x-tool-expand-east-over { background-position:-15px -180px; } .x-tool-expand-north, .x-tool-expand-south { float:right; margin:3px; } .x-tool-expand-east, .x-tool-expand-west { float:none; margin:3px 2px; } .x-accordion-hd .x-tool-toggle { background-position:0 -255px; } .x-accordion-hd .x-tool-toggle-over { background-position:-15px -255px; } .x-panel-collapsed .x-accordion-hd .x-tool-toggle { background-position:0 -240px; } .x-panel-collapsed .x-accordion-hd .x-tool-toggle-over { background-position:-15px -240px; } .x-accordion-hd { padding-top:4px; padding-bottom:3px; border-top:0 none; background: transparent repeat-x 0 -9px; } .x-layout-collapsed{ position:absolute; left:-10000px; top:-10000px; visibility:hidden; width:20px; height:20px; overflow:hidden; border:1px solid; z-index:20; } .ext-border-box .x-layout-collapsed{ width:22px; height:22px; } .x-layout-collapsed-over{ cursor:pointer; } .x-layout-collapsed-west .x-layout-collapsed-tools, .x-layout-collapsed-east .x-layout-collapsed-tools{ position:absolute; top:0; left:0; width:20px; height:20px; } .x-layout-split{ position:absolute; height:5px; width:5px; line-height:1px; font-size:1px; z-index:3; background-color:transparent; } /* IE6 strict won't drag w/out a color */ .ext-strict .ext-ie6 .x-layout-split{ background-color: #fff !important; filter: alpha(opacity=1); } .x-layout-split-h{ background-image:url(../images/default/s.gif); background-position: left; } .x-layout-split-v{ background-image:url(../images/default/s.gif); background-position: top; } .x-column-layout-ct { overflow:hidden; zoom:1; } .x-column { float:left; padding:0; margin:0; overflow:hidden; zoom:1; } .x-column-inner { overflow:hidden; zoom:1; } /* mini mode */ .x-layout-mini { position:absolute; top:0; left:0; display:block; width:5px; height:35px; cursor:pointer; opacity:.5; -moz-opacity:.5; filter:alpha(opacity=50); } .x-layout-mini-over, .x-layout-collapsed-over .x-layout-mini{ opacity:1; -moz-opacity:1; filter:none; } .x-layout-split-west .x-layout-mini { top:48%; } .x-layout-split-east .x-layout-mini { top:48%; } .x-layout-split-north .x-layout-mini { left:48%; height:5px; width:35px; } .x-layout-split-south .x-layout-mini { left:48%; height:5px; width:35px; } .x-layout-cmini-west .x-layout-mini { top:48%; } .x-layout-cmini-east .x-layout-mini { top:48%; } .x-layout-cmini-north .x-layout-mini { left:48%; height:5px; width:35px; } .x-layout-cmini-south .x-layout-mini { left:48%; height:5px; width:35px; } .x-layout-cmini-west, .x-layout-cmini-east { border:0 none; width:5px !important; padding:0; background-color:transparent; } .x-layout-cmini-north, .x-layout-cmini-south { border:0 none; height:5px !important; padding:0; background-color:transparent; } .x-viewport, .x-viewport body { margin: 0; padding: 0; border: 0 none; overflow: hidden; height: 100%; } .x-abs-layout-item { position:absolute; left:0; top:0; } .ext-ie input.x-abs-layout-item, .ext-ie textarea.x-abs-layout-item { margin:0; } .x-box-layout-ct { overflow:hidden; zoom:1; } .x-box-inner { overflow:hidden; zoom:1; position:relative; left:0; top:0; } .x-box-item { position:absolute; left:0; top:0; }.x-progress-wrap { border:1px solid; overflow:hidden; } .x-progress-inner { height:18px; background:repeat-x; position:relative; } .x-progress-bar { height:18px; float:left; width:0; background: repeat-x left center; border-top:1px solid; border-bottom:1px solid; border-right:1px solid; } .x-progress-text { padding:1px 5px; overflow:hidden; position:absolute; left:0; text-align:center; } .x-progress-text-back { line-height:16px; } .ext-ie .x-progress-text-back { line-height:15px; } .ext-strict .ext-ie7 .x-progress-text-back{ width: 100%; } .x-list-header{ background: repeat-x 0 bottom; cursor:default; zoom:1; height:22px; } .x-list-header-inner div { display:block; float:left; overflow:hidden; -o-text-overflow: ellipsis; text-overflow: ellipsis; white-space: nowrap; } .x-list-header-inner div em { display:block; border-left:1px solid; padding:4px 4px; overflow:hidden; -moz-user-select: none; -khtml-user-select: none; line-height:14px; } .x-list-body { overflow:auto; overflow-x:hidden; overflow-y:auto; zoom:1; float: left; width: 100%; } .x-list-body dl { zoom:1; } .x-list-body dt { display:block; float:left; overflow:hidden; -o-text-overflow: ellipsis; text-overflow: ellipsis; white-space: nowrap; cursor:pointer; zoom:1; } .x-list-body dt em { display:block; padding:3px 4px; overflow:hidden; -moz-user-select: none; -khtml-user-select: none; } .x-list-resizer { border-left:1px solid; border-right:1px solid; position:absolute; left:0; top:0; } .x-list-header-inner em.sort-asc { background: transparent no-repeat center 0; border-style:solid; border-width: 0 1px 1px; padding-bottom:3px; } .x-list-header-inner em.sort-desc { background: transparent no-repeat center -23px; border-style:solid; border-width: 0 1px 1px; padding-bottom:3px; } /* Shared styles */ .x-slider { zoom:1; } .x-slider-inner { position:relative; left:0; top:0; overflow:visible; zoom:1; } .x-slider-focus { position:absolute; left:0; top:0; width:1px; height:1px; line-height:1px; font-size:1px; -moz-outline:0 none; outline:0 none; -moz-user-select: none; -khtml-user-select:none; -webkit-user-select:ignore; display:block; overflow:hidden; } /* Horizontal styles */ .x-slider-horz { padding-left:7px; background:transparent no-repeat 0 -22px; } .x-slider-horz .x-slider-end { padding-right:7px; zoom:1; background:transparent no-repeat right -44px; } .x-slider-horz .x-slider-inner { background:transparent repeat-x 0 0; height:22px; } .x-slider-horz .x-slider-thumb { width:14px; height:15px; position:absolute; left:0; top:3px; background:transparent no-repeat 0 0; } .x-slider-horz .x-slider-thumb-over { background-position: -14px -15px; } .x-slider-horz .x-slider-thumb-drag { background-position: -28px -30px; } /* Vertical styles */ .x-slider-vert { padding-top:7px; background:transparent no-repeat -44px 0; width:22px; } .x-slider-vert .x-slider-end { padding-bottom:7px; zoom:1; background:transparent no-repeat -22px bottom; } .x-slider-vert .x-slider-inner { background:transparent repeat-y 0 0; } .x-slider-vert .x-slider-thumb { width:15px; height:14px; position:absolute; left:3px; bottom:0; background:transparent no-repeat 0 0; } .x-slider-vert .x-slider-thumb-over { background-position: -15px -14px; } .x-slider-vert .x-slider-thumb-drag { background-position: -30px -28px; }.x-window-dlg .x-window-body { border:0 none !important; padding:5px 10px; overflow:hidden !important; } .x-window-dlg .x-window-mc { border:0 none !important; } .x-window-dlg .ext-mb-input { margin-top:4px; width:95%; } .x-window-dlg .ext-mb-textarea { margin-top:4px; } .x-window-dlg .x-progress-wrap { margin-top:4px; } .ext-ie .x-window-dlg .x-progress-wrap { margin-top:6px; } .x-window-dlg .x-msg-box-wait { background:transparent no-repeat left; display:block; width:300px; padding-left:18px; line-height:18px; } .x-window-dlg .ext-mb-icon { float:left; width:47px; height:32px; } .x-window-dlg .x-dlg-icon .ext-mb-content{ zoom: 1; margin-left: 47px; } .x-window-dlg .ext-mb-info, .x-window-dlg .ext-mb-warning, .x-window-dlg .ext-mb-question, .x-window-dlg .ext-mb-error { background:transparent no-repeat top left; } .ext-gecko2 .ext-mb-fix-cursor { overflow:auto; }.ext-el-mask { background-color: #ccc; } .ext-el-mask-msg { border-color:#6593cf; background-color:#c3daf9; background-image:url(../images/default/box/tb-blue.gif); } .ext-el-mask-msg div { background-color: #eee; border-color:#a3bad9; color:#222; font:normal 11px tahoma, arial, helvetica, sans-serif; } .x-mask-loading div { background-color:#fbfbfb; background-image:url(../images/default/grid/loading.gif); } .x-item-disabled { color: gray; } .x-item-disabled * { color: gray !important; } .x-splitbar-proxy { background-color: #aaa; } .x-color-palette a { border-color:#fff; } .x-color-palette a:hover, .x-color-palette a.x-color-palette-sel { border-color:#8bb8f3; background-color: #deecfd; } /* .x-color-palette em:hover, .x-color-palette span:hover{ background-color: #deecfd; } */ .x-color-palette em { border-color:#aca899; } .x-ie-shadow { background-color:#777; } .x-shadow .xsmc { background-image: url(../images/default/shadow-c.png); } .x-shadow .xsml, .x-shadow .xsmr { background-image: url(../images/default/shadow-lr.png); } .x-shadow .xstl, .x-shadow .xstc, .x-shadow .xstr, .x-shadow .xsbl, .x-shadow .xsbc, .x-shadow .xsbr{ background-image: url(../images/default/shadow.png); } .loading-indicator { font-size: 11px; background-image: url(../images/default/grid/loading.gif); } .x-spotlight { background-color: #ccc; } .x-tab-panel-header, .x-tab-panel-footer { background-color: #deecfd; border-color:#8db2e3; overflow:hidden; zoom:1; } .x-tab-panel-header, .x-tab-panel-footer { border-color:#8db2e3; } ul.x-tab-strip-top{ background-color:#cedff5; background-image: url(../images/default/tabs/tab-strip-bg.gif); border-bottom-color:#8db2e3; } ul.x-tab-strip-bottom{ background-color:#cedff5; background-image: url(../images/default/tabs/tab-strip-btm-bg.gif); border-top-color:#8db2e3; } .x-tab-panel-header-plain .x-tab-strip-spacer, .x-tab-panel-footer-plain .x-tab-strip-spacer { border-color:#8db2e3; background-color: #deecfd; } .x-tab-strip span.x-tab-strip-text { font:normal 11px tahoma,arial,helvetica; color:#416aa3; } .x-tab-strip-over span.x-tab-strip-text { color:#15428b; } .x-tab-strip-active span.x-tab-strip-text { color:#15428b; font-weight:bold; } .x-tab-strip-disabled .x-tabs-text { color:#aaaaaa; } .x-tab-strip-top .x-tab-right, .x-tab-strip-top .x-tab-left, .x-tab-strip-top .x-tab-strip-inner{ background-image: url(../images/default/tabs/tabs-sprite.gif); } .x-tab-strip-bottom .x-tab-right { background-image: url(../images/default/tabs/tab-btm-inactive-right-bg.gif); } .x-tab-strip-bottom .x-tab-left { background-image: url(../images/default/tabs/tab-btm-inactive-left-bg.gif); } .x-tab-strip-bottom .x-tab-strip-over .x-tab-right { background-image: url(../images/default/tabs/tab-btm-over-right-bg.gif); } .x-tab-strip-bottom .x-tab-strip-over .x-tab-left { background-image: url(../images/default/tabs/tab-btm-over-left-bg.gif); } .x-tab-strip-bottom .x-tab-strip-active .x-tab-right { background-image: url(../images/default/tabs/tab-btm-right-bg.gif); } .x-tab-strip-bottom .x-tab-strip-active .x-tab-left { background-image: url(../images/default/tabs/tab-btm-left-bg.gif); } .x-tab-strip .x-tab-strip-closable a.x-tab-strip-close { background-image:url(../images/default/tabs/tab-close.gif); } .x-tab-strip .x-tab-strip-closable a.x-tab-strip-close:hover{ background-image:url(../images/default/tabs/tab-close.gif); } .x-tab-panel-body { border-color:#8db2e3; background-color:#fff; } .x-tab-panel-body-top { border-top: 0 none; } .x-tab-panel-body-bottom { border-bottom: 0 none; } .x-tab-scroller-left { background-image:url(../images/default/tabs/scroll-left.gif); border-bottom-color:#8db2e3; } .x-tab-scroller-left-over { background-position: 0 0; } .x-tab-scroller-left-disabled { background-position: -18px 0; opacity:.5; -moz-opacity:.5; filter:alpha(opacity=50); cursor:default; } .x-tab-scroller-right { background-image:url(../images/default/tabs/scroll-right.gif); border-bottom-color:#8db2e3; } .x-tab-panel-bbar .x-toolbar, .x-tab-panel-tbar .x-toolbar { border-color:#99bbe8; }.x-form-field { font:normal 12px tahoma, arial, helvetica, sans-serif; } .x-form-text, textarea.x-form-field { background-color:#fff; background-image:url(../images/default/form/text-bg.gif); border-color:#b5b8c8; } .x-form-select-one { background-color:#fff; border-color:#b5b8c8; } .x-form-check-group-label { border-bottom: 1px solid #99bbe8; color: #15428b; } .x-editor .x-form-check-wrap { background-color:#fff; } .x-form-field-wrap .x-form-trigger { background-image:url(../images/default/form/trigger.gif); border-bottom-color:#b5b8c8; } .x-form-field-wrap .x-form-date-trigger { background-image: url(../images/default/form/date-trigger.gif); } .x-form-field-wrap .x-form-clear-trigger { background-image: url(../images/default/form/clear-trigger.gif); } .x-form-field-wrap .x-form-search-trigger { background-image: url(../images/default/form/search-trigger.gif); } .x-trigger-wrap-focus .x-form-trigger { border-bottom-color:#7eadd9; } .x-item-disabled .x-form-trigger-over { border-bottom-color:#b5b8c8; } .x-item-disabled .x-form-trigger-click { border-bottom-color:#b5b8c8; } .x-form-focus, textarea.x-form-focus { border-color:#7eadd9; } .x-form-invalid, textarea.x-form-invalid { background-color:#fff; background-image:url(../images/default/grid/invalid_line.gif); border-color:#c30; } .x-form-invalid.x-form-composite { border: none; background-image: none; } .x-form-invalid.x-form-composite .x-form-invalid { background-color:#fff; background-image:url(../images/default/grid/invalid_line.gif); border-color:#c30; } .x-form-inner-invalid, textarea.x-form-inner-invalid { background-color:#fff; background-image:url(../images/default/grid/invalid_line.gif); } .x-form-grow-sizer { font:normal 12px tahoma, arial, helvetica, sans-serif; } .x-form-item { font:normal 12px tahoma, arial, helvetica, sans-serif; } .x-form-invalid-msg { color:#c0272b; font:normal 11px tahoma, arial, helvetica, sans-serif; background-image:url(../images/default/shared/warning.gif); } .x-form-empty-field { color:gray; } .x-small-editor .x-form-field { font:normal 11px arial, tahoma, helvetica, sans-serif; } .ext-webkit .x-small-editor .x-form-field { font:normal 11px arial, tahoma, helvetica, sans-serif; } .x-form-invalid-icon { background-image:url(../images/default/form/exclamation.gif); } .x-fieldset { border-color:#b5b8c8; } .x-fieldset legend { font:bold 11px tahoma, arial, helvetica, sans-serif; color:#15428b; } .x-btn{ font:normal 11px tahoma, verdana, helvetica; } .x-btn button{ font:normal 11px arial,tahoma,verdana,helvetica; color:#333; } .x-btn em { font-style:normal; font-weight:normal; } .x-btn-tl, .x-btn-tr, .x-btn-tc, .x-btn-ml, .x-btn-mr, .x-btn-mc, .x-btn-bl, .x-btn-br, .x-btn-bc{ background-image:url(../images/default/button/btn.gif); } .x-btn-click .x-btn-text, .x-btn-menu-active .x-btn-text, .x-btn-pressed .x-btn-text{ color:#000; } .x-btn-disabled *{ color:gray !important; } .x-btn-mc em.x-btn-arrow { background-image:url(../images/default/button/arrow.gif); } .x-btn-mc em.x-btn-split { background-image:url(../images/default/button/s-arrow.gif); } .x-btn-over .x-btn-mc em.x-btn-split, .x-btn-click .x-btn-mc em.x-btn-split, .x-btn-menu-active .x-btn-mc em.x-btn-split, .x-btn-pressed .x-btn-mc em.x-btn-split { background-image:url(../images/default/button/s-arrow-o.gif); } .x-btn-mc em.x-btn-arrow-bottom { background-image:url(../images/default/button/s-arrow-b-noline.gif); } .x-btn-mc em.x-btn-split-bottom { background-image:url(../images/default/button/s-arrow-b.gif); } .x-btn-over .x-btn-mc em.x-btn-split-bottom, .x-btn-click .x-btn-mc em.x-btn-split-bottom, .x-btn-menu-active .x-btn-mc em.x-btn-split-bottom, .x-btn-pressed .x-btn-mc em.x-btn-split-bottom { background-image:url(../images/default/button/s-arrow-bo.gif); } .x-btn-group-header { color: #3e6aaa; } .x-btn-group-tc { background-image: url(../images/default/button/group-tb.gif); } .x-btn-group-tl { background-image: url(../images/default/button/group-cs.gif); } .x-btn-group-tr { background-image: url(../images/default/button/group-cs.gif); } .x-btn-group-bc { background-image: url(../images/default/button/group-tb.gif); } .x-btn-group-bl { background-image: url(../images/default/button/group-cs.gif); } .x-btn-group-br { background-image: url(../images/default/button/group-cs.gif); } .x-btn-group-ml { background-image: url(../images/default/button/group-lr.gif); } .x-btn-group-mr { background-image: url(../images/default/button/group-lr.gif); } .x-btn-group-notitle .x-btn-group-tc { background-image: url(../images/default/button/group-tb.gif); }.x-toolbar{ border-color:#a9bfd3; background-color:#d0def0; background-image:url(../images/default/toolbar/bg.gif); } .x-toolbar td,.x-toolbar span,.x-toolbar input,.x-toolbar div,.x-toolbar select,.x-toolbar label{ font:normal 11px arial,tahoma, helvetica, sans-serif; } .x-toolbar .x-item-disabled { color:gray; } .x-toolbar .x-item-disabled * { color:gray; } .x-toolbar .x-btn-mc em.x-btn-split { background-image:url(../images/default/button/s-arrow-noline.gif); } .x-toolbar .x-btn-over .x-btn-mc em.x-btn-split, .x-toolbar .x-btn-click .x-btn-mc em.x-btn-split, .x-toolbar .x-btn-menu-active .x-btn-mc em.x-btn-split, .x-toolbar .x-btn-pressed .x-btn-mc em.x-btn-split { background-image:url(../images/default/button/s-arrow-o.gif); } .x-toolbar .x-btn-mc em.x-btn-split-bottom { background-image:url(../images/default/button/s-arrow-b-noline.gif); } .x-toolbar .x-btn-over .x-btn-mc em.x-btn-split-bottom, .x-toolbar .x-btn-click .x-btn-mc em.x-btn-split-bottom, .x-toolbar .x-btn-menu-active .x-btn-mc em.x-btn-split-bottom, .x-toolbar .x-btn-pressed .x-btn-mc em.x-btn-split-bottom { background-image:url(../images/default/button/s-arrow-bo.gif); } .x-toolbar .xtb-sep { background-image: url(../images/default/grid/grid-blue-split.gif); } .x-tbar-page-first{ background-image: url(../images/default/grid/page-first.gif) !important; } .x-tbar-loading{ background-image: url(../images/default/grid/refresh.gif) !important; } .x-tbar-page-last{ background-image: url(../images/default/grid/page-last.gif) !important; } .x-tbar-page-next{ background-image: url(../images/default/grid/page-next.gif) !important; } .x-tbar-page-prev{ background-image: url(../images/default/grid/page-prev.gif) !important; } .x-item-disabled .x-tbar-loading{ background-image: url(../images/default/grid/refresh-disabled.gif) !important; } .x-item-disabled .x-tbar-page-first{ background-image: url(../images/default/grid/page-first-disabled.gif) !important; } .x-item-disabled .x-tbar-page-last{ background-image: url(../images/default/grid/page-last-disabled.gif) !important; } .x-item-disabled .x-tbar-page-next{ background-image: url(../images/default/grid/page-next-disabled.gif) !important; } .x-item-disabled .x-tbar-page-prev{ background-image: url(../images/default/grid/page-prev-disabled.gif) !important; } .x-paging-info { color:#444; } .x-toolbar-more-icon { background-image: url(../images/default/toolbar/more.gif) !important; }.x-resizable-handle { background-color:#fff; } .x-resizable-over .x-resizable-handle-east, .x-resizable-pinned .x-resizable-handle-east, .x-resizable-over .x-resizable-handle-west, .x-resizable-pinned .x-resizable-handle-west { background-image:url(../images/default/sizer/e-handle.gif); } .x-resizable-over .x-resizable-handle-south, .x-resizable-pinned .x-resizable-handle-south, .x-resizable-over .x-resizable-handle-north, .x-resizable-pinned .x-resizable-handle-north { background-image:url(../images/default/sizer/s-handle.gif); } .x-resizable-over .x-resizable-handle-north, .x-resizable-pinned .x-resizable-handle-north{ background-image:url(../images/default/sizer/s-handle.gif); } .x-resizable-over .x-resizable-handle-southeast, .x-resizable-pinned .x-resizable-handle-southeast{ background-image:url(../images/default/sizer/se-handle.gif); } .x-resizable-over .x-resizable-handle-northwest, .x-resizable-pinned .x-resizable-handle-northwest{ background-image:url(../images/default/sizer/nw-handle.gif); } .x-resizable-over .x-resizable-handle-northeast, .x-resizable-pinned .x-resizable-handle-northeast{ background-image:url(../images/default/sizer/ne-handle.gif); } .x-resizable-over .x-resizable-handle-southwest, .x-resizable-pinned .x-resizable-handle-southwest{ background-image:url(../images/default/sizer/sw-handle.gif); } .x-resizable-proxy{ border-color:#3b5a82; } .x-resizable-overlay{ background-color:#fff; } .x-grid3 { background-color:#fff; } .x-grid-panel .x-panel-mc .x-panel-body { border-color:#99bbe8; } .x-grid3-row td, .x-grid3-summary-row td{ font:normal 11px/13px arial, tahoma, helvetica, sans-serif; } .x-grid3-hd-row td { font:normal 11px/15px arial, tahoma, helvetica, sans-serif; } .x-grid3-hd-row td { border-left-color:#eee; border-right-color:#d0d0d0; } .x-grid-row-loading { background-color: #fff; background-image:url(../images/default/shared/loading-balls.gif); } .x-grid3-row { border-color:#ededed; border-top-color:#fff; } .x-grid3-row-alt{ background-color:#fafafa; } .x-grid3-row-over { border-color:#ddd; background-color:#efefef; background-image:url(../images/default/grid/row-over.gif); } .x-grid3-resize-proxy { background-color:#777; } .x-grid3-resize-marker { background-color:#777; } .x-grid3-header{ background-color:#f9f9f9; background-image:url(../images/default/grid/grid3-hrow.gif); } .x-grid3-header-pop { border-left-color:#d0d0d0; } .x-grid3-header-pop-inner { border-left-color:#eee; background-image:url(../images/default/grid/hd-pop.gif); } td.x-grid3-hd-over, td.sort-desc, td.sort-asc, td.x-grid3-hd-menu-open { border-left-color:#aaccf6; border-right-color:#aaccf6; } td.x-grid3-hd-over .x-grid3-hd-inner, td.sort-desc .x-grid3-hd-inner, td.sort-asc .x-grid3-hd-inner, td.x-grid3-hd-menu-open .x-grid3-hd-inner { background-color:#ebf3fd; background-image:url(../images/default/grid/grid3-hrow-over.gif); } .sort-asc .x-grid3-sort-icon { background-image: url(../images/default/grid/sort_asc.gif); } .sort-desc .x-grid3-sort-icon { background-image: url(../images/default/grid/sort_desc.gif); } .x-grid3-cell-text, .x-grid3-hd-text { color:#000; } .x-grid3-split { background-image: url(../images/default/grid/grid-split.gif); } .x-grid3-hd-text { color:#15428b; } .x-dd-drag-proxy .x-grid3-hd-inner{ background-color:#ebf3fd; background-image:url(../images/default/grid/grid3-hrow-over.gif); border-color:#aaccf6; } .col-move-top{ background-image:url(../images/default/grid/col-move-top.gif); } .col-move-bottom{ background-image:url(../images/default/grid/col-move-bottom.gif); } td.grid-hd-group-cell { background: url(../images/default/grid/grid3-hrow.gif) repeat-x bottom; } .x-grid3-row-selected { background-color: #dfe8f6 !important; background-image: none; border-color:#a3bae9; } .x-grid3-cell-selected{ background-color: #b8cfee !important; color:#000; } .x-grid3-cell-selected span{ color:#000 !important; } .x-grid3-cell-selected .x-grid3-cell-text{ color:#000; } .x-grid3-locked td.x-grid3-row-marker, .x-grid3-locked .x-grid3-row-selected td.x-grid3-row-marker{ background-color:#ebeadb !important; background-image:url(../images/default/grid/grid-hrow.gif) !important; color:#000; border-top-color:#fff; border-right-color:#6fa0df !important; } .x-grid3-locked td.x-grid3-row-marker div, .x-grid3-locked .x-grid3-row-selected td.x-grid3-row-marker div{ color:#15428b !important; } .x-grid3-dirty-cell { background-image:url(../images/default/grid/dirty.gif); } .x-grid3-topbar, .x-grid3-bottombar{ font:normal 11px arial, tahoma, helvetica, sans-serif; } .x-grid3-bottombar .x-toolbar{ border-top-color:#a9bfd3; } .x-props-grid .x-grid3-td-name .x-grid3-cell-inner{ background-image:url(../images/default/grid/grid3-special-col-bg.gif) !important; color:#000 !important; } .x-props-grid .x-grid3-body .x-grid3-td-name{ background-color:#fff !important; border-right-color:#eee; } .xg-hmenu-sort-asc .x-menu-item-icon{ background-image: url(../images/default/grid/hmenu-asc.gif); } .xg-hmenu-sort-desc .x-menu-item-icon{ background-image: url(../images/default/grid/hmenu-desc.gif); } .xg-hmenu-lock .x-menu-item-icon{ background-image: url(../images/default/grid/hmenu-lock.gif); } .xg-hmenu-unlock .x-menu-item-icon{ background-image: url(../images/default/grid/hmenu-unlock.gif); } .x-grid3-hd-btn { background-color:#c3daf9; background-image:url(../images/default/grid/grid3-hd-btn.gif); } .x-grid3-body .x-grid3-td-expander { background-image:url(../images/default/grid/grid3-special-col-bg.gif); } .x-grid3-row-expander { background-image:url(../images/default/grid/row-expand-sprite.gif); } .x-grid3-body .x-grid3-td-checker { background-image: url(../images/default/grid/grid3-special-col-bg.gif); } .x-grid3-row-checker, .x-grid3-hd-checker { background-image:url(../images/default/grid/row-check-sprite.gif); } .x-grid3-body .x-grid3-td-numberer { background-image:url(../images/default/grid/grid3-special-col-bg.gif); } .x-grid3-body .x-grid3-td-numberer .x-grid3-cell-inner { color:#444; } .x-grid3-body .x-grid3-td-row-icon { background-image:url(../images/default/grid/grid3-special-col-bg.gif); } .x-grid3-body .x-grid3-row-selected .x-grid3-td-numberer, .x-grid3-body .x-grid3-row-selected .x-grid3-td-checker, .x-grid3-body .x-grid3-row-selected .x-grid3-td-expander { background-image:url(../images/default/grid/grid3-special-col-sel-bg.gif); } .x-grid3-check-col { background-image:url(../images/default/menu/unchecked.gif); } .x-grid3-check-col-on { background-image:url(../images/default/menu/checked.gif); } .x-grid-group, .x-grid-group-body, .x-grid-group-hd { zoom:1; } .x-grid-group-hd { border-bottom-color:#99bbe8; } .x-grid-group-hd div.x-grid-group-title { background-image:url(../images/default/grid/group-collapse.gif); color:#3764a0; font:bold 11px tahoma, arial, helvetica, sans-serif; } .x-grid-group-collapsed .x-grid-group-hd div.x-grid-group-title { background-image:url(../images/default/grid/group-expand.gif); } .x-group-by-icon { background-image:url(../images/default/grid/group-by.gif); } .x-cols-icon { background-image:url(../images/default/grid/columns.gif); } .x-show-groups-icon { background-image:url(../images/default/grid/group-by.gif); } .x-grid-empty { color:gray; font:normal 11px tahoma, arial, helvetica, sans-serif; } .x-grid-with-col-lines .x-grid3-row td.x-grid3-cell { border-right-color:#ededed; } .x-grid-with-col-lines .x-grid3-row-selected { border-top-color:#a3bae9; }.x-pivotgrid .x-grid3-header-offset table td { background: url(../images/default/grid/grid3-hrow.gif) repeat-x 50% 100%; border-left: 1px solid; border-right: 1px solid; border-left-color: #EEE; border-right-color: #D0D0D0; } .x-pivotgrid .x-grid3-row-headers { background-color: #f9f9f9; } .x-pivotgrid .x-grid3-row-headers table td { background: #EEE url(../images/default/grid/grid3-rowheader.gif) repeat-x left top; border-left: 1px solid; border-right: 1px solid; border-left-color: #EEE; border-right-color: #D0D0D0; border-bottom: 1px solid; border-bottom-color: #D0D0D0; height: 18px; } .x-dd-drag-ghost{ color:#000; font: normal 11px arial, helvetica, sans-serif; border-color: #ddd #bbb #bbb #ddd; background-color:#fff; } .x-dd-drop-nodrop .x-dd-drop-icon{ background-image: url(../images/default/dd/drop-no.gif); } .x-dd-drop-ok .x-dd-drop-icon{ background-image: url(../images/default/dd/drop-yes.gif); } .x-dd-drop-ok-add .x-dd-drop-icon{ background-image: url(../images/default/dd/drop-add.gif); } .x-view-selector { background-color:#c3daf9; border-color:#3399bb; }.x-tree-node-expanded .x-tree-node-icon{ background-image:url(../images/default/tree/folder-open.gif); } .x-tree-node-leaf .x-tree-node-icon{ background-image:url(../images/default/tree/leaf.gif); } .x-tree-node-collapsed .x-tree-node-icon{ background-image:url(../images/default/tree/folder.gif); } .x-tree-node-loading .x-tree-node-icon{ background-image:url(../images/default/tree/loading.gif) !important; } .x-tree-node .x-tree-node-inline-icon { background-image: none; } .x-tree-node-loading a span{ font-style: italic; color:#444444; } .x-tree-lines .x-tree-elbow{ background-image:url(../images/default/tree/elbow.gif); } .x-tree-lines .x-tree-elbow-plus{ background-image:url(../images/default/tree/elbow-plus.gif); } .x-tree-lines .x-tree-elbow-minus{ background-image:url(../images/default/tree/elbow-minus.gif); } .x-tree-lines .x-tree-elbow-end{ background-image:url(../images/default/tree/elbow-end.gif); } .x-tree-lines .x-tree-elbow-end-plus{ background-image:url(../images/default/tree/elbow-end-plus.gif); } .x-tree-lines .x-tree-elbow-end-minus{ background-image:url(../images/default/tree/elbow-end-minus.gif); } .x-tree-lines .x-tree-elbow-line{ background-image:url(../images/default/tree/elbow-line.gif); } .x-tree-no-lines .x-tree-elbow-plus{ background-image:url(../images/default/tree/elbow-plus-nl.gif); } .x-tree-no-lines .x-tree-elbow-minus{ background-image:url(../images/default/tree/elbow-minus-nl.gif); } .x-tree-no-lines .x-tree-elbow-end-plus{ background-image:url(../images/default/tree/elbow-end-plus-nl.gif); } .x-tree-no-lines .x-tree-elbow-end-minus{ background-image:url(../images/default/tree/elbow-end-minus-nl.gif); } .x-tree-arrows .x-tree-elbow-plus{ background-image:url(../images/default/tree/arrows.gif); } .x-tree-arrows .x-tree-elbow-minus{ background-image:url(../images/default/tree/arrows.gif); } .x-tree-arrows .x-tree-elbow-end-plus{ background-image:url(../images/default/tree/arrows.gif); } .x-tree-arrows .x-tree-elbow-end-minus{ background-image:url(../images/default/tree/arrows.gif); } .x-tree-node{ color:#000; font: normal 11px arial, tahoma, helvetica, sans-serif; } .x-tree-node a, .x-dd-drag-ghost a{ color:#000; } .x-tree-node a span, .x-dd-drag-ghost a span{ color:#000; } .x-tree-node .x-tree-node-disabled a span{ color:gray !important; } .x-tree-node div.x-tree-drag-insert-below{ border-bottom-color:#36c; } .x-tree-node div.x-tree-drag-insert-above{ border-top-color:#36c; } .x-tree-dd-underline .x-tree-node div.x-tree-drag-insert-below a{ border-bottom-color:#36c; } .x-tree-dd-underline .x-tree-node div.x-tree-drag-insert-above a{ border-top-color:#36c; } .x-tree-node .x-tree-drag-append a span{ background-color:#ddd; border-color:gray; } .x-tree-node .x-tree-node-over { background-color: #eee; } .x-tree-node .x-tree-selected { background-color: #d9e8fb; } .x-tree-drop-ok-append .x-dd-drop-icon{ background-image: url(../images/default/tree/drop-add.gif); } .x-tree-drop-ok-above .x-dd-drop-icon{ background-image: url(../images/default/tree/drop-over.gif); } .x-tree-drop-ok-below .x-dd-drop-icon{ background-image: url(../images/default/tree/drop-under.gif); } .x-tree-drop-ok-between .x-dd-drop-icon{ background-image: url(../images/default/tree/drop-between.gif); }.x-date-picker { border-color: #1b376c; background-color:#fff; } .x-date-middle,.x-date-left,.x-date-right { background-image: url(../images/default/shared/hd-sprite.gif); color:#fff; font:bold 11px "sans serif", tahoma, verdana, helvetica; } .x-date-middle .x-btn .x-btn-text { color:#fff; } .x-date-middle .x-btn-mc em.x-btn-arrow { background-image:url(../images/default/toolbar/btn-arrow-light.gif); } .x-date-right a { background-image: url(../images/default/shared/right-btn.gif); } .x-date-left a{ background-image: url(../images/default/shared/left-btn.gif); } .x-date-inner th { background-color:#dfecfb; background-image:url(../images/default/shared/glass-bg.gif); border-bottom-color:#a3bad9; font:normal 10px arial, helvetica,tahoma,sans-serif; color:#233d6d; } .x-date-inner td { border-color:#fff; } .x-date-inner a { font:normal 11px arial, helvetica,tahoma,sans-serif; color:#000; } .x-date-inner .x-date-active{ color:#000; } .x-date-inner .x-date-selected a{ background-color:#dfecfb; background-image:url(../images/default/shared/glass-bg.gif); border-color:#8db2e3; } .x-date-inner .x-date-today a{ border-color:darkred; } .x-date-inner .x-date-selected span{ font-weight:bold; } .x-date-inner .x-date-prevday a,.x-date-inner .x-date-nextday a { color:#aaa; } .x-date-bottom { border-top-color:#a3bad9; background-color:#dfecfb; background-image:url(../images/default/shared/glass-bg.gif); } .x-date-inner a:hover, .x-date-inner .x-date-disabled a:hover{ color:#000; background-color:#ddecfe; } .x-date-inner .x-date-disabled a { background-color:#eee; color:#bbb; } .x-date-mmenu{ background-color:#eee !important; } .x-date-mmenu .x-menu-item { font-size:10px; color:#000; } .x-date-mp { background-color:#fff; } .x-date-mp td { font:normal 11px arial, helvetica,tahoma,sans-serif; } .x-date-mp-btns button { background-color:#083772; color:#fff; border-color: #3366cc #000055 #000055 #3366cc; font:normal 11px arial, helvetica,tahoma,sans-serif; } .x-date-mp-btns { background-color: #dfecfb; background-image: url(../images/default/shared/glass-bg.gif); } .x-date-mp-btns td { border-top-color: #c5d2df; } td.x-date-mp-month a,td.x-date-mp-year a { color:#15428b; } td.x-date-mp-month a:hover,td.x-date-mp-year a:hover { color:#15428b; background-color: #ddecfe; } td.x-date-mp-sel a { background-color: #dfecfb; background-image: url(../images/default/shared/glass-bg.gif); border-color:#8db2e3; } .x-date-mp-ybtn a { background-image:url(../images/default/panel/tool-sprites.gif); } td.x-date-mp-sep { border-right-color:#c5d2df; }.x-tip .x-tip-close{ background-image: url(../images/default/qtip/close.gif); } .x-tip .x-tip-tc, .x-tip .x-tip-tl, .x-tip .x-tip-tr, .x-tip .x-tip-bc, .x-tip .x-tip-bl, .x-tip .x-tip-br, .x-tip .x-tip-ml, .x-tip .x-tip-mr { background-image: url(../images/default/qtip/tip-sprite.gif); } .x-tip .x-tip-mc { font: normal 11px tahoma,arial,helvetica,sans-serif; } .x-tip .x-tip-ml { background-color: #fff; } .x-tip .x-tip-header-text { font: bold 11px tahoma,arial,helvetica,sans-serif; color:#444; } .x-tip .x-tip-body { font: normal 11px tahoma,arial,helvetica,sans-serif; color:#444; } .x-form-invalid-tip .x-tip-tc, .x-form-invalid-tip .x-tip-tl, .x-form-invalid-tip .x-tip-tr, .x-form-invalid-tip .x-tip-bc, .x-form-invalid-tip .x-tip-bl, .x-form-invalid-tip .x-tip-br, .x-form-invalid-tip .x-tip-ml, .x-form-invalid-tip .x-tip-mr { background-image: url(../images/default/form/error-tip-corners.gif); } .x-form-invalid-tip .x-tip-body { background-image:url(../images/default/form/exclamation.gif); } .x-tip-anchor { background-image:url(../images/default/qtip/tip-anchor-sprite.gif); }.x-menu { background-color:#f0f0f0; background-image:url(../images/default/menu/menu.gif); } .x-menu-floating{ border-color:#718bb7; } .x-menu-nosep { background-image:none; } .x-menu-list-item{ font:normal 11px arial,tahoma,sans-serif; } .x-menu-item-arrow{ background-image:url(../images/default/menu/menu-parent.gif); } .x-menu-sep { background-color:#e0e0e0; border-bottom-color:#fff; } a.x-menu-item { color:#222; } .x-menu-item-active { background-image: url(../images/default/menu/item-over.gif); background-color: #dbecf4; border-color:#aaccf6; } .x-menu-item-active a.x-menu-item { border-color:#aaccf6; } .x-menu-check-item .x-menu-item-icon{ background-image:url(../images/default/menu/unchecked.gif); } .x-menu-item-checked .x-menu-item-icon{ background-image:url(../images/default/menu/checked.gif); } .x-menu-item-checked .x-menu-group-item .x-menu-item-icon{ background-image:url(../images/default/menu/group-checked.gif); } .x-menu-group-item .x-menu-item-icon{ background-image:none; } .x-menu-plain { background-color:#f0f0f0 !important; background-image: none; } .x-date-menu, .x-color-menu{ background-color: #fff !important; } .x-menu .x-date-picker{ border-color:#a3bad9; } .x-cycle-menu .x-menu-item-checked { border-color:#a3bae9 !important; background-color:#def8f6; } .x-menu-scroller-top { background-image:url(../images/default/layout/mini-top.gif); } .x-menu-scroller-bottom { background-image:url(../images/default/layout/mini-bottom.gif); } .x-box-tl { background-image: url(../images/default/box/corners.gif); } .x-box-tc { background-image: url(../images/default/box/tb.gif); } .x-box-tr { background-image: url(../images/default/box/corners.gif); } .x-box-ml { background-image: url(../images/default/box/l.gif); } .x-box-mc { background-color: #eee; background-image: url(../images/default/box/tb.gif); font-family: "Myriad Pro","Myriad Web","Tahoma","Helvetica","Arial",sans-serif; color: #393939; font-size: 12px; } .x-box-mc h3 { font-size: 14px; font-weight: bold; } .x-box-mr { background-image: url(../images/default/box/r.gif); } .x-box-bl { background-image: url(../images/default/box/corners.gif); } .x-box-bc { background-image: url(../images/default/box/tb.gif); } .x-box-br { background-image: url(../images/default/box/corners.gif); } .x-box-blue .x-box-bl, .x-box-blue .x-box-br, .x-box-blue .x-box-tl, .x-box-blue .x-box-tr { background-image: url(../images/default/box/corners-blue.gif); } .x-box-blue .x-box-bc, .x-box-blue .x-box-mc, .x-box-blue .x-box-tc { background-image: url(../images/default/box/tb-blue.gif); } .x-box-blue .x-box-mc { background-color: #c3daf9; } .x-box-blue .x-box-mc h3 { color: #17385b; } .x-box-blue .x-box-ml { background-image: url(../images/default/box/l-blue.gif); } .x-box-blue .x-box-mr { background-image: url(../images/default/box/r-blue.gif); }.x-combo-list { border-color:#98c0f4; background-color:#ddecfe; font:normal 12px tahoma, arial, helvetica, sans-serif; } .x-combo-list-inner { background-color:#fff; } .x-combo-list-hd { font:bold 11px tahoma, arial, helvetica, sans-serif; color:#15428b; background-image: url(../images/default/layout/panel-title-light-bg.gif); border-bottom-color:#98c0f4; } .x-resizable-pinned .x-combo-list-inner { border-bottom-color:#98c0f4; } .x-combo-list-item { border-color:#fff; } .x-combo-list .x-combo-selected{ border-color:#a3bae9 !important; background-color:#dfe8f6; } .x-combo-list .x-toolbar { border-top-color:#98c0f4; } .x-combo-list-small { font:normal 11px tahoma, arial, helvetica, sans-serif; }.x-panel { border-color: #99bbe8; } .x-panel-header { color:#15428b; font-weight:bold; font-size: 11px; font-family: tahoma,arial,verdana,sans-serif; border-color:#99bbe8; background-image: url(../images/default/panel/white-top-bottom.gif); } .x-panel-body { border-color:#99bbe8; background-color:#fff; } .x-panel-bbar .x-toolbar, .x-panel-tbar .x-toolbar { border-color:#99bbe8; } .x-panel-tbar-noheader .x-toolbar, .x-panel-mc .x-panel-tbar .x-toolbar { border-top-color:#99bbe8; } .x-panel-body-noheader, .x-panel-mc .x-panel-body { border-top-color:#99bbe8; } .x-panel-tl .x-panel-header { color:#15428b; font:bold 11px tahoma,arial,verdana,sans-serif; } .x-panel-tc { background-image: url(../images/default/panel/top-bottom.gif); } .x-panel-tl, .x-panel-tr, .x-panel-bl, .x-panel-br{ background-image: url(../images/default/panel/corners-sprite.gif); border-bottom-color:#99bbe8; } .x-panel-bc { background-image: url(../images/default/panel/top-bottom.gif); } .x-panel-mc { font: normal 11px tahoma,arial,helvetica,sans-serif; background-color:#dfe8f6; } .x-panel-ml { background-color: #fff; background-image:url(../images/default/panel/left-right.gif); } .x-panel-mr { background-image: url(../images/default/panel/left-right.gif); } .x-tool { background-image:url(../images/default/panel/tool-sprites.gif); } .x-panel-ghost { background-color:#cbddf3; } .x-panel-ghost ul { border-color:#99bbe8; } .x-panel-dd-spacer { border-color:#99bbe8; } .x-panel-fbar td,.x-panel-fbar span,.x-panel-fbar input,.x-panel-fbar div,.x-panel-fbar select,.x-panel-fbar label{ font:normal 11px arial,tahoma, helvetica, sans-serif; } .x-window-proxy { background-color:#c7dffc; border-color:#99bbe8; } .x-window-tl .x-window-header { color:#15428b; font:bold 11px tahoma,arial,verdana,sans-serif; } .x-window-tc { background-image: url(../images/default/window/top-bottom.png); } .x-window-tl { background-image: url(../images/default/window/left-corners.png); } .x-window-tr { background-image: url(../images/default/window/right-corners.png); } .x-window-bc { background-image: url(../images/default/window/top-bottom.png); } .x-window-bl { background-image: url(../images/default/window/left-corners.png); } .x-window-br { background-image: url(../images/default/window/right-corners.png); } .x-window-mc { border-color:#99bbe8; font: normal 11px tahoma,arial,helvetica,sans-serif; background-color:#dfe8f6; } .x-window-ml { background-image: url(../images/default/window/left-right.png); } .x-window-mr { background-image: url(../images/default/window/left-right.png); } .x-window-maximized .x-window-tc { background-color:#fff; } .x-window-bbar .x-toolbar { border-top-color:#99bbe8; } .x-panel-ghost .x-window-tl { border-bottom-color:#99bbe8; } .x-panel-collapsed .x-window-tl { border-bottom-color:#84a0c4; } .x-dlg-mask{ background-color:#ccc; } .x-window-plain .x-window-mc { background-color: #ccd9e8; border-color: #a3bae9 #dfe8f6 #dfe8f6 #a3bae9; } .x-window-plain .x-window-body { border-color: #dfe8f6 #a3bae9 #a3bae9 #dfe8f6; } body.x-body-masked .x-window-plain .x-window-mc { background-color: #ccd9e8; }.x-html-editor-wrap { border-color:#a9bfd3; background-color:#fff; } .x-html-editor-tb .x-btn-text { background-image:url(../images/default/editor/tb-sprite.gif); }.x-panel-noborder .x-panel-header-noborder { border-bottom-color:#99bbe8; } .x-panel-noborder .x-panel-tbar-noborder .x-toolbar { border-bottom-color:#99bbe8; } .x-panel-noborder .x-panel-bbar-noborder .x-toolbar { border-top-color:#99bbe8; } .x-tab-panel-bbar-noborder .x-toolbar { border-top-color:#99bbe8; } .x-tab-panel-tbar-noborder .x-toolbar { border-bottom-color:#99bbe8; }.x-border-layout-ct { background-color:#dfe8f6; } .x-accordion-hd { color:#222; font-weight:normal; background-image: url(../images/default/panel/light-hd.gif); } .x-layout-collapsed{ background-color:#d2e0f2; border-color:#98c0f4; } .x-layout-collapsed-over{ background-color:#d9e8fb; } .x-layout-split-west .x-layout-mini { background-image:url(../images/default/layout/mini-left.gif); } .x-layout-split-east .x-layout-mini { background-image:url(../images/default/layout/mini-right.gif); } .x-layout-split-north .x-layout-mini { background-image:url(../images/default/layout/mini-top.gif); } .x-layout-split-south .x-layout-mini { background-image:url(../images/default/layout/mini-bottom.gif); } .x-layout-cmini-west .x-layout-mini { background-image:url(../images/default/layout/mini-right.gif); } .x-layout-cmini-east .x-layout-mini { background-image:url(../images/default/layout/mini-left.gif); } .x-layout-cmini-north .x-layout-mini { background-image:url(../images/default/layout/mini-bottom.gif); } .x-layout-cmini-south .x-layout-mini { background-image:url(../images/default/layout/mini-top.gif); }.x-progress-wrap { border-color:#6593cf; } .x-progress-inner { background-color:#e0e8f3; background-image:url(../images/default/qtip/bg.gif); } .x-progress-bar { background-color:#9cbfee; background-image:url(../images/default/progress/progress-bg.gif); border-top-color:#d1e4fd; border-bottom-color:#7fa9e4; border-right-color:#7fa9e4; } .x-progress-text { font-size:11px; font-weight:bold; color:#fff; } .x-progress-text-back { color:#396095; }.x-list-header{ background-color:#f9f9f9; background-image:url(../images/default/grid/grid3-hrow.gif); } .x-list-header-inner div em { border-left-color:#ddd; font:normal 11px arial, tahoma, helvetica, sans-serif; } .x-list-body dt em { font:normal 11px arial, tahoma, helvetica, sans-serif; } .x-list-over { background-color:#eee; } .x-list-selected { background-color:#dfe8f6; } .x-list-resizer { border-left-color:#555; border-right-color:#555; } .x-list-header-inner em.sort-asc, .x-list-header-inner em.sort-desc { background-image:url(../images/default/grid/sort-hd.gif); border-color: #99bbe8; }.x-slider-horz, .x-slider-horz .x-slider-end, .x-slider-horz .x-slider-inner { background-image:url(../images/default/slider/slider-bg.png); } .x-slider-horz .x-slider-thumb { background-image:url(../images/default/slider/slider-thumb.png); } .x-slider-vert, .x-slider-vert .x-slider-end, .x-slider-vert .x-slider-inner { background-image:url(../images/default/slider/slider-v-bg.png); } .x-slider-vert .x-slider-thumb { background-image:url(../images/default/slider/slider-v-thumb.png); }.x-window-dlg .ext-mb-text, .x-window-dlg .x-window-header-text { font-size:12px; } .x-window-dlg .ext-mb-textarea { font:normal 12px tahoma,arial,helvetica,sans-serif; } .x-window-dlg .x-msg-box-wait { background-image:url(../images/default/grid/loading.gif); } .x-window-dlg .ext-mb-info { background-image:url(../images/default/window/icon-info.gif); } .x-window-dlg .ext-mb-warning { background-image:url(../images/default/window/icon-warning.gif); } .x-window-dlg .ext-mb-question { background-image:url(../images/default/window/icon-question.gif); } .x-window-dlg .ext-mb-error { background-image:url(../images/default/window/icon-error.gif); }
zzm-calender-gadgets
trunk/ext/resources/css/ext-all.css
CSS
asf20
146,583
package com.zp.resource; import java.util.ArrayList; import java.util.List; import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.springframework.stereotype.Component; import com.sun.jersey.spi.resource.Singleton; import com.zp.bean.common.ResultCommonVo; import com.zp.bean.paper.AnswerResultVo; import com.zp.bean.paper.ResultAnswerResultVo; import com.zp.bean.paper.ResultPaperVo; import com.zp.domain.AnswerItem; import com.zp.domain.AnswerResult; import com.zp.domain.Paper; import com.zp.domain.Question; import com.zp.resource.common.BaseServices; import com.zp.util.Constant; import com.zp.util.MyException; /** * answer result services * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/2/22 * */ @Component @Path("/rest/anresult") @Singleton public class AnswerResultServices extends BaseServices { /** * add one AnswerResult path:/anresult/addAnResult Http:POST * * @param anresult * * @return Response, ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":0} */ @POST @Path("/addAnResult") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response addAnResult(AnswerResult anresult) { ResultCommonVo result = new ResultCommonVo(); try { jpaDao.save(anresult); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * update one AnswerResult path:/anresult/updateAnResult Http:PUT * * @param anresult * * @return Response, ResultCommonVo with JSON String * like:like:{"code":268,"message":"OK","totalCount":0} */ @PUT @Path("/updateAnResult") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response updateAnResult(AnswerResult anresult) { ResultCommonVo result = new ResultCommonVo(); try { jpaDao.update(anresult); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * * get all the papers which user has been done by its id * path:/anresult/getPapersForUser Http:GET * * @param pageNo * * @param pageSize * * @param userId * the id of user * * @return Response, ResultAnswerResultVo with JSON String * like:{"code":268,"message" * :"OK","totalCount":1,"paper":null,"list" * :[{"id":"402881e6445c883e01445c8a74290001","name":"心理关爱"}]} * */ @GET @Path("/getPapersForUser") @Produces({ MediaType.APPLICATION_JSON }) public Response getPapersForUser(@QueryParam("pageNo") int pageNo, @QueryParam("pageSize") int pageSize, @QueryParam("userId") String userId) { logger.info("getAnResultsForUser called json pageNo:" + pageNo + " pageSize:" + pageSize + " userId:" + userId); ResultPaperVo result = new ResultPaperVo(); if ("".equals(userId) || userId == null) { result.setCode(Constant.FAILE_CODE); result.setMessage("userId is null"); } else { String jpql = "select distinct paperId from AnswerResult where author=?"; String countSql = "select count(distinct paperId) from AnswerResult where author=?"; List<?> list = null; result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); Object[] param = { userId }; try { list = this.jpaDao.getResultData(pageNo, pageSize, jpql, param); long totalCount = this.jpaDao.getCount(countSql, param); result.setTotalCount(totalCount); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } if (list != null && list.size() > Constant.ZERO) { List<Paper> lp = new ArrayList<Paper>(); for (Object o : list) { String anresult = (String) o; try { lp.add((Paper) this.jpaDao.findById(Paper.class, anresult)); } catch (MyException e) { lp.add(null); e.printStackTrace(); } } result.setList(lp); } } return Response.ok(result).build(); } /** * get result for user with specific paper path:/anresult/getResultsForUser * Http:GET * * @param pageNo * @param pageSize * @param userId * the primary key of user * @param paperId * the primary key of paper * @return Response ResultAnswerResultVo with JSON String * like:{"code":268,"message" * :"OK","totalCount":3,"vo":null,"list":[{ * "id":1,"question":{"id":"402881e6445cc3a301445cc4332b0001" * ,"title":"心理关爱题目1","questionType":"QUS00001","questionAnswer":"", * "businessType" * :null},"item":{"id":"402881e6445d4c3701445d515f8e0002" * ,"questionId" * :"402881e6445cc3a301445cc4332b0001","answerCode":"A", * "value":"心理关爱题目1答案1"},"status":"1"},{"id":2,"question":{"id": * "402881e6445cc3a301445cc4b9890002" * ,"title":"心理关爱题目2","questionType" * :"QUS00001","questionAnswer":null * ,"businessType":null},"item":{"id" * :"402881e6445d53b401445d5688d50005" * ,"questionId":"402881e6445cc3a301445cc4b9890002" * ,"answerCode":"B","value":"心理关爱题目2答案2"},"status":"1"}]} */ @GET @Path("/getResultsForUser") @Produces({ MediaType.APPLICATION_JSON }) public Response getResultFromPaperAndUser(@QueryParam("pageNo") int pageNo, @QueryParam("pageSize") int pageSize, @QueryParam("userId") String userId, @QueryParam("paperId") String paperId) { ResultAnswerResultVo result = new ResultAnswerResultVo(); logger.info("getResultFromPaperAndUser called json pageNo:" + pageNo + " pageSize:" + pageSize + " userId:" + userId + " paperId:" + paperId); String jpql = "from AnswerResult where author=? and paperId=?"; String countSql = "select count(id) from AnswerResult where author=? and paperId=?"; List<?> list = null; result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); Object[] param = { userId, paperId }; try { list = this.jpaDao.getResultData(pageNo, pageSize, jpql, param); long totalCount = this.jpaDao.getCount(countSql, param); result.setTotalCount(totalCount); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } if (list != null && list.size() > Constant.ZERO) { List<AnswerResultVo> lp = new ArrayList<AnswerResultVo>(); for (Object o : list) { AnswerResult anresult = (AnswerResult) o; AnswerResultVo vo = new AnswerResultVo(); vo.setId(anresult.getId()); try { vo.setItem((AnswerItem) this.jpaDao.findById( AnswerItem.class, anresult.getAnswerItemId())); } catch (MyException e) { vo.setItem(null); e.printStackTrace(); } try { vo.setQuestion((Question) this.jpaDao.findById( Question.class, anresult.getQuestionId())); } catch (MyException e) { vo.setQuestion(null); e.printStackTrace(); } vo.setStatus(anresult.getStatus()); lp.add(vo); } result.setList(lp); } return Response.ok(result).build(); } /** * get the score of specific paper with user id path:/anresult/getScore * * @param userId * primary key of LoginInfo * @param paperId * primary key of paper * @return Response ResultCommonVo with JSON String * like:{"code":268,"message":"40","totalCount":0} */ @GET @Path("/getScore") @Produces(MediaType.APPLICATION_JSON) public Response getScore(@QueryParam("userId") String userId, @QueryParam("paperId") String paperId) { ResultCommonVo result = new ResultCommonVo(); String commitjpql = "select count(a.id) from AnswerResult a,Question q where a.answerItemId=q.questionAnswer and a.author=? and a.paperId=?"; String totalJpql = "select count(paperId)from PaperQuestion"; Object[] queryParams = { userId, paperId }; long correctNum = this.jpaDao.getCount(commitjpql, queryParams); long totalNum = this.jpaDao.getCount(totalJpql, null); String score = String .valueOf(((float) correctNum / (float) totalNum) * 100); result.setCode(Constant.SUCCESS_CODE); result.setMessage(score); return Response.ok(result).build(); } }
zzyyp
trunk/zp/src/com/zp/resource/AnswerResultServices.java
Java
asf20
8,762
package com.zp.resource; import java.util.ArrayList; import java.util.List; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.springframework.stereotype.Component; import com.sun.jersey.spi.resource.Singleton; import com.zp.bean.common.ResultCommonVo; import com.zp.bean.order.ResultScheduleGroupVo; import com.zp.bean.order.ScheduleGroupVo; import com.zp.bean.user.ResultUserVo; import com.zp.bean.user.UserVo; import com.zp.domain.ScheduleGroup; import com.zp.domain.User; import com.zp.resource.common.BaseServices; import com.zp.util.Constant; import com.zp.util.MyException; /** * schedule group services * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/2/24 * */ @Component @Path("/rest/schgroup") @Singleton public class ScheduleGroupServices extends BaseServices { /** * add schgroup path:/schgroup/addScheduleGroup Http:POST * * @param schgroup * * @return Response,ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":1} */ @POST @Path("/addScheduleGroup") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response addScheduleGroup(ScheduleGroup schgroup) { ResultCommonVo result = new ResultCommonVo(); try { this.jpaDao.save(schgroup); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * update ScheduleGroup information path:/schgroup/updateScheduleGroup * Http:PUT * * @param schgroup * * @return Response,ResultScheduleGroupVo with JSON String like: */ @PUT @Path("/updateScheduleGroup") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response updateScheduleGroup(ScheduleGroup schgroup) { ResultScheduleGroupVo result = new ResultScheduleGroupVo(); try { this.jpaDao.update(schgroup); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); ScheduleGroupVo vo = new ScheduleGroupVo(); vo.setId(schgroup.getId()); vo.setType(this.getTypeByCode(schgroup.getGroupType())); try { vo.setUser((User) this.jpaDao.findById(User.class, schgroup.getUserId())); } catch (IllegalArgumentException e) { vo.setUser(null); } result.setSg(vo); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * get ScheduleGroup by id path:/type/getScheGroById Http:GET * * @param id * primary key of ScheduleGroup * * @return Response,ResultScheduleGroupVo with JSON String like: */ @GET @Path("/getScheGroById") @Produces(MediaType.APPLICATION_JSON) public Response getScheduleGroupById(@QueryParam("id") String id) { logger.info("getScheduleGroupById called id:" + id); ResultScheduleGroupVo result = new ResultScheduleGroupVo(); try { ScheduleGroup schgroup = (ScheduleGroup) jpaDao.findById( ScheduleGroup.class, id); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); ScheduleGroupVo vo = new ScheduleGroupVo(); vo.setId(schgroup.getId()); vo.setType(this.getTypeByCode(schgroup.getGroupType())); try { vo.setUser((User) this.jpaDao.findById(User.class, schgroup.getUserId())); } catch (IllegalArgumentException e) { vo.setUser(null); } result.setSg(vo); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * get ScheduleGroup by user id path:/type/getScheGroByUser Http:GET * * @param userId * primary key of user * * @return Response,ResultScheduleGroupVo with JSON String like: */ @GET @Path("/getScheGroByUser") @Produces(MediaType.APPLICATION_JSON) public Response getScheduleGroupByUserId(@QueryParam("userId") String userId) { logger.info("getScheduleGroupById called userId:" + userId); ResultScheduleGroupVo result = new ResultScheduleGroupVo(); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); String jpql = "from ScheduleGroup where userId=?"; Object[] queryParams = { userId }; try { List<?> list = this.jpaDao.getResultData(Constant.NEGATIVE_ONE, Constant.NEGATIVE_ONE, jpql, queryParams); if (list != null && list.size() > Constant.ZERO) { ScheduleGroup schgroup = (ScheduleGroup) list .get(Constant.ZERO); ScheduleGroupVo vo = new ScheduleGroupVo(); vo.setId(schgroup.getId()); vo.setType(this.getTypeByCode(schgroup.getGroupType())); try { vo.setUser((User) this.jpaDao.findById(User.class, schgroup.getUserId())); } catch (IllegalArgumentException e) { vo.setUser(null); } result.setSg(vo); } } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * delete ScheduleGroup by id path:/schgroup/deleteScheduleGroup Http:DELETE * * @param id * primary key of ScheduleGroup * * @return Response,ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":1} */ @DELETE @Path("/deleteScheduleGroup") @Produces(MediaType.APPLICATION_JSON) public Response deleteScheduleGroup(@QueryParam("id") String id) { logger.info("deleteScheduleGroup called id:" + id); ResultCommonVo result = new ResultCommonVo(); try { this.jpaDao.deleteById(ScheduleGroup.class, id); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * search all of the users with one group path:/schgroup/searchScheduleGroup * Http:GET * * @param groupType * the code of schedule group type * * @return Response, ResultScheduleGroupVo with JSON String like: */ @GET @Path("/searchScheduleGroup") @Produces(MediaType.APPLICATION_JSON) public Response searchScheduleGroupWithType( @QueryParam("pageNo") int pageNo, @QueryParam("pageSize") int pageSize, @QueryParam("groupType") String groupType) { logger.info("searchScheduleGroup called PageNo is:" + pageNo + " pageSize is:" + pageSize + " json groupType:" + groupType); String jpql = "from ScheduleGroup where groupType=?"; List<?> list = null; ResultUserVo result = new ResultUserVo(); List<UserVo> lt = new ArrayList<UserVo>(); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); Object[] param = { groupType }; try { list = this.jpaDao.getResultData(pageNo, pageSize, jpql, param); long totalCount = this.jpaDao.getCount( "select count(id) from ScheduleGroup where groupType=?", param); result.setTotalCount(totalCount); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } if (list != null && list.size() > Constant.ZERO) { for (Object o : list) { ScheduleGroup schgroup = (ScheduleGroup) o; UserVo vo = new UserVo(); User user; try { user = (User) this.jpaDao.findById(User.class, schgroup.getUserId()); vo.setBirthday(user.getBirthday()); vo.setCertNumber(user.getGender()); vo.setGender(user.getGender()); vo.setId(user.getId()); vo.setLogin(null); vo.setName(user.getName()); vo.setRegisterTime(user.getRegisterTime()); vo.setType(null); vo.setUpdateTime(user.getUpdateTime()); lt.add(vo); } catch (MyException e) { e.printStackTrace(); } } result.setListVo(lt); } return Response.ok(result).build(); } }
zzyyp
trunk/zp/src/com/zp/resource/ScheduleGroupServices.java
Java
asf20
8,228
package com.zp.resource; import java.util.ArrayList; import java.util.List; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.springframework.stereotype.Component; import com.sun.jersey.spi.resource.Singleton; import com.zp.bean.common.ResultCommonVo; import com.zp.bean.paper.ResultPaperVo; import com.zp.domain.Paper; import com.zp.resource.common.BaseServices; import com.zp.util.Constant; import com.zp.util.MyException; /** * paper services * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/2/22 * */ @Component @Path("/rest/paper") @Singleton public class PaperServices extends BaseServices { /** * add one Paper path:/paper/addPaper Http:POST * * @param paper * * @return Response, ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":0} */ @POST @Path("/addPaper") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response addPaper(Paper paper) { ResultCommonVo result = new ResultCommonVo(); try { jpaDao.save(paper); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * update one Paper path:/paper/updatePaper Http:PUT * * @param paper * * @return Response, ResultPaperVo with JSON String * like:{"code":268,"message":"OK","totalCount":0,"paper":{"id": * "402881e6445c883e01445c8a74290001","name":"心理关爱"},"list":null} */ @PUT @Path("/updatePaper") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response updatePaper(Paper paper) { ResultPaperVo result = new ResultPaperVo(); try { jpaDao.update(paper); result.setPaper(paper); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * delete Paper by id path:/paper/deletePaper Http:DELETE * * @param paperId * primary key of Paper * * @return Response, ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":1} */ @DELETE @Path("/deletePaper") @Produces(MediaType.APPLICATION_JSON) public Response deletePaper(@QueryParam("paperId") String paperId) { logger.info("deletePaper called paperId:" + paperId); ResultCommonVo result = new ResultCommonVo(); try { jpaDao.deleteById(Paper.class, paperId); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * get Paper by id path:/paper/getPaper Http:GET * * @param paperId * primary key of Paper * * @return Response, ResultPaperVo with JSON String * like:{"code":268,"message":"OK","totalCount":0,"paper":{"id": * "402881e6445c883e01445c8a74290001","name":"心理关爱"},"list":null} * */ @GET @Path("/getPaper") @Produces(MediaType.APPLICATION_JSON) public Response getPaperById(@QueryParam("paperId") String paperId) { logger.info("getPaperById called paperId:" + paperId); ResultPaperVo result = new ResultPaperVo(); try { Paper paper = (Paper) jpaDao.findById(Paper.class, paperId); result.setPaper(paper); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * * get paper with page parameters and search condition path:/paper/getPapers * Http:GET * * @param pageNo * * @param pageSize * * @param paperName * the name of paper,if ignored the value is null * * @return Response, ResultPaperVo with JSON String * like:{"code":268,"message" * :"OK","totalCount":1,"paper":null,"list" * :[{"id":"402881e6445c883e01445c8a74290001","name":"心理关爱"}]} * * */ @GET @Path("/getPapers") @Produces({ MediaType.APPLICATION_JSON }) public Response getPaperByCodeName(@QueryParam("pageNo") int pageNo, @QueryParam("pageSize") int pageSize, @QueryParam("paperName") String paperName) { logger.info("getPaperByCritera called json pageNo:" + pageNo + " pageSize:" + pageSize + " paperName:" + paperName); String jpql = "from Paper where name=? order by name asc"; String countSql = "select count(id) from Paper where name=? order by name asc"; List<?> list = null; ResultPaperVo result = new ResultPaperVo(); List<Paper> lt = new ArrayList<Paper>(); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); if ("".equals(paperName) || paperName == null) { jpql = "from Paper order by name asc"; countSql = "select count(id) from Paper order by name asc"; try { list = this.jpaDao.getResultData(pageNo, pageSize, jpql, null); long totalCount = this.jpaDao.getCount(countSql, null); result.setTotalCount(totalCount); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } } else { Object[] param = { paperName }; try { list = this.jpaDao.getResultData(pageNo, pageSize, jpql, param); long totalCount = this.jpaDao.getCount(countSql, param); result.setTotalCount(totalCount); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } } if (list != null && list.size() > Constant.ZERO) { for (Object o : list) { Paper paper = (Paper) o; lt.add(paper); } result.setList(lt); } return Response.ok(result).build(); } }
zzyyp
trunk/zp/src/com/zp/resource/PaperServices.java
Java
asf20
6,300
package com.zp.resource.user; import java.util.ArrayList; import java.util.List; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.springframework.stereotype.Component; import com.sun.jersey.spi.resource.Singleton; import com.zp.bean.common.ResultCommonVo; import com.zp.bean.user.PermissionVo; import com.zp.bean.user.ResultPermissionVo; import com.zp.domain.Permission; import com.zp.resource.common.BaseServices; import com.zp.util.Constant; import com.zp.util.MyException; /** * permission services * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/2/12 * */ @Component @Path("/rest/permission") @Singleton public class PermissionServices extends BaseServices { /** * add permission path:/permission/addPermission Http:POST * * @param permission * * @return Response,ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":1} */ @POST @Path("/addPermission") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response addPermission(Permission permission) { ResultCommonVo result = new ResultCommonVo(); try { this.jpaDao.save(permission); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * update Permission information path:/permission/updatePermission Http:PUT * * @param permission * * @return Response,ResultPermissionVo with JSON String * like:{"code":268,"message" * :"OK","totalCount":1,"permission":{"id": * "402881e6445916b401445921eff30003" * ,"name":"用户注册","type":{"id":"402881e6445916b40144591eb6580001" * ,"name":"权限","code":"AU0001","parentCode":"DA0001"},"parentCode": * "P00001" * ,"url":"/user/registerUser","status":"1","code":"P00002"}, * "list":null} */ @PUT @Path("/updatePermission") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response updatePermission(Permission permission) { ResultPermissionVo result = new ResultPermissionVo(); try { this.jpaDao.update(permission); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); PermissionVo vo = new PermissionVo(); vo.setCode(permission.getCode()); vo.setId(permission.getId()); vo.setName(permission.getName()); vo.setParentCode(permission.getParentCode()); vo.setStatus(permission.getStatus()); vo.setType(this.getTypeByCode(permission.getTypeCode())); vo.setUrl(permission.getUrl()); result.setPermission(vo); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * get permission by id path:/permission/getPermission Http:GET * * @param permissionId * primary key of Permission * * @return Response,ResultPermissionVo with JSON String * like:{"code":268,"message" * :"OK","totalCount":1,"permission":{"id": * "402881e6445916b401445921eff30003" * ,"name":"用户注册","type":{"id":"402881e6445916b40144591eb6580001" * ,"name":"权限","code":"AU0001","parentCode":"DA0001"},"parentCode": * "P00001" * ,"url":"/user/registerUser","status":"1","code":"P00002"}, * "list":null} */ @GET @Path("/getPermission") @Produces(MediaType.APPLICATION_JSON) public Response getPermissionById( @QueryParam("permissionId") String permissionId) { logger.info("getPermissionById called permissionId:" + permissionId); ResultPermissionVo result = new ResultPermissionVo(); try { Permission permission = (Permission) jpaDao.findById( Permission.class, permissionId); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); PermissionVo vo = new PermissionVo(); vo.setCode(permission.getCode()); vo.setId(permission.getId()); vo.setName(permission.getName()); vo.setParentCode(permission.getParentCode()); vo.setStatus(permission.getStatus()); vo.setType(this.getTypeByCode(permission.getTypeCode())); vo.setUrl(permission.getUrl()); result.setPermission(vo); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * delete Permission by id path:/permission/deletePermission Http:DELETE * * @param permisionId * primary key of Permission * * @return Response,ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":1} */ @DELETE @Path("/deletePermission") @Produces(MediaType.APPLICATION_JSON) public Response deletePermission( @QueryParam("permisionId") String permisionId) { logger.info("deletePermission called permisionId:" + permisionId); ResultCommonVo result = new ResultCommonVo(); try { this.jpaDao.deleteById(Permission.class, permisionId); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * search permission with filter parameters * path:/permission/searchPermission Http:GET * * @param pageNo * * @param pageSize * * @param permNameorCode * the name of permission or code of permission if ignored the * value is null * * @return Response, ResultPermissionVo with JSON String * like:{"code":268,"message" * :"OK","totalCount":1,"permission":null,"list" * :[{"id":"402881e6445916b401445923d0300006" * ,"name":"修改用户密码","type": * {"id":"402881e6445916b40144591eb6580001","name" * :"权限","code":"AU0001" * ,"parentCode":"DA0001"},"parentCode":"P00001" * ,"url":"/user/updatePass","status":"1","code":"P00005"}]} */ @GET @Path("/searchPermission") @Produces(MediaType.APPLICATION_JSON) public Response searchPermission(@QueryParam("pageNo") int pageNo, @QueryParam("pageSize") int pageSize, @QueryParam("permNameorCode") String permNameorCode) { logger.info("searchPermission called json pageNo:" + pageNo + " pageSize:" + pageSize + " permNameorCode:" + permNameorCode); String jpql = "from Permission where name=? or code=? order by code asc"; List<?> list = null; ResultPermissionVo result = new ResultPermissionVo(); List<PermissionVo> lt = new ArrayList<PermissionVo>(); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); if ("".equals(permNameorCode) || permNameorCode == null) { jpql = "from Permission order by code asc"; try { list = this.jpaDao.getResultData(pageNo, pageSize, jpql, null); long totalCount = this.jpaDao.getCount( "select count(id) from Permission", null); result.setTotalCount(totalCount); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } } else { Object[] param = { permNameorCode, permNameorCode }; try { list = this.jpaDao.getResultData(pageNo, pageSize, jpql, param); long totalCount = this.jpaDao .getCount( "select count(id) from Permission where name=? or code=?", param); result.setTotalCount(totalCount); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } } if (list != null && list.size() > Constant.ZERO) { for (Object o : list) { Permission permission = (Permission) o; PermissionVo vo = new PermissionVo(); vo.setCode(permission.getCode()); vo.setId(permission.getId()); vo.setName(permission.getName()); vo.setParentCode(permission.getParentCode()); vo.setStatus(permission.getStatus()); vo.setType(this.getTypeByCode(permission.getTypeCode())); vo.setUrl(permission.getUrl()); lt.add(vo); } result.setList(lt); } return Response.ok(result).build(); } }
zzyyp
trunk/zp/src/com/zp/resource/user/PermissionServices.java
Java
asf20
8,563
package com.zp.resource.user; import java.util.ArrayList; import java.util.List; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.springframework.stereotype.Component; import com.sun.jersey.spi.resource.Singleton; import com.zp.bean.common.ResultCommonVo; import com.zp.bean.user.PermissionVo; import com.zp.bean.user.ResultPermissionVo; import com.zp.bean.user.ResultRoleVo; import com.zp.domain.Permission; import com.zp.domain.Role; import com.zp.domain.RolePermission; import com.zp.resource.common.BaseServices; import com.zp.util.Constant; import com.zp.util.MyException; /** * role services * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/2/12 * */ @Component @Path("/rest/role") @Singleton public class RoleServices extends BaseServices { /** * add role path:/role/addRole http:POST * * @param role * * @return Response, ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":1} */ @POST @Path("/addRole") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response addRole(Role role) { ResultCommonVo result = new ResultCommonVo(); try { this.jpaDao.save(role); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * update Role information path:/role/updateRole Http:PUT * * @param role * * @return Response, ResultRoleVo with JSON String * like:{"code":268,"message":"OK","totalCount":1} */ @PUT @Path("/updateRole") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response updateRole(Role role) { ResultRoleVo result = new ResultRoleVo(); try { this.jpaDao.update(role); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); result.setRole(role); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * get role by id path:/type/getRole Http:GET * * @param roleId * primary key of Role * * @return Response, ResultRoleVo with JSON String * like:{"code":268,"message":"OK","totalCount":1,"role":{"id": * "402881e64458d2bb014458efead00011" * ,"name":"新闻管理人员","code":"N00001","status":"1"},"list":null} */ @GET @Path("/getRole") @Produces(MediaType.APPLICATION_JSON) public Response getRoleById(@QueryParam("roleId") String roleId) { logger.info("getRoleById called roleId:" + roleId); ResultRoleVo result = new ResultRoleVo(); try { Role role = (Role) jpaDao.findById(Role.class, roleId); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); result.setRole(role); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * delete Role by id path:/role/deleteRole Http:DELETE * * @param roleId * primary key of Role * * @return Response, ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":1} */ @DELETE @Path("/deleteRole") @Produces(MediaType.APPLICATION_JSON) public Response deleteRole(@QueryParam("roleId") String roleId) { logger.info("deleteRole called typeId:" + roleId); ResultCommonVo result = new ResultCommonVo(); try { this.jpaDao.deleteById(Role.class, roleId); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * search role with criteria path:/role/searchRole Http:GET * * @param pageNo * * @param pageSize * * @param roleNameorCode * the name of Role or the code of Role if ignored the value is * null * * @return Response, ResultRoleVo with JSON String * like:{"code":268,"message" * :"OK","totalCount":4,"role":null,"list": * [{"id":"402881e64458d2bb014458ef33ab0010" * ,"name":"系统管理人员","code":"DBA001" * ,"status":"1"},{"id":"402881e64458d2bb014458f050e50012" * ,"name":"普通用户","code":"G00001","status":"1"},{"id": * "402881e64458d2bb014458f0c8920013" * ,"name":"管理人员","code":"M00001","status" * :"1"},{"id":"402881e64458d2bb014458efead00011" * ,"name":"新闻管理人员","code":"N00001","status":"1"}]} */ @GET @Path("/searchRole") @Produces(MediaType.APPLICATION_JSON) public Response searchRole(@QueryParam("pageNo") int pageNo, @QueryParam("pageSize") int pageSize, @QueryParam("roleNameorCode") String roleNameorCode) { logger.info("searchRole called json pageNo:" + pageNo + " pageSize:" + pageSize + " roleNameorCode:" + roleNameorCode); String jpql = "from Role where name=? or code=? order by code asc"; List<?> list = null; ResultRoleVo result = new ResultRoleVo(); List<Role> lt = new ArrayList<Role>(); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); if ("".equals(roleNameorCode) || roleNameorCode == null) { jpql = "from Role order by code asc"; try { list = this.jpaDao.getResultData(pageNo, pageSize, jpql, null); long totalCount = this.jpaDao.getCount( "select count(id) from Role", null); result.setTotalCount(totalCount); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } } else { Object[] param = { roleNameorCode, roleNameorCode }; try { list = this.jpaDao.getResultData(pageNo, pageSize, jpql, param); long totalCount = this.jpaDao.getCount( "select count(id) from Role where name=? or code=?", param); result.setTotalCount(totalCount); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } } if (list != null && list.size() > Constant.ZERO) { for (Object o : list) { Role type = (Role) o; lt.add(type); } result.setList(lt); } return Response.ok(result).build(); } /** * assign permission to role path:/role/assignPermission Http:POST * * @param permRole * * @return Response,ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":1} */ @POST @Path("/assignPermission") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response assignPermissionToRole(RolePermission permRole) { ResultCommonVo result = new ResultCommonVo(); try { this.jpaDao.save(permRole); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * get permission from role id path:/role/getPerFromRoleId Http:GET * * @param roleId * the primary key of Role * * @return ResultPermissionVo with JSON String * like:{"code":268,"message":"OK" * ,"totalCount":8,"permission":null,"list" * :[{"id":"402881e6445916b401445921eff30003" * ,"name":"用户注册","type":{"id" * :"402881e6445916b40144591eb6580001","name" * :"权限","code":"AU0001","parentCode" * :"DA0001"},"parentCode":"P00001" * ,"url":"/user/registerUser","status" * :"1","code":"P00002"},{"id":"402881e6445916b401445922cf300004" * ,"name" * :"用户登录","type":{"id":"402881e6445916b40144591eb6580001","name" * :"权限" * ,"code":"AU0001","parentCode":"DA0001"},"parentCode":"P00001" * ,"url":"/user/login","status":"1","code":"P00003"}]} */ @GET @Path("/getPerFromRoleId") @Produces(MediaType.APPLICATION_JSON) public Response getPermissionFromRoleId(@QueryParam("roleId") String roleId) { ResultPermissionVo result = new ResultPermissionVo(); String jpql = "from RolePermission where roleId=?"; List<?> list = null; List<PermissionVo> lt = new ArrayList<PermissionVo>(); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); Object[] param = { roleId }; try { list = this.jpaDao.getResultData(Constant.NEGATIVE_ONE, Constant.NEGATIVE_ONE, jpql, param); long totalCount = this.jpaDao.getCount( "select count(id) from RolePermission where roleId=?", param); result.setTotalCount(totalCount); if (list != null && list.size() > Constant.ZERO) { for (Object o : list) { RolePermission rolePermission = (RolePermission) o; Permission permission = (Permission) this.jpaDao.findById( Permission.class, rolePermission.getPermissionId()); PermissionVo vo = new PermissionVo(); vo.setCode(permission.getCode()); vo.setId(permission.getId()); vo.setName(permission.getName()); vo.setParentCode(permission.getParentCode()); vo.setStatus(permission.getStatus()); vo.setType(this.getTypeByCode(permission.getTypeCode())); vo.setUrl(permission.getUrl()); lt.add(vo); } result.setList(lt); } } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } }
zzyyp
trunk/zp/src/com/zp/resource/user/RoleServices.java
Java
asf20
9,959
package com.zp.resource.user; import java.util.ArrayList;import java.util.Date; import java.util.List; import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.codehaus.jettison.json.JSONException; import org.codehaus.jettison.json.JSONObject; import org.springframework.stereotype.Component; import com.sun.jersey.spi.resource.Singleton; import com.zp.bean.common.ResultCommonVo; import com.zp.bean.user.ResultLoginVo; import com.zp.bean.user.ResultRoleVo; import com.zp.bean.user.ResultUserVo; import com.zp.bean.user.UserVo; import com.zp.domain.LoginInfo; import com.zp.domain.Role; import com.zp.domain.User; import com.zp.domain.UserRole; import com.zp.resource.common.BaseServices; import com.zp.util.Constant; import com.zp.util.MD5Util; import com.zp.util.MyException; /** * user services * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/2/15 * */ @Component @Path("rest/user") @Singleton public class UserServices extends BaseServices { /** * login web system path:/user/login Http:POST * * @param loginName * * @param loginPass * * @param sysName * * @return Response,ResultUserVo with JSON String * like:{"code":268,"message":"OK","totalCount":1,"login":{"id": * "402881e64459ad0e014459adc3b00001" * ,"username":"Alex","password":"b3275960d68fda9d831facc0426c3bbc" * ,"status" * :"1","passErrorCount":0,"passStatus":"1","passUpdateTime" * :null},"key":"8ea96781b7315eb13aaca08e4ffc71ee"} */ @POST @Path("/login") @Produces(MediaType.APPLICATION_JSON) public Response login(@QueryParam("loginName") String loginName, @QueryParam("loginPass") String loginPass, @QueryParam("sysName") String sysName) { logger.info("login called loginName is:" + loginName + " sysName:" + sysName); ResultLoginVo result = new ResultLoginVo(); String jpql = "from LoginInfo where username=? and password=? and status=?"; Object[] queryParams = { loginName, loginPass, "1" }; List<?> list; try { list = this.jpaDao.getResultData(Constant.NEGATIVE_ONE, Constant.NEGATIVE_ONE, jpql, queryParams); if (list != null && list.size() > Constant.ZERO) { LoginInfo login = (LoginInfo) list.get(Constant.ZERO); result.setLogin(login); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); long expiryTime = System.currentTimeMillis(); expiryTime += 1000L * Constant.EIGHT_HOUR_S; String signatureValue = makeTokenSignature(expiryTime, loginName, loginPass, sysName); result.setKey(signatureValue); } else { result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.USER_NOT_EXITS); } } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * login out web system * * @return Response */ @GET @Path("/loginout") @Produces(MediaType.APPLICATION_JSON) public Response loginOut() { // login.setstatus(Constant.OFF); return Response.ok(Constant.OK).build(); } /** * update user password path:/user/updatePass Http:POST * * @param updatePass * like{"userId":"1234567","orginalPassword":"123456": * "newPassword":"1234567"} * * @return Response,ResultCommonVo with JSON * String,{"code":268,"message":"OK","totalCount":1} */ @POST @Path("/updatePass") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response updateUserPassword( @QueryParam("updatePass") String updatePass) { logger.info("updateUserPassword called updatePass is:" + updatePass); ResultCommonVo result = new ResultCommonVo(); try { JSONObject record = this.getJSONObject(updatePass); String userId = record.getString("userId"); String orginalPassword = record.getString("orginalPassword"); String newPassword = record.getString("newPassword"); if (orginalPassword.equals(newPassword)) { result.setCode(Constant.FAILE_CODE); result.setMessage(Constant.PASS_SAME); } else { try { LoginInfo login = (LoginInfo) this.jpaDao.findById( LoginInfo.class, userId); if(login!=null){ if (login.getPassword().equals(orginalPassword)) { login.setPassword(newPassword); this.jpaDao.update(login); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } } } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } } } catch (JSONException e) { e.printStackTrace(); } return Response.ok(result).build(); } /** * register user information path:/user/registerUser Http:POST * * @param jsonContext * JSON string like:{"username":"Alex","password": * "b3275960d68fda9d831facc0426c3bbc"} * @return Response,ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":1} */ @POST @Path("/registerUser") @Produces(MediaType.APPLICATION_JSON) public Response registerUser(@QueryParam("jsonContext") String jsonContext) { logger.info("param:"+jsonContext); ResultCommonVo result = new ResultCommonVo(); try{ JSONObject record = this.getJSONObject(jsonContext); String username = record.getString("username"); String password = record.getString("password"); LoginInfo loginInfo = this.getLoginInfoByName(username); if (loginInfo == null) { LoginInfo login = new LoginInfo(); login.setUsername(username); login.setStatus(Constant.ON); login.setPassword(password); login.setPassStatus(Constant.ON); try { this.jpaDao.save(login); loginInfo = this.getLoginInfoByName(username); User user = new User(); user.setId(loginInfo.getId()); user.setName(login.getUsername()); user.setRegisterTime(new Date()); user.setUpdateTime(new Date()); this.jpaDao.save(user); UserRole userRole = new UserRole(); userRole.setUserId(loginInfo.getId()); Role role = this.getRoleByCode(Constant.USER_ROLE); userRole.setRoleId(role.getId()); userRole.setCode(role.getCode()); this.jpaDao.save(userRole); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } } else { result.setCode(Constant.FAILE_CODE); result.setMessage(Constant.USER_EXIST); } }catch(Exception e){ e.printStackTrace(); result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); } return Response.ok(result).build(); } /** * get User information with user id path:/user/getUser Http:POST * * @param userId * * @return Response, ResultUserVo with JSON String * like:{"code":268,"message":"OK","totalCount":1,"userInfo":{"id": * "402881e64459ad0e014459adc3b00001" * ,"name":"Alex","birthday":null,"gender" * :null,"certNumber":null,"type" * :null,"registerTime":1393073964292,"updateTime" * :null,"login":{"id" * :"402881e64459ad0e014459adc3b00001","username": * "Alex","password":"e10adc3949ba59abbe56e057f20f883e" * ,"status":"1", * "passErrorCount":0,"passStatus":"1","passUpdateTime" * :null}},"listVo":null} */ @POST @Path("/getUser") @Produces(MediaType.APPLICATION_JSON) public Response getUserById(@QueryParam("userId") String userId) { logger.info("getUserById called userId:" + userId); ResultUserVo result = new ResultUserVo(); LoginInfo login; result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); try { login = (LoginInfo) this.jpaDao.findById(LoginInfo.class, userId); if (login != null) { UserVo vo = new UserVo(); User user = (User) this.jpaDao.findById(User.class, userId); vo.setBirthday(user.getBirthday()); vo.setCertNumber(user.getCertNumber()); vo.setGender(user.getGender()); vo.setId(user.getId()); vo.setLogin(login); vo.setName(user.getName()); vo.setRegisterTime(user.getRegisterTime()); vo.setType(this.getTypeByCode(user.getTypeCode())); vo.setUpdateTime(user.getUpdateTime()); result.setUserInfo(vo); } } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * get user by user name or login name or type code Path:/user/getUsers * Http:POST * * @param pageNo * * @param pageSize * * @param content * user name or login name or type code if ignored the value is * null * * @return Response,ResultUserVo with JSON String * like:{"code":268,"message": * "OK","totalCount":1,"userInfo":null,"listVo" * :[{"id":"402881e64459ad0e014459adc3b00001" * ,"name":"Alex","birthday" * :null,"gender":null,"certNumber":null,"type" * :null,"registerTime":1393073964000 * ,"updateTime":null,"login":{"id" * :"402881e64459ad0e014459adc3b00001" * ,"username":"Alex","password":"b3275960d68fda9d831facc0426c3bbc" * ,"status" * :"1","passErrorCount":0,"passStatus":"1","passUpdateTime" * :null}}]} */ @POST @Path("/getUsers") @Produces(MediaType.APPLICATION_JSON) public Response getUsersByCriteria(@QueryParam("pageNo") int pageNo, @QueryParam("pageSize") int pageSize, @QueryParam("content") String content) { logger.info("getUsersByCriteria called json pageNo:" + pageNo + " pageSize:" + pageSize + " content:" + content); String jpql = "from User u,LoginInfo l where u.id=l.id and (u.name=? or u.typeCode=? or l.username=?) order by l.username asc"; List<?> list = null; ResultUserVo result = new ResultUserVo(); List<UserVo> lt = new ArrayList<UserVo>(); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); if ("".equals(content) || content == null) { jpql = "from User u,LoginInfo l where u.id=l.id order by l.username asc"; try { list = this.jpaDao.getResultData(pageNo, pageSize, jpql, null); long totalCount = this.jpaDao .getCount( "select count(u.id) from User u,LoginInfo l where u.id=l.id", null); result.setTotalCount(totalCount); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } } else { Object[] param = { content, content, content }; try { list = this.jpaDao.getResultData(pageNo, pageSize, jpql, param); long totalCount = this.jpaDao .getCount( "select count(u.id) from User u,LoginInfo l where u.id=l.id and (u.name=? or u.typeCode=? or l.username=?)", param); result.setTotalCount(totalCount); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } } if (list != null && list.size() > Constant.ZERO) { for (Object o : list) { Object[] data = (Object[]) o; User user = (User) data[Constant.ZERO]; LoginInfo login = (LoginInfo) data[Constant.ONE]; UserVo vo = new UserVo(); vo.setBirthday(user.getBirthday()); vo.setCertNumber(user.getCertNumber()); vo.setGender(user.getGender()); vo.setId(user.getId()); vo.setLogin(login); vo.setName(user.getName()); vo.setRegisterTime(user.getRegisterTime()); vo.setType(this.getTypeByCode(user.getTypeCode())); vo.setUpdateTime(user.getUpdateTime()); lt.add(vo); } result.setListVo(lt); } return Response.ok(result).build(); } /** * update user information path:/user/updateUser Http:PUT * * @param user * * * @return Response, ResultCommonVo with JSON * String,like:{"code":268,"message":"OK","totalCount":1} */ @PUT @Path("/updateLoginInfo") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response updateUser(User user) { ResultCommonVo result = new ResultCommonVo(); try { this.jpaDao.update(user); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * used for start user,stop user,rest password,unlock function both them are * update login information path:/user/updateLogin Http:PUT * * @param loginInfo * * @return Response, ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":1} */ @PUT @Path("/updateLogin") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response controlUser(LoginInfo loginInfo) { ResultCommonVo result = new ResultCommonVo(); try { this.jpaDao.update(loginInfo); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * assign one role to user path:/user/assignRole Http:POST * * @param userRole * * @return Response,ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":1} */ @POST @Path("/assignRole") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response assignRoleToUser(UserRole userRole) { ResultCommonVo result = new ResultCommonVo(); try { this.jpaDao.save(userRole); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * get user Role with user id path:/user/getUserRole Http:POST * * @param userId * * @return Response,ResultRoleVo with JSON String * like:{"code":268,"message": * "OK","totalCount":1,"role":null,"list": * [{"id":"402881e64458d2bb014458f050e50012" * ,"name":"普通用户","code":"G00001","status":"1"}]} */ @POST @Path("/getUserRole") @Produces(MediaType.APPLICATION_JSON) public Response getUserRole(@QueryParam("userId") String userId) { ResultRoleVo result = new ResultRoleVo(); List<Role> lt = new ArrayList<Role>(); String jpql = "from UserRole where userId=? order by code asc"; Object[] queryParams = { userId }; result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); try { List<?> list = this.jpaDao.getResultData(Constant.NEGATIVE_ONE, Constant.NEGATIVE_ONE, jpql, queryParams); if (list != null && list.size() > Constant.ZERO) { for (Object o : list) { UserRole userRole = (UserRole) o; Role role = (Role) this.jpaDao.findById(Role.class, userRole.getRoleId()); lt.add(role); } result.setList(lt); result.setTotalCount(list.size()); } } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * get login information by login name * * @param loginName * * @return LoginInfo */ private LoginInfo getLoginInfoByName(String loginName) { LoginInfo login = null; try { Object[] params = { loginName }; List<?> list = this.jpaDao.getResultData(Constant.NEGATIVE_ONE, Constant.NEGATIVE_ONE, "from LoginInfo where username=?", params); if (list != null & list.size() > Constant.ZERO) { login = (LoginInfo) list.get(Constant.ZERO); } } catch (MyException e) { e.printStackTrace(); } return login; } private String makeTokenSignature(long tokenExpiryTime, String username, String password, String role) { String data = username + ":" + tokenExpiryTime + ":" + password + ":" + role + ":" + "getKey"; return MD5Util.MD5password(data); } private Role getRoleByCode(String code) { Role role = null; try { Object[] params = { code }; List<?> list = this.jpaDao.getResultData(Constant.NEGATIVE_ONE, Constant.NEGATIVE_ONE, "from Role where code=?", params); if (list != null & list.size() > Constant.ZERO) { role = (Role) list.get(Constant.ZERO); } } catch (MyException e) { e.printStackTrace(); } return role; } }
zzyyp
trunk/zp/src/com/zp/resource/user/UserServices.java
Java
asf20
16,820
package com.zp.resource; import java.util.ArrayList; import java.util.List; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.springframework.stereotype.Component; import com.sun.jersey.spi.resource.Singleton; import com.zp.bean.common.ResultCommonVo; import com.zp.bean.order.ResultScheduleTypeVo; import com.zp.bean.order.ScheduleTypeVo; import com.zp.domain.ScheduleGroup; import com.zp.domain.ScheduleType; import com.zp.resource.common.BaseServices; import com.zp.util.Constant; import com.zp.util.MyException; /** * schedule type services * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/2/24 * */ @Component @Path("/rest/schtype") @Singleton public class ScheduleTypeServices extends BaseServices { /** * add schtype path:/schtype/addScheduleType Http:POST * * @param schtype * * @return Response,ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":1} */ @POST @Path("/addScheduleType") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response addScheduleType(ScheduleType schtype) { ResultCommonVo result = new ResultCommonVo(); try { this.jpaDao.save(schtype); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * update ScheduleType information path:/schtype/updateScheduleType Http:PUT * * @param schtype * * @return Response,ResultScheduleTypeVo with JSON String like: */ @PUT @Path("/updateScheduleType") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response updateScheduleType(ScheduleType schtype) { ResultScheduleTypeVo result = new ResultScheduleTypeVo(); try { this.jpaDao.update(schtype); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); ScheduleTypeVo vo = new ScheduleTypeVo(); vo.setEndTime(schtype.getEndTime()); vo.setId(schtype.getId()); vo.setName(schtype.getName()); vo.setStartTime(schtype.getStartTime()); vo.setStatus(schtype.getStatus()); vo.setTypeCode(this.getTypeByCode(schtype.getTypeCode())); result.setSt(vo); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * get schedule type by id path:/type/getScheduleType Http:GET * * @param id * primary key of ScheduleType * * @return Response,ResultScheduleTypeVo with JSON String like: */ @GET @Path("/getScheduleType") @Produces(MediaType.APPLICATION_JSON) public Response getScheduleTypeById(@QueryParam("id") String id) { logger.info("getScheduleTypeById called id:" + id); ResultScheduleTypeVo result = new ResultScheduleTypeVo(); try { ScheduleType schtype = (ScheduleType) jpaDao.findById( ScheduleType.class, id); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); ScheduleTypeVo vo = new ScheduleTypeVo(); vo.setEndTime(schtype.getEndTime()); vo.setId(schtype.getId()); vo.setName(schtype.getName()); vo.setStartTime(schtype.getStartTime()); vo.setStatus(schtype.getStatus()); vo.setTypeCode(this.getTypeByCode(schtype.getTypeCode())); result.setSt(vo); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * delete ScheduleType by id path:/schtype/deleteScheduleType Http:DELETE * * @param id * primary key of ScheduleType * * @return Response,ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":1} */ @DELETE @Path("/deleteScheduleType") @Produces(MediaType.APPLICATION_JSON) public Response deleteScheduleType(@QueryParam("id") String id) { logger.info("deleteScheduleType called id:" + id); ResultCommonVo result = new ResultCommonVo(); try { this.jpaDao.deleteById(ScheduleType.class, id); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * search schedule type with filter parameters * path:/schtype/searchScheduleType Http:GET * * @param nameOrCode the name of schedule type or type code, if ignored the value is null * * @return Response, ResultScheduleTypeVo with JSON String like: */ @GET @Path("/searchScheduleType") @Produces(MediaType.APPLICATION_JSON) public Response searchScheduleType( @QueryParam("nameOrCode") String nameOrCode) { logger.info("searchScheduleType called json nameOrCode:" + nameOrCode); String jpql = "from ScheduleType where name=? or typeCode=? order by name asc"; List<?> list = null; ResultScheduleTypeVo result = new ResultScheduleTypeVo(); List<ScheduleTypeVo> lt = new ArrayList<ScheduleTypeVo>(); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); if ("".equals(nameOrCode) || nameOrCode == null) { list = this.jpaDao.getResultData(ScheduleGroup.class); if (list != null && list.size() > Constant.ZERO) { result.setTotalCount(list.size()); } } else { Object[] param = { nameOrCode, nameOrCode }; try { list = this.jpaDao.getResultData(Constant.NEGATIVE_ONE, Constant.NEGATIVE_ONE, jpql, param); if (list != null && list.size() > Constant.ZERO) { result.setTotalCount(list.size()); } } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } } if (list != null && list.size() > Constant.ZERO) { for (Object o : list) { ScheduleType schtype = (ScheduleType) o; ScheduleTypeVo vo = new ScheduleTypeVo(); vo.setEndTime(schtype.getEndTime()); vo.setId(schtype.getId()); vo.setName(schtype.getName()); vo.setStartTime(schtype.getStartTime()); vo.setStatus(schtype.getStatus()); vo.setTypeCode(this.getTypeByCode(schtype.getTypeCode())); lt.add(vo); } result.setList(lt); } return Response.ok(result).build(); } }
zzyyp
trunk/zp/src/com/zp/resource/ScheduleTypeServices.java
Java
asf20
6,622
package com.zp.resource.psychological; import java.util.ArrayList; import java.util.List; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.springframework.stereotype.Component; import com.sun.jersey.spi.resource.Singleton; import com.zp.bean.common.ResultCommonVo; import com.zp.bean.psychological.ResultActivityVo; import com.zp.domain.Activity; import com.zp.resource.common.BaseServices; import com.zp.util.Constant; import com.zp.util.MyException; /** * activity services * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/3/5 * */ @Component @Path("/rest/activity") @Singleton public class ActivityServices extends BaseServices { /** * add one Activity path:/activity/addActivity Http:POST * * @param activity * * @return Response, ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":0} */ @POST @Path("/addActivity") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response addActivity(Activity activity) { ResultCommonVo result = new ResultCommonVo(); try { jpaDao.save(activity); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * update one Activity path:/activity/updateActivity Http:PUT * * @param activity * * @return Response, ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":0} */ @PUT @Path("/updateActivity") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response updateActivity(Activity activity) { ResultCommonVo result = new ResultCommonVo(); try { jpaDao.update(activity); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * delete Activity by id path:/activity/deleteActivity Http:DELETE * * @param activityId * primary key of Activity * * @return Response, ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":0} */ @DELETE @Path("/deleteActivity") @Produces(MediaType.APPLICATION_JSON) public Response deleteActivity(@QueryParam("activityId") String activityId) { logger.info("deleteActivity called activityId:" + activityId); ResultCommonVo result = new ResultCommonVo(); try { jpaDao.deleteById(Activity.class, activityId); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * * get activity for one organization path:/activity/getActivitys Http:POST * * @param pageNo * * @param pageSize * * @param partyId * if ignore the default value will be null * * @return Response, ResultActivityVo with JSON String * like:{"code":268,"message":"OK","totalCount":9,"list":[{"id": * "402880e44497794e0144977b65e80001" * ,"name":"社区宣传教育活动","partyId":"402880e44492d4ac014492d533850001" * ,"contentId" * :3},{"id":"402880e44497794e0144977c07930002","name":"关爱留守儿童活动" * ,"partyId":"402880e44492d4ac014492d533850001","contentId":3}]} */ @POST @Path("/getActivitys") @Produces({ MediaType.APPLICATION_JSON }) public Response getActivityByOrgId(@QueryParam("pageNo") int pageNo, @QueryParam("pageSize") int pageSize, @QueryParam("partyId") String partyId) { logger.info("getActivityByOrgId called json pageNo:" + pageNo + " pageSize:" + pageSize + " partyId:" + partyId); String jpql = "from Activity a,Content n where a.contentId=n.id and a.partyId=? order by n.operationTime desc"; String countSql = "select count(id) from Activity where partyId=?"; List<?> list = null; ResultActivityVo result = new ResultActivityVo(); List<Activity> lt = new ArrayList<Activity>(); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); if ("".equals(partyId) || partyId == null) { result.setCode(Constant.FAILE_CODE); result.setMessage(Constant.OBJECT_NOT_EXITS); } else { Object[] param = { partyId }; try { list = this.jpaDao.getResultData(pageNo, pageSize, jpql, param); long totalCount = this.jpaDao.getCount(countSql, param); result.setTotalCount(totalCount); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } } if (list != null && list.size() > Constant.ZERO) { for (Object o : list) { Object[] data = (Object[]) o; Activity activity = (Activity) data[Constant.ZERO]; lt.add(activity); } result.setList(lt); } return Response.ok(result).build(); } }
zzyyp
trunk/zp/src/com/zp/resource/psychological/ActivityServices.java
Java
asf20
5,337
package com.zp.resource.psychological; import java.util.ArrayList; import java.util.List; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.springframework.stereotype.Component; import com.sun.jersey.spi.resource.Singleton; import com.zp.bean.common.ResultCommonVo; import com.zp.bean.psychological.BaseServiceVo; import com.zp.bean.psychological.ResultBaseServiceVo; import com.zp.bean.psychological.ResultServiceVo; import com.zp.bean.psychological.ServiceVo; import com.zp.domain.Organization; import com.zp.domain.Service; import com.zp.resource.common.BaseServices; import com.zp.util.Constant; import com.zp.util.MyException; /** * service services * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/3/8 * */ @Component @Path("/rest/service") @Singleton public class ServiceServices extends BaseServices { /** * add one Service path:/service/addService Http:POST * * @param service * * @return Response, ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":0} */ @POST @Path("/addService") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response addService(Service service) { ResultCommonVo result = new ResultCommonVo(); try { jpaDao.save(service); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * update one Service path:/service/updateService Http:PUT * * @param service * * @return Response, ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":0} */ @PUT @Path("/updateService") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response updateService(Service service) { ResultCommonVo result = new ResultCommonVo(); try { jpaDao.update(service); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * delete Service by id path:/service/deleteService Http:DELETE * * @param serviceId * primary key of Service * * @return Response, ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":0} */ @DELETE @Path("/deleteService") @Produces(MediaType.APPLICATION_JSON) public Response deleteService(@QueryParam("serviceId") String serviceId) { logger.info("deleteService called serviceId:" + serviceId); ResultCommonVo result = new ResultCommonVo(); try { jpaDao.deleteById(Service.class, serviceId); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * get Service by id path:/service/getService Http:POST * * @param serviceId * primary key of Service * * @return Response, ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":0,"vo":{"id": * "402881e544a211e70144a2126c3a0001" * ,"title":"心理减压公益服务","titleImage" * :null,"organizationName":null,"introduce" * :"心理减压是一种高效整合的心理咨询","duration" * :1,"content":"心理减压是一种高效整合的心理咨询","organization" * :{"id":"402880e44492d4ac014492d533850001" * ,"name":"四川大学青年志愿者协会","image" * :null,"summary":"四川大学青少年行动起始于","introduce" * :"四川大学青少年行动起始于1994年3月...." * ,"address":"四川省成都市武侯区科华路","character":"非营利性组织" * ,"manage":"四川大学团委","cityCode" * :"028","phone":"028-88888888","weibo" * :"http://weibo.com/schxyx","members":150}},"list":null} */ @POST @Path("/getService") @Produces(MediaType.APPLICATION_JSON) public Response getServiceById(@QueryParam("serviceId") String serviceId) { logger.info("deleteService called serviceId:" + serviceId); ResultServiceVo result = new ResultServiceVo(); String jpql = "from Service s,Organization o where s.organization=o.id and s.id=?"; List<?> list = null; result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); try { Object[] param = { serviceId }; list = this.jpaDao.getResultData(Constant.NEGATIVE_ONE, Constant.NEGATIVE_ONE, jpql, param); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } if (list != null && list.size() > Constant.ZERO) { Object[] data = (Object[]) list.get(Constant.ZERO); ServiceVo vo = new ServiceVo(); Service service = (Service) data[Constant.ZERO]; vo.setContent(service.getContent()); vo.setDuration(service.getDuration()); vo.setId(service.getId()); vo.setTitle(service.getTitle()); vo.setIntroduce(service.getIntroduce()); vo.setOrganization((Organization) data[Constant.ONE]); vo.setTitleImage(service.getTitleImage()); result.setVo(vo); } return Response.ok(result).build(); } /** * * get service for one organization path:/service/getServices Http:POST * * @param pageNo * * @param pageSize * * @param organizationId * if ignore the default value will be null * * * @return Response, ResultBaseServiceVo with JSON String * like:{"code":268,"message":"OK","totalCount":1,"list":[{"id": * "402881e544a211e70144a2126c3a0001" * ,"title":"心理减压公益服务","titleImage" * :"null","organizationName":"四川大学青年志愿者协会" * ,"introduce":"心理减压是一种高效整合的心理咨询","duration":1}]} */ @POST @Path("/getServices") @Produces({ MediaType.APPLICATION_JSON }) public Response getServicesByOrg(@QueryParam("pageNo") int pageNo, @QueryParam("pageSize") int pageSize, @QueryParam("organizationId") String organizationId) { logger.info("getServices called json pageNo:" + pageNo + " pageSize:" + pageSize); String jpql = "select s.id,o.name,s.introduce,s.duration,s.titleImage,s.title from Service s,Organization o where s.organization=o.id and o.id=?"; String countSql = "select count(s.id) from Service s,Organization o where s.organization=o.id and o.id=?"; List<?> list = null; ResultBaseServiceVo result = new ResultBaseServiceVo(); List<BaseServiceVo> lt = new ArrayList<BaseServiceVo>(); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); if ("".equals(organizationId) || organizationId == null) { try { jpql = "select s.id,o.name,s.introduce,s.duration,s.titleImage,s.title from Service s,Organization o where s.organization=o.id"; countSql = "select count(s.id) from Service s,Organization o where s.organization=o.id"; list = this.jpaDao.getResultData(pageNo, pageSize, jpql, null); long totalCount = this.jpaDao.getCount(countSql, null); result.setTotalCount(totalCount); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } } else { try { Object[] params = { organizationId }; list = this.jpaDao .getResultData(pageNo, pageSize, jpql, params); long totalCount = this.jpaDao.getCount(countSql, params); result.setTotalCount(totalCount); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } } if (list != null && list.size() > Constant.ZERO) { for (Object o : list) { Object[] data = (Object[]) o; BaseServiceVo vo = new BaseServiceVo(); vo.setId(String.valueOf(data[Constant.ZERO])); vo.setOrganizationName(String.valueOf(data[Constant.ONE])); vo.setIntroduce(String.valueOf(data[Constant.TWO])); vo.setDuration(Integer.valueOf(String .valueOf(data[Constant.THREE]))); vo.setTitleImage(String.valueOf(data[Constant.FOUR])); vo.setTitle(String.valueOf(data[Constant.FIVE])); lt.add(vo); } result.setList(lt); } return Response.ok(result).build(); } }
zzyyp
trunk/zp/src/com/zp/resource/psychological/ServiceServices.java
Java
asf20
8,743
package com.zp.resource.psychological; import java.io.InputStream; import java.util.ArrayList; import java.util.List; import javax.servlet.ServletContext; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; import com.sun.jersey.core.header.FormDataContentDisposition; import com.sun.jersey.multipart.FormDataParam; import com.sun.jersey.spi.resource.Singleton; import com.zp.bean.common.ResultCommonVo; import com.zp.bean.psychological.BaseOrganizationVo; import com.zp.bean.psychological.OrganizationVo; import com.zp.bean.psychological.ResultBaseOrganizationVo; import com.zp.bean.psychological.ResultOrganizationVo; import com.zp.bean.user.BaseUserVo; import com.zp.bean.user.ResultBaseUserVo; import com.zp.domain.ModuleOrganization; import com.zp.domain.Organization; import com.zp.domain.PersonOrganization; import com.zp.domain.Type; import com.zp.resource.common.BaseServices; import com.zp.util.Constant; import com.zp.util.FileUtil; import com.zp.util.MyException; /** * organization services * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/3/4 * */ @Component @Path("/rest/organization") @Singleton public class OrganizationServices extends BaseServices { @POST @Path("/addO") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response addType(Organization o) { ResultCommonVo result = new ResultCommonVo(); try { jpaDao.save(o); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * add organization information path:/organization/addOrganization HTTP:POST * * @param name * name of organization * @param summary * @param introduce * @param address * @param character * @param manage * @param cityCode * which city the organization in * @param phone * @param weibo * @param members * @param image * title image of organization * @return Response, ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":0} */ @POST @Path("/addOrganization") @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces(MediaType.APPLICATION_JSON) public Response addOrganization(@FormDataParam("name") String name, @FormDataParam("summary") String summary, @FormDataParam("introduce") String introduce, @FormDataParam("address") String address, @FormDataParam("character") String character, @FormDataParam("manage") String manage, @FormDataParam("cityCode") String cityCode, @FormDataParam("phone") String phone, @FormDataParam("weibo") String weibo, @FormDataParam("members") int members, @FormDataParam("image") InputStream image, @FormDataParam("image") FormDataContentDisposition fileDisposition, @Context ServletContext context) { ResultCommonVo result = new ResultCommonVo(); try { Organization organization = new Organization(); organization.setAddress(address); organization.setCharacter(character); organization.setCityCode(cityCode); organization.setImage(FileUtil.getInstance().saveFile(image, fileDisposition, context)); organization.setIntroduce(introduce); organization.setManage(manage); organization.setMembers(members); organization.setName(name); organization.setPhone(phone); organization.setSummary(summary); organization.setWeibo(weibo); jpaDao.save(organization); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * update organization information path:/organization/updateOrganization * HTTP:PUT * * @param id * primary key of organization * @param name * name of organization * @param summary * @param introduce * @param address * @param character * @param manage * @param cityCode * which city the organization in * @param phone * @param weibo * @param members * @param image * title image of organization * @return Response, ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":0} */ @PUT @Path("/updateOrganization") @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces(MediaType.APPLICATION_JSON) public Response updateOrganization(@FormDataParam("id") String id, @FormDataParam("name") String name, @FormDataParam("summary") String summary, @FormDataParam("introduce") String introduce, @FormDataParam("address") String address, @FormDataParam("character") String character, @FormDataParam("manage") String manage, @FormDataParam("cityCode") String cityCode, @FormDataParam("phone") String phone, @FormDataParam("weibo") String weibo, @FormDataParam("members") int members, @FormDataParam("image") InputStream image, @FormDataParam("image") FormDataContentDisposition fileDisposition, @Context ServletContext context) { ResultCommonVo result = new ResultCommonVo(); try { Organization organization = (Organization) this.jpaDao.findById( Organization.class, id); organization.setAddress(address); organization.setCharacter(character); organization.setCityCode(cityCode); organization.setImage(FileUtil.getInstance().saveFile(image, fileDisposition, context)); organization.setIntroduce(introduce); organization.setManage(manage); organization.setMembers(members); organization.setName(name); organization.setPhone(phone); organization.setSummary(summary); organization.setWeibo(weibo); jpaDao.update(organization); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * delete Organization by id path:/organization/deleteOrganization * Http:DELETE * * @param organizationId * primary key of Organization * * @return Response, ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":0} */ @DELETE @Path("/deleteOrganization") @Produces(MediaType.APPLICATION_JSON) public Response deleteOrganization( @QueryParam("organizationId") String organizationId) { logger.info("deleteOrganization called organizationId:" + organizationId); ResultCommonVo result = new ResultCommonVo(); try { jpaDao.deleteById(Organization.class, organizationId); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * get Organization by id path:/organization/getOrganization Http:POST * * @param organizationId * primary key of Organization * * @return Response, ResultOrganizationVo with JSON String * like:{"code":268,"message":"OK","totalCount":0,"vo":{"id": * "402880e44492d4ac014492d533850001" * ,"name":"四川大学青年志愿者协会","image":null * ,"summary":"四川大学青少年行动起始于","cityType" * :null,"introduce":"四川大学青少年行动起始于1994年3月...." * ,"address":"四川省成都市武侯区科华路" * ,"character":"非营利性组织","manage":"四川大学团委","phone" * :"028-88888888","weibo" * :"http://weibo.com/schxyx","members":150},"list":null} * */ @POST @Path("/getOrganization") @Produces(MediaType.APPLICATION_JSON) public Response getOrganizationById( @QueryParam("organizationId") String organizationId) { logger.info("getOrganizationById called organizationId:" + organizationId); ResultOrganizationVo result = new ResultOrganizationVo(); Organization organization = null; try { organization = (Organization) jpaDao.findById(Organization.class, organizationId); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } if (organization != null) { OrganizationVo vo = new OrganizationVo(); vo.setAddress(organization.getAddress()); vo.setCharacter(organization.getCharacter()); vo.setCityType(this.getTypeByCode(organization.getCityCode())); vo.setId(organization.getId()); if (organization.getImage() != null) { vo.setImage(this.serverPath + organization.getImage()); } vo.setIntroduce(organization.getIntroduce()); vo.setManage(organization.getManage()); vo.setMembers(organization.getMembers()); vo.setName(organization.getName()); vo.setPhone(organization.getPhone()); vo.setSummary(organization.getSummary()); vo.setWeibo(organization.getWeibo()); result.setVo(vo); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } else { result.setCode(Constant.FAILE_CODE); result.setMessage(Constant.OBJECT_NOT_EXITS); } return Response.ok(result).build(); } /** * get Organization with name or city code * path:/organization/getOrganizations Http:POST * * @param pageNo * @param pageSize * @param moduleCode * the code of module * @param value * name of organization or city code of organization if ignore * the default value will be null * @return Response ResultOrganizationVo with JSON String * like:{"code":268,"message" * :"OK","totalCount":6,"vo":null,"list":[{ * "id":"402880e44492d4ac014492d7f9c10004" * ,"name":"四川交通大学青年志愿者协会","image" * :null,"summary":"四川交通大学青少年行动起始于","cityType" * :{"id":"402880e44492d4ac014492e4a09b0009" * ,"name":"四川-成都","code":"028" * ,"parentCode":"0000"},"introduce":"四川交通大学青少年行动起始于1994年3月...." * ,"address" * :"四川省成都市武侯区科华路","character":"非营利性组织","manage":"四川交通大学团委" * ,"phone":"028-88888888" * ,"weibo":"http://weibo.com/schxyx","members" * :150},{"id":"402880e44492d4ac014492d533850001" * ,"name":"四川大学青年志愿者协会" * ,"image":null,"summary":"四川大学青少年行动起始于","cityType" * :{"id":"402880e44492d4ac014492e4a09b0009" * ,"name":"四川-成都","code":"028" * ,"parentCode":"0000"},"introduce":"四川大学青少年行动起始于1994年3月...." * ,"address" * :"四川省成都市武侯区科华路","character":"非营利性组织","manage":"四川大学团委","phone" * :"028-88888888" * ,"weibo":"http://weibo.com/schxyx","members":150}]} */ @POST @Path("/getOrganizations") @Produces(MediaType.APPLICATION_JSON) public Response getOrganizationWithNameOrCity( @QueryParam("pageNo") int pageNo, @QueryParam("pageSize") int pageSize, @QueryParam("moduleCode") String moduleCode, @QueryParam("value") String value) { logger.info("getOrganizationWithNameOrCity called pageNo:" + pageNo + " pageSize:" + pageSize + " moduleCode:" + moduleCode + " value:" + value); ResultOrganizationVo result = new ResultOrganizationVo(); String jpql = "from Organization o,Type t, ModuleOrganization mo,ModuleType mt where o.cityCode=t.code and (o.name=? or o.cityCode=?) and o.id=mo.organizationId and mo.moduleId=mt.id and mt.code=? order by o.name"; String countSql = "select count(o.id) from Organization o, ModuleOrganization mo,ModuleType mt where (o.name=? or o.cityCode=?) and o.id=mo.organizationId and mo.moduleId=mt.id and mt.code=?"; List<?> list = null; List<OrganizationVo> lt = new ArrayList<OrganizationVo>(); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); if ("".equals(value) || value == null) { jpql = "from Organization o,Type t, ModuleOrganization mo,ModuleType mt where o.cityCode=t.code and o.id=mo.organizationId and mo.moduleId=mt.id and mt.code=? order by o.name"; countSql = "select count(o.id) from Organization o, ModuleOrganization mo,ModuleType mt where o.id=mo.organizationId and mo.moduleId=mt.id and mt.code=?"; try { Object[] queryParams = { moduleCode }; list = this.jpaDao.getResultData(pageNo, pageSize, jpql, queryParams); result.setTotalCount(this.jpaDao .getCount(countSql, queryParams)); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } } else { Object[] queryParams = { value, value, moduleCode }; try { list = this.jpaDao.getResultData(pageNo, pageSize, jpql, queryParams); result.setTotalCount(this.jpaDao .getCount(countSql, queryParams)); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } } if (list != null && list.size() > Constant.ZERO) { for (Object o : list) { Object data[] = (Object[]) o; Organization organization = (Organization) data[Constant.ZERO]; OrganizationVo vo = new OrganizationVo(); vo.setAddress(organization.getAddress()); vo.setCharacter(organization.getCharacter()); vo.setCityType((Type) data[Constant.ONE]); vo.setId(organization.getId()); if (organization.getImage() != null) { vo.setImage(this.serverPath + organization.getImage()); } vo.setIntroduce(organization.getIntroduce()); vo.setManage(organization.getManage()); vo.setMembers(organization.getMembers()); vo.setName(organization.getName()); vo.setPhone(organization.getPhone()); vo.setSummary(organization.getSummary()); vo.setWeibo(organization.getWeibo()); lt.add(vo); } result.setList(lt); } return Response.ok(result).build(); } /** * get base Organization with name or city code * path:/organization/getBaseOrans Http:POST * * @param pageNo * @param pageSize * @param moduleCode * the code of module * @param value * name of organization or city code of organization if ignore * the value will be null * @return Response ResultBaseOrganizationVo with JSON String like: * {"code":268 * ,"message":"OK","totalCount":6,"list":[{"id":"四川交通大学青年志愿者协会" * ,"name" * :null,"image":"null","summary":"四川交通大学青少年行动起始于","cityType": * {"id":"402880e44492d4ac014492e4a09b0009" * ,"name":"四川-成都","code":"028" * ,"parentCode":"0000"}},{"id":"四川大学青年志愿者协会" * ,"name":null,"image":"null" * ,"summary":"四川大学青少年行动起始于","cityType":{"id" * :"402880e44492d4ac014492e4a09b0009" * ,"name":"四川-成都","code":"028","parentCode":"0000"}}]} */ @POST @Path("/getBaseOrans") @Produces(MediaType.APPLICATION_JSON) public Response getBaseOrganizationWithNameOrCity( @QueryParam("pageNo") int pageNo, @QueryParam("pageSize") int pageSize, @QueryParam("moduleCode") String moduleCode, @QueryParam("value") String value) { logger.info("getOrganizationWithNameOrCity called pageNo:" + pageNo + " pageSize:" + pageSize + " value:" + value); ResultBaseOrganizationVo result = new ResultBaseOrganizationVo(); String jpql = "select o.id,o.name,o.image,o.summary,o.cityCode from Organization o,ModuleOrganization mo,ModuleType mt where (o.name=? or o.cityCode=?) and o.id=mo.organizationId and mo.moduleId=mt.id and mt.code=? order by o.name"; String countSql = "select count(o.id) from Organization o,ModuleOrganization mo,ModuleType mt where (o.name=? or o.cityCode=?) and o.id=mo.organizationId and mo.moduleId=mt.id and mt.code=?"; List<?> list = null; List<BaseOrganizationVo> lt = new ArrayList<BaseOrganizationVo>(); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); if ("".equals(value) || value == null) { jpql = "select o.id,o.name,o.image,o.summary,o.cityCode from Organization o,ModuleOrganization mo,ModuleType mt where o.id=mo.organizationId and mo.moduleId=mt.id and mt.code=? order by o.name"; countSql = "select count(o.id) from Organization o,ModuleOrganization mo,ModuleType mt where o.id=mo.organizationId and mo.moduleId=mt.id and mt.code=?"; Object[] queryParams = { moduleCode }; try { list = this.jpaDao.getResultData(pageNo, pageSize, jpql, queryParams); result.setTotalCount(this.jpaDao .getCount(countSql, queryParams)); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } } else { Object[] queryParams = { value, value, moduleCode }; try { list = this.jpaDao.getResultData(pageNo, pageSize, jpql, queryParams); result.setTotalCount(this.jpaDao .getCount(countSql, queryParams)); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } } if (list != null && list.size() > Constant.ZERO) { for (Object o : list) { Object[] data = (Object[]) o; BaseOrganizationVo vo = new BaseOrganizationVo(); vo.setCityType(this.getTypeByCode(String .valueOf(data[Constant.FOUR]))); vo.setId(String.valueOf(data[Constant.ZERO])); vo.setName(String.valueOf(data[Constant.ONE])); if (data[Constant.TWO] != null) { vo.setImage(this.serverPath + String.valueOf(data[Constant.TWO])); } vo.setSummary(String.valueOf(data[Constant.THREE])); lt.add(vo); } result.setList(lt); } return Response.ok(result).build(); } /** * get users belong to one organization path:/organization/getUsers * Http:POST * * @param pageNo * @param pageSize * @param organizationId * primary key of organization if ignore the value will be null * @return Response ResultBaseUserVo with JSON String * like:{"code":268,"message":"OK","totalCount":10,"listVo":[{"id": * "402881e74481be89014481c1e74d0001" * ,"name":"李总","title":"心理咨询专家","image" * :"http://localhost:8082/ZP/upload/image/20144444444.jpg" * ,"introduce" * :"null"},{"id":"402881e64459ad0e014459af0a6e0005","name" * :"李林峰","title":"心理咨询专家","image": * "http://localhost:8082/ZP/upload/image/20144444444.jpg" * ,"introduce":"null"}]} */ @POST @Path("/getUsers") @Produces(MediaType.APPLICATION_JSON) public Response getUserFromOrganization(@QueryParam("pageNo") int pageNo, @QueryParam("pageSize") int pageSize, @QueryParam("organizationId") String organizationId) { logger.info("getUserFromOrganization called pageNo:" + pageNo + " pageSize:" + pageSize + " organizationId:" + organizationId); ResultBaseUserVo result = new ResultBaseUserVo(); String jpql = "select u.id,u.name,u.title,u.image,u.introduce from User u,PersonOrganization o where u.id=o.userId and o.organizationId=? order by u.name"; String countSql = "select count(u.id) from User u,PersonOrganization o where u.id=o.userId and o.organizationId=?"; List<?> list = null; List<BaseUserVo> lt = new ArrayList<BaseUserVo>(); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); if ("".equals(organizationId) || organizationId == null) { result.setCode(Constant.FAILE_CODE); result.setMessage(Constant.OBJECT_NOT_EXITS); } else { Object[] queryParams = { organizationId }; try { list = this.jpaDao.getResultData(pageNo, pageSize, jpql, queryParams); result.setTotalCount(this.jpaDao .getCount(countSql, queryParams)); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } } if (list != null && list.size() > Constant.ZERO) { for (Object o : list) { Object[] data = (Object[]) o; BaseUserVo vo = new BaseUserVo(); vo.setId(String.valueOf(data[Constant.ZERO])); vo.setName(String.valueOf(data[Constant.ONE])); vo.setTitle(String.valueOf(data[Constant.TWO])); if (data[Constant.THREE] != null) { vo.setImage(this.serverPath + String.valueOf(data[Constant.THREE])); } vo.setIntroduce(String.valueOf(data[Constant.FOUR])); lt.add(vo); } result.setListVo(lt); } return Response.ok(result).build(); } /** * add person to organization path:/organization/addUser Http:POST * * @param po * * @return Response, ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":0} */ @POST @Path("/addUser") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Transactional public Response addUser(PersonOrganization po) { ResultCommonVo result = new ResultCommonVo(); try { jpaDao.save(po); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * remove user from organization path:/organization/rmUser Http:DELETE * * @param id * primary key of PersonOrganization * * @return Response, ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":1} */ @DELETE @Path("/rmUser") @Produces(MediaType.APPLICATION_JSON) public Response removeUser(@QueryParam("id") String id) { logger.info("removeUser called id:" + id); ResultCommonVo result = new ResultCommonVo(); try { jpaDao.deleteById(PersonOrganization.class, id); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * assign to one module path:/organization/assignModule Http:POST * * @param mo * * @return Response, ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":0} */ @POST @Path("/assignModule") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response assignModule(ModuleOrganization mo) { ResultCommonVo result = new ResultCommonVo(); try { jpaDao.save(mo); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * remove organization from module path:/organization/rmFromModule * Http:DELETE * * @param id * primary key of ModuleOrganization * * @return Response, ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":1} */ @DELETE @Path("/rmFromModule") @Produces(MediaType.APPLICATION_JSON) public Response removeOrg(@QueryParam("id") String id) { logger.info("removeOrg called id:" + id); ResultCommonVo result = new ResultCommonVo(); try { jpaDao.deleteById(ModuleOrganization.class, id); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } }
zzyyp
trunk/zp/src/com/zp/resource/psychological/OrganizationServices.java
Java
asf20
24,264
package com.zp.resource; import java.util.ArrayList; import java.util.List; import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.springframework.stereotype.Component; import com.sun.jersey.spi.resource.Singleton; import com.zp.bean.common.ResultCommonVo; import com.zp.bean.paper.PaperQuestionVo; import com.zp.bean.paper.QuestionsVo; import com.zp.bean.paper.ResultPaperQuestionVo; import com.zp.domain.AnswerItem; import com.zp.domain.Paper; import com.zp.domain.PaperQuestion; import com.zp.domain.Question; import com.zp.resource.common.BaseServices; import com.zp.util.Constant; import com.zp.util.MyException; /** * paper question services * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/2/23 * */ @Component @Path("/rest/paperques") @Singleton public class PaperQuestionServices extends BaseServices { /** * add one paper question path:/paperques/addPaperques Http:POST * * @param paperques * * @return Response, ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":0} */ @POST @Path("/addPaperques") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response addPaperQuestion(PaperQuestion paperques) { ResultCommonVo result = new ResultCommonVo(); try { jpaDao.save(paperques); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * update paper question path:/paperques/updatePaperques Http:PUT * * @param paperques * * @return Response, ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":0} * */ @PUT @Path("/updatePaperques") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response updatePaperQuestion(PaperQuestion paperques) { ResultCommonVo result = new ResultCommonVo(); try { jpaDao.update(paperques); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * delete paper question by paper id path:/paperques/deletePaperques * Http:GET * * @param paperId * * @return Response, ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":1} */ @GET @Path("/deletePaperques") @Produces(MediaType.APPLICATION_JSON) public Response deletePaperQuestion(@QueryParam("paperId") String paperId) { logger.info("deleteQuestion called paperId:" + paperId); ResultCommonVo result = new ResultCommonVo(); String jpql = "from PaperQuestion where paperId=?"; Object[] queryParams = { paperId }; try { this.jpaDao.deleteFromCriteria(jpql, queryParams); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * get all the questions by paper id path:/paperques/getQuestions Http:GET * * @param paperId * * @return Response, ResultPaperQuestionVo with JSON String * like:{"code":268,"message" * :"OK","totalCount":5,"paperQuestionVo":{ * "paper":{"id":"402881e6445c883e01445c8a74290001" * ,"name":"心理关爱"},"list":[{"title":"心理关爱题目1","questionId": * "402881e6445cc3a301445cc4332b0001" * ,"item":[{"id":"402881e6445d4c3701445d515f8e0002" * ,"questionId":"402881e6445cc3a301445cc4332b0001" * ,"answerCode":"A", * "value":"心理关爱题目1答案1"},{"id":"402881e6445d53b401445d54be830001" * ,"questionId" * :"402881e6445cc3a301445cc4332b0001","answerCode":"B", * "value":"心理关爱题目1答案2" * },{"id":"402881e6445d53b401445d54fa180002","questionId" * :"402881e6445cc3a301445cc4332b0001" * ,"answerCode":"C","value":"心理关爱题目1答案3" * },{"id":"402881e6445d53b401445d55bb6b0003" * ,"questionId":"402881e6445cc3a301445cc4332b0001" * ,"answerCode":"D","value":"心理关爱题目1答案4"}]}]}} */ @GET @Path("/getQuestions") @Produces(MediaType.APPLICATION_JSON) public Response getQuestionsByPaper(@QueryParam("pageNo") int pageNo, @QueryParam("pageSize") int pageSize, @QueryParam("paperId") String paperId) { logger.info("getQuestionsByPaper called pageNo is:" + pageNo + " pageSize is:" + pageSize + " paperId is:" + paperId); ResultPaperQuestionVo result = new ResultPaperQuestionVo(); String jpql = "from PaperQuestion where paperId=?"; String countJpql = "select count(id) from PaperQuestion where paperId=?"; Object[] queryParams = { paperId }; result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); try { List<?> list = this.jpaDao.getResultData(pageNo, pageSize, jpql, queryParams); if (list != null && list.size() > Constant.ZERO) { PaperQuestionVo vo = new PaperQuestionVo(); vo.setPaper((Paper) this.jpaDao.findById(Paper.class, ((PaperQuestion) list.get(Constant.ZERO)).getPaperId())); List<QuestionsVo> listq = new ArrayList<QuestionsVo>(); for (Object o : list) { PaperQuestion pq = (PaperQuestion) o; Question quesion = (Question) this.jpaDao.findById( Question.class, pq.getQuestionId()); QuestionsVo qvo = new QuestionsVo(); qvo.setQuestionId(quesion.getId()); qvo.setTitle(quesion.getTitle()); qvo.setItem(this.getItemsFromQuestion(quesion.getId())); listq.add(qvo); } vo.setList(listq); result.setPaperQuestionVo(vo); result.setTotalCount(this.jpaDao.getCount(countJpql, queryParams)); } } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * get answer items with question id * * @param questionId * * @return List<AnswerItem> */ private List<AnswerItem> getItemsFromQuestion(String questionId) { String jpql = "from AnswerItem where questionId=?"; List<?> list = null; List<AnswerItem> lt = new ArrayList<AnswerItem>(); Object[] param = { questionId }; try { list = this.jpaDao.getResultData(Constant.NEGATIVE_ONE, Constant.NEGATIVE_ONE, jpql, param); } catch (MyException e) { e.printStackTrace(); } if (list != null && list.size() > Constant.ZERO) { for (Object o : list) { AnswerItem aitem = (AnswerItem) o; lt.add(aitem); } } return lt; } }
zzyyp
trunk/zp/src/com/zp/resource/PaperQuestionServices.java
Java
asf20
7,063
package com.zp.resource; import java.util.ArrayList; import java.util.List; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.springframework.stereotype.Component; import com.sun.jersey.spi.resource.Singleton; import com.zp.bean.common.ResultCommonVo; import com.zp.bean.order.ResultScheduleVo; import com.zp.bean.order.ScheduleVo; import com.zp.domain.Schedule; import com.zp.domain.ScheduleType; import com.zp.domain.User; import com.zp.resource.common.BaseServices; import com.zp.util.Constant; import com.zp.util.MyException; /** * schedule services * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/2/24 * */ @Component @Path("/rest/schedule") @Singleton public class ScheduleServices extends BaseServices { /** * add schedule path:/schedule/addSchedule Http:POST * * @param schedule * * @return Response,ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":1} */ @POST @Path("/addSchedule") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response addSchedule(Schedule schedule) { ResultCommonVo result = new ResultCommonVo(); try { this.jpaDao.save(schedule); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * update Schedule information path:/schedule/updateSchedule Http:PUT * * @param schedule * * @return Response,ResultScheduleVo with JSON String like: */ @PUT @Path("/updateSchedule") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response updateSchedule(Schedule schedule) { ResultScheduleVo result = new ResultScheduleVo(); try { this.jpaDao.update(schedule); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); ScheduleVo vo = new ScheduleVo(); vo.setId(schedule.getId()); vo.setScheduleDate(schedule.getScheduleDate()); vo.setSt((ScheduleType) this.jpaDao.findById(ScheduleType.class, schedule.getId())); vo.setStatus(schedule.getStatus()); vo.setUser((User) this.jpaDao.findById(User.class, schedule.getUserId())); result.setSchedule(vo); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * get schedule by id path:/type/getSchedule Http:GET * * @param id * primary key of Schedule * * @return Response,ResultScheduleVo with JSON String like: */ @GET @Path("/getSchedule") @Produces(MediaType.APPLICATION_JSON) public Response getScheduleById(@QueryParam("id") String id) { logger.info("getScheduleById called id:" + id); ResultScheduleVo result = new ResultScheduleVo(); try { Schedule schedule = (Schedule) jpaDao.findById(Schedule.class, id); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); ScheduleVo vo = new ScheduleVo(); vo.setId(schedule.getId()); vo.setScheduleDate(schedule.getScheduleDate()); vo.setSt((ScheduleType) this.jpaDao.findById(ScheduleType.class, schedule.getId())); vo.setStatus(schedule.getStatus()); vo.setUser((User) this.jpaDao.findById(User.class, schedule.getUserId())); result.setSchedule(vo); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * delete Schedule by id path:/schedule/deleteSchedule Http:DELETE * * @param id * primary key of Schedule * * @return Response,ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":1} */ @DELETE @Path("/deleteSchedule") @Produces(MediaType.APPLICATION_JSON) public Response deleteSchedule(@QueryParam("id") String id) { logger.info("deleteSchedule called id:" + id); ResultCommonVo result = new ResultCommonVo(); try { this.jpaDao.deleteById(Schedule.class, id); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * search schedule with filter parameters path:/schedule/searchSchedule * Http:GET * * @param pageNo * * @param pageSize * * @param content * the id of user or the code of Type,if ignored the value is * null * * @return Response, ResultScheduleVo with JSON String like: */ @GET @Path("/searchSchedule") @Produces(MediaType.APPLICATION_JSON) public Response searchSchedule(@QueryParam("pageNo") int pageNo, @QueryParam("pageSize") int pageSize, @QueryParam("content") String content) { logger.info("searchSchedule called json pageNo is:" + pageNo + " pageSize is:" + pageSize + " content:" + content); String jpql = "from Schedule where userId=? or typeName=? order by scheduleDate desc"; String countSql = "select count(id)from Schedule where userId=? or typeName=?"; List<?> list = null; ResultScheduleVo result = new ResultScheduleVo(); List<ScheduleVo> lt = new ArrayList<ScheduleVo>(); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); if ("".equals(content) || content == null) { jpql = "from Schedule"; countSql = "select count(id)from Schedule"; try { list = this.jpaDao.getResultData(pageNo, pageSize, jpql, null); result.setTotalCount(this.jpaDao.getCount(countSql, null)); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } } else { Object[] param = { content, content }; try { list = this.jpaDao.getResultData(Constant.NEGATIVE_ONE, Constant.NEGATIVE_ONE, jpql, param); result.setTotalCount(this.jpaDao.getCount(countSql, param)); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } } if (list != null && list.size() > Constant.ZERO) { for (Object o : list) { Schedule schedule = (Schedule) o; ScheduleVo vo = new ScheduleVo(); vo.setId(schedule.getId()); vo.setScheduleDate(schedule.getScheduleDate()); try { vo.setSt((ScheduleType) this.jpaDao.findById( ScheduleType.class, schedule.getId())); } catch (MyException e) { vo.setSt(null); } try { vo.setUser((User) this.jpaDao.findById(User.class, schedule.getUserId())); } catch (MyException e) { vo.setUser(null); } vo.setStatus(schedule.getStatus()); lt.add(vo); } result.setList(lt); } return Response.ok(result).build(); } }
zzyyp
trunk/zp/src/com/zp/resource/ScheduleServices.java
Java
asf20
7,167
package com.zp.resource; import java.util.ArrayList; import java.util.List; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.springframework.stereotype.Component; import com.sun.jersey.spi.resource.Singleton; import com.zp.bean.common.ResultCommonVo; import com.zp.bean.paper.AnswerItemVo; import com.zp.bean.paper.QuestionVo; import com.zp.bean.paper.ResultAnswerItemVo; import com.zp.bean.paper.ResultQuestionVo; import com.zp.domain.AnswerItem; import com.zp.domain.Question; import com.zp.resource.common.BaseServices; import com.zp.util.Constant; import com.zp.util.MyException; /** * question services * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/2/22 * */ @Component @Path("/rest/question") @Singleton public class QuestionServices extends BaseServices { /** * add one Question path:/question/addQuestion Http:POST * * @param question * * @return Response, ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":0} */ @POST @Path("/addQuestion") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response addQuestion(Question question) { ResultCommonVo result = new ResultCommonVo(); try { jpaDao.save(question); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * update one Question path:/question/updateQuestion Http:PUT * * @param question * * @return Response, ResultQuestionVo with JSON String * like:{"code":268,"message":"OK","totalCount":0,"vo":{"id": * "402881e6445cc3a301445cc4332b0001" * ,"title":"心理关爱题目11","questionType" * :{"id":"402881e6445c8fc601445c980f1f0005" * ,"name":"单选题","code":"QUS00001" * ,"parentCode":"QU0001"},"businessType" * :null,"item":null},"list":null} */ @PUT @Path("/updateQuestion") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response updateQuestion(Question question) { ResultQuestionVo result = new ResultQuestionVo(); try { jpaDao.update(question); QuestionVo vo = new QuestionVo(); vo.setBusinessType(null); vo.setId(question.getId()); try { vo.setItem((AnswerItem) this.jpaDao.findById(AnswerItem.class, question.getQuestionAnswer())); } catch (IllegalArgumentException e) { vo.setItem(null); } vo.setQuestionType(this.getTypeByCode(question.getQuestionType())); vo.setTitle(question.getTitle()); result.setVo(vo); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * delete Question by id path:/question/deleteQuestion Http:DELETE * * @param questionId * primary key of Question * * @return Response, ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":1} */ @DELETE @Path("/deleteQuestion") @Produces(MediaType.APPLICATION_JSON) public Response deleteQuestion(@QueryParam("questionId") String questionId) { logger.info("deleteQuestion called questionId:" + questionId); ResultCommonVo result = new ResultCommonVo(); try { jpaDao.deleteById(Question.class, questionId); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * get Question by id path:/question/getQuestion Http:GET * * @param questionId * primary key of Question * * @return Response, ResultQuestionVo with JSON String * like:{"code":268,"message":"OK","totalCount":0,"vo":{"id": * "402881e6445cc3a301445cc4332b0001" * ,"title":"心理关爱题目11","questionType" * :{"id":"402881e6445c8fc601445c980f1f0005" * ,"name":"单选题","code":"QUS00001" * ,"parentCode":"QU0001"},"businessType" * :null,"item":null},"list":null} * */ @GET @Path("/getQuestion") @Produces(MediaType.APPLICATION_JSON) public Response getQuestionById(@QueryParam("questionId") String questionId) { logger.info("getQuestionById called questionId:" + questionId); ResultQuestionVo result = new ResultQuestionVo(); try { Question question = (Question) jpaDao.findById(Question.class, questionId); QuestionVo vo = new QuestionVo(); vo.setBusinessType(null); vo.setId(question.getId()); vo.setItem((AnswerItem) this.jpaDao.findById(AnswerItem.class, question.getQuestionAnswer())); vo.setQuestionType(this.getTypeByCode(question.getQuestionType())); vo.setTitle(question.getTitle()); result.setVo(vo); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * get all the answer items with question id * * @param questionId * @return Response,ResultAnswerItemVo with JSON String * like:{"code":268,"message" * :"OK","totalCount":4,"vo":null,"list":[{ * "id":"402881e6445d4c3701445d515f8e0002" * ,"code":"A","question":null * ,"value":"心理关爱题目1答案1"},{"id":"402881e6445d53b401445d54be830001" * ,"code":"B","question":null,"value":"心理关爱题目1答案2"},{"id": * "402881e6445d53b401445d54fa180002" * ,"code":"C","question":null,"value" * :"心理关爱题目1答案3"},{"id":"402881e6445d53b401445d55bb6b0003" * ,"code":"D","question":null,"value":"心理关爱题目1答案4"}]} */ @GET @Path("/getAitems") @Produces(MediaType.APPLICATION_JSON) public Response getAnswerItemFromQuestion( @QueryParam("questionId") String questionId) { logger.info("getAnswerItemFromQuestion called questionId:" + questionId); ResultAnswerItemVo result = new ResultAnswerItemVo(); String jpql = "from AnswerItem where questionId=?"; String countSql = "select count(id) from AnswerItem where questionId=?"; List<?> list = null; List<AnswerItemVo> lt = new ArrayList<AnswerItemVo>(); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); Object[] param = { questionId }; try { list = this.jpaDao.getResultData(Constant.NEGATIVE_ONE, Constant.NEGATIVE_ONE, jpql, param); long totalCount = this.jpaDao.getCount(countSql, param); result.setTotalCount(totalCount); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } if (list != null && list.size() > Constant.ZERO) { for (Object o : list) { AnswerItem aitem = (AnswerItem) o; AnswerItemVo vo = new AnswerItemVo(); vo.setId(aitem.getId()); vo.setCode(aitem.getAnswerCode()); vo.setQuestion(null); vo.setValue(aitem.getValue()); lt.add(vo); } result.setList(lt); } return Response.ok(result).build(); } /** * * get question with page parameters and search condition * path:/question/getQuestions Http:GET * * @param pageNo * * @param pageSize * * @param questionTitle * the title of question if ignored the value is null * * @return Response, ResultQuestionVo with JSON String * like:{"code":268,"message" * :"OK","totalCount":10,"vo":null,"list":[ * {"id":"402881e6445cc3a301445cc4332b0001" * ,"title":"心理关爱题目1","questionType" * :{"id":"402881e6445c8fc601445c980f1f0005" * ,"name":"单选题","code":"QUS00001" * ,"parentCode":"QU0001"},"businessType" * :null,"item":null},{"id":"402881e6445cc3a301445cc62ac7000a" * ,"title":"心理关爱题目10","questionType":{"id": * "402881e6445c8fc601445c980f1f0005" * ,"name":"单选题","code":"QUS00001", * "parentCode":"QU0001"},"businessType":null,"item":null}]} * * */ @GET @Path("/getQuestions") @Produces({ MediaType.APPLICATION_JSON }) public Response getQuestionByCodeName(@QueryParam("pageNo") int pageNo, @QueryParam("pageSize") int pageSize, @QueryParam("questionTitle") String questionTitle) { logger.info("getQuestionByCodeName called json pageNo:" + pageNo + " pageSize:" + pageSize + " questionTitle:" + questionTitle); String jpql = "from Question where title=? order by title asc"; String countSql = "select count(id) from Question where title=? order by title asc"; List<?> list = null; ResultQuestionVo result = new ResultQuestionVo(); List<QuestionVo> lt = new ArrayList<QuestionVo>(); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); if ("".equals(questionTitle) || questionTitle == null) { jpql = "from Question order by title asc"; countSql = "select count(id) from Question order by title asc"; try { list = this.jpaDao.getResultData(pageNo, pageSize, jpql, null); long totalCount = this.jpaDao.getCount(countSql, null); result.setTotalCount(totalCount); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } } else { Object[] param = { questionTitle }; try { list = this.jpaDao.getResultData(pageNo, pageSize, jpql, param); long totalCount = this.jpaDao.getCount(countSql, param); result.setTotalCount(totalCount); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } } if (list != null && list.size() > Constant.ZERO) { for (Object o : list) { Question question = (Question) o; QuestionVo vo = new QuestionVo(); vo.setBusinessType(null); vo.setId(question.getId()); try { vo.setItem((AnswerItem) this.jpaDao.findById( AnswerItem.class, question.getQuestionAnswer())); } catch (MyException e) { vo.setItem(null); } vo.setQuestionType(this.getTypeByCode(question .getQuestionType())); vo.setTitle(question.getTitle()); lt.add(vo); } result.setList(lt); } return Response.ok(result).build(); } }
zzyyp
trunk/zp/src/com/zp/resource/QuestionServices.java
Java
asf20
10,841
package com.zp.resource; import java.util.ArrayList; import java.util.List; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.springframework.stereotype.Component; import com.sun.jersey.spi.resource.Singleton; import com.zp.bean.common.ResultCommonVo; import com.zp.bean.paper.AnswerItemVo; import com.zp.bean.paper.ResultAnswerItemVo; import com.zp.domain.AnswerItem; import com.zp.domain.Question; import com.zp.resource.common.BaseServices; import com.zp.util.Constant; import com.zp.util.MyException; /** * answer item services * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/2/22 * */ @Component @Path("/rest/aitem") @Singleton public class AnswerItemServices extends BaseServices { /** * add one AnswerItem path:/aitem/addItem Http:POST * * @param aitem * * @return Response, ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":0} */ @POST @Path("/addItem") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response addItem(AnswerItem aitem) { ResultCommonVo result = new ResultCommonVo(); try { jpaDao.save(aitem); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * update one AnswerItem path:/aitem/updateItem Http:PUT * * @param aitem * * @return Response, ResultAnswerItemVo with JSON String * like:{"code":268,"message":"OK","totalCount":0,"vo":{"id": * "402881e6445d4c3701445d515f8e0002" * ,"code":"A","question":{"id":"402881e6445cc3a301445cc4332b0001" * ,"title":"心理关爱题目1","questionType":"QUS00001","questionAnswer":"", * "businessType":null},"value":"心理关爱题目1答案1"},"list":null} */ @PUT @Path("/updateItem") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response updateItem(AnswerItem aitem) { ResultAnswerItemVo result = new ResultAnswerItemVo(); try { jpaDao.update(aitem); AnswerItemVo vo = new AnswerItemVo(); vo.setId(aitem.getId()); vo.setCode(aitem.getAnswerCode()); vo.setQuestion((Question) this.jpaDao.findById(Question.class, aitem.getQuestionId())); vo.setValue(aitem.getValue()); result.setVo(vo); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * delete AnswerItem by id path:/aitem/deleteItem Http:DELETE * * @param itemId * primary key of AnswerItem * * @return Response, ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":1} */ @DELETE @Path("/deleteItem") @Produces(MediaType.APPLICATION_JSON) public Response deleteItem(@QueryParam("itemId") String itemId) { logger.info("deleteItem called itemId:" + itemId); ResultCommonVo result = new ResultCommonVo(); try { jpaDao.deleteById(AnswerItem.class, itemId); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * get AnswerItem by id path:/aitem/getItem Http:GET * * @param itemId * primary key of AnswerItem * * @return Response, ResultAnswerItemVo with JSON String * like:{"code":268,"message":"OK","totalCount":0,"vo":{"id": * "402881e6445d4c3701445d515f8e0002" * ,"code":"A","question":{"id":"402881e6445cc3a301445cc4332b0001" * ,"title":"心理关爱题目1","questionType":"QUS00001","questionAnswer":"", * "businessType":null},"value":"心理关爱题目1答案1"},"list":null} * */ @GET @Path("/getItem") @Produces(MediaType.APPLICATION_JSON) public Response getItemById(@QueryParam("itemId") String itemId) { logger.info("getItemById called itemId:" + itemId); ResultAnswerItemVo result = new ResultAnswerItemVo(); AnswerItem aitem; try { aitem = (AnswerItem) jpaDao.findById(AnswerItem.class, itemId); AnswerItemVo vo = new AnswerItemVo(); vo.setId(aitem.getId()); vo.setCode(aitem.getAnswerCode()); try { vo.setQuestion((Question) this.jpaDao.findById(Question.class, aitem.getQuestionId())); } catch (IllegalArgumentException e) { vo.setQuestion(null); } vo.setValue(aitem.getValue()); result.setVo(vo); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * * get answer items with page parameters and search condition * path:/aitem/getItems Http:GET * * @param pageNo * * @param pageSize * * @param value * the value of answer,if ignored the value is null * * @return Response, ResultAnswerItemVo with JSON String * like:{"code":268,"message" * :"OK","totalCount":12,"vo":null,"list":[ * {"id":"402881e6445d53b401445d54be830001" * ,"code":"B","question":{"id" * :"402881e6445cc3a301445cc4332b0001","title" * :"心理关爱题目1","questionType" * :"QUS00001","questionAnswer":"","businessType" * :null},"value":"心理关爱题目1答案2" * },{"id":"402881e6445d53b401445d54fa180002" * ,"code":"C","question":{ * "id":"402881e6445cc3a301445cc4332b0001","title" * :"心理关爱题目1","questionType" * :"QUS00001","questionAnswer":"","businessType" * :null},"value":"心理关爱题目1答案3"}]} * * */ @GET @Path("/getItems") @Produces({ MediaType.APPLICATION_JSON }) public Response getItemByCodeName(@QueryParam("pageNo") int pageNo, @QueryParam("pageSize") int pageSize, @QueryParam("value") String value) { logger.info("getItemByCodeName called json pageNo:" + pageNo + " pageSize:" + pageSize + " value:" + value); String jpql = "from AnswerItem where value=? order by questionId asc"; String countSql = "select count(id) from AnswerItem where value=? order by questionId asc"; List<?> list = null; ResultAnswerItemVo result = new ResultAnswerItemVo(); List<AnswerItemVo> lt = new ArrayList<AnswerItemVo>(); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); if ("".equals(value) || value == null) { jpql = "from AnswerItem order by questionId asc"; countSql = "select count(id) from AnswerItem order by questionId asc"; try { list = this.jpaDao.getResultData(pageNo, pageSize, jpql, null); long totalCount = this.jpaDao.getCount(countSql, null); result.setTotalCount(totalCount); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } } else { Object[] param = { value }; try { list = this.jpaDao.getResultData(pageNo, pageSize, jpql, param); long totalCount = this.jpaDao.getCount(countSql, param); result.setTotalCount(totalCount); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } } if (list != null && list.size() > Constant.ZERO) { for (Object o : list) { AnswerItem aitem = (AnswerItem) o; AnswerItemVo vo = new AnswerItemVo(); vo.setId(aitem.getId()); vo.setCode(aitem.getAnswerCode()); try { vo.setQuestion((Question) this.jpaDao.findById( Question.class, aitem.getQuestionId())); } catch (MyException e) { vo.setQuestion(null); e.printStackTrace(); } vo.setValue(aitem.getValue()); lt.add(vo); } result.setList(lt); } return Response.ok(result).build(); } }
zzyyp
trunk/zp/src/com/zp/resource/AnswerItemServices.java
Java
asf20
8,390
package com.zp.resource.common; import java.util.ArrayList; import java.util.List; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.springframework.stereotype.Component; import com.sun.jersey.spi.resource.Singleton; import com.zp.bean.common.ResultCommonVo; import com.zp.bean.common.ResultModuleTypeVo; import com.zp.domain.ModuleType; import com.zp.util.Constant; import com.zp.util.MyException; /** * module type services * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/3/12 * */ @Component @Path("/rest/mtype") @Singleton public class ModuleTypeServices extends BaseServices { /** * add one ModuleType path:/mtype/addType Http:POST * * @param mtype * * @return Response, ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":0} */ @POST @Path("/addType") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response addType(ModuleType mtype) { ResultCommonVo result = new ResultCommonVo(); try { jpaDao.save(mtype); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * update one ModuleType path:/mtype/updateType Http:PUT * * @param mtype * * @return Response, ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":0} */ @PUT @Path("/updateType") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response updateType(ModuleType mtype) { ResultCommonVo result = new ResultCommonVo(); try { jpaDao.update(mtype); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * delete ModuleType by id path:/mtype/deleteType Http:DELETE * * @param typeId * primary key of ModuleType * * @return Response, ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":1} */ @DELETE @Path("/deleteType") @Produces(MediaType.APPLICATION_JSON) public Response deleteType(@QueryParam("typeId") String typeId) { logger.info("deleteType called typeId:" + typeId); ResultCommonVo result = new ResultCommonVo(); try { jpaDao.deleteById(ModuleType.class, typeId); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * get ModuleType by id path:/mtype/getType Http:POST * * @param typeId * primary key of ModuleType * * @return Response, ResultModuleTypeVo with JSON String * like:{"code":268,"message":"OK","totalCount":0,"type":{"id": * "402881e844b6bda90144b6c07fe60004" * ,"name":"创业指导","code":"mo03","parentCode":"mo"},"listVo":null} */ @POST @Path("/getType") @Produces(MediaType.APPLICATION_JSON) public Response getTypeById(@QueryParam("typeId") String typeId) { logger.info("getTypeById called typeId:" + typeId); ResultModuleTypeVo result = new ResultModuleTypeVo(); try { ModuleType mtype = (ModuleType) jpaDao.findById(ModuleType.class, typeId); result.setType(mtype); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * * get module type with page parameters and search condition * path:/mtype/getTypes Http:POST * * @param pageNo * * @param pageSize * * @param codeName * if ignored the value is null * * @return Response, ResultModuleTypeVo with JSON String * like:{"code":268,"message" * :"OK","totalCount":1,"type":null,"listVo" * :[{"id":"402881e844b6bda90144b6bfec510002" * ,"name":"心理关爱","code":"mo01","parentCode":"mo"}]} */ @POST @Path("/getTypes") @Produces({ MediaType.APPLICATION_JSON }) public Response getTypeByCodeName(@QueryParam("pageNo") int pageNo, @QueryParam("pageSize") int pageSize, @QueryParam("codeName") String codeName) { logger.info("getTypeByCodeName called json pageNo:" + pageNo + " pageSize:" + pageSize + " codeName:" + codeName); String jpql = "from ModuleType where code=? order by code asc"; String countSql = "select count(id) from ModuleType where code=? order by code asc"; List<?> list = null; ResultModuleTypeVo result = new ResultModuleTypeVo(); List<ModuleType> lt = new ArrayList<ModuleType>(); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); if ("".equals(codeName) || codeName == null) { jpql = "from ModuleType order by code asc"; countSql = "select count(id) from ModuleType order by code asc"; try { list = this.jpaDao.getResultData(pageNo, pageSize, jpql, null); long totalCount = this.jpaDao.getCount(countSql, null); result.setTotalCount(totalCount); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } } else { Object[] param = { codeName }; try { list = this.jpaDao.getResultData(pageNo, pageSize, jpql, param); long totalCount = this.jpaDao.getCount(countSql, param); result.setTotalCount(totalCount); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } } if (list != null && list.size() > Constant.ZERO) { for (Object o : list) { ModuleType mtype = (ModuleType) o; lt.add(mtype); } result.setListVo(lt); } return Response.ok(result).build(); } }
zzyyp
trunk/zp/src/com/zp/resource/common/ModuleTypeServices.java
Java
asf20
6,308
package com.zp.resource.common; import java.util.ArrayList; import java.util.List; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.springframework.stereotype.Component; import com.sun.jersey.spi.resource.Singleton; import com.zp.bean.common.OperationLogVo; import com.zp.bean.common.ResultCommonVo; import com.zp.bean.common.ResultOperationLogVo; import com.zp.domain.OperationLog; import com.zp.domain.Type; import com.zp.domain.User; import com.zp.util.Constant; import com.zp.util.MyException; /** * operation log services * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/2/12 * */ @Component @Path("/rest/operationLog") @Singleton public class OperationLogServices extends BaseServices { /** * add one Log path:/operationLog/addLog Http:POST * * @param operationLog * * @return Response, ResultCommonVo with JSON String */ @POST @Path("/addLog") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response addLog(OperationLog operationLog) { ResultCommonVo result = new ResultCommonVo(); try { jpaDao.save(operationLog); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * update one Log path:/operationLog/updateLog Http:PUT * * @param operationLog * * @return Response, ResultCommonVo with JSON String */ @PUT @Path("/updateLog") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response updateLog(OperationLog operationLog) { ResultCommonVo result = new ResultCommonVo(); try { jpaDao.update(operationLog); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * delete Log by id path:/operationLog/deleteLog Http:DELETE * * @param logId * the primary key of OperationLog * * @return Response, ResultCommonVo with JSON String */ @DELETE @Path("/deleteLog") @Produces(MediaType.APPLICATION_JSON) public Response deleteLog(@QueryParam("logId") String logId) { logger.info("deleteLog called logId:" + logId); ResultCommonVo result = new ResultCommonVo(); try { jpaDao.deleteById(OperationLog.class, logId); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * get Log by id path:/operationLog/getLog Http:GET * * @param logId * the primary key of OperationLog * * @return Response,ResultOperationLogVo with JSON String * like:{"code":268,"message":"OK","totalCount":1} */ @GET @Path("/getLog") @Produces(MediaType.APPLICATION_JSON) public Response getLogById(@QueryParam("logId") String logId) { logger.info("getLogById called logId:" + logId); ResultOperationLogVo result = new ResultOperationLogVo(); try { OperationLog log = (OperationLog) jpaDao.findById( OperationLog.class, logId); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); OperationLogVo vo = new OperationLogVo(); vo.setLogDate(log.getLogTime()); vo.setType(this.getTypeByCode(log.getTypeCode())); vo.setUser((User) this.jpaDao.findById(User.class, log.getUserId())); result.setLog(vo); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * * get operationLog with page parameters * path:/operationLog/getLogs Http:GET * * @param pageNo * * @param pageSize * * @return Response ResultOperationLogVo with JSON String * like:{"code":268,"message" * :"OK","totalCount":4,"log":null,"listVo" * :[{"user":{"id":"402881e64459ad0e014459adc3b00001" * ,"name":"Alex","birthday" * :null,"gender":null,"certNumber":null,"typeCode" * :null,"registerTime" * :1393073964000,"updateTime":null},"type":{"id" * :"402881e64458d2bb014458eb7fb6000f" * ,"name":"删除数据","code":"D00001", * "parentCode":"DA0001"},"logDate":1393079012000 * },{"user":{"id":"402881e64459ad0e014459adc3b00001" * ,"name":"Alex","birthday" * :null,"gender":null,"certNumber":null,"typeCode" * :null,"registerTime" * :1393073964000,"updateTime":null},"type":{"id" * :"402881e64458d2bb014458eb1665000e" * ,"name":"查询数据","code":"S00001", * "parentCode":"DA0001"},"logDate":1393078998000}]} */ @GET @Path("/getLogs") @Produces({ MediaType.APPLICATION_JSON }) public Response getLogWithPages(@QueryParam("pageNo") int pageNo, @QueryParam("pageSize") int pageSize) { logger.info("getLogWithPages called json param: pageNo is:" + pageNo + " pageSize is:" + pageSize); ResultOperationLogVo result = new ResultOperationLogVo(); List<OperationLogVo> listVo = new ArrayList<OperationLogVo>(); try { String jpql = "from OperationLog order by logTime desc"; List<?> list = this.jpaDao.getResultData(pageNo, pageSize, jpql, null); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); if (list != null && list.size() > Constant.ZERO) { for (Object o : list) { OperationLog log = (OperationLog) o; OperationLogVo vo = new OperationLogVo(); vo.setLogDate(log.getLogTime()); vo.setType((Type) this.getTypeByCode(log.getTypeCode())); vo.setUser((User) this.jpaDao.findById(User.class, log.getUserId())); listVo.add(vo); } result.setListVo(listVo); result.setTotalCount(this.jpaDao.getCount( "select count(id) from OperationLog", null)); } } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } }
zzyyp
trunk/zp/src/com/zp/resource/common/OperationLogServices.java
Java
asf20
6,549
package com.zp.resource.common; import java.util.ArrayList; import java.util.List; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.springframework.stereotype.Component; import com.sun.jersey.spi.resource.Singleton; import com.zp.bean.common.ResultCommonVo; import com.zp.bean.common.ResultContentTypeVo; import com.zp.domain.ContentType; import com.zp.util.Constant; import com.zp.util.MyException; /** * ctype services * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/2/12 * */ @Component @Path("/rest/ctype") @Singleton public class ContentTypeServices extends BaseServices { /** * add one ContentType path:/ctype/addType Http:POST * * @param ctype * * @return Response, ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":0} */ @POST @Path("/addType") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response addType(ContentType ctype) { ResultCommonVo result = new ResultCommonVo(); try { jpaDao.save(ctype); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * update one ContentType path:/ctype/updateType Http:PUT * * @param ctype * * @return Response, ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":0} */ @PUT @Path("/updateType") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response updateType(ContentType ctype) { ResultCommonVo result = new ResultCommonVo(); try { jpaDao.update(ctype); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * delete ContentType by id path:/ctype/deleteType Http:DELETE * * @param typeId * primary key of ContentType * * @return Response, ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":1} */ @DELETE @Path("/deleteType") @Produces(MediaType.APPLICATION_JSON) public Response deleteType(@QueryParam("typeId") String typeId) { logger.info("deleteType called typeId:" + typeId); ResultCommonVo result = new ResultCommonVo(); try { jpaDao.deleteById(ContentType.class, typeId); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * get ContentType by id path:/ctype/getType Http:POST * * @param typeId * primary key of ContentType * * @return Response, ResultContentTypeVo with JSON String * like:{"code":268,"message":"OK","totalCount":0,"type":{"id": * "402881e744791cd2014479213e260005" * ,"name":"心理关爱","code":"cm01","parentCode":"cm"},"listVo":null} */ @POST @Path("/getType") @Produces(MediaType.APPLICATION_JSON) public Response getTypeById(@QueryParam("typeId") String typeId) { logger.info("getTypeById called typeId:" + typeId); ResultContentTypeVo result = new ResultContentTypeVo(); try { ContentType ctype = (ContentType) jpaDao.findById( ContentType.class, typeId); result.setType(ctype); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * * get ctype with page parameters and search condition path:/ctype/getTypes * Http:POST * * @param pageNo * * @param pageSize * * @param codeName * if ignored the value is null * * @return Response, ResultContentTypeVo with JSON String * like:{"code":268,"message" * :"OK","totalCount":1,"type":null,"listVo" * :[{"id":"402881e744791cd2014479213e260005" * ,"name":"心理关爱","code":"cm01","parentCode":"cm"}]} */ @POST @Path("/getTypes") @Produces({ MediaType.APPLICATION_JSON }) public Response getTypeByCodeName(@QueryParam("pageNo") int pageNo, @QueryParam("pageSize") int pageSize, @QueryParam("codeName") String codeName) { logger.info("getTypeByCodeName called json pageNo:" + pageNo + " pageSize:" + pageSize + " codeName:" + codeName); String jpql = "from ContentType where code=? order by code asc"; String countSql = "select count(id) from ContentType where code=? order by code asc"; List<?> list = null; ResultContentTypeVo result = new ResultContentTypeVo(); List<ContentType> lt = new ArrayList<ContentType>(); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); if ("".equals(codeName) || codeName == null) { jpql = "from ContentType order by code asc"; countSql = "select count(id) from ContentType order by code asc"; try { list = this.jpaDao.getResultData(pageNo, pageSize, jpql, null); long totalCount = this.jpaDao.getCount(countSql, null); result.setTotalCount(totalCount); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } } else { Object[] param = { codeName }; try { list = this.jpaDao.getResultData(pageNo, pageSize, jpql, param); long totalCount = this.jpaDao.getCount(countSql, param); result.setTotalCount(totalCount); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } } if (list != null && list.size() > Constant.ZERO) { for (Object o : list) { ContentType ctype = (ContentType) o; lt.add(ctype); } result.setListVo(lt); } return Response.ok(result).build(); } }
zzyyp
trunk/zp/src/com/zp/resource/common/ContentTypeServices.java
Java
asf20
6,326
package com.zp.resource.common; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.Date; import java.util.List; import javax.activation.MimetypesFileTypeMap; import javax.servlet.ServletContext; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.springframework.stereotype.Component; import com.sun.jersey.core.header.FormDataContentDisposition; import com.sun.jersey.multipart.FormDataParam; import com.sun.jersey.spi.resource.Singleton; import com.zp.bean.common.ContentBaseVo; import com.zp.bean.common.ContentVo; import com.zp.bean.common.ResultCommonVo; import com.zp.bean.common.ResultContentBaseVo; import com.zp.bean.common.ResultContentVo; import com.zp.domain.Content; import com.zp.util.Constant; import com.zp.util.FileUtil; import com.zp.util.MyException; /** * News services * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/2/26 * */ @Component @Path("/rest/news") @Singleton public class ContentServices extends BaseServices { /** * publish content along with image or media * * @param title * the tile of content * @param content * the content of content * @param author * the author of content * @param source * where the content come from * @param typeCode * which type of content * @param top * whether put in head * @param titleImage * the input stream of title image if have * @param mediaType * the type of media * @param mediaFile * the input stream of media file * @return Response,ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":1} */ @POST @Path("/uploadNews") @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces(MediaType.APPLICATION_JSON) public Response addNews( @FormDataParam("title") String title, @FormDataParam("summary") String summary, @FormDataParam("content") String content, @FormDataParam("author") String author, @FormDataParam("source") String source, @FormDataParam("typeCode") String typeCode, @FormDataParam("top") String top, @FormDataParam("titleImage") InputStream titleImage, @FormDataParam("titleImage") FormDataContentDisposition fileDisposition, @FormDataParam("mediaFile") InputStream mediaFile, @FormDataParam("mediaFile") FormDataContentDisposition MediafileDisposition, @Context ServletContext context) { ResultCommonVo result = new ResultCommonVo(); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); String imagePath = FileUtil.getInstance().saveFile(titleImage, fileDisposition, context); if (imagePath == null || !imagePath.equals(Constant.MAX_IMAGE_SIZE_MESSAGE)) { Content news = new Content(); news.setAuthor(author); news.setContent(content); news.setCreateTime(new Date()); news.setTitleImage(imagePath); news.setTitleImageMin(imagePath); news.setMediaPath(FileUtil.getInstance().saveFile(mediaFile, MediafileDisposition, context)); news.setOperationTime(new Date()); news.setSource(source); news.setStatus("1"); news.setTitle(title); news.setSummary(summary); news.setTop(top); news.setTypeCode(typeCode); try { this.jpaDao.save(news); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } } else { result.setCode(Constant.FAILE_CODE); result.setMessage(imagePath); } return Response.ok(result).build(); } /** * get news by id path:/news/getNews Http:POST * * @param newsId * primary key of Content * * @return Response,ResultContentVo with JSON String * like:{"code":268,"message": * "OK","totalCount":0,"content":{"id":3,"title" * :"心理关爱测试01新闻","operationTime" * :1393603880000,"top":"1","summary":null * ,"titleImage":"upload/image/20143101120.jpg","content": * "心理关爱测试01新闻心理关爱测试01新闻心理关爱测试01新闻心理关爱测试01新闻心理关爱测试01新闻心理关爱测试01新闻心理关爱测试01新闻心理关爱测试01新闻心理关爱测试01新闻心理关爱测试01新闻心理关爱测试01新闻" * ,"author":"Alex","source":"http://localhost:8082/TestWeb/", * "contentType" * :{"id":"402881e744791cd2014479213e260005","name":"心理关爱" * ,"code":"cm01" * ,"parentCode":"cm"},"status":"1","createTime":1393603880000 * ,"mediaPath":null,"mediaType":null},"list":null} */ @POST @Path("/getNews") @Produces(MediaType.APPLICATION_JSON) public Response getNewsById(@QueryParam("newsId") int newsId) { logger.info("getNewsById called newsId:" + newsId); ResultContentVo result = new ResultContentVo(); try { Content news = (Content) jpaDao.findById(Content.class, newsId); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); if (news != null) { ContentVo vo = new ContentVo(); vo.setAuthor(news.getAuthor()); vo.setContent(news.getContent()); vo.setCreateTime(news.getCreateTime()); vo.setId(news.getId()); vo.setMediaPath(news.getMediaPath()); vo.setContentType(this.getContentTypeByCode(news.getTypeCode())); vo.setMediaType(this.getContentTypeByCode(news.getMediaType())); vo.setOperationTime(news.getOperationTime()); vo.setSource(news.getSource()); vo.setStatus(news.getStatus()); vo.setTitle(news.getTitle()); if (news.getTitleImage() != null) { vo.setTitleImage(news.getTitleImage()); } vo.setTop(news.getTop()); result.setContent(vo); } } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * delete Content by id path:/news/deleteNews Http:DELETE * * @param newsId * primary key of News * * @return Response,ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":1} */ @DELETE @Path("/deleteNews") @Produces(MediaType.APPLICATION_JSON) public Response deleteNews(@QueryParam("newsId") int newsId) { logger.info("deleteNews called newsId:" + newsId); ResultCommonVo result = new ResultCommonVo(); try { this.jpaDao.deleteById(Content.class, newsId); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * search news with filter parameters path:/news/searchNews Http:POST * * @param pageNo * * @param pageSize * * @param value * the type code of news or the title of news or the author of * news,if ignore the default value will be null * * @param top * whether put in first head value,if ignore the default value * will be null * * @return Response, ResultNewsBaseVo with JSON String * like:{"code":268,"message" * :"OK","totalCount":4,"list":[{"id":6,"title" * :"心理关爱新闻4","operationTime" * :1393604703000,"top":"1","summary":"心理关爱新闻4","titleImageMin": * "http://localhost:8082/ZP/upload/image/201431215026.jpg" * },{"id":5, * "title":"心理关爱新闻3","operationTime":1393604641000,"top":"1" * ,"summary":"心理关爱新闻3","titleImageMin": * "http://localhost:8082/ZP/upload/image/20143101120.jpg" * },{"id":4,"title" * :"心理关爱测试02新闻","operationTime":1393603896000,"top" * :"1","summary":"心理关爱新闻2","titleImageMin": * "http://localhost:8082/ZP/upload/image/20143101120.jpg" * },{"id":3,"title" * :"心理关爱测试01新闻","operationTime":1393603880000,"top" * :"1","summary":"心理关爱新闻1","titleImageMin": * "http://localhost:8082/ZP/upload/image/20143101120.jpg"}]} */ @POST @Path("/searchNews") @Produces(MediaType.APPLICATION_JSON) public Response searchNewsByType(@QueryParam("pageNo") int pageNo, @QueryParam("pageSize") int pageSize, @QueryParam("value") String value, @QueryParam("top") String top) { logger.info("searchNewsByType called json pageNo:" + pageNo + " pageSize:" + pageSize + " value:" + value + " top is:" + top); String jpql = "select id,title,summary,titleImageMin,operationTime,top from Content where (author=? or typeCode=?) and top=? order by operationTime desc"; List<?> list = null; ResultContentBaseVo result = new ResultContentBaseVo(); List<ContentBaseVo> lt = new ArrayList<ContentBaseVo>(); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); if (("".equals(value) || value == null) && ("".equals(top) || top == null)) { jpql = "select id,title,summary,titleImageMin,operationTime,top from Content order by operationTime desc"; try { list = this.jpaDao.getResultData(pageNo, pageSize, jpql, null); long totalCount = this.jpaDao.getCount( "select count(id) from Content", null); result.setTotalCount(totalCount); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } } else if (("".equals(value) || value == null) && ((top != null) || !("").equals(top))) { jpql = "select id,title,summary,titleImageMin,operationTime,top from Content where top=? order by operationTime desc"; Object[] param = { top }; try { list = this.jpaDao.getResultData(pageNo, pageSize, jpql, param); long totalCount = this.jpaDao.getCount( "select count(id) from Content where top=?", param); result.setTotalCount(totalCount); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } } else if ((value != null && !("".equals(top))) && ((top == null) || ("".equals(top)))) { jpql = "select id,title,summary,titleImageMin,operationTime,top from Content where author=? or typeCode=? order by operationTime desc"; Object[] param = { value, value }; try { list = this.jpaDao.getResultData(pageNo, pageSize, jpql, param); long totalCount = this.jpaDao .getCount( "select count(id)from Content where author=? or typeCode=?", param); result.setTotalCount(totalCount); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } } else { Object[] param = { value, value, top }; try { list = this.jpaDao.getResultData(pageNo, pageSize, jpql, param); long totalCount = this.jpaDao .getCount( "select count(id)from Content where (author=? or typeCode=?) and top=?", param); result.setTotalCount(totalCount); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } } if (list != null && list.size() > Constant.ZERO) { for (Object o : list) { Object[] news = (Object[]) o; ContentBaseVo vo = new ContentBaseVo(); vo.setId(Integer.valueOf(String.valueOf((news[Constant.ZERO])))); vo.setTitle(String.valueOf(news[Constant.ONE])); vo.setSummary(String.valueOf(news[Constant.TWO])); if (news[Constant.THREE] != null) { vo.setTitleImage(this.serverPath + String.valueOf(news[Constant.THREE])); } vo.setOperationTime((Date) news[Constant.FOUR]); vo.setTop(String.valueOf(news[Constant.FIVE])); lt.add(vo); } result.setList(lt); } return Response.ok(result).build(); } /** * get top Content with type * * @param number * how many rows you want to fetch path:/news/searchTopNews * Http:POST * @param typeCode * which kinds of type of Content,if ignore the default value * will be null * @return Response ResultBaseVo with JSON String like: * {"code":268,"message" * :"OK","totalCount":3,"list":[{"id":6,"title": * null,"operationTime":null,"top":null,"summary":null,"titleImage": * "http://localhost:8082/ZP/upload/image/201431215026.jpg" * },{"id":5, * "title":null,"operationTime":null,"top":null,"summary":null * ,"titleImage" * :"http://localhost:8082/ZP/upload/image/201431215026.jpg" * },{"id":4 * ,"title":null,"operationTime":null,"top":null,"summary":null * ,"titleImage" * :"http://localhost:8082/ZP/upload/image/201431215026.jpg"}]} */ @POST @Path("/searchTopNews") @Produces(MediaType.APPLICATION_JSON) public Response searchTopNews(@QueryParam("number") int number, @QueryParam("typeCode") String typeCode) { logger.info("searchNewsByType called json number:" + number + " typeCode:" + typeCode); String jpql = "select id,titleImage from Content where typeCode=? and top=? order by operationTime desc"; List<?> list = null; ResultContentBaseVo result = new ResultContentBaseVo(); List<ContentBaseVo> lt = new ArrayList<ContentBaseVo>(); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); if (!"".equals(typeCode) || typeCode != null) { Object[] param = { typeCode, "1" }; try { list = this.jpaDao.getResultData(Constant.ONE, number, jpql, param); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } } if (list != null && list.size() > Constant.ZERO) { result.setTotalCount(list.size()); for (Object o : list) { Object[] news = (Object[]) o; ContentBaseVo vo = new ContentBaseVo(); vo.setId(Integer.valueOf(String.valueOf((news[Constant.ZERO])))); if (news[Constant.ONE] != null) { vo.setTitleImage(this.serverPath + String.valueOf(news[Constant.ONE])); } lt.add(vo); } result.setList(lt); } return Response.ok(result).build(); } /** * get file with filename * * @param application * ServletContext * @param filename * String * @param path * String * @param postfix * String * @return Response */ @SuppressWarnings("unused") private Response getFile(@Context ServletContext application, String filename, String path, String postfix) { String realPath = application.getRealPath(path); File file = new File(realPath, filename + postfix); if (!file.exists()) { throw new WebApplicationException(404); } String MimeFileType = new MimetypesFileTypeMap().getContentType(file); return Response .ok(file, MimeFileType) .header("Content-disposition", "attachment;filename=" + filename + postfix) .header("ragma", "No-cache") .header("Cache-Control", "no-cache").build(); } protected boolean bigSize(InputStream input) { boolean result = false; try { int length = Constant.ZERO; int total = Constant.ZERO; byte[] buff = new byte[Constant.MD5_MAX_INDEX]; while (Constant.NEGATIVE_ONE != (length = input.read(buff))) { total += length; if (total > Constant.MAX_IMAGE_SIZE) { result = true; } } } catch (IOException e) { e.printStackTrace(); } finally { try { input.close(); } catch (IOException e) { e.printStackTrace(); } } return result; } }
zzyyp
trunk/zp/src/com/zp/resource/common/ContentServices.java
Java
asf20
15,948
package com.zp.resource.common; import java.util.List; import javax.annotation.Resource; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.codehaus.jettison.json.JSONException; import org.codehaus.jettison.json.JSONObject; import org.springframework.stereotype.Component; import com.zp.domain.ContentType; import com.zp.domain.ModuleType; import com.zp.domain.Type; import com.zp.framework.jpa.IJpaDao; import com.zp.util.Constant; import com.zp.util.Dom4JUtil; import com.zp.util.MyException; /** * common services for all the services class * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/2/12 * */ @Component public class BaseServices { @Resource(name="jpaDao") protected IJpaDao jpaDao; protected Log logger = LogFactory.getLog(BaseServices.class); protected String serverPath=Dom4JUtil.parserXml(Constant.PATH_FILE_NAME).get(Constant.SERVER_PATH_KEY); protected JSONObject getJSONObject(String json) { JSONObject JO = null; try { JO = new JSONObject(json); } catch (JSONException e) { e.printStackTrace(); } return JO; } protected Type getTypeByCode(String code) { String jpql = "from Type where code=?"; Object[] queryParams = { code }; Type type = null; try { List<?> list = this.jpaDao.getResultData(Constant.NEGATIVE_ONE, Constant.NEGATIVE_ONE, jpql, queryParams); if (list != null && list.size() > Constant.ZERO) { type = (Type) list.get(Constant.ZERO); } } catch (MyException e) { e.printStackTrace(); } return type; } protected ContentType getContentTypeByCode(String code) { String jpql = "from ContentType where code=?"; Object[] queryParams = { code }; ContentType type = null; try { List<?> list = this.jpaDao.getResultData(Constant.NEGATIVE_ONE, Constant.NEGATIVE_ONE, jpql, queryParams); if (list != null && list.size() > Constant.ZERO) { type = (ContentType) list.get(Constant.ZERO); } } catch (MyException e) { e.printStackTrace(); } return type; } protected ModuleType getModuleTypeByCode(String code) { String jpql = "from ModuleType where code=?"; Object[] queryParams = { code }; ModuleType type = null; try { List<?> list = this.jpaDao.getResultData(Constant.NEGATIVE_ONE, Constant.NEGATIVE_ONE, jpql, queryParams); if (list != null && list.size() > Constant.ZERO) { type = (ModuleType) list.get(Constant.ZERO); } } catch (MyException e) { e.printStackTrace(); } return type; } }
zzyyp
trunk/zp/src/com/zp/resource/common/BaseServices.java
Java
asf20
2,529
package com.zp.resource.common; import java.util.ArrayList; import java.util.List; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.springframework.stereotype.Component; import com.sun.jersey.spi.resource.Singleton; import com.zp.bean.common.ResultCommonVo; import com.zp.bean.common.ResultTypeVo; import com.zp.domain.Type; import com.zp.util.Constant; import com.zp.util.MyException; /** * type services * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/2/12 * */ @Component @Path("/rest/type") @Singleton public class TypeServices extends BaseServices { /** * add one Type path:/type/addType Http:POST * * @param type * * @return Response, ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":0} */ @POST @Path("/addType") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response addType(Type type) { ResultCommonVo result = new ResultCommonVo(); try { jpaDao.save(type); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * update one Type path:/type/updateType Http:PUT * * @param type * * @return Response, ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":0} */ @PUT @Path("/updateType") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response updateType(Type type) { ResultCommonVo result = new ResultCommonVo(); try { jpaDao.update(type); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * delete Type by id path:/type/deleteType Http:DELETE * * @param typeId * primary key of Type * * @return Response, ResultCommonVo with JSON String * like:{"code":268,"message":"OK","totalCount":1} */ @DELETE @Path("/deleteType") @Produces(MediaType.APPLICATION_JSON) public Response deleteType(@QueryParam("typeId") String typeId) { logger.info("deleteType called typeId:" + typeId); ResultCommonVo result = new ResultCommonVo(); try { jpaDao.deleteById(Type.class, typeId); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * get Type by id path:/type/getType Http:POST * * @param typeId * primary key of Type * * @return Response, ResultTypeVo with JSON String * like:{"code":268,"message":"OK","totalCount":1,"type":{"id": * "402881e64458c50c014458c5a56d0001" * ,"name":"身份证","code":"C000001","parentCode":null},"listVo":null} */ @POST @Path("/getType") @Produces(MediaType.APPLICATION_JSON) public Response getTypeById(@QueryParam("typeId") String typeId) { logger.info("getTypeById called typeId:" + typeId); ResultTypeVo result = new ResultTypeVo(); try { Type type = (Type) jpaDao.findById(Type.class, typeId); result.setType(type); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } return Response.ok(result).build(); } /** * * get type with page parameters and search condition path:/type/getTypes * Http:POST * * @param pageNo * * @param pageSize * * @param codeName if ignored the value is null * * @return Response, ResultTypeVo with JSON String * like:{"code":268,"message" * :"OK","totalCount":1,"type":null,"listVo" * :[{"id":"402881e64458c50c014458c5a56d0001" * ,"name":"身份证","code":"C000001","parentCode":null}]} */ @POST @Path("/getTypes") @Produces({ MediaType.APPLICATION_JSON }) public Response getTypeByCodeName(@QueryParam("pageNo") int pageNo, @QueryParam("pageSize") int pageSize, @QueryParam("codeName") String codeName) { logger.info("getTypeByCodeName called json pageNo:" + pageNo + " pageSize:" + pageSize + " codeName:" + codeName); String jpql = "from Type where code=? order by code asc"; String countSql = "select count(id) from Type where code=? order by code asc"; List<?> list = null; ResultTypeVo result = new ResultTypeVo(); List<Type> lt = new ArrayList<Type>(); result.setCode(Constant.SUCCESS_CODE); result.setMessage(Constant.OK); if ("".equals(codeName) || codeName == null) { jpql = "from Type order by code asc"; countSql = "select count(id) from Type order by code asc"; try { list = this.jpaDao.getResultData(pageNo, pageSize, jpql, null); long totalCount = this.jpaDao.getCount(countSql, null); result.setTotalCount(totalCount); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } } else { Object[] param = { codeName }; try { list = this.jpaDao.getResultData(pageNo, pageSize, jpql, param); long totalCount = this.jpaDao.getCount(countSql, param); result.setTotalCount(totalCount); } catch (MyException e) { result.setCode(Constant.FAILE_CODE); result.setMessage(e.getMessage()); e.printStackTrace(); } } if (list != null && list.size() > Constant.ZERO) { for (Object o : list) { Type type = (Type) o; lt.add(type); } result.setListVo(lt); } return Response.ok(result).build(); } }
zzyyp
trunk/zp/src/com/zp/resource/common/TypeServices.java
Java
asf20
6,084
package com.zp.framework.spring.web.filter; /* * Copyright 2002-2004 the original author or authors. * * 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. */ import java.io.IOException; import javax.servlet.FilterChain; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.web.filter.OncePerRequestFilter; /** * Servlet 2.3 Filter that allows to specify a character encoding for requests. * This is useful because current browsers typically do not set a character * encoding even if specified in the HTML page respectively form. * * <p> * Can either just apply this filter's encoding if the request does not already * specify an encoding, or apply this filter's encoding in any case. * * @author Juergen Hoeller * @since 15.03.2004 * @see #setEncoding * @see #setForceEncoding */ public class CharacterEncodingFilter extends OncePerRequestFilter { private String encoding; private boolean forceEncoding; /** * Set the encoding to use for requests. This encoding will be passed into a * ServletRequest.setCharacterEncoding call. * <p> * Whether this encoding will override existing request encodings depends on * the "forceEncoding" flag. * * @see #setForceEncoding * @see javax.servlet.ServletRequest#setCharacterEncoding */ public void setEncoding(String encoding) { this.encoding = encoding; } /** * Set whether the encoding of this filter should override existing request * encodings. Default is false, i.e. do not modify encoding if * ServletRequest.getCharacterEncoding returns a non-null value. * * @see #setEncoding * @see javax.servlet.ServletRequest#getCharacterEncoding */ public void setForceEncoding(boolean forceEncoding) { this.forceEncoding = forceEncoding; } protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { if (this.forceEncoding || request.getCharacterEncoding() == null) { request.setCharacterEncoding(this.encoding); } filterChain.doFilter(request, response); } }
zzyyp
trunk/zp/src/com/zp/framework/spring/web/filter/CharacterEncodingFilter.java
Java
asf20
2,769
package com.zp.framework.bean; public class InitBean { // 上传文件时缓冲区目录 public static String TEMP_PATH; // 上传文件时缓冲区大小 public static int TEMP_SIZE; public void init() { } }
zzyyp
trunk/zp/src/com/zp/framework/bean/InitBean.java
Java
asf20
233
package com.zp.framework.jpa.test; import java.util.Date; import java.util.List; import junit.framework.Assert; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.transaction.annotation.Transactional; import com.zp.domain.User; import com.zp.framework.jpa.IJpaDao; import com.zp.util.MyException; /** * test JPADao function with Junit * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/2/7 * */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:configure/applicationContext.xml" }) public class RunJPA { private IJpaDao JpaDao; private static final Log logger = LogFactory.getLog(RunJPA.class); @Before public void init() { JpaDao = (IJpaDao) new ClassPathXmlApplicationContext( "configure/applicationContext.xml").getBean("jpaDao"); logger.info("*********** testing to initial spring container ****************"); } @After public void destory() { JpaDao = null; logger.info("*********** testing to destory JPADao instance ******************"); } @Test @Transactional public void testSave() { logger.info("*********** begin testing to create user *****************"); User user = new User(); user.setName("Alex07"); user.setCertNumber("123456790"); user.setTypeCode("1111111111111111");; user.setGender("1"); user.setRegisterTime(new Date()); user.setUpdateTime(new Date()); try { JpaDao.save(user); } catch (MyException e) { e.printStackTrace(); } logger.info("*********** end testing to create user ******************"); } @Test @Transactional public void testUpdate() { logger.info("*********** begin testing to update user *****************"); String user_id = "ff80808143aaecf70143aaed02ca0002"; User user = null; try { user = (User) JpaDao.findById(User.class, user_id); Date now = new Date(); user.setBirthday(now); try { JpaDao.update(user); } catch (MyException e) { e.printStackTrace(); } Assert.assertEquals(now, ((User) JpaDao.findById(User.class, user_id)).getBirthday()); logger.info("*********** end testing to update user *****************"); } catch (MyException e1) { e1.printStackTrace(); } } @Test @Transactional public void testDeleteByIds() { logger.info("*********** begin testing to delete user by id *****************"); String user_id = "402881e6440b6d2a01440b6d370e0004"; try { JpaDao.deleteById(User.class, user_id); try { User user = (User) JpaDao.findById(User.class, user_id); Assert.assertNull(user); logger.info("*********** end testing to delete user by id *****************"); } catch (MyException e) { e.printStackTrace(); } } catch (MyException e1) { e1.printStackTrace(); } } @Test @Transactional public void testDeleteByCriteria() { logger.info("*********** begin testing to delete user by criteria with none pages *****************"); String jpql = "from User u where u.username=? and u.password=?"; Object[] queryParams = { "Alex05", "123456" }; try { JpaDao.deleteFromCriteria(jpql, queryParams); List<?> userList = JpaDao.getResultData(-1, -1, jpql, queryParams); Assert.assertEquals(0, userList.size()); logger.info("*********** end testing to delete user by criteria with none pages *****************"); } catch (MyException e) { e.printStackTrace(); } } @Test public void testFindById() { logger.info("*********** begin testing to find user by id *****************"); String user_id = "402881e6440b6a0901440b6a11e30002"; try { User user = (User) JpaDao.findById(User.class, user_id); Assert.assertNotNull(user); logger.info("*********** end testing to find user by id *****************"); } catch (MyException e) { e.printStackTrace(); } } @Test public void testCount() { logger.info("*********** begin testing to count user record rows *****************"); String jql = "select count(id) from User"; long rows = JpaDao.getCount(jql, null); Assert.assertEquals(5, rows); logger.info("*********** end testing to count user record rows *****************"); } @Test public void testGetResultData() { logger.info("*********** begin testing to get result for user with criteria order by username *****************"); Object[] queryParam = { "Alex" }; try { List<?> list = JpaDao.getResultData(1, 5, "from User u where u.username=? order by u.username asc", queryParam); Assert.assertEquals(1, list.size()); logger.info("*********** end testing to get result for user with criteria order by username *****************"); } catch (MyException e) { e.printStackTrace(); } } @Test public void testFindByNativeSQL() { logger.info("*********** begin testing to get result for user with native sql order by username *****************"); String sql = "select * from tb_user where user_password=? order by user_login_name desc"; Object[] queryParams = { "123456" }; List<?> list = JpaDao.findByNativeQuery(1, 5, sql, queryParams); Assert.assertEquals(3, list.size()); logger.info("*********** end testing to get result for user with native sql order by username *****************"); } @Test public void testGetResultByClass() { logger.info("*********** begin testing to get result for user using Class *****************"); List<?> list = JpaDao.getResultData(User.class); Assert.assertEquals(3, list.size()); logger.info("*********** end testing to get result for user using Class *****************"); } }
zzyyp
trunk/zp/src/com/zp/framework/jpa/test/RunJPA.java
Java
asf20
6,083
package com.zp.framework.jpa; import java.util.List; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import javax.persistence.PersistenceException; import javax.persistence.Query; import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.Root; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import com.zp.util.Constant; import com.zp.util.MyException; /** * implement the JPA DAO interface * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/2/6 * */ public class JpaDao implements IJpaDao { private static final Log logger = LogFactory.getLog(JpaDao.class); @PersistenceContext private EntityManager entityManager; @Override public void clear() throws MyException { try { entityManager.clear(); logger.info("Flush cache sucssfully"); } catch (Exception e) { logger.error("Flush cache failed"); throw new MyException(e.getMessage()); } } @Override public void save(Object entity) throws MyException { try { entityManager.persist(entity); logger.info("Save object sucssfully"); } catch (Exception e) { logger.error("Save object failed"); throw new MyException(e.getMessage()); } } @Override public Object update(Object entity) throws MyException { Object result = Constant.OBJECT_NULL; try { result = entityManager.merge(entity); logger.info("Update object sucssfully"); } catch (Exception e) { logger.error("Update object failed"); throw new MyException(e.getMessage()); } return result; } @Override public void deleteObject(Object entity) throws MyException { try { entityManager.remove(entity); logger.info("Delete object sucssfully"); } catch (Exception e) { logger.error("Delete object failed"); throw new MyException(e.getMessage()); } } @Override public void deleteById(Class<?> entityClass, Object id) throws MyException { Object obj = this.findById(entityClass, id); if (obj != Constant.OBJECT_NULL) { this.deleteObject(obj); } } @Override public void deleteFromCriteria(String jpql, Object[] queryParams) throws MyException { List<?> list = this.getScrollData(Constant.NEGATIVE_ONE, Constant.NEGATIVE_ONE, jpql, queryParams); for (Object object : list) { this.deleteObject(object); } } @Override public Object findById(Class<?> entityClass, Object id) throws MyException { Object result = Constant.OBJECT_NULL; try { result = entityManager.find(entityClass, id); logger.info("Object is found from:" + entityClass + " with " + id); } catch (Exception e) { logger.error("Object is not exits from:" + entityClass + " with " + id); throw new MyException(e.getMessage()); } return result; } /** * get all the data records with entity class * * @param entityClass * * @return List<?> * * @exception PersistenceException */ @SuppressWarnings({ "rawtypes", "unchecked" }) @Override public List<?> getResultData(final Class<?> entityClass) throws PersistenceException { List<?> resultList = Constant.LIST_NULL; try { CriteriaBuilder cb = entityManager.getCriteriaBuilder(); CriteriaQuery<?> criteria = cb.createQuery(entityClass); Root root = criteria.from(entityClass); criteria.select(root).distinct(true); resultList = entityManager.createQuery(criteria).getResultList(); logger.info("Get data with class,result is:" + resultList.toArray().toString()); } catch (PersistenceException pe) { logger.error("Get data with class:get data failed please see below information"); throw new PersistenceException(pe.getMessage()); } return resultList; } @Override @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true) public List<?> getResultData(int pageNo, int pageSize, String jpql, Object[] queryParams) throws MyException { return this.getScrollData(pageNo, pageSize, jpql, queryParams); } /** * get count data with id JPQL like "select id from User where ...." * * @param jpql * * @param queryParams * * @return the count of result data * * @exception PersistenceException */ @Override public long getCount(final String jpql, final Object[] queryParams) throws PersistenceException { logger.info("Get count with Jpql:" + jpql); Object rawCount = Constant.ZERO; try { Query query = entityManager.createQuery(jpql); setQueryParams(query, queryParams); rawCount = query.getSingleResult(); } catch (PersistenceException pe) { logger.error("Get count with Jpql:get data rows failed,plese check below information"); throw new PersistenceException(pe.getMessage()); } return (Long) rawCount; } /** * get result from native SQL * * @param pageNo * the page index * * @param pageSize * how many rows you want to fetch for one page * * @param sql * * @param queryParams * * @return List<?> * * @exception PersistenceException */ @Override public List<?> findByNativeQuery(final int pageNo, final int pageSize, final String sql, final Object[] queryParams) throws PersistenceException { logger.info("Get data with native SQL:" + sql); List<?> resultList = Constant.LIST_NULL; try { Query query = entityManager.createNativeQuery(sql); setQueryParams(query, queryParams); if (pageNo != Constant.NEGATIVE_ONE && pageSize != Constant.NEGATIVE_ONE) { query.setFirstResult((pageNo - Constant.ONE) * pageSize) .setMaxResults(pageSize); query.setHint("org.hibernate.cacheable", true); } else { logger.info("Get data with native SQL:page is not used pageNo is " + pageNo + " pageSize is " + pageSize); } resultList = query.getResultList(); } catch (PersistenceException pe) { logger.error("Get data with native SQL:get result data failed with native sql,please check below information"); throw new PersistenceException(pe.getMessage()); } return resultList; } /** * get result from JPQL * * @param pageNo * the page index * * @param pageSize * how many rows you want to fetch for one page * * @param jpql * * @param queryParams * * @return List<?> * * @exception PersistenceException */ protected List<?> getScrollData(final int pageNo, final int pageSize, final String jpql, final Object[] queryParams) throws PersistenceException { logger.info("Get scrollData with Jpql:" + jpql); List<?> resultData = Constant.LIST_NULL; try { Query query = entityManager.createQuery(jpql); setQueryParams(query, queryParams); if (pageNo != Constant.NEGATIVE_ONE && pageSize != Constant.NEGATIVE_ONE) { query.setFirstResult((pageNo - Constant.ONE) * pageSize) .setMaxResults(pageSize); query.setHint("org.hibernate.cacheable", true); } else { logger.info("Get scrollData with Jpql:page is not used, pageNo is " + pageNo + " pageSize is " + pageSize); } resultData = query.getResultList(); } catch (PersistenceException pe) { logger.error("Get scrollData with Jpql:get data failed,please see below information"); throw new PersistenceException(pe.getMessage()); } return resultData; } /** * set the parameter to SQL dynamicly * * @param query * * @param queryParams * */ protected void setQueryParams(Query query, Object[] queryParams) { if (queryParams != Constant.OBJECT_NULL && queryParams.length > Constant.ZERO) { for (int i = Constant.ZERO; i < queryParams.length; i++) { query.setParameter(i + Constant.ONE, queryParams[i]); } } } // public static IJpaDao getFromApplicationContext(ApplicationContext ctx) { // return (IJpaDao) ctx.getBean("jpaDao"); // } }
zzyyp
trunk/zp/src/com/zp/framework/jpa/JpaDao.java
Java
asf20
8,259
package com.zp.framework.jpa; import java.util.List; import com.zp.util.MyException; /** * define JPA interface for entity data operation * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/2/1 * */ public interface IJpaDao { public void clear() throws MyException; public void save(Object entity) throws MyException; public Object update(Object entity) throws MyException; public void deleteObject(Object entity) throws MyException; public void deleteById(Class<?> entityClass, Object id)throws MyException; public void deleteFromCriteria(String jpql, Object[] queryParam)throws MyException; public Object findById(Class<?> entityClass, Object id) throws MyException; public List<?> getResultData(Class<?> entityClass); public List<?> getResultData(final int pageNo, final int pageSize,final String jpql, final Object[] queryParams) throws MyException; public long getCount(final String jpql, final Object[] queryParams); public List<?> findByNativeQuery(final int pageNo, final int pageSize,final String sql, final Object[] queryParams); }
zzyyp
trunk/zp/src/com/zp/framework/jpa/IJpaDao.java
Java
asf20
1,132
package com.zp.framework.services.test; import javax.ws.rs.core.MediaType; import junit.framework.Assert; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.UniformInterfaceException; import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.config.ClientConfig; import com.sun.jersey.api.client.config.DefaultClientConfig; import com.zp.bean.common.ResultCommonVo; import com.zp.bean.psychological.ResultBaseServiceVo; import com.zp.bean.psychological.ResultServiceVo; import com.zp.domain.Service; import com.zp.util.Constant; /** * test Service services function with Junit * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/3/8 * */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:configure/applicationContext.xml" }) public class RunServiceServices { private static final Log logger = LogFactory .getLog(RunServiceServices.class); private static final String URI = "http://localhost:8082/ZP/rest/"; private WebResource service; @Before public void init() { ClientConfig config = new DefaultClientConfig(); Client client = Client.create(config); service = client.resource(URI); logger.info("*********** testing to initial services client ****************"); } @After public void destory() { service = null; logger.info("*********** testing to destory services instance ******************"); } @Test public void testAddService() { try { Service s = new Service(); s.setContent("cessfs"); s.setDuration(1); s.setIntroduce("sfsdfsdfsd"); s.setOrganization("4028810844c8ebd90144c95b6127005f"); s.setTitle("cessfs"); ClientResponse response = service.path("service/addService") .type(MediaType.APPLICATION_JSON_TYPE) .post(ClientResponse.class, s); ResultCommonVo result = response.getEntity(ResultCommonVo.class); Assert.assertEquals(Constant.OK, result.getMessage()); } catch (UniformInterfaceException e) { System.out.println(e.getResponse().getStatus()); if (e.getResponse().getStatus() == 404) { } else if (e.getResponse().getStatus() == 401) { throw new IllegalStateException(e); } else if (e.getResponse().getStatus() == 403) { throw new IllegalStateException(e); } else { throw e; } } } /**@Test**/ public void testGetServiceById() { ClientResponse response = service.path("service/getService") .queryParam("serviceId", "402881e544a211e70144a2126c3a0001") .post(ClientResponse.class); ResultServiceVo result = response.getEntity(ResultServiceVo.class); Assert.assertNotNull(result.getVo()); } /**@Test**/ public void testGetServices() { ClientResponse response = service.path("service/getServices") .queryParam("pageNo", "1").queryParam("pageSize", "2") .post(ClientResponse.class); ResultBaseServiceVo result = response .getEntity(ResultBaseServiceVo.class); Assert.assertEquals(1, result.getTotalCount()); } }
zzyyp
trunk/zp/src/com/zp/framework/services/test/RunServiceServices.java
Java
asf20
3,462
package com.zp.framework.services.test; import javax.ws.rs.core.MediaType; import junit.framework.Assert; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.UniformInterfaceException; import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.config.ClientConfig; import com.sun.jersey.api.client.config.DefaultClientConfig; import com.zp.bean.common.ResultCommonVo; import com.zp.bean.common.ResultContentTypeVo; import com.zp.domain.ModuleType; import com.zp.util.Constant; /** * test module type services function with Junit * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/3/12 * */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:configure/applicationContext.xml" }) public class RunModuleTypeServices { private static final Log logger = LogFactory .getLog(RunModuleTypeServices.class); private static final String URI = "http://localhost:8082/ZP/rest/"; private WebResource service; @Before public void init() { ClientConfig config = new DefaultClientConfig(); Client client = Client.create(config); service = client.resource(URI); logger.info("*********** testing to initial services client ****************"); } @After public void destory() { service = null; logger.info("*********** testing to destory services instance ******************"); } @Test public void testAddType() { try { ModuleType type = new ModuleType(); type.setName("创业指导"); type.setCode("mo05"); type.setParentCode("mo"); ClientResponse response = service.path("mtype/addType") .type(MediaType.APPLICATION_JSON_TYPE) .post(ClientResponse.class, type); ResultCommonVo result = response.getEntity(ResultCommonVo.class); Assert.assertEquals(Constant.OK, result.getMessage()); } catch (UniformInterfaceException e) { System.out.println(e.getResponse().getStatus()); if (e.getResponse().getStatus() == 404) { } else if (e.getResponse().getStatus() == 401) { throw new IllegalStateException(e); } else if (e.getResponse().getStatus() == 403) { throw new IllegalStateException(e); } else { throw e; } } } /** @Test **/ public void testfindTypeById() { String id = "402881e844b6bda90144b6c07fe60004"; ClientResponse response = service.path("mtype/getType") .queryParam("typeId", id).post(ClientResponse.class); ResultContentTypeVo result = response .getEntity(ResultContentTypeVo.class); Assert.assertNotNull(result.getType()); } /**@Test**/ public void testUpdateType() { ModuleType t = new ModuleType(); t.setId("402881e844b6bda90144b6bf20280001"); t.setName("模块管理"); t.setCode("mo"); ClientResponse response = service.path("mtype/updateType") .type(MediaType.APPLICATION_JSON_TYPE) .put(ClientResponse.class, t); Assert.assertEquals(Constant.OK, response.getEntity(ResultCommonVo.class).getMessage()); } /** @Test **/ public void testDeleteType() { ClientResponse response = service.path("mtype/deleteType") .queryParam("typeId", "402881e844b6a7d30144b6ab12370001") .delete(ClientResponse.class); Assert.assertEquals(Constant.OK, response.getEntity(ResultCommonVo.class).getMessage()); } /** @Test **/ public void testGetTypeByCritera() { ClientResponse response = service.path("mtype/getTypes") .queryParam("pageNo", "1").queryParam("pageSize", "10") .queryParam("codeName", "mo01") .type(MediaType.APPLICATION_JSON_TYPE) .post(ClientResponse.class); ResultContentTypeVo result = response .getEntity(ResultContentTypeVo.class); Assert.assertEquals(1, result.getTotalCount()); } }
zzyyp
trunk/zp/src/com/zp/framework/services/test/RunModuleTypeServices.java
Java
asf20
4,193
package com.zp.framework.services.test; import java.util.Date; import javax.ws.rs.core.MediaType; import junit.framework.Assert; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.UniformInterfaceException; import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.config.ClientConfig; import com.sun.jersey.api.client.config.DefaultClientConfig; import com.zp.bean.common.ResultCommonVo; import com.zp.bean.common.ResultOperationLogVo; import com.zp.domain.OperationLog; import com.zp.util.Constant; /** * test role services function with Junit * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/2/16 * */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:configure/applicationContext.xml" }) public class RunOperationLogServices { private static final Log logger = LogFactory .getLog(RunOperationLogServices.class); private static final String URI = "http://localhost:8082/ZP"; private WebResource service; @Before public void init() { ClientConfig config = new DefaultClientConfig(); Client client = Client.create(config); service = client.resource(URI); logger.info("*********** testing to initial services client ****************"); } @After public void destory() { service = null; logger.info("*********** testing to destory services instance ******************"); } /**@Test**/ public void testAddLog() { try { OperationLog operationLog = new OperationLog(); operationLog.setLogTime(new Date()); operationLog.setTypeCode("D00001"); operationLog.setUserId("402881e64459ad0e014459adc3b00001"); ClientResponse response = service.path("/operationLog/addLog") .type(MediaType.APPLICATION_JSON_TYPE) .post(ClientResponse.class, operationLog); Assert.assertEquals(Constant.OK, response.getEntity(ResultCommonVo.class).getMessage()); } catch (UniformInterfaceException e) { System.out.println(e.getResponse().getStatus()); if (e.getResponse().getStatus() == 404) { } else if (e.getResponse().getStatus() == 401) { throw new IllegalStateException(e); } else if (e.getResponse().getStatus() == 403) { throw new IllegalStateException(e); } else { throw e; } } } @Test public void testSearchRole() { ClientResponse response = service.path("/operationLog/getLogs") .queryParam("pageNo", "1").queryParam("pageSize", "2") .type(MediaType.APPLICATION_JSON_TYPE) .get(ClientResponse.class); Assert.assertEquals(2, response.getEntity(ResultOperationLogVo.class) .getTotalCount()); } }
zzyyp
trunk/zp/src/com/zp/framework/services/test/RunOperationLogServices.java
Java
asf20
3,092
package com.zp.framework.services.test; import javax.ws.rs.core.MediaType; import junit.framework.Assert; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.UniformInterfaceException; import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.config.ClientConfig; import com.sun.jersey.api.client.config.DefaultClientConfig; import com.zp.bean.common.ResultCommonVo; import com.zp.bean.paper.ResultAnswerItemVo; import com.zp.domain.AnswerItem; import com.zp.util.Constant; /** * test AnswerItem services function with Junit * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/2/23 * */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:configure/applicationContext.xml" }) public class RunAnswerItemServices { private static final Log logger = LogFactory .getLog(RunAnswerItemServices.class); private static final String URI = "http://localhost:8082/ZP"; private WebResource service; @Before public void init() { ClientConfig config = new DefaultClientConfig(); Client client = Client.create(config); service = client.resource(URI); logger.info("*********** testing to initial services client ****************"); } @After public void destory() { service = null; logger.info("*********** testing to destory services instance ******************"); } /**@Test**/ public void testAddAnswerItem() { try { AnswerItem aitem = new AnswerItem(); aitem.setAnswerCode("D"); aitem.setQuestionId("402881e6445cc3a301445cc4e73b0003"); aitem.setValue("心理关爱题目3答案4"); ClientResponse response = service.path("aitem/addItem") .type(MediaType.APPLICATION_JSON_TYPE) .post(ClientResponse.class, aitem); ResultCommonVo result=response.getEntity(ResultCommonVo.class); Assert.assertEquals(Constant.OK, result.getMessage()); } catch (UniformInterfaceException e) { System.out.println(e.getResponse().getStatus()); if (e.getResponse().getStatus() == 404) { } else if (e.getResponse().getStatus() == 401) { throw new IllegalStateException(e); } else if (e.getResponse().getStatus() == 403) { throw new IllegalStateException(e); } else { throw e; } } } /**@Test**/ public void testfindAnswerItemById() { String id = "402881e6445d4c3701445d515f8e0002"; ClientResponse response = service.path("aitem/getItem") .queryParam("itemId", id).get(ClientResponse.class); ResultAnswerItemVo result = response.getEntity(ResultAnswerItemVo.class); Assert.assertNotNull(result.getVo()); } /**@Test**/ public void testUpdateAnswerItem() { AnswerItem t = new AnswerItem(); t.setId("402881e6445d4c3701445d515f8e0002"); t.setAnswerCode("A"); t.setQuestionId("402881e6445cc3a301445cc4332b0001"); t.setValue("心理关爱题目1答案1"); ClientResponse response = service.path("aitem/updateItem") .type(MediaType.APPLICATION_JSON_TYPE).put(ClientResponse.class, t); Assert.assertNotNull(response.getEntity(ResultAnswerItemVo.class)); } /**@Test**/ public void testDeleteAnswerItem() { ClientResponse response = service.path("aitem/deleteItem") .queryParam("aitemId", "402881e6445c883e01445c8a74290001") .delete(ClientResponse.class); Assert.assertEquals(Constant.OK, response.getEntity(ResultCommonVo.class).getMessage()); } @Test public void testGetAnswerItemByCritera() { ClientResponse response = service.path("aitem/getItems") .queryParam("pageNo", "1").queryParam("pageSize", "2").queryParam("value", "心理关爱题目1答案1").type(MediaType.APPLICATION_JSON_TYPE).get(ClientResponse.class); ResultAnswerItemVo result=response.getEntity(ResultAnswerItemVo.class); Assert.assertEquals(1, result.getTotalCount()); } }
zzyyp
trunk/zp/src/com/zp/framework/services/test/RunAnswerItemServices.java
Java
asf20
4,277
package com.zp.framework.services.test; import javax.ws.rs.core.MediaType; import junit.framework.Assert; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.UniformInterfaceException; import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.config.ClientConfig; import com.sun.jersey.api.client.config.DefaultClientConfig; import com.zp.bean.common.ResultCommonVo; import com.zp.bean.common.ResultTypeVo; import com.zp.domain.Type; import com.zp.util.Constant; /** * test Type services function with Junit * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/2/9 * */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:configure/applicationContext.xml" }) public class RunTypeServices { private static final Log logger = LogFactory .getLog(RunTypeServices.class); private static final String URI = "http://localhost:8082/ZP/rest/"; private WebResource service; @Before public void init() { ClientConfig config = new DefaultClientConfig(); Client client = Client.create(config); service = client.resource(URI); logger.info("*********** testing to initial services client ****************"); } @After public void destory() { service = null; logger.info("*********** testing to destory services instance ******************"); } @Test public void testAddType() { try { Type type = new Type(); type.setName("四川-成都"); type.setCode("028"); type.setParentCode("0000"); ClientResponse response = service.path("type/addType") .type(MediaType.APPLICATION_JSON_TYPE) .post(ClientResponse.class, type); ResultCommonVo result=response.getEntity(ResultCommonVo.class); Assert.assertEquals(Constant.OK, result.getMessage()); } catch (UniformInterfaceException e) { System.out.println(e.getResponse().getStatus()); if (e.getResponse().getStatus() == 404) { } else if (e.getResponse().getStatus() == 401) { throw new IllegalStateException(e); } else if (e.getResponse().getStatus() == 403) { throw new IllegalStateException(e); } else { throw e; } } } /**@Test**/ public void testfindTypeById() { String id = "402881e64458c50c014458c5a56d0001"; ClientResponse response = service.path("type/getType") .queryParam("typeId", id).get(ClientResponse.class); ResultTypeVo result = response.getEntity(ResultTypeVo.class); Assert.assertNotNull(result.getType()); } /**@Test**/ public void testUpdateType() { Type t = new Type(); t.setId("402881e6441246a101441248aa0f0001"); t.setName("修改成功"); t.setCode("C00000001"); t.setParentCode("C00000002"); ClientResponse response = service.path("type/updateType") .type(MediaType.APPLICATION_JSON_TYPE).put(ClientResponse.class, t); Assert.assertEquals(Constant.OK, response.getEntity(ResultCommonVo.class).getMessage()); } /**@Test**/ public void testDeleteType() { ClientResponse response = service.path("type/deleteType") .queryParam("typeId", "402881e6441246a101441248aa0f0001") .delete(ClientResponse.class); Assert.assertEquals(Constant.OK, response.getEntity(ResultCommonVo.class).getMessage()); } /**@Test**/ public void testGetTypeByCritera() { ClientResponse response = service.path("type/getTypes") .queryParam("pageNo", "1").queryParam("pageSize", "10").queryParam("codeName", "C000001").type(MediaType.APPLICATION_JSON_TYPE).get(ClientResponse.class); ResultTypeVo result=response.getEntity(ResultTypeVo.class); Assert.assertEquals(1, result.getTotalCount()); } }
zzyyp
trunk/zp/src/com/zp/framework/services/test/RunTypeServices.java
Java
asf20
4,093
package com.zp.framework.services.test; import javax.ws.rs.core.MediaType; import junit.framework.Assert; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.codehaus.jettison.json.JSONException; import org.codehaus.jettison.json.JSONObject; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.UniformInterfaceException; import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.config.ClientConfig; import com.sun.jersey.api.client.config.DefaultClientConfig; import com.zp.bean.common.ResultCommonVo; import com.zp.bean.user.ResultLoginVo; import com.zp.bean.user.ResultRoleVo; import com.zp.bean.user.ResultUserVo; import com.zp.util.Constant; import com.zp.util.MD5Util; /** * test Type services function with Junit * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/2/9 * */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:configure/applicationContext.xml" }) public class RunUserServices { private static final Log logger = LogFactory.getLog(RunUserServices.class); private static final String URI = "http://localhost:8082/ZP/rest/"; private WebResource service; @Before public void init() { ClientConfig config = new DefaultClientConfig(); Client client = Client.create(config); service = client.resource(URI); logger.info("*********** testing to initial services client ****************"); } @After public void destory() { service = null; logger.info("*********** testing to destory services instance ******************"); } @Test public void testRegisterUser() { try { JSONObject register = new JSONObject(); try { register.put("username", "小菲"); register.put("password", "123456"); } catch (JSONException e) { e.printStackTrace(); } ClientResponse response = service.path("user/registerUser") .queryParam("jsonContext", register.toString()) .type(MediaType.APPLICATION_JSON_TYPE) .post(ClientResponse.class); Assert.assertEquals(Constant.OK, response.getEntity(ResultCommonVo.class).getMessage()); } catch (UniformInterfaceException e) { System.out.println(e.getResponse().getStatus()); if (e.getResponse().getStatus() == 404) { } else if (e.getResponse().getStatus() == 401) { throw new IllegalStateException(e); } else if (e.getResponse().getStatus() == 403) { throw new IllegalStateException(e); } else { throw e; } } } /** @Test **/ public void testfindUserById() { String id = "402881e64459ad0e014459adc3b00001"; ClientResponse response = service.path("user/getUser") .queryParam("userId", id).get(ClientResponse.class); Assert.assertEquals("Alex", response.getEntity(ResultUserVo.class) .getUserInfo().getLogin().getUsername()); } /** @Test **/ public void testUpdatePassword() { JSONObject o = new JSONObject(); try { o.put("userId", "402881e64459ad0e014459adc3b00001"); o.put("orginalPassword", MD5Util.MD5password("123456")); o.put("newPassword", MD5Util.MD5password("2345678")); ClientResponse response = service.path("user/updatePass") .queryParam("updatePass", o.toString()) .type(MediaType.APPLICATION_JSON_TYPE) .get(ClientResponse.class); Assert.assertEquals(Constant.OK, response.getEntity(ResultCommonVo.class).getMessage()); } catch (JSONException e) { e.printStackTrace(); } } /** @Test **/ public void testGetUsersByCriteria() { ClientResponse response = service.path("user/getUsers") .queryParam("pageNo", "1").queryParam("pageSize", "5") .type(MediaType.APPLICATION_JSON_TYPE) .get(ClientResponse.class); ResultUserVo result = response.getEntity(ResultUserVo.class); Assert.assertEquals(4, result.getTotalCount()); } /** @Test **/ public void testGetUserRole() { ClientResponse response = service.path("user/getUserRole") .queryParam("userId", "402881e64459ad0e014459adc3b0001") .type(MediaType.APPLICATION_JSON_TYPE) .post(ClientResponse.class); ResultRoleVo result = response.getEntity(ResultRoleVo.class); Assert.assertEquals(1, result.getTotalCount()); } /**@Test**/ public void testLogin(){ ClientResponse response = service.path("user/login") .queryParam("loginName", "HHHHHH").queryParam("loginPass", "DDDDDDDD").queryParam("sysName", "") .type(MediaType.APPLICATION_JSON_TYPE) .post(ClientResponse.class); ResultLoginVo result = response.getEntity(ResultLoginVo.class); logger.info(result.getLogin().getId()); Assert.assertEquals(0, result.getTotalCount()); } }
zzyyp
trunk/zp/src/com/zp/framework/services/test/RunUserServices.java
Java
asf20
5,074
package com.zp.framework.services.test; import javax.ws.rs.core.MediaType; import junit.framework.Assert; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.UniformInterfaceException; import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.config.ClientConfig; import com.sun.jersey.api.client.config.DefaultClientConfig; import com.zp.bean.common.ResultCommonVo; import com.zp.bean.paper.ResultAnswerResultVo; import com.zp.bean.paper.ResultPaperVo; import com.zp.domain.AnswerResult; import com.zp.util.Constant; /** * test Answer result services function with Junit * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/2/23 * */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:configure/applicationContext.xml" }) public class RunAnswerResultServices { private static final Log logger = LogFactory .getLog(RunAnswerResultServices.class); private static final String URI = "http://localhost:8082/ZP"; private WebResource service; @Before public void init() { ClientConfig config = new DefaultClientConfig(); Client client = Client.create(config); service = client.resource(URI); logger.info("*********** testing to initial services client ****************"); } @After public void destory() { service = null; logger.info("*********** testing to destory services instance ******************"); } /** @Test **/ public void testAddAnswerResult() { try { AnswerResult anresult = new AnswerResult(); anresult.setPaperId("402881e6445c883e01445c8a74290001"); anresult.setQuestionId("402881e6445cc3a301445cc4e73b0003"); anresult.setAnswerItemId("402881e6445d53b401445d584d7c000b"); anresult.setAuthor("402881e64459ad0e014459adc3b00001"); anresult.setStatus("1"); ClientResponse response = service.path("anresult/addAnResult") .type(MediaType.APPLICATION_JSON_TYPE) .post(ClientResponse.class, anresult); ResultCommonVo result = response.getEntity(ResultCommonVo.class); Assert.assertEquals(Constant.OK, result.getMessage()); } catch (UniformInterfaceException e) { System.out.println(e.getResponse().getStatus()); if (e.getResponse().getStatus() == 404) { } else if (e.getResponse().getStatus() == 401) { throw new IllegalStateException(e); } else if (e.getResponse().getStatus() == 403) { throw new IllegalStateException(e); } else { throw e; } } } /** @Test **/ public void testUpdateAnResult() { AnswerResult anresult = new AnswerResult(); ClientResponse response = service.path("anresult/updateAnResult") .type(MediaType.APPLICATION_JSON_TYPE) .put(ClientResponse.class, anresult); Assert.assertNotNull(response.getEntity(ResultCommonVo.class)); } /** @Test **/ public void testGetPapersForUser() { ClientResponse response = service.path("anresult/getPapersForUser") .queryParam("pageNo", "1").queryParam("pageSize", "2") .queryParam("userId", "402881e64459ad0e014459adc3b00001") .type(MediaType.APPLICATION_JSON_TYPE) .get(ClientResponse.class); ResultPaperVo result = response.getEntity(ResultPaperVo.class); Assert.assertEquals(1, result.getTotalCount()); } /** @Test **/ public void testGetResultsForUser() { ClientResponse response = service.path("anresult/getResultsForUser") .queryParam("pageNo", "1").queryParam("pageSize", "2") .queryParam("userId", "402881e64459ad0e014459adc3b00001") .queryParam("paperId", "402881e6445c883e01445c8a74290001") .type(MediaType.APPLICATION_JSON_TYPE) .get(ClientResponse.class); ResultAnswerResultVo result = response .getEntity(ResultAnswerResultVo.class); Assert.assertEquals(3, result.getTotalCount()); } @Test public void testGetScore() { ClientResponse response = service.path("anresult/getScore") .queryParam("userId", "402881e64459ad0e014459adc3b00001") .queryParam("paperId", "402881e6445c883e01445c8a74290001") .type(MediaType.APPLICATION_JSON_TYPE) .get(ClientResponse.class); Assert.assertEquals("66",response.getEntity(ResultCommonVo.class).getMessage()); } }
zzyyp
trunk/zp/src/com/zp/framework/services/test/RunAnswerResultServices.java
Java
asf20
4,644
package com.zp.framework.services.test; import javax.ws.rs.core.MediaType; import junit.framework.Assert; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.UniformInterfaceException; import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.config.ClientConfig; import com.sun.jersey.api.client.config.DefaultClientConfig; import com.zp.bean.common.ResultCommonVo; import com.zp.bean.common.ResultContentTypeVo; import com.zp.domain.ContentType; import com.zp.util.Constant; /** * test ContentType services function with Junit * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/2/9 * */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:configure/applicationContext.xml" }) public class RunContentTypeServices { private static final Log logger = LogFactory .getLog(RunContentTypeServices.class); private static final String URI = "http://localhost:8082/ZP/rest/"; private WebResource service; @Before public void init() { ClientConfig config = new DefaultClientConfig(); Client client = Client.create(config); service = client.resource(URI); logger.info("*********** testing to initial services client ****************"); } @After public void destory() { service = null; logger.info("*********** testing to destory services instance ******************"); } /**@Test**/ public void testAddType() { try { ContentType type = new ContentType(); type.setName("测试"); type.setCode("cmX"); type.setParentCode("cm"); ClientResponse response = service.path("ctype/addType") .type(MediaType.APPLICATION_JSON_TYPE) .post(ClientResponse.class, type); ResultCommonVo result=response.getEntity(ResultCommonVo.class); Assert.assertEquals(Constant.OK, result.getMessage()); } catch (UniformInterfaceException e) { System.out.println(e.getResponse().getStatus()); if (e.getResponse().getStatus() == 404) { } else if (e.getResponse().getStatus() == 401) { throw new IllegalStateException(e); } else if (e.getResponse().getStatus() == 403) { throw new IllegalStateException(e); } else { throw e; } } } @Test public void testfindTypeById() { String id = "402881e744791cd2014479213e260005"; ClientResponse response = service.path("ctype/getType") .queryParam("typeId", id).post(ClientResponse.class); ResultContentTypeVo result = response.getEntity(ResultContentTypeVo.class); Assert.assertNotNull(result.getType()); } /**@Test**/ public void testUpdateType() { ContentType t = new ContentType(); t.setId("402881e844b6a7d30144b6ab12370001"); t.setName("修改成功"); t.setCode("C00000001"); ClientResponse response = service.path("ctype/updateType") .type(MediaType.APPLICATION_JSON_TYPE).put(ClientResponse.class, t); Assert.assertEquals(Constant.OK, response.getEntity(ResultCommonVo.class).getMessage()); } /**@Test**/ public void testDeleteType() { ClientResponse response = service.path("ctype/deleteType") .queryParam("typeId", "402881e844b6a7d30144b6ab12370001") .delete(ClientResponse.class); Assert.assertEquals(Constant.OK, response.getEntity(ResultCommonVo.class).getMessage()); } /**@Test**/ public void testGetTypeByCritera() { ClientResponse response = service.path("ctype/getTypes") .queryParam("pageNo", "1").queryParam("pageSize", "10").queryParam("codeName", "cm01").type(MediaType.APPLICATION_JSON_TYPE).post(ClientResponse.class); ResultContentTypeVo result=response.getEntity(ResultContentTypeVo.class); Assert.assertEquals(1, result.getTotalCount()); } }
zzyyp
trunk/zp/src/com/zp/framework/services/test/RunContentTypeServices.java
Java
asf20
4,146
package com.zp.framework.services.test; import javax.ws.rs.core.MediaType; import junit.framework.Assert; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.UniformInterfaceException; import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.config.ClientConfig; import com.sun.jersey.api.client.config.DefaultClientConfig; import com.zp.bean.common.ResultCommonVo; import com.zp.bean.paper.ResultPaperQuestionVo; import com.zp.domain.PaperQuestion; import com.zp.util.Constant; /** * test paper question services function with Junit * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/2/23 * */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:configure/applicationContext.xml" }) public class RunPaperQuestionServices { private static final Log logger = LogFactory .getLog(RunPaperQuestionServices.class); private static final String URI = "http://localhost:8082/ZP"; private WebResource service; @Before public void init() { ClientConfig config = new DefaultClientConfig(); Client client = Client.create(config); service = client.resource(URI); logger.info("*********** testing to initial services client ****************"); } @After public void destory() { service = null; logger.info("*********** testing to destory services instance ******************"); } /**@Test**/ public void testAddPaperQuestion() { try { PaperQuestion question = new PaperQuestion(); question.setPaperId("402881e6445c883e01445c8a74290001"); question.setQuestionId("402881e6445cc3a301445cc546660005"); question.setSerialNo(5); ClientResponse response = service.path("paperques/addPaperques") .type(MediaType.APPLICATION_JSON_TYPE) .post(ClientResponse.class, question); ResultCommonVo result=response.getEntity(ResultCommonVo.class); Assert.assertEquals(Constant.OK, result.getMessage()); } catch (UniformInterfaceException e) { System.out.println(e.getResponse().getStatus()); if (e.getResponse().getStatus() == 404) { } else if (e.getResponse().getStatus() == 401) { throw new IllegalStateException(e); } else if (e.getResponse().getStatus() == 403) { throw new IllegalStateException(e); } else { throw e; } } } /**@Test**/ public void testDeleteQuestions() { ClientResponse response = service.path("paperques/deletePaperques") .queryParam("paperId", "402881e6445c883e01445c8a74290001") .get(ClientResponse.class); Assert.assertEquals(Constant.OK, response.getEntity(ResultCommonVo.class).getMessage()); } @Test public void testGetQuestionsByPaper() { ClientResponse response = service.path("paperques/getQuestions") .queryParam("pageNo", "1").queryParam("pageSize", "5").queryParam("paperId", "402881e6445c883e01445c8a74290001").type(MediaType.APPLICATION_JSON_TYPE).get(ClientResponse.class); ResultPaperQuestionVo result=response.getEntity(ResultPaperQuestionVo.class); Assert.assertEquals(5, result.getTotalCount()); } }
zzyyp
trunk/zp/src/com/zp/framework/services/test/RunPaperQuestionServices.java
Java
asf20
3,532
package com.zp.framework.services.test; import javax.ws.rs.core.MediaType; import junit.framework.Assert; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.config.ClientConfig; import com.sun.jersey.api.client.config.DefaultClientConfig; import com.zp.bean.common.ResultContentBaseVo; import com.zp.bean.common.ResultContentVo; /** * test News services function with Junit * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/3/1 * */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:configure/applicationContext.xml" }) public class RunContentServices { private static final Log logger = LogFactory .getLog(RunContentServices.class); private static final String URI = "http://localhost:8082/ZP/rest"; private WebResource service; @Before public void init() { ClientConfig config = new DefaultClientConfig(); Client client = Client.create(config); service = client.resource(URI); logger.info("*********** testing to initial services client ****************"); } @After public void destory() { service = null; logger.info("*********** testing to destory services instance ******************"); } /**@Test**/ public void testfindNewsById() { ClientResponse response = service.path("news/getNews") .queryParam("newsId", "3").post(ClientResponse.class); ResultContentVo result = response.getEntity(ResultContentVo.class); Assert.assertNotNull(result.getContent()); } @Test public void testSearchNewsByType() { ClientResponse response = service.path("news/searchNews") .queryParam("pageNo", "1").queryParam("pageSize", "10").queryParam("value", "cm02").queryParam("top", "1").type(MediaType.APPLICATION_JSON_TYPE).post(ClientResponse.class); ResultContentBaseVo result=response.getEntity(ResultContentBaseVo.class); Assert.assertEquals(3, result.getTotalCount()); } /**@Test**/ public void testSearchTopNews() { ClientResponse response = service.path("news/searchTopNews") .queryParam("number", "3").queryParam("typeCode", "cm04").post(ClientResponse.class); ResultContentBaseVo result=response.getEntity(ResultContentBaseVo.class); Assert.assertEquals(3, result.getTotalCount()); } }
zzyyp
trunk/zp/src/com/zp/framework/services/test/RunContentServices.java
Java
asf20
2,743
package com.zp.framework.services.test; import javax.ws.rs.core.MediaType; import junit.framework.Assert; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.UniformInterfaceException; import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.config.ClientConfig; import com.sun.jersey.api.client.config.DefaultClientConfig; import com.zp.bean.common.ResultCommonVo; import com.zp.bean.user.ResultPermissionVo; import com.zp.bean.user.ResultRoleVo; import com.zp.domain.Role; import com.zp.domain.RolePermission; import com.zp.util.Constant; /** * test role services function with Junit * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/2/16 * */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:configure/applicationContext.xml" }) public class RunRoleServices { private static final Log logger = LogFactory.getLog(RunRoleServices.class); private static final String URI = "http://localhost:8082/ZP"; private WebResource service; @Before public void init() { ClientConfig config = new DefaultClientConfig(); Client client = Client.create(config); service = client.resource(URI); logger.info("*********** testing to initial services client ****************"); } @After public void destory() { service = null; logger.info("*********** testing to destory services instance ******************"); } /** @Test **/ public void testAddRole() { try { Role r = new Role(); r.setName("管理人员"); r.setCode("M00001"); r.setStatus("1"); ClientResponse response = service.path("/role/addRole") .type(MediaType.APPLICATION_JSON_TYPE) .post(ClientResponse.class, r); Assert.assertEquals(Constant.OK, response.getEntity(ResultCommonVo.class).getMessage()); } catch (UniformInterfaceException e) { System.out.println(e.getResponse().getStatus()); if (e.getResponse().getStatus() == 404) { } else if (e.getResponse().getStatus() == 401) { throw new IllegalStateException(e); } else if (e.getResponse().getStatus() == 403) { throw new IllegalStateException(e); } else { throw e; } } } /** @Test **/ public void testFindRoleById() { ClientResponse response = service.path("/role/getRole") .queryParam("roleId", "402881e64458d2bb014458efead00011") .type(MediaType.APPLICATION_JSON_TYPE) .get(ClientResponse.class); Assert.assertNotNull(response.getEntity(ResultRoleVo.class)); } /** @Test **/ public void testSearchRole() { ClientResponse response = service.path("/role/searchRole") .queryParam("pageNo", "1").queryParam("pageSize", "5") .type(MediaType.APPLICATION_JSON_TYPE) .get(ClientResponse.class); ResultRoleVo result = response.getEntity(ResultRoleVo.class); Assert.assertEquals(1, result.getTotalCount()); } /** @Test **/ public void testAssignPermissionToRole() { RolePermission rp = new RolePermission(); rp.setPermissionCode("P00009"); rp.setPermissionId("402881e6445916b401445926e7ff000a"); rp.setRoleCode("M00001"); rp.setRoleId("402881e64458d2bb014458f0c8920013"); ClientResponse response = service.path("/role/assignPermission") .type(MediaType.APPLICATION_JSON_TYPE) .post(ClientResponse.class, rp); ResultCommonVo result = response.getEntity(ResultCommonVo.class); Assert.assertEquals(Constant.OK, result.getMessage()); } @Test public void testGetPermissionFromRoleId() { ClientResponse response = service.path("/role/getPerFromRoleId") .queryParam("roleId", "402881e64458d2bb014458f0c8920013") .type(MediaType.APPLICATION_JSON_TYPE) .get(ClientResponse.class); ResultPermissionVo result = response .getEntity(ResultPermissionVo.class); Assert.assertEquals(8, result.getTotalCount()); } }
zzyyp
trunk/zp/src/com/zp/framework/services/test/RunRoleServices.java
Java
asf20
4,309
package com.zp.framework.services.test; import javax.ws.rs.core.MediaType; import junit.framework.Assert; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.UniformInterfaceException; import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.config.ClientConfig; import com.sun.jersey.api.client.config.DefaultClientConfig; import com.zp.bean.common.ResultCommonVo; import com.zp.bean.paper.ResultAnswerItemVo; import com.zp.bean.paper.ResultQuestionVo; import com.zp.domain.Question; import com.zp.util.Constant; /** * test Question services function with Junit * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/2/23 * */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:configure/applicationContext.xml" }) public class RunQuestionServices { private static final Log logger = LogFactory .getLog(RunQuestionServices.class); private static final String URI = "http://localhost:8082/ZP"; private WebResource service; @Before public void init() { ClientConfig config = new DefaultClientConfig(); Client client = Client.create(config); service = client.resource(URI); logger.info("*********** testing to initial services client ****************"); } @After public void destory() { service = null; logger.info("*********** testing to destory services instance ******************"); } /**@Test**/ public void testAddQuestion() { try { Question question = new Question(); question.setTitle("心理关爱题目10"); question.setQuestionType("QUS00001"); ClientResponse response = service.path("question/addQuestion") .type(MediaType.APPLICATION_JSON_TYPE) .post(ClientResponse.class, question); ResultCommonVo result=response.getEntity(ResultCommonVo.class); Assert.assertEquals(Constant.OK, result.getMessage()); } catch (UniformInterfaceException e) { System.out.println(e.getResponse().getStatus()); if (e.getResponse().getStatus() == 404) { } else if (e.getResponse().getStatus() == 401) { throw new IllegalStateException(e); } else if (e.getResponse().getStatus() == 403) { throw new IllegalStateException(e); } else { throw e; } } } /**@Test**/ public void testfindQuestionById() { String id = "402881e6445cc3a301445cc4332b0001"; ClientResponse response = service.path("question/getQuestion") .queryParam("questionId", id).get(ClientResponse.class); ResultQuestionVo result = response.getEntity(ResultQuestionVo.class); Assert.assertNotNull(result.getVo()); } /**@Test**/ public void testUpdateQuestion() { Question t = new Question(); t.setId("402881e6445cc3a301445cc4332b0001"); t.setTitle("心理关爱题目11"); t.setQuestionType("QUS00001"); t.setQuestionAnswer(""); ClientResponse response = service.path("question/updateQuestion") .type(MediaType.APPLICATION_JSON_TYPE).put(ClientResponse.class, t); Assert.assertNotNull(response.getEntity(ResultQuestionVo.class)); } /**@Test**/ public void testDeleteQuestion() { ClientResponse response = service.path("question/deleteQuestion") .queryParam("questionId", "402881e6445c883e01445c8a74290001") .delete(ClientResponse.class); Assert.assertEquals(Constant.OK, response.getEntity(ResultCommonVo.class).getMessage()); } /**@Test**/ public void testGetQuestionByCritera() { ClientResponse response = service.path("question/getQuestions") .queryParam("pageNo", "1").queryParam("pageSize", "2").type(MediaType.APPLICATION_JSON_TYPE).get(ClientResponse.class); ResultQuestionVo result=response.getEntity(ResultQuestionVo.class); Assert.assertEquals(10, result.getTotalCount()); } @Test public void testGetItemsFromQuestion() { ClientResponse response = service.path("question/getAitems") .queryParam("questionId", "402881e6445cc3a301445cc4332b0001").type(MediaType.APPLICATION_JSON_TYPE).get(ClientResponse.class); ResultAnswerItemVo result=response.getEntity(ResultAnswerItemVo.class); Assert.assertEquals(4, result.getTotalCount()); } }
zzyyp
trunk/zp/src/com/zp/framework/services/test/RunQuestionServices.java
Java
asf20
4,588
package com.zp.framework.services.test; import javax.ws.rs.core.MediaType; import junit.framework.Assert; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.UniformInterfaceException; import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.config.ClientConfig; import com.sun.jersey.api.client.config.DefaultClientConfig; import com.zp.bean.common.ResultCommonVo; import com.zp.bean.paper.ResultPaperVo; import com.zp.domain.Paper; import com.zp.util.Constant; /** * test Paper services function with Junit * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/2/23 * */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:configure/applicationContext.xml" }) public class RunPaperServices { private static final Log logger = LogFactory .getLog(RunPaperServices.class); private static final String URI = "http://localhost:8082/ZP"; private WebResource service; @Before public void init() { ClientConfig config = new DefaultClientConfig(); Client client = Client.create(config); service = client.resource(URI); logger.info("*********** testing to initial services client ****************"); } @After public void destory() { service = null; logger.info("*********** testing to destory services instance ******************"); } /**@Test**/ public void testAddPaper() { try { Paper paper = new Paper(); paper.setName("志愿服务"); ClientResponse response = service.path("paper/addPaper") .type(MediaType.APPLICATION_JSON_TYPE) .post(ClientResponse.class, paper); ResultCommonVo result=response.getEntity(ResultCommonVo.class); Assert.assertEquals(Constant.OK, result.getMessage()); } catch (UniformInterfaceException e) { System.out.println(e.getResponse().getStatus()); if (e.getResponse().getStatus() == 404) { } else if (e.getResponse().getStatus() == 401) { throw new IllegalStateException(e); } else if (e.getResponse().getStatus() == 403) { throw new IllegalStateException(e); } else { throw e; } } } /**@Test**/ public void testfindPaperById() { String id = "402881e6445c883e01445c8a74290001"; ClientResponse response = service.path("paper/getPaper") .queryParam("paperId", id).get(ClientResponse.class); ResultPaperVo result = response.getEntity(ResultPaperVo.class); Assert.assertNotNull(result.getPaper()); } /**@Test**/ public void testUpdatePaper() { Paper t = new Paper(); t.setId("402881e6445c883e01445c8a74290001"); t.setName("心理关爱"); ClientResponse response = service.path("paper/updatePaper") .type(MediaType.APPLICATION_JSON_TYPE).put(ClientResponse.class, t); Assert.assertNotNull(response.getEntity(ResultPaperVo.class).getPaper()); } /**@Test**/ public void testDeletePaper() { ClientResponse response = service.path("paper/deletePaper") .queryParam("paperId", "402881e6445c883e01445c8a74290001") .delete(ClientResponse.class); Assert.assertEquals(Constant.OK, response.getEntity(ResultCommonVo.class).getMessage()); } @Test public void testGetPaperByCritera() { ClientResponse response = service.path("paper/getPapers") .queryParam("pageNo", "1").queryParam("pageSize", "10").type(MediaType.APPLICATION_JSON_TYPE).get(ClientResponse.class); ResultPaperVo result=response.getEntity(ResultPaperVo.class); Assert.assertEquals(4, result.getTotalCount()); } }
zzyyp
trunk/zp/src/com/zp/framework/services/test/RunPaperServices.java
Java
asf20
3,951
package com.zp.framework.services.test; import javax.ws.rs.core.MediaType; import junit.framework.Assert; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.UniformInterfaceException; import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.config.ClientConfig; import com.sun.jersey.api.client.config.DefaultClientConfig; import com.zp.bean.common.ResultCommonVo; import com.zp.bean.psychological.ResultBaseOrganizationVo; import com.zp.bean.psychological.ResultOrganizationVo; import com.zp.bean.user.ResultBaseUserVo; import com.zp.domain.ModuleOrganization; import com.zp.domain.Organization; import com.zp.domain.PersonOrganization; import com.zp.util.Constant; /** * test organization services function with Junit * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/3/5 * */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:configure/applicationContext.xml" }) public class RunOrganizationServices { private static final Log logger = LogFactory .getLog(RunOrganizationServices.class); private static final String URI = "http://localhost:8082/ZP/rest/"; private WebResource service; @Before public void init() { ClientConfig config = new DefaultClientConfig(); Client client = Client.create(config); service = client.resource(URI); logger.info("*********** testing to initial services client ****************"); } @After public void destory() { service = null; logger.info("*********** testing to destory services instance ******************"); } /**@Test**/ public void testAddType() { try { Organization o = new Organization(); o.setAddress("四川省成都市武侯区科华路"); o.setCharacter("非营利性组织"); o.setCityCode("028"); o.setImage(null); o.setIntroduce("电子科技大学青少年行动起始于1994年3月...."); o.setManage("电子科技大学教育培训"); o.setMembers(150); o.setName("电子科技大学教育培训组织"); o.setPhone("028-88888888"); o.setSummary("电子科技大学青少年行动起始于"); o.setWeibo("http://weibo.com/schxyx"); ClientResponse response = service.path("organization/addO") .type(MediaType.APPLICATION_JSON_TYPE) .post(ClientResponse.class, o); ResultCommonVo result = response.getEntity(ResultCommonVo.class); Assert.assertEquals(Constant.OK, result.getMessage()); } catch (UniformInterfaceException e) { System.out.println(e.getResponse().getStatus()); if (e.getResponse().getStatus() == 404) { } else if (e.getResponse().getStatus() == 401) { throw new IllegalStateException(e); } else if (e.getResponse().getStatus() == 403) { throw new IllegalStateException(e); } else { throw e; } } } /**@Test**/ public void testAssignModule() { try { ModuleOrganization mo = new ModuleOrganization(); mo.setModuleId("4028810844ca14300144ca314b780003"); mo.setOrganizationId("4028810844cb26d60144cb44f4e1000c"); ClientResponse response = service.path("organization/assignModule") .type(MediaType.APPLICATION_JSON_TYPE) .post(ClientResponse.class, mo); ResultCommonVo result = response.getEntity(ResultCommonVo.class); Assert.assertEquals(Constant.OK, result.getMessage()); } catch (UniformInterfaceException e) { System.out.println(e.getResponse().getStatus()); if (e.getResponse().getStatus() == 404) { } else if (e.getResponse().getStatus() == 401) { throw new IllegalStateException(e); } else if (e.getResponse().getStatus() == 403) { throw new IllegalStateException(e); } else { throw e; } } } /** @Test **/ public void testGetOrganizationById() { ClientResponse response = service .path("organization/getOrganization") .queryParam("organizationId", "402880e44492d4ac014492d533850001") .post(ClientResponse.class); ResultOrganizationVo result = response .getEntity(ResultOrganizationVo.class); Assert.assertNull(result.getVo()); } /** @Test **/ public void testGetOrganizationWithNameOrCity() { ClientResponse response = service.path("organization/getOrganizations") .queryParam("pageNo", "1").queryParam("pageSize", "2").queryParam("moduleCode", "mo01") .type(MediaType.APPLICATION_JSON_TYPE) .post(ClientResponse.class); ResultOrganizationVo result = response .getEntity(ResultOrganizationVo.class); Assert.assertEquals(6, result.getTotalCount()); } @Test public void testGetBaseOrganizationWithNameOrCity() { ClientResponse response = service.path("organization/getBaseOrans") .queryParam("pageNo", "1").queryParam("pageSize", "2").queryParam("moduleCode", "mo02").queryParam("value", "028") .type(MediaType.APPLICATION_JSON_TYPE) .post(ClientResponse.class); ResultBaseOrganizationVo result = response .getEntity(ResultBaseOrganizationVo.class); Assert.assertEquals(6, result.getTotalCount()); } /** @Test **/ public void testGetUserFromOrganization() { ClientResponse response = service .path("organization/getUsers") .queryParam("pageNo", "1") .queryParam("pageSize", "2") .queryParam("organizationId", "402880e44492d4ac014492d533850001") .type(MediaType.APPLICATION_JSON_TYPE) .post(ClientResponse.class); ResultBaseUserVo result = response.getEntity(ResultBaseUserVo.class); Assert.assertEquals(10, result.getTotalCount()); } @Test public void testAddUser() { try { PersonOrganization po = new PersonOrganization(); po.setOrganizationId("4028810844cb26d60144cb44f4e1000c"); po.setUserId("4028810844c8ebd90144c95239ec0059"); ClientResponse response = service.path("organization/addUser") .type(MediaType.APPLICATION_JSON_TYPE) .post(ClientResponse.class, po); ResultCommonVo result = response.getEntity(ResultCommonVo.class); Assert.assertEquals(Constant.OK, result.getMessage()); } catch (UniformInterfaceException e) { System.out.println(e.getResponse().getStatus()); if (e.getResponse().getStatus() == 404) { } else if (e.getResponse().getStatus() == 401) { throw new IllegalStateException(e); } else if (e.getResponse().getStatus() == 403) { throw new IllegalStateException(e); } else { throw e; } } } }
zzyyp
trunk/zp/src/com/zp/framework/services/test/RunOrganizationServices.java
Java
asf20
6,853
package com.zp.framework.services.test; import javax.ws.rs.core.MediaType; import junit.framework.Assert; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.UniformInterfaceException; import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.config.ClientConfig; import com.sun.jersey.api.client.config.DefaultClientConfig; import com.zp.bean.common.ResultCommonVo; import com.zp.bean.user.ResultPermissionVo; import com.zp.domain.Permission; import com.zp.util.Constant; /** * test permission services function with Junit * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/2/16 * */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:configure/applicationContext.xml" }) public class RunPermissionServices { private static final Log logger = LogFactory .getLog(RunPermissionServices.class); private static final String URI = "http://localhost:8082/ZP"; private WebResource service; @Before public void init() { ClientConfig config = new DefaultClientConfig(); Client client = Client.create(config); service = client.resource(URI); logger.info("*********** testing to initial services client ****************"); } @After public void destory() { service = null; logger.info("*********** testing to destory services instance ******************"); } /** @Test **/ public void testAddPermission() { try { Permission p = new Permission(); p.setName("获取用户角色"); p.setCode("P00009"); p.setStatus("1"); p.setTypeCode("AU0001"); p.setParentCode("P00001"); p.setUrl("/user/getUserRole"); ClientResponse response = service.path("/permission/addPermission") .type(MediaType.APPLICATION_JSON_TYPE) .post(ClientResponse.class, p); Assert.assertEquals(Constant.OK, response.getEntity(ResultCommonVo.class).getMessage()); } catch (UniformInterfaceException e) { System.out.println(e.getResponse().getStatus()); if (e.getResponse().getStatus() == 404) { } else if (e.getResponse().getStatus() == 401) { throw new IllegalStateException(e); } else if (e.getResponse().getStatus() == 403) { throw new IllegalStateException(e); } else { throw e; } } } /** @Test **/ public void findPermissionById() { ClientResponse response = service.path("/permission/getPermission") .queryParam("permissionId", "402881e6445916b401445921eff30003") .type(MediaType.APPLICATION_JSON_TYPE) .get(ClientResponse.class); Assert.assertEquals("AU0001", response.getEntity(ResultPermissionVo.class).getPermission() .getType().getCode()); } @Test public void testSearchPermission() { ClientResponse response = service.path("/permission/searchPermission") .queryParam("pageNo", "1").queryParam("pageSize", "10") .type(MediaType.APPLICATION_JSON_TYPE) .get(ClientResponse.class); ResultPermissionVo result = response .getEntity(ResultPermissionVo.class); Assert.assertEquals(9, result.getTotalCount()); } }
zzyyp
trunk/zp/src/com/zp/framework/services/test/RunPermissionServices.java
Java
asf20
3,538
//package com.zp.framework.services.test; // //import javax.ws.rs.core.MediaType; // //import junit.framework.Assert; // //import org.apache.commons.logging.Log; //import org.apache.commons.logging.LogFactory; //import org.junit.After; //import org.junit.Before; //import org.junit.Test; //import org.junit.runner.RunWith; //import org.springframework.test.context.ContextConfiguration; //import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; // //import com.sun.jersey.api.client.Client; //import com.sun.jersey.api.client.ClientResponse; //import com.sun.jersey.api.client.WebResource; //import com.sun.jersey.api.client.config.ClientConfig; //import com.sun.jersey.api.client.config.DefaultClientConfig; //import com.zp.domain.demo.ResultDataVo; // // ///** // * test Type services function with Junit // * // * @author chenlijun08@gmail.com // * // * @version 1.0 // * // * @date 2014/2/9 // * // */ // //@RunWith(SpringJUnit4ClassRunner.class) //@ContextConfiguration(locations = { "classpath:configure/applicationContext.xml" }) //public class RunDemoServices { // // private static final Log logger = LogFactory // .getLog(RunDemoServices.class); // private static final String URI = "http://localhost:8082/ZP"; // private WebResource service; // // @Before // public void init() { // ClientConfig config = new DefaultClientConfig(); // Client client = Client.create(config); // service = client.resource(URI); // logger.info("*********** testing to initial services client ****************"); // } // // @After // public void destory() { // service = null; // logger.info("*********** testing to destory services instance ******************"); // } //@Test // public void testDemo(){ // ClientResponse response = service.path("/demo/hello") // .type(MediaType.APPLICATION_JSON_TYPE) // .get(ClientResponse.class); // ResultDataVo result=response.getEntity(ResultDataVo.class); // Assert.assertEquals("Alex",result.getUser().getUser().getName()); // // } //}
zzyyp
trunk/zp/src/com/zp/framework/services/test/RunDemoServices.java
Java
asf20
2,072
package com.zp.framework.services.test; import javax.ws.rs.core.MediaType; import junit.framework.Assert; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.UniformInterfaceException; import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.config.ClientConfig; import com.sun.jersey.api.client.config.DefaultClientConfig; import com.zp.bean.common.ResultCommonVo; import com.zp.bean.psychological.ResultActivityVo; import com.zp.domain.Activity; import com.zp.util.Constant; /** * test Activity services function with Junit * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/2/9 * */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:configure/applicationContext.xml" }) public class RunActivityServices { private static final Log logger = LogFactory .getLog(RunActivityServices.class); private static final String URI = "http://localhost:8082/ZP/rest/"; private WebResource service; @Before public void init() { ClientConfig config = new DefaultClientConfig(); Client client = Client.create(config); service = client.resource(URI); logger.info("*********** testing to initial services client ****************"); } @After public void destory() { service = null; logger.info("*********** testing to destory services instance ******************"); } @Test public void testAddActivity() { try { Activity activity = new Activity(); activity.setContentId(49); activity.setName("教育培训宣传活动"); activity.setPartyId("4028810844cb26d60144cb4372b60007"); ClientResponse response = service.path("activity/addActivity") .type(MediaType.APPLICATION_JSON_TYPE) .post(ClientResponse.class, activity); ResultCommonVo result=response.getEntity(ResultCommonVo.class); Assert.assertEquals(Constant.OK, result.getMessage()); } catch (UniformInterfaceException e) { System.out.println(e.getResponse().getStatus()); if (e.getResponse().getStatus() == 404) { } else if (e.getResponse().getStatus() == 401) { throw new IllegalStateException(e); } else if (e.getResponse().getStatus() == 403) { throw new IllegalStateException(e); } else { throw e; } } } /**@Test**/ public void testGetActivityByCritera() { ClientResponse response = service.path("activity/getActivitys") .queryParam("pageNo", "1").queryParam("pageSize", "2").queryParam("partyId", "402880e44492d4ac014492d533850001").type(MediaType.APPLICATION_JSON_TYPE).post(ClientResponse.class); ResultActivityVo result=response.getEntity(ResultActivityVo.class); Assert.assertEquals(9, result.getTotalCount()); } }
zzyyp
trunk/zp/src/com/zp/framework/services/test/RunActivityServices.java
Java
asf20
3,163
package com.zp.util; import java.util.List; /** * define all the Constant used in program * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/2/7 * */ public class Constant { public static final Object OBJECT_NULL = null; public static final List<?> LIST_NULL = null; public static final int ZERO = 0; public static final int ONE = 1; public static final int TWO = 2; public static final int THREE = 3; public static final int FOUR = 4; public static final int FIVE = 5; public static final int MAX_PASS_ERROR_NUM = 3; public static final int NEGATIVE_ONE = -1; public static final int PAGE_SIZE = 10; public static final int PAGE_NO = 1; public static final int MD5_MAX_INDEX = 256; public static final int MD5_DIGIT_NUM = 16; public static final int IMAGE_BUFFER=1024*5; public static final String OK = "OK"; public static final String NOK = "NOK"; public static final String USER_NOT_EXITS = "USER_NOT_EXITS"; public static final String ON = "1"; public static final String OFF = "0"; public static final int SUCCESS_CODE = 268; public static final int FAILE_CODE = 267; public static final int EIGHT_HOUR_S = 28800; public static final String USER_ROLE = "G00001"; public static final String PASS_LOCKED = "PASS_LOCKED"; public static final String PASS_SAME = "PASS_SAME"; public static final String USER_EXIST = "USER_EXIST"; //this will be replaced by program automatically after public static final String PARENT_PATH="F:\\android_workspace\\ZP\\WebContent\\"; public static final String FILE_LOCAL_PATH="F:/android_workspace/ZP/WebContent"; public static final String UPLOAD_FOLDER="upload"; public static final String IMAGE_SAVE_PATH ="upload\\image\\"; public static final String COMP_IMAGE_SAVE_PATH = "cpupload\\image\\"; public static final String COMMON_SAVE_PATH ="upload\\common\\"; public static final String PNG_POSTFIX = ".png"; public static final String JPG_POSTFIX = ".jpg"; public static final String JPEG_POSTFIX = ".jpeg"; public static final String BMP_POSTFIX = ".bmp"; public static final String JPE_POSTFIX = ".jpe"; public static final String GIF_POSTFIX = ".gif"; public static final String JPEG_TYPE="image/jpeg"; public static final String PNG_TYPE="image/png"; public static final String GIF_TYPE="image/gif"; public static final String BMP_TYPE="image/bmp"; public static final long MAX_IMAGE_SIZE=1024*250; public static final String MAX_IMAGE_SIZE_MESSAGE="图片大小不能超过50Kb"; public static final String ERROR_IMAGE_TYPE_MESSAGE="图片类型错误目前支持JEPG,PNG,GIF,BMP格式"; public static final String OBJECT_NOT_EXITS="对象不存在"; public static final String PATH_FILE_NAME="server.xml"; public static final String SERVER_PATH_KEY="serverpath"; public static final String SERVER_CONTENT_PATH="/"; }
zzyyp
trunk/zp/src/com/zp/util/Constant.java
Java
asf20
2,914
package com.zp.util; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; /** * package format date tool * * @author chenlijun08@gmail.com * * @version 1.0 * * @since 1.0 * * @date 2014/1/20 */ public class DateFormatUtil { /** * format Date * * @param date * * @return String like 'yyyy-MM-dd HH:mm:ss' */ public static String DateFormat(Date date) { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); return format.format(date); } /** * format the Date * * @param date * * @return String like 'yyyyMMddHHmmss' */ public static String DateFormatToFile(Date date) { SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss"); return format.format(date); } /** * create the file name along with date code * * @return String */ public static String createFlieName() { Calendar calCurrent = Calendar.getInstance(); int intDay = calCurrent.get(Calendar.DATE); int intMonth = calCurrent.get(Calendar.MONTH) + 1; int intYear = calCurrent.get(Calendar.YEAR); int intHour = calCurrent.get(Calendar.HOUR); int intMinute = calCurrent.get(Calendar.MINUTE); int intSecond = calCurrent.get(Calendar.SECOND); StringBuilder builder = new StringBuilder(); return builder.append(String.valueOf(intYear)).append(String.valueOf(intMonth)).append(String.valueOf(intDay)) .append(String.valueOf(intHour)).append(String.valueOf(intMinute)).append(String.valueOf(intSecond)) .append(".amr").toString(); } }
zzyyp
trunk/zp/src/com/zp/util/DateFormatUtil.java
Java
asf20
1,725
package com.zp.util; import java.lang.reflect.Method; import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; import org.springframework.aop.AfterReturningAdvice; import org.springframework.aop.MethodBeforeAdvice; public class MyAdvice implements MethodBeforeAdvice,AfterReturningAdvice,MethodInterceptor{ @Override public void before(Method arg0, Object[] arg1, Object arg2) throws Throwable { System.out.println("before call method:"+arg0.getName()); } @Override public void afterReturning(Object arg0, Method arg1, Object[] arg2, Object arg3) throws Throwable { System.out.println("after call method:"+arg1.getName()); } @Override public Object invoke(MethodInvocation arg0) throws Throwable { // TODO Auto-generated method stub return arg0.getMethod(); } }
zzyyp
trunk/zp/src/com/zp/util/MyAdvice.java
Java
asf20
844
package com.zp.util; import java.io.UnsupportedEncodingException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** * package the MD5 encryption algorithm * * @since 1.0 * * @version 1.0 * * @author chenlijun08@gmail.com * * @date 2014/1/21 * */ public class MD5Util { private static final Log logger = LogFactory.getLog(MD5Util.class); /** * encrypt the password * * @param password the String value * * @return get the password which is encrypted * * @exception NoSuchAlgorithmException if the argument is not allowed */ public static String MD5password(String password) { String str = null; int i; StringBuffer buf = new StringBuffer(""); MessageDigest messageDigest = null; try { messageDigest = MessageDigest.getInstance("MD5"); try { messageDigest.update(password.getBytes("UTF-8")); } catch (UnsupportedEncodingException e) { logger.error("unsupport UTF-8 exception"); e.printStackTrace(); } } catch (NoSuchAlgorithmException e) { logger.error("NoSuchAlgorithmException caught!"); e.printStackTrace(); System.exit(Constant.NEGATIVE_ONE); } byte b[] = messageDigest.digest(); for (int offset = Constant.ZERO; offset < b.length; offset++) { i = b[offset]; if (i < Constant.ZERO) i += Constant.MD5_MAX_INDEX; if (i < Constant.MD5_DIGIT_NUM) buf.append("0"); buf.append(Integer.toHexString(i)); } str = buf.toString(); return str; } }
zzyyp
trunk/zp/src/com/zp/util/MD5Util.java
Java
asf20
1,584
package com.zp.util; import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; import java.io.Writer; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import org.dom4j.Document; import org.dom4j.DocumentException; import org.dom4j.DocumentHelper; import org.dom4j.Element; import org.dom4j.io.SAXReader; import org.dom4j.io.XMLWriter; /** * encapsulation XML util * * @version 1.0 * * @author chenlijun08@gmail.com * */ public class Dom4JUtil { /** * generate XML file with file name * * @param fileName * file name */ public static void createXml(String fileName) { Document document = DocumentHelper.createDocument(); Element employees = document.addElement("Testing"); Element employee = employees.addElement("Test"); Element name = employee.addElement("name"); name.setText("ddvip"); Element sex = employee.addElement("sex"); sex.setText("m"); Element age = employee.addElement("age"); age.setText("29"); try { Writer fileWriter = new FileWriter(fileName); XMLWriter xmlWriter = new XMLWriter(fileWriter); xmlWriter.write(document); xmlWriter.close(); } catch (IOException e) { e.printStackTrace(); } } /** * parser special file name * * @param fileName */ @SuppressWarnings("rawtypes") public static Map<String, String> parserXml(String fileName) { Map<String, String> map = new HashMap<String, String>(); InputStream inputStream = Dom4JUtil.class .getResourceAsStream("/configure/" + fileName); SAXReader saxReader = new SAXReader(); try { Document document = saxReader.read(inputStream); Element elements = document.getRootElement(); for (Iterator i = elements.elementIterator(); i.hasNext();) { Element node = (Element) i.next(); map.put(node.getName(), node.getText()); } } catch (DocumentException e) { System.out.println(e.getMessage()); } return map; } }
zzyyp
trunk/zp/src/com/zp/util/Dom4JUtil.java
Java
asf20
1,951
package com.zp.util; /** * define all the Constant type code in program * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/3/2 * */ public class ConstantCode { public static final String CONTENT_CODE = "cm"; public static final String CONTENT_PHILOSOPHY_CODE = "cm01"; public static final String CONTENT_LAW_CODE = "cm02"; public static final String CONTENT_SOCIAL_SERVICES_CODE = "cm03"; public static final String CONTENT_EDUCATIONAL_TRAINNING_CODE = "cm04"; public static final String CONTENT_ENTREPRENEURSHIP = "cm05"; public static final String MODULE_CODE = "mo"; public static final String MODULE_PHILOSOPHY_CODE = "mo01"; public static final String MODULE_LAW_CODE = "mo02"; public static final String MODULE_SOCIAL_SERVICES_CODE = "mo03"; public static final String MODULE_EDUCATIONAL_TRAINNING_CODE = "mo04"; public static final String MODULE_ENTREPRENEURSHIP = "mo05"; }
zzyyp
trunk/zp/src/com/zp/util/ConstantCode.java
Java
asf20
953
package com.zp.util; /** * define exception for program * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/2/7 * */ public class MyException extends Exception { private static final long serialVersionUID = 1L; public MyException() { super(); } public MyException(String s) { super(s); } public MyException(Throwable b) { super(b); } }
zzyyp
trunk/zp/src/com/zp/util/MyException.java
Java
asf20
413
package com.zp.util; import java.awt.Image; import java.awt.image.BufferedImage; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import javax.imageio.ImageIO; import net.sf.jmimemagic.Magic; import net.sf.jmimemagic.MagicException; import net.sf.jmimemagic.MagicMatch; import net.sf.jmimemagic.MagicMatchNotFoundException; import net.sf.jmimemagic.MagicParseException; import com.sun.image.codec.jpeg.JPEGCodec; import com.sun.image.codec.jpeg.JPEGImageEncoder; public class ImageUtil { /** * compress image * * @param oldFile * the path of original image * @param width * compress width * @param height * compress height * @param percentage * whether perceptual if true the width and height will adjust * automatically * * @return String the path of file * @throws Exception * IOException */ public static String compressImg(String oldFile, int widthdist, int heightdist, boolean percentage) { String path = null; BufferedImage bufferImage = null; try { File srcfile = new File(oldFile); if (srcfile.exists()) { Image source = ImageIO.read(srcfile); // set the extension for the target file String postfix = oldFile.substring(oldFile.indexOf(".")); String newFile = Constant.PARENT_PATH + Constant.COMP_IMAGE_SAVE_PATH + FileUtil.getInstance().getFileName(postfix); if (percentage) { // compute the perceptual width and height double rate1 = ((double) source.getWidth(null)) / (double) widthdist + 0.1; double rate2 = ((double) source.getHeight(null)) / (double) heightdist + 0.1; double rate = rate1 > rate2 ? rate1 : rate2; int target_width = (int) (((double) source.getWidth(null)) / rate); int target_height = (int) (((double) source.getHeight(null)) / rate); // set the image width and height bufferImage = new BufferedImage(target_width, target_height, BufferedImage.TYPE_INT_RGB); bufferImage.getGraphics().drawImage( source.getScaledInstance(target_width, target_height, Image.SCALE_AREA_AVERAGING), Constant.ZERO, Constant.ZERO, null); } else { bufferImage = new BufferedImage(widthdist, heightdist, BufferedImage.TYPE_INT_RGB); bufferImage.getGraphics().drawImage( source.getScaledInstance(widthdist, heightdist, Image.SCALE_AREA_AVERAGING), Constant.ZERO, Constant.ZERO, null); } FileOutputStream out = new FileOutputStream(newFile); JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out); encoder.encode(bufferImage); out.close(); path = newFile; } } catch (IOException ex) { ex.printStackTrace(); } return path; } /** * get the type of file * * @param file * @return String the type of file */ public static String getType(File file) { String type = null; MagicMatch match; try { match = Magic.getMagicMatch(file, true); type = match.getMimeType(); } catch (MagicParseException e) { e.printStackTrace(); } catch (MagicMatchNotFoundException e) { e.printStackTrace(); } catch (MagicException e) { e.printStackTrace(); } return type; } /** * filter the file to accept only accept JPEG,GIF,BMP,PNG * * @param file * @return if accept return true otherwise false */ public static boolean acceptType(File file) { String type = getType(file); if (type.equals(Constant.BMP_TYPE) || type.equals(Constant.GIF_TYPE) || type.equals(Constant.JPEG_TYPE) || type.equals(Constant.PNG_TYPE)) { return true; } else { return false; } } }
zzyyp
trunk/zp/src/com/zp/util/ImageUtil.java
Java
asf20
3,816
package com.zp.util; import java.io.IOException; import java.io.StringWriter; import java.io.Writer; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.codehaus.jackson.JsonGenerationException; import org.codehaus.jackson.JsonGenerator; import org.codehaus.jackson.JsonParseException; import org.codehaus.jackson.JsonProcessingException; import org.codehaus.jackson.map.JsonMappingException; import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.SerializationConfig; /** * deal with JOSN conversion between String and Object * * @since 1.0 * * @version 1.0 * * @author chenlijun08@gmail.com * * @date 2014/1/21 * */ public class JSONUtil { private static final Log logger = LogFactory.getLog(JSONUtil.class); private ObjectMapper objectMapper = null; private JsonGenerator jsonGenerator = null; private static JSONUtil jsonUtil = new JSONUtil(); private Writer output = new StringWriter(); public JSONUtil() { init(); } /** * initial the jsonGenerator */ public void init() { objectMapper = new ObjectMapper(); try { jsonGenerator = objectMapper.getJsonFactory().createJsonGenerator( output); } catch (IOException e) { logger.error("IO exception"); e.printStackTrace(); } } /** * get single instance of JSONUtil * * @return JSONUtil */ public static JSONUtil getInstance() { if (jsonUtil == null) { jsonUtil = new JSONUtil(); } return jsonUtil; } /** * covert object to JSON String * * @param o * @return String */ public String convertObjectToJSON(Object o) { try { SerializationConfig sc = objectMapper.copySerializationConfig(); sc.with(SerializationConfig.Feature.WRITE_NULL_MAP_VALUES); objectMapper.writeValue(jsonGenerator, o, sc); } catch (JsonProcessingException e) { logger.error("JsonProcessingException"); e.printStackTrace(); } catch (IOException e) { logger.error("IOException"); e.printStackTrace(); } return output.toString(); } /** * convert complex data to JSON * * @param names * * @param objects * * @return String */ public String convertComplexDataToJSON(String[] names, Object[] objects) { if (names != null && objects != null && names.length == objects.length) { try { jsonGenerator.writeStartObject(); } catch (JsonGenerationException e1) { logger.error("start write object:JsonProcessingException"); e1.printStackTrace(); } catch (IOException e1) { logger.error("start write object:IOException"); e1.printStackTrace(); } for (int i = 0; i < names.length; i++) { try { jsonGenerator.writeObjectField(names[i], objects[i]); } catch (JsonProcessingException e) { logger.error("write object:JsonProcessingException"); e.printStackTrace(); } catch (IOException e) { logger.error("write object:IOException"); e.printStackTrace(); } } try { jsonGenerator.writeEndObject(); } catch (JsonGenerationException e) { logger.error("end write object:JsonProcessingException"); e.printStackTrace(); } catch (IOException e) { logger.error("end write object:IOException"); e.printStackTrace(); } } else { logger.error("please check the parameters whether its null or the length of objects whether it's equal"); } return output.toString(); } /** * convert JSON String to Object * * @param jsonContext * * @param clssz * * @return T */ public <T> T convertJSONToObject(String jsonContext, Class<T> clssz) { T o = null; try { o = objectMapper.readValue(jsonContext, clssz); } catch (JsonParseException e) { logger.error("JsonParseException"); e.printStackTrace(); } catch (JsonMappingException e) { logger.error("JsonMappingException"); e.printStackTrace(); } catch (IOException e) { logger.error("IOException"); e.printStackTrace(); } return o; } public String decorateJSONString(String jsonStr) { return jsonStr.replace("\"", "\\\""); } /** * destroy jsonGenerator */ public void destroy() { if (jsonGenerator != null) { try { jsonGenerator.flush(); if (!jsonGenerator.isClosed()) { jsonGenerator.close(); } } catch (IOException e) { e.printStackTrace(); } jsonGenerator = null; objectMapper = null; } } }
zzyyp
trunk/zp/src/com/zp/util/JSONUtil.java
Java
asf20
4,373
package com.zp.util; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.Calendar; import javax.servlet.ServletContext; import com.sun.jersey.core.header.FormDataContentDisposition; /** * File util * * @author chenlijun08@gmail.com * * @date 2014/1/20 * * @version 1.0 * */ public class FileUtil { private static final FileUtil fileUtil = new FileUtil(); public static FileUtil getInstance() { return fileUtil; } public void deleteFile(String path) { File f = new File(path); if (!f.exists()) { return; } f.delete(); } public String getSavePath(String path) { File directory = new File(path); if (!directory.exists() && !directory.isDirectory()) { directory.mkdirs(); } return path; } /** * Get file name that combined with year month date time, for example: * 2012112143825.jpg * * @param postfix * the postfix of file * * @return String name of file saved */ public String getFileName(String postfix) { Calendar calCurrent = Calendar.getInstance(); StringBuilder builder = new StringBuilder(); int intDay = calCurrent.get(Calendar.DATE); int intMonth = calCurrent.get(Calendar.MONTH) + 1; int intYear = calCurrent.get(Calendar.YEAR); int intHour = calCurrent.get(Calendar.HOUR_OF_DAY); int intMinute = calCurrent.get(Calendar.MINUTE); int intSecond = calCurrent.get(Calendar.SECOND); builder.append(String.valueOf(intYear)) .append(String.valueOf(intMonth)) .append(String.valueOf(intDay)).append(String.valueOf(intHour)) .append(String.valueOf(intMinute)) .append(String.valueOf(intSecond)).append(postfix); return builder.toString(); } /** * create image folder * * @return folder name */ public String createDirctory() { Calendar calCurrent = Calendar.getInstance(); StringBuilder builder = new StringBuilder(); int intweek = calCurrent.get(Calendar.WEEK_OF_MONTH); int intMonth = calCurrent.get(Calendar.MONTH) + 1; int intYear = calCurrent.get(Calendar.YEAR); builder.append(String.valueOf(intYear)) .append(String.valueOf(intMonth)) .append(String.valueOf(intweek)); return builder.toString(); } /** * save file * * @param input * the input stream of file * @param fileDisposition * filename information * @return String save path file */ public String saveFile(InputStream input, FormDataContentDisposition fileDisposition,ServletContext context) { String savePath = null; long total = Constant.ZERO; boolean tooBig = false; File file = null; BufferedOutputStream bufferOutputStream = null; String fileFullName = fileDisposition.getFileName(); if (!("".equals(fileFullName)) && fileFullName != null) { String postfix = fileFullName.substring(fileFullName.indexOf("."), fileFullName.length()); if (Constant.JPEG_POSTFIX.equals(postfix) || Constant.JPE_POSTFIX.equals(postfix) || Constant.JPG_POSTFIX.equals(postfix) || Constant.BMP_POSTFIX.equals(postfix) || Constant.GIF_POSTFIX.equals(postfix) || Constant.PNG_POSTFIX.equals(postfix)) { savePath = Constant.IMAGE_SAVE_PATH; } else { savePath = Constant.COMMON_SAVE_PATH; } //savePath=context.getRealPath(Constant.SERVER_CONTENT_PATH)+savePath; //String directory = savePath + this.createDirctory(); String directory = Constant.PARENT_PATH+savePath + this.createDirctory(); File f = new File(directory); if (!f.exists()) { f.mkdir(); } try { file = new File(directory.concat("\\"), this.getFileName(postfix)); bufferOutputStream = new BufferedOutputStream( new FileOutputStream(file)); int length = Constant.ZERO; byte[] buff = new byte[Constant.IMAGE_BUFFER]; while (Constant.NEGATIVE_ONE != (length = input.read(buff))) { total += length; if (total > Constant.MAX_IMAGE_SIZE) { tooBig = true; break; } else { bufferOutputStream.write(buff, Constant.ZERO, length); } } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { try { input.close(); } catch (IOException e) { e.printStackTrace(); } try { bufferOutputStream.flush(); bufferOutputStream.close(); } catch (IOException e) { e.printStackTrace(); } } if (!tooBig) { savePath = file.getPath().replace("\\", "/"); savePath = savePath.substring(savePath .indexOf(Constant.UPLOAD_FOLDER)); } else { if (file != null & file.exists()) { file.delete(); } savePath = Constant.MAX_IMAGE_SIZE_MESSAGE; } } return savePath; } }
zzyyp
trunk/zp/src/com/zp/util/FileUtil.java
Java
asf20
5,009
package com.zp.bean.user; import javax.xml.bind.annotation.XmlRootElement; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; import com.zp.bean.common.ResultCommonVo; import com.zp.domain.LoginInfo; /** * define Login java bean for web services return which include LoginInfo Object * and token * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/2/14 * */ @XmlRootElement @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) public class ResultLoginVo extends ResultCommonVo { private static final long serialVersionUID = 1L; private LoginInfo login; // token key for user use to identity whether this user is valid private String key; public LoginInfo getLogin() { return login; } public void setLogin(LoginInfo login) { this.login = login; } public String getKey() { return key; } public void setKey(String key) { this.key = key; } }
zzyyp
trunk/zp/src/com/zp/bean/user/ResultLoginVo.java
Java
asf20
942
package com.zp.bean.user; import java.io.Serializable; import javax.xml.bind.annotation.XmlRootElement; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; /** * use to register user information include user information and login * information * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/2/14 * */ @XmlRootElement @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) public class RegisterUserVo implements Serializable { private static final long serialVersionUID = 1L; private String loginName; private String password; public String getLoginName() { return loginName; } public void setLoginName(String loginName) { this.loginName = loginName; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } }
zzyyp
trunk/zp/src/com/zp/bean/user/RegisterUserVo.java
Java
asf20
879
package com.zp.bean.user; import java.util.List; import javax.xml.bind.annotation.XmlRootElement; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; import com.zp.bean.common.ResultCommonVo; /** * define user java bean for web services return which include User information * object or collection of user information * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/2/14 * */ @XmlRootElement @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) public class ResultUserVo extends ResultCommonVo { private static final long serialVersionUID = 1L; private UserVo userInfo; private List<UserVo> listVo; public UserVo getUserInfo() { return userInfo; } public void setUserInfo(UserVo userInfo) { this.userInfo = userInfo; } public List<UserVo> getListVo() { return listVo; } public void setListVo(List<UserVo> listVo) { this.listVo = listVo; } }
zzyyp
trunk/zp/src/com/zp/bean/user/ResultUserVo.java
Java
asf20
948
package com.zp.bean.user; import java.util.List; import javax.xml.bind.annotation.XmlRootElement; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; import com.zp.bean.common.ResultCommonVo; import com.zp.domain.Role; /** * define role java bean for web services return which include Role object or * collection of role * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/2/20 */ @XmlRootElement @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) public class ResultRoleVo extends ResultCommonVo { private static final long serialVersionUID = 1L; private Role role; private List<Role> list; public Role getRole() { return role; } public void setRole(Role role) { this.role = role; } public List<Role> getList() { return list; } public void setList(List<Role> list) { this.list = list; } }
zzyyp
trunk/zp/src/com/zp/bean/user/ResultRoleVo.java
Java
asf20
895
package com.zp.bean.user; import java.util.List; import javax.xml.bind.annotation.XmlRootElement; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; import com.zp.bean.common.ResultCommonVo; /** * define permission java bean for web services return which include permisionVo * object or collection of permissionVo * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/2/20 */ @XmlRootElement @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) public class ResultPermissionVo extends ResultCommonVo { private static final long serialVersionUID = 1L; private PermissionVo permission; private List<PermissionVo> list; public PermissionVo getPermission() { return permission; } public void setPermission(PermissionVo permission) { this.permission = permission; } public List<PermissionVo> getList() { return list; } public void setList(List<PermissionVo> list) { this.list = list; } }
zzyyp
trunk/zp/src/com/zp/bean/user/ResultPermissionVo.java
Java
asf20
985
package com.zp.bean.user; import java.io.Serializable;import java.util.Date; import javax.xml.bind.annotation.XmlRootElement; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; import com.zp.domain.LoginInfo; import com.zp.domain.Type; /** * define UserVo which include user information and login information * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/2/14 * */ @XmlRootElement @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) public class UserVo implements Serializable { private static final long serialVersionUID = 1L; private String id; private String name; private Date birthday; private String gender; private String certNumber; private Type type; private Date registerTime; private Date updateTime; private LoginInfo login; public String getId() { return id; } public void setId(String id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public Date getBirthday() { return birthday; } public void setBirthday(Date birthday) { this.birthday = birthday; } public String getGender() { return gender; } public void setGender(String gender) { this.gender = gender; } public String getCertNumber() { return certNumber; } public void setCertNumber(String certNumber) { this.certNumber = certNumber; } public Type getType() { return type; } public void setType(Type type) { this.type = type; } public Date getRegisterTime() { return registerTime; } public void setRegisterTime(Date registerTime) { this.registerTime = registerTime; } public Date getUpdateTime() { return updateTime; } public void setUpdateTime(Date updateTime) { this.updateTime = updateTime; } public LoginInfo getLogin() { return login; } public void setLogin(LoginInfo login) { this.login = login; } }
zzyyp
trunk/zp/src/com/zp/bean/user/UserVo.java
Java
asf20
1,929
package com.zp.bean.user; import java.io.Serializable; import javax.xml.bind.annotation.XmlRootElement; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; import com.zp.domain.Type; /** * define java bean for permission * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/2/14 * */ @XmlRootElement @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) public class PermissionVo implements Serializable { private static final long serialVersionUID = 1L; private String id; private String name; private Type type; private String parentCode; private String url; private String status; // code of permission private String code; public String getId() { return id; } public void setId(String id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public Type getType() { return type; } public void setType(Type type) { this.type = type; } public String getParentCode() { return parentCode; } public void setParentCode(String parentCode) { this.parentCode = parentCode; } public String getCode() { return code; } public void setCode(String code) { this.code = code; } public String getUrl() { return url; } public void setUrl(String url) { this.url = url; } public String getStatus() { return status; } public void setStatus(String status) { this.status = status; } }
zzyyp
trunk/zp/src/com/zp/bean/user/PermissionVo.java
Java
asf20
1,483
package com.zp.bean.user; import java.io.Serializable; import javax.xml.bind.annotation.XmlRootElement; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; /** * define base user information java bean * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/3/5 * */ @XmlRootElement @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) public class BaseUserVo implements Serializable { private static final long serialVersionUID = 1L; private String id; private String name; private String title; private String image; private String introduce; public String getId() { return id; } public void setId(String id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public String getImage() { return image; } public void setImage(String image) { this.image = image; } public String getIntroduce() { return introduce; } public void setIntroduce(String introduce) { this.introduce = introduce; } }
zzyyp
trunk/zp/src/com/zp/bean/user/BaseUserVo.java
Java
asf20
1,186
package com.zp.bean.user; import java.util.List; import javax.xml.bind.annotation.XmlRootElement; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; import com.zp.bean.common.ResultCommonVo; /** * define user java bean for web services return which include collection of * base user information * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/3/5 * */ @XmlRootElement @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) public class ResultBaseUserVo extends ResultCommonVo { private static final long serialVersionUID = 1L; private List<BaseUserVo> listVo; public List<BaseUserVo> getListVo() { return listVo; } public void setListVo(List<BaseUserVo> listVo) { this.listVo = listVo; } }
zzyyp
trunk/zp/src/com/zp/bean/user/ResultBaseUserVo.java
Java
asf20
785
package com.zp.bean.psychological; import java.util.List; import javax.xml.bind.annotation.XmlRootElement; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; import com.zp.bean.common.ResultCommonVo; /** * define role java bean for web services return which include collection of * BaseOrganizationVo * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/3/4 */ @XmlRootElement @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) public class ResultBaseOrganizationVo extends ResultCommonVo { private static final long serialVersionUID = 1L; private List<BaseOrganizationVo> list; public List<BaseOrganizationVo> getList() { return list; } public void setList(List<BaseOrganizationVo> list) { this.list = list; } }
zzyyp
trunk/zp/src/com/zp/bean/psychological/ResultBaseOrganizationVo.java
Java
asf20
807
package com.zp.bean.psychological; import java.io.Serializable; import javax.xml.bind.annotation.XmlRootElement; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; /** * define java bean for base service * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/3/8 * */ @XmlRootElement @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) public class BaseServiceVo implements Serializable { protected static final long serialVersionUID = 1L; protected String id; protected String title; protected String titleImage; protected String organizationName; protected String introduce; protected int duration; public String getId() { return id; } public void setId(String id) { this.id = id; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public String getTitleImage() { return titleImage; } public void setTitleImage(String titleImage) { this.titleImage = titleImage; } public String getOrganizationName() { return organizationName; } public void setOrganizationName(String organizationName) { this.organizationName = organizationName; } public String getIntroduce() { return introduce; } public void setIntroduce(String introduce) { this.introduce = introduce; } public int getDuration() { return duration; } public void setDuration(int duration) { this.duration = duration; } }
zzyyp
trunk/zp/src/com/zp/bean/psychological/BaseServiceVo.java
Java
asf20
1,472
package com.zp.bean.psychological; import javax.xml.bind.annotation.XmlRootElement; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; /** * define java bean for organization * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/3/4 * */ @XmlRootElement @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) public class OrganizationVo extends BaseOrganizationVo { private static final long serialVersionUID = 1L; private String introduce; private String address; private String character; private String manage; private String phone; private String weibo; private int members; public String getIntroduce() { return introduce; } public void setIntroduce(String introduce) { this.introduce = introduce; } public String getAddress() { return address; } public void setAddress(String address) { this.address = address; } public String getCharacter() { return character; } public void setCharacter(String character) { this.character = character; } public String getManage() { return manage; } public void setManage(String manage) { this.manage = manage; } public String getPhone() { return phone; } public void setPhone(String phone) { this.phone = phone; } public String getWeibo() { return weibo; } public void setWeibo(String weibo) { this.weibo = weibo; } public int getMembers() { return members; } public void setMembers(int members) { this.members = members; } }
zzyyp
trunk/zp/src/com/zp/bean/psychological/OrganizationVo.java
Java
asf20
1,520
package com.zp.bean.psychological; import java.io.Serializable; import javax.xml.bind.annotation.XmlRootElement; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; import com.zp.domain.Type; /** * define java bean for base organization * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/3/4 * */ @XmlRootElement @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) public class BaseOrganizationVo implements Serializable { protected static final long serialVersionUID = 1L; protected String id; protected String name; protected String image; protected String summary; protected Type cityType; public String getId() { return id; } public void setId(String id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getImage() { return image; } public void setImage(String image) { this.image = image; } public String getSummary() { return summary; } public void setSummary(String summary) { this.summary = summary; } public Type getCityType() { return cityType; } public void setCityType(Type cityType) { this.cityType = cityType; } }
zzyyp
trunk/zp/src/com/zp/bean/psychological/BaseOrganizationVo.java
Java
asf20
1,244
package com.zp.bean.psychological; import java.util.List; import javax.xml.bind.annotation.XmlRootElement; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; import com.zp.bean.common.ResultCommonVo; import com.zp.domain.Activity; /** * define activity information java bean for web services return collection of * Activity * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/3/5 * */ @XmlRootElement @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) public class ResultActivityVo extends ResultCommonVo { private static final long serialVersionUID = 1L; private List<Activity> list; public List<Activity> getList() { return list; } public void setList(List<Activity> list) { this.list = list; } }
zzyyp
trunk/zp/src/com/zp/bean/psychological/ResultActivityVo.java
Java
asf20
794
package com.zp.bean.psychological; import javax.xml.bind.annotation.XmlRootElement; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; import com.zp.domain.Organization; /** * define java bean for service * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/3/8 * */ @XmlRootElement @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) public class ServiceVo extends BaseServiceVo { private static final long serialVersionUID = 1L; private String content; private Organization organization; public String getContent() { return content; } public void setContent(String content) { this.content = content; } public Organization getOrganization() { return organization; } public void setOrganization(Organization organization) { this.organization = organization; } }
zzyyp
trunk/zp/src/com/zp/bean/psychological/ServiceVo.java
Java
asf20
864
package com.zp.bean.psychological; import java.util.List; import javax.xml.bind.annotation.XmlRootElement; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; import com.zp.bean.common.ResultCommonVo; /** * define service information java bean for web services return service object * or collection of ServiceVo * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/3/8 * */ @XmlRootElement @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) public class ResultServiceVo extends ResultCommonVo { private static final long serialVersionUID = 1L; private ServiceVo vo; private List<ServiceVo> list; public ServiceVo getVo() { return vo; } public void setVo(ServiceVo vo) { this.vo = vo; } public List<ServiceVo> getList() { return list; } public void setList(List<ServiceVo> list) { this.list = list; } }
zzyyp
trunk/zp/src/com/zp/bean/psychological/ResultServiceVo.java
Java
asf20
906
package com.zp.bean.psychological; import java.util.List; import javax.xml.bind.annotation.XmlRootElement; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; import com.zp.bean.common.ResultCommonVo; /** * define base ervice information java bean for web services return collection of * BaseServiceVo * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/3/8 * */ @XmlRootElement @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) public class ResultBaseServiceVo extends ResultCommonVo { private static final long serialVersionUID = 1L; private List<BaseServiceVo> list; public List<BaseServiceVo> getList() { return list; } public void setList(List<BaseServiceVo> list) { this.list = list; } }
zzyyp
trunk/zp/src/com/zp/bean/psychological/ResultBaseServiceVo.java
Java
asf20
789
package com.zp.bean.psychological; import java.util.List; import javax.xml.bind.annotation.XmlRootElement; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; import com.zp.bean.common.ResultCommonVo; /** * define role java bean for web services return which include organization * object and collection of organization * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/3/4 */ @XmlRootElement @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) public class ResultOrganizationVo extends ResultCommonVo { private static final long serialVersionUID = 1L; private OrganizationVo vo; private List<OrganizationVo> list; public OrganizationVo getVo() { return vo; } public void setVo(OrganizationVo vo) { this.vo = vo; } public List<OrganizationVo> getList() { return list; } public void setList(List<OrganizationVo> list) { this.list = list; } }
zzyyp
trunk/zp/src/com/zp/bean/psychological/ResultOrganizationVo.java
Java
asf20
947
package com.zp.bean.paper; import java.util.List; import javax.xml.bind.annotation.XmlRootElement; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; import com.zp.bean.common.ResultCommonVo; import com.zp.domain.Paper; /** * define paper java bean for web services return which include Paper or * collection of Paper * * @author chenlijun08@gmail.com * * @version 1.0 * * @date 2014/2/22 * */ @XmlRootElement @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) public class ResultPaperVo extends ResultCommonVo { private static final long serialVersionUID = 1L; private Paper paper; private List<Paper> list; public Paper getPaper() { return paper; } public void setPaper(Paper paper) { this.paper = paper; } public List<Paper> getList() { return list; } public void setList(List<Paper> list) { this.list = list; } }
zzyyp
trunk/zp/src/com/zp/bean/paper/ResultPaperVo.java
Java
asf20
909