You can subscribe to this list here.
| 2004 |
Jan
|
Feb
(11) |
Mar
(106) |
Apr
(146) |
May
(79) |
Jun
(233) |
Jul
(218) |
Aug
(160) |
Sep
(155) |
Oct
(80) |
Nov
(176) |
Dec
(115) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2005 |
Jan
(77) |
Feb
(106) |
Mar
(10) |
Apr
(54) |
May
(29) |
Jun
(29) |
Jul
(65) |
Aug
(80) |
Sep
|
Oct
(42) |
Nov
(45) |
Dec
(33) |
| 2006 |
Jan
(49) |
Feb
(52) |
Mar
(8) |
Apr
(3) |
May
(108) |
Jun
(43) |
Jul
(13) |
Aug
(1) |
Sep
(58) |
Oct
(66) |
Nov
(70) |
Dec
(115) |
| 2007 |
Jan
(26) |
Feb
(3) |
Mar
(17) |
Apr
(1) |
May
(4) |
Jun
(3) |
Jul
(2) |
Aug
(1) |
Sep
|
Oct
(1) |
Nov
(1) |
Dec
(1) |
| 2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(4) |
Jun
|
Jul
(10) |
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
(1) |
| 2009 |
Jan
(5) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(3) |
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <ko...@us...> - 2004-03-09 16:24:06
|
Update of /cvsroot/cobricks/cobricks2/conf/org.cobricks.user In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23435/conf/org.cobricks.user Modified Files: properties.txt Log Message: Index: properties.txt =================================================================== RCS file: /cvsroot/cobricks/cobricks2/conf/org.cobricks.user/properties.txt,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** properties.txt 23 Feb 2004 08:20:58 -0000 1.3 --- properties.txt 9 Mar 2004 15:58:54 -0000 1.4 *************** *** 27,30 **** ! # user domain handlers - postfixs of uses logins that receive special handling user.domain.cobricks.org.class=org.cobricks.user.DefaultUserHandler --- 27,35 ---- ! # user domain handlers - postfixs of user logins that receive special handling user.domain.cobricks.org.class=org.cobricks.user.DefaultUserHandler + + # properties for LdapUserHandler + #user.domain.XXX.ldap.providerurl=ldap://dstum.lrz-muenchen.de/o=lrz-muenchen,c=de + #user.domain.XXX.ldap.security.principal= + #user.domain.XXX.ldap.security.credentials= |
|
From: <ko...@us...> - 2004-03-09 16:22:58
|
Update of /cvsroot/cobricks/cobricks2/src/net/sourceforge/jradiusclient/exception In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23085/net/sourceforge/jradiusclient/exception Added Files: InvalidParameterException.java RadiusException.java Log Message: --- NEW FILE: InvalidParameterException.java --- package net.sourceforge.jradiusclient.exception; import java.lang.Exception; /** * * @author <a href="mailto:bl...@us...">Robert J. Loihl</a> * @version $Revision: 1.1 $ */ public class InvalidParameterException extends Exception{ /** * The default message constructor */ public InvalidParameterException(){ this("An Invalid Parameter was sent to this method!"); } /** * Constructs an InvalidParameterException with the specified message * @param message the exception message */ public InvalidParameterException(String message){ super(message); } } --- NEW FILE: RadiusException.java --- package net.sourceforge.jradiusclient.exception; import java.lang.Exception; /** * * @author <a href="mailto:bl...@us...">Robert J. Loihl</a> * @version $Revision: 1.1 $ */ public class RadiusException extends Exception{ /** * @param message the exception message */ public RadiusException(String message){ super(message); } } |
|
From: <ko...@us...> - 2004-03-09 16:22:58
|
Update of /cvsroot/cobricks/cobricks2/src/net/sourceforge/jradiusclient In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23085/net/sourceforge/jradiusclient Added Files: RadiusClient.java RadiusValues.java TestRadiusClient.java Log Message: --- NEW FILE: RadiusClient.java --- package net.sourceforge.jradiusclient; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.net.InetAddress; import java.net.DatagramPacket; import java.net.DatagramSocket; import java.net.SocketException; import java.net.UnknownHostException; import java.util.Hashtable; import java.util.Random; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import net.sourceforge.jradiusclient.exception.InvalidParameterException; import net.sourceforge.jradiusclient.exception.RadiusException; [...1305 lines suppressed...] sb.append(Integer.toString(this.getAuthPort())); sb.append(this.getSharedSecret()); sb.append(this.getUserName()); return sb.toString().hashCode(); } /** * closes the socket * */ protected void closeSocket(){ this.socket.close(); } /** * overrides finalize to close socket and then normal finalize on super class */ public void finalize() throws Throwable{ this.closeSocket(); super.finalize(); } } --- NEW FILE: RadiusValues.java --- package net.sourceforge.jradiusclient; /** * * Special Thanks to the original creator of the "RadiusClient" * <a href="http://augiesoft.com/java/radius/">August Mueller </a> * http://augiesoft.com/java/radius/ and to * <a href="http://sourceforge.net/projects/jradius-client">Aziz Abouchi</a> * for laying the groundwork for the development of this class. * * @author <a href="mailto:bl...@us...">Robert J. Loihl</a> * @version $Revision: 1.1 $ */ public interface RadiusValues { public static final int MIN_PACKET_LENGTH = 20; public static final int MAX_PACKET_LENGTH = 4096; /** *RADIUS_HEADER_LENGTH is 20 bytes (corresponding to *1 byte for code + 1 byte for Identifier + 2 bytes for Length + 16 bytes for Request Authenticator) *It is not a coincidence that it is the same as the MIN_PACKET_LENGTH **/ public static final short RADIUS_HEADER_LENGTH = 20; public static final String EMPTYSTRING = ""; /* *************** Constant Packet Type Codes **************************/ public static final int ACCESS_REQUEST = 1; public static final int ACCESS_ACCEPT = 2; public static final int ACCESS_REJECT = 3; public static final int ACCOUNTING_REQUEST = 4; public static final int ACCOUNTING_RESPONSE = 5; public static final int ACCOUNTING_STATUS = 6; public static final int PASSWORD_REQUEST = 7; public static final int PASSWORD_ACCEPT = 8; public static final int PASSWORD_REJECT = 9; public static final int ACCOUNTING_MESSAGE = 10; public static final int ACCESS_CHALLENGE = 11; public static final int STATUS_SERVER = 12; // experimental public static final int STATUS_CLIENT = 13; // experimental public static final int RESERVED = 255; /* ****************** Constant Packet Type Codes *************************/ /* ****************** Constant Attribute Types *************************/ public static final int USER_NAME = 1; public static final int USER_PASSWORD = 2; public static final int CHAP_PASSWORD = 3; public static final int NAS_IP_ADDRESS = 4; public static final int NAS_PORT = 5; public static final int SERVICE_TYPE = 6; public static final int FRAMED_PROTOCOL = 7; public static final int FRAMED_IP_ADDRESS = 8; public static final int FRAMED_IP_NETMASK = 9; public static final int FRAMED_ROUTING = 10; public static final int FILTER_ID = 11; public static final int FRAMED_MTU = 12; public static final int FRAMED_COMPRESSION = 13; public static final int LOGIN_IP_HOST = 14; public static final int LOGIN_SERVICE = 15; public static final int LOGIN_TCP_PORT = 16; //17 (unassigned) public static final int REPLY_MESSAGE = 18; public static final int CALLBACK_NUMBER = 19; public static final int CALLBACK_ID = 20; //21 (unassigned) public static final int FRAMED_ROUTE = 22; public static final int FRAMED_IPX_NETWORK = 23; public static final int STATE = 24; public static final int CLASS = 25; public static final int VENDOR_SPECIFIC = 26; public static final int SESSION_TIMEOUT = 27; public static final int IDLE_TIMEOUT = 28; public static final int TERMINATION_ACTION = 29; public static final int CALLED_STATION_ID = 30; public static final int CALLING_STATION_ID = 31; public static final int NAS_IDENTIFIER = 32; public static final int PROXY_STATE = 33; public static final int LOGIN_LAT_SERVICE = 34; public static final int LOGIN_LAT_NODE = 35; public static final int LOGIN_LAT_GROUP = 36; public static final int FRAMED_APPLETALK_LINK = 37; public static final int FRAMED_APPLETALK_NETWORK = 38; public static final int FRAMED_APPLETALK_ZONE = 39; //40_59 (reserved for accounting) public static final int ACCT_STATUS_TYPE = 40; public static final int ACCT_DELAY_TIME = 41; public static final int ACCT_INPUT_OCTETS = 42; public static final int ACCT_OUTPUT_OCTETS = 43; public static final int ACCT_SESSION_ID = 44; public static final int ACCT_AUTHENTIC = 45; public static final int ACCT_SESSION_TIME = 46; public static final int ACCT_INPUT_PACKETS = 47; public static final int ACCT_OUTPUT_PACKETS = 48; public static final int ACCT_TERMINATE_CAUSE = 49; public static final int ACCT_MULTI_SESSION_ID = 50; public static final int ACCT_LINK_COUNT = 51; public static final int ACCT_INPUT_GIGAWORDS = 52; public static final int ACCT_OUTPUT_GIGAWORDS = 53; public static final int EVENT_TIMESTAMP = 55; public static final int CHAP_CHALLENGE = 60; public static final int NAS_PORT_TYPE = 61; public static final int PORT_LIMIT = 62; public static final int LOGIN_LAT_PORT = 63; public static final int ARAP_PASSWORD = 70; public static final int ARAP_FEATURES = 71; public static final int ARAP_ZONE_ACCESS = 72; public static final int ARAP_SECURITY = 73; public static final int ARAP_SECURITY_DATA = 74; public static final int PASSWORD_RETRY = 75; public static final int PROMPT = 76; public static final int CONNECT_INFO = 77; public static final int CONFIGURATION_TOKEN = 78; public static final int EAP_MESSAGE = 79; public static final int MESSAGE_AUTHENTICATOR = 80; public static final int ARAP_CHALLENGE_RESPONSE = 84; public static final int ACCT_INTERIM_INTERVAL = 85; public static final int NAS_PORT_ID = 87; public static final int FRAMED_POOL = 88; /* ******************* Constant Attribute Types **************************/ /* ****************** Constant Attribute Types *************************/ // Service-Type or User Types public static final int LOGIN = 1; public static final int FRAMED = 2; public static final int CALLBACK_LOGIN = 3; public static final int CALLBACK_FRAMED = 4; public static final int OUTBOUND = 5; public static final int ADMINISTRATIVE = 6; public static final int NAS_PROMPT = 7; public static final int AUTHENTICATE_ONLY = 8; public static final int CALLBACK_NAS_PROMPT = 9; public static final int Call_CHECK = 10; public static final int CALLBACK_ADMINISTRATIVE = 11; // Framed-Protocol public static final int PPP = 1; public static final int SLIP = 2; public static final int ARAP = 3; public static final int GANDALF_SLML = 4; public static final int XYLOGICS_PROPRIETARY_IPX_SLIP = 5; public static final int X75_SYNCHRONOUS = 6; // Framed-Routing public static final int NONE = 0; public static final int BROADCAST = 1; public static final int LISTEN = 2; public static final int BROADCAST_LISTEN = 3; // Framed-Compression //public static final int None = 0; public static final int VJ_TCP_IP_HEADER_COMPRESSION = 1; public static final int IPX_HEADER_COMPRESSION = 2; public static final int STAC_LZS_COMPRESSION = 3; // Login-Service public static final int TELNET = 0; public static final int RLOGIN = 1; public static final int TCP_CLEAR = 2; public static final int PORTMASTER = 3; public static final int LAT = 4; public static final int X25_PAD = 5; public static final int X25_T3POS = 7; public static final int TCP_CLEAR_QUIET = 8; // Termination-Action public static final int DEFAULT = 0; public static final int RADIUS_REQUEST = 1; // NAS-PORT-TYPE public static final int ASYNC = 0; public static final int SYNC = 1; public static final int ISDN_SYNC = 2; public static final int ISDN_ASYNC_V120 = 3; public static final int ISDN_ASYNC_V110 = 4; public static final int VIRTUAL = 5; public static final int PIAFS = 6; public static final int HDLC_CLEAR_CHANNEL = 7; public static final int X25 = 8; public static final int X75 = 9; public static final int G3_FAX = 10; public static final int SDSL = 11; public static final int ADSL_CAP = 12; public static final int ADSL_DMT = 13; public static final int IDSL = 14; public static final int ETHERNET = 15; public static final int XDSL = 16; public static final int CABLE = 17; public static final int WIRELESS_OTHER = 18; public static final int WIRELESS_IEEE_802_11 = 19; /* ****************** Constant Attribute Types *************************/ /* ***************** Attributes and sub attributes for SIP ***************/ // SIP DIGEST AUTH - draft-sterman-aaa-sip-00 public static final int DIGEST_RESPONSE = 206; public static final int DIGEST_ATTRIBUTE = 207; // SIP DIGEST AUTH - draft-sterman-aaa-sip-00 public static final int SIP_REALM = 1; public static final int SIP_NONCE = 2; public static final int SIP_METHOD = 3; public static final int SIP_URI = 4; public static final int SIP_QOP = 5; public static final int SIP_ALGORITHM = 6; public static final int SIP_BODY_DIGEST = 7; public static final int SIP_CNONCE = 8; public static final int SIP_NONCE_COUNT = 9; public static final int SIP_USER_NAME = 10; /* ***************** Attributes and sub attributes for SIP ***************/ } --- NEW FILE: TestRadiusClient.java --- package net.sourceforge.jradiusclient; import java.io.InputStreamReader; import java.io.BufferedReader; import java.io.ByteArrayOutputStream; import net.sourceforge.jradiusclient.exception.*; /** * @author <a href="mailto:bl...@us...">Robert J. Loihl</a> * @version $Revision: 1.1 $ */ public class TestRadiusClient{ public static String getUsage(){ return "usage: RadiusClient server authPort acctPort secret user password [calling-station-id]"; } public static void main(String [] args) { if ((args.length < 6) || (args.length > 7)) { TestRadiusClient.log(getUsage()); System.exit(2); } int authport = 0 ; int acctport = 0 ; try{ authport = Integer.parseInt(args[1]); acctport = Integer.parseInt(args[2]); }catch (NumberFormatException nfex){ TestRadiusClient.log("port must be a positive integer!"); TestRadiusClient.log(getUsage()); System.exit(3); } RadiusClient rc = null; try{ rc = new RadiusClient(args[0], authport,acctport, args[3],args[4]); }catch(java.net.SocketException soex){ TestRadiusClient.log("Unable to create Radius Client due to failure to create socket!"); TestRadiusClient.log(getUsage()); System.exit(4); }catch(java.security.NoSuchAlgorithmException nsaex){ TestRadiusClient.log("Unable to create Radius Client due to failure to create MD5 MessageDigest!"); TestRadiusClient.log(getUsage()); System.exit(5); }catch(InvalidParameterException ivpex){ TestRadiusClient.log("Unable to create Radius Client due to invalid parameter!"); TestRadiusClient.log(ivpex.getMessage()); TestRadiusClient.log(getUsage()); System.exit(6); } String userPass = args[5]; byte[] callingStationId = null; if(args.length > 6 ){//the seventh one should be calling station ID callingStationId = args[6].getBytes(); } try{ boolean returned = TestRadiusClient.authenticate(rc, userPass, callingStationId); if (returned){ TestRadiusClient.log("------------------------------------------------------"); returned = rc.startAccounting(args[5]); if (returned){ TestRadiusClient.log("Accounting start succeeded."); }else{ TestRadiusClient.log("Accounting start failed."); } TestRadiusClient.log("------------------------------------------------------"); returned = rc.stopAccounting(args[5]); if (returned){ TestRadiusClient.log("Accounting stop succeeded."); }else{ TestRadiusClient.log("Accounting stop failed."); } TestRadiusClient.log("------------------------------------------------------"); } }catch(InvalidParameterException ivpex){ TestRadiusClient.log(ivpex.getMessage()); }catch(java.net.UnknownHostException uhex){ TestRadiusClient.log(uhex.getMessage()); }catch(java.io.IOException ioex){ TestRadiusClient.log(ioex.getMessage()); }catch(RadiusException rex){ TestRadiusClient.log(rex.getMessage()); } } public static boolean authenticate(RadiusClient rc, String userPass, byte[] callingStationId) throws InvalidParameterException, java.net.UnknownHostException, java.io.IOException, RadiusException{ int returnCode; if(callingStationId != null){ ByteArrayOutputStream reqAttributes = new ByteArrayOutputStream(); try{ rc.setUserAttribute(RadiusClient.CALLING_STATION_ID, callingStationId, reqAttributes); }catch(InvalidParameterException ivpex){ System.out.println(ivpex); } returnCode = rc.authenticate(userPass, reqAttributes); }else{ returnCode = rc.authenticate(userPass); } boolean returned = false; TestRadiusClient.log("++++++++++++++++++++++++++++++++++++++++++++++++++++++"); switch (returnCode){ case RadiusClient.ACCESS_ACCEPT: TestRadiusClient.log("Authenticated"); returned = true; break; case RadiusClient.ACCESS_REJECT: TestRadiusClient.log("Not Authenticated"); returned = false; break; case RadiusClient.ACCESS_CHALLENGE: TestRadiusClient.log(rc.getChallengeMessage()); //wait for user input BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); userPass = br.readLine(); returned = TestRadiusClient.authenticate(rc, userPass, callingStationId); break; default: TestRadiusClient.log("How the hell did we get here?"); returned = false; break; } TestRadiusClient.log("++++++++++++++++++++++++++++++++++++++++++++++++++++++"); return returned; } private static void log(String message) { System.out.print ("TestRadiusClient: "); System.out.println(message); } private void setSIPAttributes(RadiusClient rc, ByteArrayOutputStream reqAttributes) throws InvalidParameterException { rc.setUserAttribute(RadiusClient.DIGEST_RESPONSE, "0c02a1cc5ec9a986aaa7232bb975faffa".getBytes(), reqAttributes); rc.setUserSubAttribute( RadiusClient.DIGEST_ATTRIBUTE, RadiusClient.SIP_REALM, "buddyphone".getBytes(), reqAttributes ); rc.setUserSubAttribute( RadiusClient.DIGEST_ATTRIBUTE, RadiusClient.SIP_USER_NAME, "koehler".getBytes(), reqAttributes ); rc.setUserSubAttribute( RadiusClient.DIGEST_ATTRIBUTE, RadiusClient.SIP_NONCE, "1a80ff0a".getBytes(), reqAttributes ); rc.setUserSubAttribute( RadiusClient.DIGEST_ATTRIBUTE, RadiusClient.SIP_URI, "sip:buddyphone.com:5060".getBytes(), reqAttributes ); rc.setUserSubAttribute( RadiusClient.DIGEST_ATTRIBUTE, RadiusClient.SIP_METHOD, "REGISTER".getBytes(), reqAttributes ); rc.setUserSubAttribute( RadiusClient.DIGEST_ATTRIBUTE, RadiusClient.SIP_ALGORITHM, "MD5".getBytes(), reqAttributes ); } } |
Update of /cvsroot/cobricks/cobricks2/src/net/sourceforge/jradiusclient/jaas In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23085/net/sourceforge/jradiusclient/jaas Added Files: RadiusCallback.java RadiusLoginHandler.java RadiusLoginModule.java RadiusPrincipal.java Log Message: --- NEW FILE: RadiusCallback.java --- package net.sourceforge.jradiusclient.jaas; import javax.security.auth.callback.Callback; public class RadiusCallback implements Callback { private String hostName; private String sharedSecret; private int authPort; private int acctPort; private String callingStationID; private int numRetries; private int reqTimeout; public String getHostName() { return hostName; } public String getSharedSecret() { return sharedSecret; } public int getAuthPort() { return authPort; } public int getAcctPort() { return acctPort; } public String getCallingStationID() { return callingStationID; } public int getNumRetries() { return numRetries; } public int getTimeout(){ return reqTimeout; } public void setHostName(String hostName) { this.hostName = hostName; } public void setSharedSecret(String sharedSecret) { this.sharedSecret = sharedSecret; } public void setAuthPort(int authPort) { this.authPort = authPort; } public void setAcctPort(int acctPort) { this.acctPort = acctPort; } public void setCallingStationID(String callingStationId){ this.callingStationID = callingStationId; } public void setNumRetries(int numRetries) { if (numRetries <=0){ numRetries = 1; } this.numRetries = numRetries; } public void setTimeout(int seconds){ if (seconds < 0) { seconds = 0; } this.reqTimeout = seconds * 1000; } } --- NEW FILE: RadiusLoginHandler.java --- package net.sourceforge.jradiusclient.jaas; import java.io.IOException; import javax.security.auth.callback.Callback; import javax.security.auth.callback.CallbackHandler; import javax.security.auth.callback.NameCallback; import javax.security.auth.callback.PasswordCallback; import javax.security.auth.callback.TextInputCallback; import javax.security.auth.callback.UnsupportedCallbackException; import javax.security.auth.login.LoginContext; import javax.security.auth.login.LoginException; /** * Title: * Description: * Copyright: Copyright (c) 2003 * @author <a href="mailto:bl...@us...">Robert J. Loihl</a> * @version $Revision: 1.1 $ */ public class RadiusLoginHandler implements CallbackHandler { public static final String JAAS_MODULE_KEY = "JRadiusClientLoginModule"; /* fields for storing credentials */ private String name; private String password; private String clientIP; private String hostName; private String sharedSecret; private int authPort; private int acctPort; private String callingStationID; private int numRetries; private int timeout; /** * Constructor * @throws java.lang.IllegalArgumentException if any param is null */ public RadiusLoginHandler(final String name, final String password, final String clientIP, final String callingStationID, final String radiusHostname, final String sharedSecret, final int authPort, final int acctPort, final int retries, final int timeout) { if (name == null || password == null || clientIP == null) { throw new IllegalArgumentException("Arguments cannont be null"); } this.name = name; this.password = password; this.clientIP = clientIP; this.callingStationID = callingStationID; this.hostName = radiusHostname; this.sharedSecret = sharedSecret; this.authPort = authPort; this.acctPort = acctPort; this.numRetries = retries; this.timeout = timeout; } /** * If this method returns the login was successfull, but if it throws an * exception it failed. There are subclasses of LoginException for the * specific kinds of failures. */ public void login() throws LoginException { LoginContext loginContext = new LoginContext(JAAS_MODULE_KEY, this); loginContext.login(); } /** * Callback Handler for the login service * @param javax.security.auth.callback.Callback array of callback objects to * fill in with requested data * @throws java.io.IOException * @throws javax.security.auth.callback.UnsupportedCallbackException */ public void handle(Callback[] callback) throws IOException, UnsupportedCallbackException { for(int i = 0; i < callback.length; i++){ handle(callback[i]); } } protected void handle(Callback callback) throws UnsupportedCallbackException { if (callback instanceof NameCallback) { ((NameCallback)callback).setName(name); }else if (callback instanceof PasswordCallback) { ((PasswordCallback)callback).setPassword(password.toCharArray()); }else if (callback instanceof TextInputCallback) { // this code assumes that there will only be one TextInputCallback and it is used for the client IP ((TextInputCallback)callback).setText(clientIP); }else if (callback instanceof RadiusCallback) { RadiusCallback radiusCallback = (RadiusCallback)callback; radiusCallback.setHostName(this.hostName); radiusCallback.setSharedSecret(this.sharedSecret); radiusCallback.setAuthPort(this.authPort); radiusCallback.setAcctPort(this.acctPort); radiusCallback.setCallingStationID(this.callingStationID); radiusCallback.setNumRetries(this.numRetries); radiusCallback.setTimeout(this.timeout); }else { throw new UnsupportedCallbackException(callback); } } } --- NEW FILE: RadiusLoginModule.java --- package net.sourceforge.jradiusclient.jaas; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.net.SocketException; import java.net.UnknownHostException; import java.security.NoSuchAlgorithmException; import java.util.Map; import javax.security.auth.Subject; import javax.security.auth.callback.*; import javax.security.auth.spi.LoginModule; import javax.security.auth.login.AccountExpiredException; import javax.security.auth.login.CredentialExpiredException; import javax.security.auth.login.FailedLoginException; import javax.security.auth.login.LoginException; import net.sourceforge.jradiusclient.RadiusClient; import net.sourceforge.jradiusclient.exception.InvalidParameterException; import net.sourceforge.jradiusclient.exception.RadiusException; /** * This is an implementation of javax.security.auth.spi.LoginModule specific to * using a RADIUS Server for authentication. * @author <a href="mailto:bl...@us...">Robert J. Loihl</a> * @version $Revision: 1.1 $ */ public class RadiusLoginModule implements LoginModule { public static final int MAX_CHALLENGE_ATTEMPTS = 3; //initial state variables private Subject radiusSubject; private CallbackHandler callbackHandler; private Map sharedState; private Map moduleOptions; //private state of the authentication attempt private boolean authenticationSucceeded = false; private boolean authenticationCommitted = false; //state variables for this auth attempt private String userName; private RadiusPrincipal userPrincipal; private int challengedAttempts = 0; private RadiusClient radiusClient; /** * Method to abort the authentication process (phase 2). This method gets * called if the LoginContext's overall authentication process failed * (i.e. one of the relevant REQUIRED, REQUISITE, SUFFICIENT and OPTIONAL * <code>LoginModules</code> did not succeed). It also cleans up any * internal state saved by the login method. * @return boolean true if this method succeeds false if this * <code>LoginModule</code> should be ignored * @exception LoginException If the abort fails */ public boolean abort() throws LoginException{ if(!this.authenticationSucceeded){ return false; }else if(this.authenticationSucceeded && !this.authenticationCommitted){ //Radius authentication succeeded but overall authentication failed this.authenticationSucceeded = false; this.userName = null; this.radiusClient = null; this.userPrincipal = null; this.challengedAttempts = 0; }else{ //overall authentication succeeded and our commit succeeded, //but someone else's commit failed this.logout(); } return true; } /** * Method to commit the authentication process (phase 2). This method gets * called if the LoginContext's overall authentication process succeeded * (i.e. all of the relevant REQUIRED, REQUISITE, SUFFICIENT and OPTIONAL * <code>LoginModules</code> succeeded). * If this LoginModule's own authentication attempt succeeded (checked by * retrieving the private state saved by the login method), then this * method associates relevant Principals and Credentials with the Subject * located in the LoginModule. If this LoginModule's own authentication * attempt failed, then this method cleans up any internal state saved by * the login method. (TODO perform * a RADIUS accounting request to notify RADIUS server of login time.) * @return boolean true if this method succeeds false if this * <code>LoginModule</code> should be ignored * @exception LoginException If the commit action fails */ public boolean commit() throws LoginException{ if(!this.authenticationSucceeded){ return false; } else { //add a principal to the subject this.userPrincipal = new RadiusPrincipal(this.userName); if(!this.radiusSubject.getPrincipals().contains(this.userPrincipal)){ this.radiusSubject.getPrincipals().add(this.userPrincipal); } //now clean out state this.userName = null;//??? this.radiusClient = null;//???? this.challengedAttempts = 0; this.authenticationCommitted = true; } return true; } /** * Initialize this <code>LoginModule</code>. * This method is called by the LoginContext after this LoginModule has * been instantiated. The purpose of this method is to initialize this * LoginModule with the relevant information. If this LoginModule does not * understand any of the data stored in sharedState or options parameters, * they can be ignored. There MUST be the following parameters specified in * the options:<br> * <ul> * <li>hostname - the fully qualified name or IP address of the RADIUS Server</li> * <li>shared secret - the secret shared between us and the RADIUS Server</li> * </ul> * The following parameters MAY be specified, but they must be supplied together:<br> * <ul> * <li>Authenication Port - The port the RADIUS Server is listening on for * authentication</li> * <li>Accounting Port - The port the RADIUS Server is listening on for * accounting requests</li> * </ul> * @param subject javax.security.auth.Subject * @param callbackHandler javax.security.auth.callback.CallbackHandler * @param sharedState java.util.Map * @param options java.util.Map */ public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) { this.radiusSubject = subject; this.callbackHandler = callbackHandler; this.sharedState = sharedState; this.moduleOptions = options; } /** * Authenticates this Subject against a RADIUS Server (phase 1). It uses * the callbacks to request a UserName and a Password, and possibly requests * a response to a challenge recieved from the RADIUS server. * @return boolean True if this <code>LoginModule</code> succeeds, False if * this <code>LoginModule</code> should be ignored * @exception FailedLoginException if the login fails * @exception LoginException If this <code>LoginModule</code> can't perform * the requested authentication */ public boolean login() throws LoginException{ //perform callbacks if (this.callbackHandler == null) { throw new LoginException("Error: No callback handler installed to gather username and password."); } // create callbacks NameCallback nameCallback = new NameCallback("User Name: "); PasswordCallback passwordCallback = new PasswordCallback("Password: ",true);//turn on password echo(?) RadiusCallback radiusCallback = new RadiusCallback(); Callback[] callbacks = new Callback[3]; callbacks[0] = nameCallback; callbacks[1] = passwordCallback; callbacks[2] = radiusCallback; try { // send callbacks to callback handler this.callbackHandler.handle(callbacks); } catch(IOException ioex) { throw new LoginException(ioex.getMessage()); } catch(UnsupportedCallbackException uscbex) { StringBuffer sb = new StringBuffer("Error: callback "); sb.append(uscbex.getCallback().toString()); sb.append(" not supported."); throw new LoginException(sb.toString()); } this.userName = nameCallback.getName(); char[] userPassword = passwordCallback.getPassword(); if(userPassword == null){ //treat a null password as a zero length password userPassword = new char[0]; } //finally clear the password passwordCallback.clearPassword(); //now authenticate try{ this.radiusClient = new RadiusClient(radiusCallback.getHostName(), radiusCallback.getAuthPort(), radiusCallback.getAcctPort(), radiusCallback.getSharedSecret(), this.userName, radiusCallback.getTimeout()); this.authenticate(userPassword, radiusCallback.getCallingStationID(), radiusCallback.getNumRetries() ); }catch(InvalidParameterException ivpex){ StringBuffer sb1 = new StringBuffer("Configuration of the RADIUS client is incorrect. "); sb1.append(ivpex.getMessage()); throw new LoginException(sb1.toString()); }catch(SocketException sex){ StringBuffer sb2 = new StringBuffer("Configuration of the RADIUS client is incorrect. "); sb2.append(sex.getMessage()); throw new LoginException(sb2.toString()); }catch(NoSuchAlgorithmException nsaex){ StringBuffer sb3 = new StringBuffer("Configuration of the RADIUS client is incorrect. "); sb3.append(nsaex.getMessage()); throw new LoginException(sb3.toString()); } //finally clear the password in memory for(int i = 0; i < userPassword.length;i++){ userPassword[i] = ' '; } userPassword = null; this.authenticationSucceeded = true; //everything went well, return true return true; } /** * Authenticates this Subject against a RADIUS Server (phase 1). It may request * a response to a challenge recieved from the RADIUS server. It will do this * using a single PasswordCallback with the Challenge message as the prompt. * @exception FailedLoginException if the login fails * @exception LoginException If this <code>LoginModule</code> can't perform * the requested authentication */ private void authenticate(char[] password, String callingStationID, int numRetries) throws LoginException { try { ByteArrayOutputStream requestAttributes = null; if(callingStationID != null){ requestAttributes = new ByteArrayOutputStream(); try{ this.radiusClient.setUserAttribute(RadiusClient.CALLING_STATION_ID, callingStationID.getBytes(), requestAttributes); }catch(InvalidParameterException ivpex){ //only get this if setting to a type of RadiusClient.USER_NAME, //RadiusClient.USER_PASSWORD, RadiusClient.NAS_IDENTIFIER, or RadiusClient.STATE //set requestAttributes back to null and try anyway requestAttributes = null; } } //requestAttributes can be null, the radiusClient.authenticate method checks for this and handles it fine - BL switch (this.radiusClient.authenticate(String.valueOf(password), requestAttributes, numRetries)) { case RadiusClient.ACCESS_ACCEPT: //SUCCESS!!!! break; case RadiusClient.ACCESS_REJECT: throw new CredentialExpiredException("Incorrect User Name or Password."); case RadiusClient.ACCESS_CHALLENGE: if (this.challengedAttempts > RadiusLoginModule.MAX_CHALLENGE_ATTEMPTS) { this.challengedAttempts = 0; throw new LoginException("Maximum number of challenge retries exceeded."); } Callback[] callbacks = new Callback[1]; callbacks[0] = new PasswordCallback(this.radiusClient.getChallengeMessage(),true); try { this.callbackHandler.handle(callbacks); password = ((PasswordCallback)callbacks[0]).getPassword(); if (password == null) { //treat a null password as a zero length password password = new char[0]; } //finally clear the password ((PasswordCallback)callbacks[0]).clearPassword(); } catch(IOException ioex) { throw new LoginException(ioex.getMessage()); } catch(UnsupportedCallbackException uscbex) { StringBuffer sb = new StringBuffer("Error: callback "); sb.append(uscbex.getCallback().toString()); sb.append(" not supported."); throw new LoginException(sb.toString()); } //do this first so that we are actually incrementing the BEFORE //we get recursive this.challengedAttempts++; this.authenticate(password, callingStationID, 1); break; default: throw new LoginException("Received an Invalid response from the RADIUS Server."); } } catch(InvalidParameterException ivpex) { throw new LoginException(ivpex.getMessage()); } catch(UnknownHostException uhex) { throw new LoginException(uhex.getMessage()); } catch(IOException ioex) { throw new LoginException(ioex.getMessage()); } catch(RadiusException rex) { throw new LoginException(rex.getMessage()); } } /** * This method logs out a Subject (TODO perform * a RADIUS accounting request to notify RADIUS server of logout time.) * @return boolean return true if the logout was successful, False if * this <code>LoginModule</code> should be ignored * @exception LoginException if the logout fails. */ public boolean logout() throws LoginException { this.radiusSubject.getPrincipals().remove(this.userPrincipal); this.authenticationCommitted = false; this.authenticationSucceeded = false; this.userName = null; this.radiusClient = null; this.userPrincipal = null; this.challengedAttempts = 0; return true; } } --- NEW FILE: RadiusPrincipal.java --- package net.sourceforge.jradiusclient.jaas; import java.security.Principal; /** * * @author <a href="mailto:bl...@us...">Robert J. Loihl</a> * @version $Revision: 1.1 $ */ public class RadiusPrincipal implements Principal{ private String principalName; /** * Constructs RadiusPrincipal objects * @param name java.lang.String The name of this principal */ public RadiusPrincipal(String name){ if (name == null){ throw new NullPointerException("Illegal name input, name cannot be null."); } this.principalName = name; } /** * Gets the name of this <code>RadiusPrincipal</code> * @return java.lang.String The name of this <code>RadiusPrincipal</code> */ public String getName(){ return this.principalName; } /** * This method returns a string representation of this * <code>RadiusPrincipal</code>. * * @return a string representation of this <code>RadiusPrincipal</code>. */ public String toString(){ return this.getName(); } /** * Compares the specified Object with this <code>RadiusPrincipal</code> * for equality. Returns true if the given object is also a * <code>RadiusPrincipal</code> and the two RadiusPrincipal * have the same username. * @param object Object to be compared for equality with this * <code>RadiusPrincipal</code>. * * @return true if the specified Object is equal to this * <code>RadiusPrincipal</code>. */ public boolean equals(Object object){ if (object == null){ return false; } if (this == object){ return true; } if (!(object instanceof RadiusPrincipal)){ return false; } RadiusPrincipal that = (RadiusPrincipal)object; if (this.getName().equals(that.getName())){ return true; } return true; } /** * @return int the hashCode for this <code>RadiusPrincipal</code> */ public int hashCode(){ return this.principalName.hashCode(); } } |
|
From: <ko...@us...> - 2004-03-09 16:22:52
|
Update of /cvsroot/cobricks/cobricks2/src/org/cobricks/user In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23085/org/cobricks/user Added Files: LdapUserHandler.java Log Message: --- NEW FILE: LdapUserHandler.java --- /* * Copyright (c) 2004 Cobricks Group. All rights reserved. * * This file is part of a free software package; you can redistribute * it and/or modify it under the terms of the Cobricks Software Licence; * either version 1.0 of the License, or (at your option) any later * version (see www.cobricks.org). * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. */ package org.cobricks.user; import java.util.*; import javax.naming.*; import javax.naming.directory.*; import org.apache.log4j.Logger; import org.cobricks.core.CoreManager; import org.cobricks.core.util.LogUtil; /** * User handler that imports user data from a LDAP directory and that * authenticates accounts versus the LDAP directory. * * @author mic...@ac... * @version $Date: 2004/03/09 15:57:40 $ */ public class LdapUserHandler implements UserHandler { static Logger logger = Logger.getLogger(LdapUserHandler.class); protected CoreManager coreManager; protected UserManager userManager; protected String domain; protected Properties env; protected DirContext dirContext; /** * */ public void init(String domain, CoreManager coreManager) { this.domain = domain; this.coreManager = coreManager; this.userManager = (UserManager) coreManager.getComponentDirectory().getManager("userManager"); env = System.getProperties(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); String providerurl = coreManager.getProperty("user.domain."+domain+".ldap.providerurl"); if (providerurl == null) { logger.error("no providerurl for LdapUserHandler for domain "+domain); return; } env.put(Context.PROVIDER_URL, providerurl); /* specify authentication information */ env.put(Context.SECURITY_AUTHENTICATION, "simple"); String securityprincipal = coreManager.getProperty("user.domain."+domain+".ldap.security.principal"); String securitycredentials = coreManager.getProperty("user.domain."+domain+".ldap.security.credentials"); env.put(Context.SECURITY_PRINCIPAL, securityprincipal); env.put(Context.SECURITY_CREDENTIALS, securitycredentials); try { dirContext = new InitialDirContext(env); } catch (Exception e) { logger.error(LogUtil.ex("Failed initializing directory context.", e)); } } /** * */ public User handleUnknownUser(String userlogin) { logger.info("handleUnknownUser("+userlogin+")"); try { Map attrs = searchUser(userlogin); // tbd import attributes Map uattrs = new HashMap(); User user = userManager.createUser(userlogin, uattrs); return user; } catch (Exception e) { logger.error(LogUtil.ex("Failed in searchUser("+userlogin+")", e)); } return null; } /** * Load attributes from LDAP directory */ protected Map searchUser(String userlogin) throws Exception { Map result = new HashMap(); // search login in directory Attributes matchAttrs = new BasicAttributes(true); matchAttrs.put(new BasicAttribute("login", userlogin)); NamingEnumeration answer = dirContext.search("", matchAttrs); if (answer.hasMore()) { // tbd: copy attributes to result } return result; } /** * */ public void handleGetUser(User user) { } /** * */ public boolean handleCheckCredential(User user, Object credential) { String userlogin = user.getUserLogin(); logger.info("handleCheckCredential("+userlogin+")"); // check authentication try { Properties tmpEnv = System.getProperties(); tmpEnv.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); String providerurl = coreManager.getProperty("user.domain."+domain+".ldap.providerurl"); tmpEnv.put(Context.PROVIDER_URL, providerurl); tmpEnv.put(Context.SECURITY_AUTHENTICATION, "simple"); tmpEnv.put(Context.SECURITY_PRINCIPAL, ""); // "mwnID="+mwnId+",ou=tum,o=lrz-muenchen,c=de"); env.put(Context.SECURITY_CREDENTIALS, credential.toString()); DirContext tmpDirContext = new InitialDirContext(env); } catch (Exception e) { // javax.naming.AuthenticationException: // [LDAP: error code 32 - NDS error: no such entry (-601)] // javax.naming.AuthenticationException: // [LDAP: error code 49 - NDS error: failed authentication (-669)] return false; } return true; } } |
|
From: <ko...@us...> - 2004-03-09 16:21:15
|
Update of /cvsroot/cobricks/cobricks2/src/net/sourceforge/jradiusclient/jaas In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22666/jaas Log Message: Directory /cvsroot/cobricks/cobricks2/src/net/sourceforge/jradiusclient/jaas added to the repository |
|
From: <ko...@us...> - 2004-03-09 16:21:15
|
Update of /cvsroot/cobricks/cobricks2/src/net/sourceforge/jradiusclient/exception In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22666/exception Log Message: Directory /cvsroot/cobricks/cobricks2/src/net/sourceforge/jradiusclient/exception added to the repository |
|
From: <ko...@us...> - 2004-03-09 16:19:34
|
Update of /cvsroot/cobricks/cobricks2/src/net/sourceforge/jradiusclient In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22094/jradiusclient Log Message: Directory /cvsroot/cobricks/cobricks2/src/net/sourceforge/jradiusclient added to the repository |
|
From: <ko...@us...> - 2004-03-09 16:19:14
|
Update of /cvsroot/cobricks/cobricks2/src/net/sourceforge In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21959/sourceforge Log Message: Directory /cvsroot/cobricks/cobricks2/src/net/sourceforge added to the repository |
|
From: <i_z...@us...> - 2004-03-09 16:16:17
|
Update of /cvsroot/cobricks/cobricks2/src/org/cobricks/user In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21398/src/org/cobricks/user Modified Files: FormConstants.java Log Message: Index: FormConstants.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/user/FormConstants.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** FormConstants.java 11 Feb 2004 14:06:14 -0000 1.1 --- FormConstants.java 9 Mar 2004 15:51:06 -0000 1.2 *************** *** 12,15 **** --- 12,18 ---- /* * $Log$ + * Revision 1.2 2004/03/09 15:51:06 i_zhitomirskaja + * *** empty log message *** + * * Revision 1.1 2004/02/11 14:06:14 kochm * *** empty log message *** *************** *** 59,65 **** //search formular ! public static final String IS_EQUAL = "ist_gleich"; ! public static final String LIKE = "like"; ! public static final String COMARISON_FUNCTION = "compare_func_"; public static final String SORT = "sort"; --- 62,68 ---- //search formular ! // public static final String IS_EQUAL = "ist_gleich"; ! // public static final String LIKE = "like"; ! public static final String COMPARISON_FUNCTION = "compare_func_"; public static final String SORT = "sort"; |
|
From: <ko...@us...> - 2004-03-09 16:11:42
|
Update of /cvsroot/cobricks/cobricks2/src/net In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20005/net Log Message: Directory /cvsroot/cobricks/cobricks2/src/net added to the repository |
|
From: <i_z...@us...> - 2004-03-09 12:33:35
|
Update of /cvsroot/cobricks/cobricks2/src/org/cobricks/user In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29061/src/org/cobricks/user Modified Files: UserServlet.java Log Message: e_mail sending by creating of user Index: UserServlet.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/user/UserServlet.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** UserServlet.java 11 Feb 2004 14:06:14 -0000 1.1 --- UserServlet.java 9 Mar 2004 12:08:31 -0000 1.2 *************** *** 1,5 **** /** ! * Servlet for the User Component - handling the update tasks of the components ! * Web user interface * * @acm.org --- 1,5 ---- /** ! * Servlet for the User Component - handling the update tasks of the ! * components Web user interface * * @acm.org *************** *** 21,24 **** --- 21,29 ---- import java.util.regex.Pattern; + import org.apache.log4j.*; + + import org.apache.velocity.Template; + import org.apache.velocity.app.Velocity; + import org.cobricks.core.ComponentDirectory; import org.cobricks.core.ComponentManagerInterface; *************** *** 31,39 **** import org.cobricks.portal.PortalUser; - import org.apache.log4j.*; - - import org.apache.velocity.Template; - import org.apache.velocity.app.Velocity; - public class UserServlet extends PortalServletAdaptor { --- 36,39 ---- *************** *** 78,82 **** super.init(config); ! this.addTarget(FormConstants.REGISTER_CMD, "performRegister", "", false); this.addTarget("registeradmin", "performRegisterAdmin", "", false); this.addTarget("createrole", "performCreateRole", "", true); --- 78,83 ---- super.init(config); ! this.addTarget(FormConstants.REGISTER_CMD, "performRegister", "", ! false); this.addTarget("registeradmin", "performRegisterAdmin", "", false); this.addTarget("createrole", "performCreateRole", "", true); *************** *** 89,93 **** ComponentDirectory componentDirectory = coreManager .getComponentDirectory(); ! userManager = (UserManager)componentDirectory.getManager("userManager"); if (userManager == null) { --- 90,95 ---- ComponentDirectory componentDirectory = coreManager .getComponentDirectory(); ! userManager = (UserManager)componentDirectory.getManager( ! "userManager"); if (userManager == null) { *************** *** 272,281 **** String fromAddr = coreManager.getProperty( "message.email.defaultfrom"); ! String emailAddr = "iri...@ya..."; String subjectOfMail = "Cobricks Registrierung"; String contentOfMail = "Sie haben sich bei der Cobricks Plattform registriert " ! + "Ihr Benutzername ist " + userLogin ! + "Ihr Passwort lautet " + pswd; logger.debug("befor e-mail sending"); --- 274,283 ---- String fromAddr = coreManager.getProperty( "message.email.defaultfrom"); ! String emailAddr = email; String subjectOfMail = "Cobricks Registrierung"; String contentOfMail = "Sie haben sich bei der Cobricks Plattform registriert " ! + " Ihr Benutzername ist " + userLogin ! + " Ihr Passwort lautet " + pswd; logger.debug("befor e-mail sending"); *************** *** 329,332 **** --- 331,364 ---- logger.info("performSearch"); + // check access rights + PortalUser portalUser = prequest.getPortalUser(); + + /* + if (!userManager.getAccessControl(). + checkPermission(portalUser.getUserId(), + "user", "search", null)) { + prequest.setReturnCode(2000); + return "noaccess"; + } + */ + Map conditions = new HashMap(); + conditions.put("1", "="); + conditions.put("2", "~"); + conditions.put("3", ">"); + conditions.put("4", "<"); + conditions.put("5", ">="); + conditions.put("6", "<="); + + Map sortBys = new HashMap(); + sortBys.put("1", User.USERLOGIN); + sortBys.put("2", User.LASTNAME); + sortBys.put("3", User.FIRSTNAME); + sortBys.put("4", " basic.status "); + sortBys.put("5", User.EMAIL); + sortBys.put("6", " basic.title "); + + String aname; + Set avalueSet; + try { Map attrs = new HashMap(); *************** *** 339,352 **** allIsNull = false; ! String cond = prequest.getRequestParameter(FormConstants.COMARISON_FUNCTION .concat(FormConstants.USERLOGIN)); ! StringTokenizer commaToken = new StringTokenizer(userLogin, ","); if (commaToken.countTokens() > 1) { ! cond = FormConstants.IS_EQUAL; ! } ! userLogin.trim().concat(cond); ! attrs.put(User.USERLOGIN, userLogin); } --- 371,396 ---- allIsNull = false; ! String cond = prequest.getRequestParameter(FormConstants.COMPARISON_FUNCTION .concat(FormConstants.USERLOGIN)); ! StringTokenizer commaToken = new StringTokenizer(userLogin, ! ","); ! String cond_1 = (String)conditions.get(cond); if (commaToken.countTokens() > 1) { ! avalueSet = new HashSet(); ! cond_1 = (String)conditions.get("1"); ! while (commaToken.hasMoreTokens()) { ! avalueSet.add(commaToken.nextToken()); ! } ! ! aname = User.USERLOGIN.trim().concat(cond_1); ! ! attrs.put(aname, avalueSet); ! } else { ! aname = User.USERLOGIN.trim().concat(cond_1); ! ! attrs.put(aname, userLogin); ! } } *************** *** 357,370 **** allIsNull = false; ! String cond = prequest.getRequestParameter(FormConstants.COMARISON_FUNCTION .concat(FormConstants.FIRST_NAME)); ! StringTokenizer commaToken = new StringTokenizer(firstName, ","); if (commaToken.countTokens() > 1) { ! cond = FormConstants.IS_EQUAL; } ! firstName.trim().concat(cond); ! attrs.put(User.FIRSTNAME, firstName); } --- 401,419 ---- allIsNull = false; ! String cond = prequest.getRequestParameter(FormConstants.COMPARISON_FUNCTION .concat(FormConstants.FIRST_NAME)); ! logger.debug("cond = " + cond); ! ! StringTokenizer commaToken = new StringTokenizer(firstName, ! ","); if (commaToken.countTokens() > 1) { ! cond = (String)conditions.get("1"); ! ; } ! aname = User.FIRSTNAME.trim().concat((String)conditions.get( ! cond)); ! attrs.put(aname, firstName); } *************** *** 375,388 **** allIsNull = false; ! String cond = prequest.getRequestParameter(FormConstants.COMARISON_FUNCTION .concat(FormConstants.LAST_NAME)); StringTokenizer commaToken = new StringTokenizer(lastName, ","); if (commaToken.countTokens() > 1) { ! cond = FormConstants.IS_EQUAL; } ! lastName.trim().concat(cond); ! attrs.put(User.LASTNAME, lastName); } --- 424,438 ---- allIsNull = false; ! String cond = prequest.getRequestParameter(FormConstants.COMPARISON_FUNCTION .concat(FormConstants.LAST_NAME)); StringTokenizer commaToken = new StringTokenizer(lastName, ","); if (commaToken.countTokens() > 1) { ! cond = (String)conditions.get("1"); } ! aname = User.LASTNAME.trim().concat((String)conditions.get( ! cond)); ! attrs.put(aname, lastName); } *************** *** 400,404 **** for (Iterator i = moreAttrs.iterator(); i.hasNext();) { ! String aname = ((String)i.next()); //???how can I detect the type of attr??? --- 450,454 ---- for (Iterator i = moreAttrs.iterator(); i.hasNext();) { ! aname = ((String)i.next()); //???how can I detect the type of attr??? *************** *** 408,412 **** allIsNull = false; ! String cond = prequest.getRequestParameter(FormConstants.COMARISON_FUNCTION .concat(aname)); StringTokenizer commaToken = new StringTokenizer(avalue, --- 458,462 ---- allIsNull = false; ! String cond = prequest.getRequestParameter(FormConstants.COMPARISON_FUNCTION .concat(aname)); StringTokenizer commaToken = new StringTokenizer(avalue, *************** *** 414,422 **** if (commaToken.countTokens() > 1) { ! cond = FormConstants.IS_EQUAL; } ! avalue.trim().concat(cond); ! attrs.put(aname, avalue); } } --- 464,472 ---- if (commaToken.countTokens() > 1) { ! cond = (String)conditions.get("1"); } ! attrs.put(aname.trim().concat((String)conditions.get( ! cond)), avalue); } } *************** *** 436,445 **** //ERROR: one search criteria must be entered at least. - if (allIsNull) { - prequest.setReturnCode(1001); - - return "error"; - } boolean orFlag = true; --- 486,496 ---- //ERROR: one search criteria must be entered at least. + /* + if (allIsNull) { + prequest.setReturnCode(1001); + return "error"; + } + */ boolean orFlag = true; *************** *** 448,459 **** } ! String sortBy = prequest.getRequestParameter(FormConstants.SORT); ! List result = userManager.getUserIdList(attrs, orFlag); ! if (result == null) ! { ! prequest.setReturnCode(1002); ! return "error"; } - // List result = userManager.getUserIdList(attrs, orFlag, sortBy); --- 499,511 ---- } ! String sortBy = (String)sortBys.get(prequest.getRequestParameter( ! FormConstants.SORT)); ! List result = userManager.getUserIdList(attrs, orFlag, sortBy); ! ! if (result == null) { ! prequest.setReturnCode(1002); ! ! return "error"; } // List result = userManager.getUserIdList(attrs, orFlag, sortBy); *************** *** 464,467 **** --- 516,527 ---- } + for (Iterator i = result.iterator(); i.hasNext();) { + if (logger.isDebugEnabled()) { + logger.debug(i.next()); + } + } + + prequest.setContextObject("res", result); + return "success"; } catch (Exception e) { *************** *** 599,604 **** // standard attributes ! if (userManager.getAccessControl().checkPermission(portalUser.getUserId(), ! "userrole", "update", null)) { String rolename = prequest.getRequestParameter("rolename"); String roledescr = prequest.getRequestParameter("roledescription"); --- 659,664 ---- // standard attributes ! if (userManager.getAccessControl().checkPermission(portalUser ! .getUserId(), "userrole", "update", null)) { String rolename = prequest.getRequestParameter("rolename"); String roledescr = prequest.getRequestParameter("roledescription"); *************** *** 713,717 **** return "editperm"; } else if (subcmd.equals("Update User Assignments")) { ! String roleusers[] = prequest.getRequestParameterValues("roleusers"); Collection users = accessControl.getAccessRoleUsers(roleid); --- 773,778 ---- return "editperm"; } else if (subcmd.equals("Update User Assignments")) { ! String roleusers[] = prequest.getRequestParameterValues( ! "roleusers"); Collection users = accessControl.getAccessRoleUsers(roleid); *************** *** 768,772 **** if (!userManager.getAccessControl().checkPermission(portalUser ! .getUserId(), "userrole", "assignuser", attrsmap)) { prequest.setReturnCode(2000); --- 829,834 ---- if (!userManager.getAccessControl().checkPermission(portalUser ! .getUserId(), "userrole", "assignuser", ! attrsmap)) { prequest.setReturnCode(2000); |
|
From: <a_...@us...> - 2004-03-08 21:22:34
|
Update of /cvsroot/cobricks/cobricks2/src/org/cobricks/item In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17975/src/org/cobricks/item Modified Files: Item.java ItemManagerImpl.java Log Message: Index: Item.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/item/Item.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Item.java 6 Mar 2004 21:35:04 -0000 1.7 --- Item.java 8 Mar 2004 20:57:59 -0000 1.8 *************** *** 20,23 **** --- 20,24 ---- import java.text.DateFormat; + import java.text.SimpleDateFormat; import java.util.*; *************** *** 308,319 **** public String getItemAsXML(boolean withAnnotations, boolean withAttachments) { logger.debug("getItemAsXML"); ! //String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<item>\n" + ! String xml = "<?xml version=\"1.0\" encoding=\"" + this.xmlEncoding + "\"?>\n<item>\n" + " <itemid>" + new Integer(this.itemid).toString() + "</itemid>\n" + " <globalid>" + this.globalid + "</globalid>\n " ! + "<itemclass>" + this.getItemClass() + "</itemclass>\n"; // tbd: + defaultLanguage? --- 309,320 ---- public String getItemAsXML(boolean withAnnotations, boolean withAttachments) { logger.debug("getItemAsXML"); ! StringBuffer xml = new StringBuffer(); //String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<item>\n" + ! xml.append( "<?xml version=\"1.0\" encoding=\"" + this.xmlEncoding + "\"?>\n<item>\n" + " <itemid>" + new Integer(this.itemid).toString() + "</itemid>\n" + " <globalid>" + this.globalid + "</globalid>\n " ! + "<itemclass>" + this.getItemClass() + "</itemclass>\n"); // tbd: + defaultLanguage? *************** *** 328,332 **** if (part != null) { ! xml += (" " + part); } } else { --- 329,333 ---- if (part != null) { ! xml.append(" " + part); } } else { *************** *** 344,350 **** } ! xml += "</item>"; ! return xml; } --- 345,351 ---- } ! xml.append("</item>"); ! return xml.toString(); } *************** *** 390,398 **** protected String getItemAttributeAsXML(String attribute, boolean withXMLDeclaration, Object value) { ! String xml = ""; if (withXMLDeclaration) { ! xml = "<?xml version=\"1.0\" encoding=\"" + this.xmlEncoding ! + "\"?>\n"; } --- 391,399 ---- protected String getItemAttributeAsXML(String attribute, boolean withXMLDeclaration, Object value) { ! StringBuffer xml = new StringBuffer(); if (withXMLDeclaration) { ! xml.append("<?xml version=\"1.0\" encoding=\"" + this.xmlEncoding ! + "\"?>\n"); } *************** *** 403,423 **** } ! // Handling multilanguage attributes ! if (attribute.matches(".+_..")) { // multilanguage attribute int pos = attribute.lastIndexOf("_"); ! String lang = attribute.substring(pos + 1); //tbd length=2, kleingeschrieben attribute = attribute.substring(0, pos); ! xml += ("<" + attribute + " lang=\"" + lang + "\""); } else { // no multilanguage attribute ! xml += ("<" + attribute); } if (value instanceof String) { ! xml += (">" + value + "</" + attribute + ">\n"); ! if (ItemAttrs.checkWellFormedXML(xml).length() > 0) { logger.warn( "getItemAttributeAsXML: Value of XML Attribute " --- 404,424 ---- } ! // handling multilanguage attributes ! if (attribute.matches(".+_[a-z]{2}")) { // multilanguage attribute int pos = attribute.lastIndexOf("_"); ! String lang = attribute.substring(pos + 1); attribute = attribute.substring(0, pos); ! xml.append("<" + attribute + " lang=\"" + lang + "\""); } else { // no multilanguage attribute ! xml.append("<" + attribute); } if (value instanceof String) { ! xml.append(">" + value + "</" + attribute + ">\n"); ! if (ItemAttrs.checkWellFormedXML(xml.toString()).length() > 0) { logger.warn( "getItemAttributeAsXML: Value of XML Attribute " *************** *** 438,471 **** return null; } ! String name = "string"; ! int count = 1; ! xml += ">\n"; ! ! Object temp = ! getItemAttributeAsXML(name.concat(Integer.toString(count)), ! false, obj); if (temp != null) { ! xml += (" " + temp); ! } else { ! count--; } ! while (i.hasNext()) { ! count++; ! obj = i.next(); ! temp = ! getItemAttributeAsXML(name.concat(Integer.toString( ! count)), false, obj); if (temp != null) { ! xml += (" " + temp); ! } else { ! count--; } } ! xml += (" </" + attribute + ">\n"); } else if (value instanceof Set) { Iterator i = ((Set) value).iterator(); --- 439,460 ---- return null; } + + xml.append(">\n"); ! Object temp = getItemAttributeAsXML("string", false, obj); if (temp != null) { ! xml.append(" " + temp); } ! while (i.hasNext()) { ! temp = getItemAttributeAsXML("string", false, i.next()); if (temp != null) { ! xml.append(" " + temp); } } ! xml.append(" </" + attribute + ">\n"); } else if (value instanceof Set) { Iterator i = ((Set) value).iterator(); *************** *** 489,546 **** return null; } ! int count = 1; ! xml += ">\n"; ! ! Object temp = ! getItemAttributeAsXML(name.concat(Integer.toString(count)), ! false, obj); if (temp != null) { ! xml += (" " + temp); ! } else { ! count--; } ! ! while (i.hasNext()) { ! count++; ! obj = i.next(); ! temp = ! getItemAttributeAsXML(name.concat(Integer.toString( ! count)), false, obj); if (temp != null) { ! xml += (" " + temp); ! } else { ! count--; } } ! xml += (" </" + attribute + ">\n"); } else if (value instanceof Boolean) { ! xml += (">" + ((Boolean) value).toString() + "</" + attribute + ">\n"); } else if (value instanceof User) { ! xml += (" id=\"" + new Integer(((User) value).getId()).toString() + "\">" + value.toString() + "</" + attribute + ">\n"); } else if (value instanceof Category) { ! xml += (" id=\"" + new Integer(((Category) value).getCategoryId()).toString() + "\">" + value.toString() + "</" + attribute + ">\n"); } else if (value instanceof Item) { ! xml += (" id=\"" + new Integer(((Item) value).getLocalId()).toString() + "\">" + value.toString() + "</" + attribute + ">\n"); } else if (value instanceof Timestamp) { ! xml += (">" ! + ((Timestamp) value).toString() // tbd: special formatting ! + "</" + attribute + ">\n"); } else if (value instanceof Date) { DateFormat dateFormat = DateFormat.getDateInstance(); ! xml += (">" + dateFormat.format(value) + "</" + attribute + ">\n"); } else if (value instanceof Integer) { ! xml += (">" + ((Integer) value).toString() + "</" + attribute + ">\n"); } else { --- 478,523 ---- return null; } + + xml.append(">\n"); ! Object temp = getItemAttributeAsXML(name, false, obj); if (temp != null) { ! xml.append(" " + temp); } ! ! while (i.hasNext()) { ! temp = getItemAttributeAsXML(name, false, i.next()); if (temp != null) { ! xml.append(" " + temp); } } ! xml.append(" </" + attribute + ">\n"); } else if (value instanceof Boolean) { ! xml.append(">" + ((Boolean) value).toString() + "</" + attribute + ">\n"); } else if (value instanceof User) { ! xml.append(" id=\"" + new Integer(((User) value).getId()).toString() + "\">" + value.toString() + "</" + attribute + ">\n"); } else if (value instanceof Category) { ! xml.append(" id=\"" + new Integer(((Category) value).getCategoryId()).toString() + "\">" + value.toString() + "</" + attribute + ">\n"); } else if (value instanceof Item) { ! xml.append(" id=\"" + new Integer(((Item) value).getLocalId()).toString() + "\">" + value.toString() + "</" + attribute + ">\n"); } else if (value instanceof Timestamp) { ! DateFormat format = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"); ! xml.append(">" + format.format(value) + "</" + attribute + ">\n"); } else if (value instanceof Date) { DateFormat dateFormat = DateFormat.getDateInstance(); ! xml.append(">" + dateFormat.format(value) + "</" + attribute + ">\n"); } else if (value instanceof Integer) { ! xml.append(">" + ((Integer) value).toString() + "</" + attribute + ">\n"); } else { *************** *** 551,555 **** } ! return xml; } catch (Exception e) { logger.warn(LogUtil.exception("getItemAttributeAsXML: Failed " --- 528,532 ---- } ! return xml.toString(); } catch (Exception e) { logger.warn(LogUtil.exception("getItemAttributeAsXML: Failed " Index: ItemManagerImpl.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/item/ItemManagerImpl.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ItemManagerImpl.java 6 Mar 2004 23:34:20 -0000 1.8 --- ItemManagerImpl.java 8 Mar 2004 20:57:59 -0000 1.9 *************** *** 36,40 **** --- 36,44 ---- import java.sql.Timestamp; import java.text.DateFormat; + import java.text.SimpleDateFormat; + import java.util.*; + import java.util.regex.Matcher; + import java.util.regex.Pattern; import java.util.Map; import java.util.Set; *************** *** 322,325 **** --- 326,411 ---- } + // public List searchItems(String query) { + // logger.info("searchItems(" + query + ")"); + // + // String xPath = mapQueryToXPath(query); + // //tbd + // List items = FunktionVonJohannesDieItemsZurückgibt(xPath); + // List list = new ArrayList(); + // Item i = new Item(defaultLanguage); + // i.setTitle("titel des items ..."); + // list.add(i); + // + // return new ArrayList(); + // } + + private String mapQueryToXPath(String query) { + // I. substitute all datetimespans in the query + String xPath = query; + Pattern today = + Pattern.compile("(?i)(\\w+)(= | != | < | > | <= | >=)TODAY([-+]\\d+)?"); + Matcher m = today.matcher(xPath); + while (m.find()) { + String replacement = + handleDateTimeSpan( + m.group(), + m.group(1), + m.group(2), + m.group(3)); + m.replaceFirst(replacement); + } + + System.out.println("XPath: " + xPath); + + return null; + } + + private String handleDateTimeSpan( + String wholeMatch, + String tagName, + String cmpOperator, + String dayChange) { + if (cmpOperator.equals("=")) { + Calendar cal = Calendar.getInstance(); + Integer day = new Integer(cal.get(Calendar.DAY_OF_MONTH)); + Integer month = new Integer(cal.get(Calendar.MONTH)); + Integer year = new Integer(cal.get(Calendar.YEAR)); + + String date = + day.toString() + "." + month.toString() + "." + year.toString(); + //tbd: perhaps date isn't recognized correctly because of 0 + //(1.3.2004 or 01.03.2004) + return "starts-with(" + tagName + ", '" + date + "')"; + + } else { + //prepare a sql-query for the specified datetimespan and execute it + if (dayChange == null) { + dayChange = ""; + } + List listOfMaps = + this.dbAccess.sqlQuery("SELECT itemid FROM item WHERE TO_DAYS(" + + tagName + ")" + cmpOperator + "TO_DAYS(NOW())" + dayChange); + + //get the itemids + Iterator i = listOfMaps.iterator(); + while (i.hasNext()) { + Map mapOfItemids = (Map) i.next(); + Object o = mapOfItemids.get("itemid"); + if (o instanceof String) { + logger.info("handleDateImespan: o ist String"); + } + else if (o instanceof Integer) { + logger.info("handleDateImespan: o ist Integer"); + } + else { + logger.info("handleDateImespan: o ist was anderes"); + } + } + return null; + } + //tbd + + } + /** * @see org.cobricks.item.ItemManager#addItemAnnotation(org.cobricks.item. *************** *** 1009,1016 **** } ! /** * This method is a helper method for extractFromXMLDocument. It extracts * and returns an Object from a org.w3c.dom.Node. To handle String it calls ! * the handleString-method, to handle Integer it calls the method handleInt. * @param n The org.w3c.dom.Node that should be extracted * @param ontType The ontology data type for org.w3c.dom.Node n --- 1095,1102 ---- } ! /** * This method is a helper method for extractFromXMLDocument. It extracts * and returns an Object from a org.w3c.dom.Node. To handle String it calls ! * the handleString-method, to handle Integer it calls the method handleInt. * @param n The org.w3c.dom.Node that should be extracted * @param ontType The ontology data type for org.w3c.dom.Node n *************** *** 1081,1091 **** DateFormat dateFormat = DateFormat.getDateInstance(); ! return dateFormat.parse(n.getFirstChild().getNodeValue()); ! ! } else if (typeName.equals("datetime")) { //datetime (->Timestamp) ! return Timestamp.valueOf(n.getFirstChild().getNodeValue()); ! ! } else if ((typeName.equals("uri")) || (typeName.equals("text"))) { //uri or text (->String) --- 1167,1184 ---- DateFormat dateFormat = DateFormat.getDateInstance(); ! return dateFormat.parse(n.getFirstChild().getNodeValue()); ! } else if ( ! typeName.equals("datetime")) { //datetime (->Timestamp) ! DateFormat format = ! new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"); ! ! return new Timestamp( ! format ! .parse(n.getFirstChild().getNodeValue()) ! .getTime()); ! ! } else if ( ! (typeName.equals("uri")) || (typeName.equals("text"))) { //uri or text (->String) *************** *** 1115,1119 **** "extractFromXMLNode: Argument Node n isn't an instance " + "of Element"); ! */ return null; } --- 1208,1212 ---- "extractFromXMLNode: Argument Node n isn't an instance " + "of Element"); ! */ return null; } *************** *** 1208,1212 **** if (ontattr == null) { ! // Additional attribute or attribute that // wasn't defined in the itemontology value = extractFromXMLNode(child, new OntologyDataType("string")); --- 1301,1305 ---- if (ontattr == null) { ! // additional attribute or attribute that // wasn't defined in the itemontology value = extractFromXMLNode(child, new OntologyDataType("string")); *************** *** 1217,1240 **** + "additional (datatype = string)."); } else { ! // Attribute was defined in the itemontology ! OntologyDataType datatype = ontattr.getOntologyDataType(); String type = datatype.getTypeName(); if (type.equals("xml")) { ! // Attribute is of type XML value = extractFromXMLString(xml, tag); ! } else { //Attribute is non XML value = extractFromXMLNode(child, datatype); } ! //Try to get the correct language if ! //specified ! // tbd: if multilanguage==true abprüfen ! String lang = ! ((Element) child).getAttribute("lang"); ! ! if (!lang.equals("")) { //tbd length=2, kleingeschrieben ! // multilanguage string ! tag += ("_" + lang); } } --- 1310,1336 ---- + "additional (datatype = string)."); } else { ! // attribute was defined in the itemontology ! OntologyDataType datatype = ! ontattr.getOntologyDataType(); String type = datatype.getTypeName(); if (type.equals("xml")) { ! // attribute is of type XML value = extractFromXMLString(xml, tag); ! } else { //attribute is non XML value = extractFromXMLNode(child, datatype); } ! //handling multilanguage attributes ! if (ontattr.isMultiLanguage()) { ! String lang = ! ((Element) child).getAttribute("lang"); ! if (lang.matches("[a-z]{2}")) { ! tag += ("_" + lang); ! } else { ! logger.warn("extractFromXMLDocument: " ! + "language attribute isn't " ! + "valid."); ! } } } *************** *** 1263,1268 **** } } ! ! //Ende while-Schleife return attr; } else { --- 1359,1363 ---- } } ! return attr; } else { *************** *** 1280,1287 **** } ! /** * This method returns a HashMap consisting of the Objects described by the ! * String xml argument. In order to do this it creates a org.w3c.dom.Document ! * from the xml String and calls the method extractFromXMLDocument. * @param xml String to be parsed * @return HashMap filled with extracted Objects from xml --- 1375,1382 ---- } ! /** * This method returns a HashMap consisting of the Objects described by the ! * String xml argument. In order to do this it creates a org.w3c.dom.Document ! * from the xml String and calls the method extractFromXMLDocument. * @param xml String to be parsed * @return HashMap filled with extracted Objects from xml |
|
From: <j_m...@us...> - 2004-03-06 23:57:26
|
Update of /cvsroot/cobricks/cobricks2/src/org/cobricks/item In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4751/src/org/cobricks/item Modified Files: ItemManagerImpl.java ItemManager.java ItemPresenter.java ItemAttrs.java Log Message: getOntology Index: ItemManagerImpl.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/item/ItemManagerImpl.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ItemManagerImpl.java 6 Mar 2004 21:35:04 -0000 1.7 --- ItemManagerImpl.java 6 Mar 2004 23:34:20 -0000 1.8 *************** *** 250,254 **** } ! protected final Ontology getOntology() { return ontology; } --- 250,254 ---- } ! public final Ontology getOntology() { return ontology; } Index: ItemManager.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/item/ItemManager.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ItemManager.java 6 Mar 2004 21:35:04 -0000 1.3 --- ItemManager.java 6 Mar 2004 23:34:20 -0000 1.4 *************** *** 8,12 **** import org.cobricks.core.ComponentManagerInterface; ! //import org.cobricks.core.Ontology; /** * --- 8,12 ---- import org.cobricks.core.ComponentManagerInterface; ! import org.cobricks.core.Ontology; /** * *************** *** 96,100 **** // get HashMap of Objects from xml-input public Map extractFromXML(String xml); ! //public Ontology getOntology(); /** --- 96,100 ---- // get HashMap of Objects from xml-input public Map extractFromXML(String xml); ! public Ontology getOntology(); /** Index: ItemPresenter.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/item/ItemPresenter.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ItemPresenter.java 6 Mar 2004 21:35:04 -0000 1.4 --- ItemPresenter.java 6 Mar 2004 23:34:20 -0000 1.5 *************** *** 77,81 **** (ItemManager) coreManager.getComponentDirectory().getManager("itemManager"); this.coreManager = coreManager; ! ontology = ((ItemManagerImpl)itemManager).getOntology(); File file = new File((String) properties.get("configdir") + File.separator + "org.cobricks.item" + File.separator --- 77,81 ---- (ItemManager) coreManager.getComponentDirectory().getManager("itemManager"); this.coreManager = coreManager; ! ontology = (itemManager).getOntology(); File file = new File((String) properties.get("configdir") + File.separator + "org.cobricks.item" + File.separator Index: ItemAttrs.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/item/ItemAttrs.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ItemAttrs.java 6 Mar 2004 21:35:04 -0000 1.7 --- ItemAttrs.java 6 Mar 2004 23:34:20 -0000 1.8 *************** *** 1034,1038 **** String aname, String itemClassName) { OntologyClassAttr oca = ! getItemClass(((ItemManagerImpl) im).getOntology(), itemClassName).getAttribute(aname); OntologyDataType ontType; --- 1034,1038 ---- String aname, String itemClassName) { OntologyClassAttr oca = ! getItemClass( im.getOntology(), itemClassName).getAttribute(aname); OntologyDataType ontType; |
|
From: <j_m...@us...> - 2004-03-06 21:58:29
|
Update of /cvsroot/cobricks/cobricks2/src/org/cobricks/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17378/src/org/cobricks/core Modified Files: OntologyDataType.java Log Message: Index: OntologyDataType.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/core/OntologyDataType.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** OntologyDataType.java 29 Feb 2004 12:06:01 -0000 1.1 --- OntologyDataType.java 6 Mar 2004 21:35:27 -0000 1.2 *************** *** 46,50 **** /** * Constructs a new instance of OntologyDataType using the given ontology ! * keyword * @param ontKeyWord The ontology keyword specifying the type (e.g. string[]) */ --- 46,52 ---- /** * Constructs a new instance of OntologyDataType using the given ontology ! * keyword. ! * The keyword is tokenized and then analyzed, e.g. keyword string[]: It has ! * the name string and has Brackets --> isSet() = true, getTypeName()=string. * @param ontKeyWord The ontology keyword specifying the type (e.g. string[]) */ |
Update of /cvsroot/cobricks/cobricks2/src/org/cobricks/item In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17236/src/org/cobricks/item Modified Files: ItemManagerDB.java Item.java ItemManagerImpl.java ItemManager.java ItemServlet.java ItemPresenter.java ItemAttrs.java Log Message: Index: ItemManagerDB.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/item/ItemManagerDB.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ItemManagerDB.java 2 Mar 2004 17:58:10 -0000 1.6 --- ItemManagerDB.java 6 Mar 2004 21:35:04 -0000 1.7 *************** *** 14,17 **** --- 14,18 ---- */ import org.cobricks.core.db.DBAccess; + import org.cobricks.core.CobricksException; import org.cobricks.item.xmldb.XMLDBAccess; *************** *** 146,154 **** * @param newItem The new item (the one which has changed) * @param itemclass The item class which correspond to this item */ protected final void updateAttributeXMLDB(String name, Item oldItem, Item newItem, OntologyClass itemclass) throws XMLDBException { ! String xpath = "/item[globalid='" + newItem.getGlobalId() + "']"; //ItemAttrs.buildXPathForAttribute(name, oldItem.getGlobalId()); --- 147,157 ---- * @param newItem The new item (the one which has changed) * @param itemclass The item class which correspond to this item + * @throws XMLDBException Is thrown in case there were major problems + * while updating (so that the calling method can try a failsafe update). */ protected final void updateAttributeXMLDB(String name, Item oldItem, Item newItem, OntologyClass itemclass) throws XMLDBException { ! String xpath = "/item[itemid='" + newItem.getLocalId() + "']"; //ItemAttrs.buildXPathForAttribute(name, oldItem.getGlobalId()); *************** *** 167,172 **** */ protected final void storeItemXMLDB(Item item) { ! this.xmlDBAccess.insertDocument(item.getItemAsXML(false, false), ! String.valueOf(item.getLocalId())); } /** --- 170,186 ---- */ protected final void storeItemXMLDB(Item item) { ! try { ! this.xmlDBAccess.insertDocument(item.getItemAsXML(false, false), ! String.valueOf(item.getLocalId())); ! } catch (CobricksException e) { ! if (e.getExceptionId().equals("3001")) { ! logger.warn("Offline-Exception"); ! //TBD: Offline Error handling? ! } ! //TBD ! } catch (XMLDBException e) { ! logger.warn("Error during storing", e); ! } ! } /** *************** *** 305,310 **** protected final void performSafeUpdateXMLDB(Item item) { logger.info("Performing safe update for item: " + item.getLocalId()); ! this.xmlDBAccess.updateWholeDocument(item.getItemAsXML(false, false), ! String.valueOf(item.getLocalId())); } --- 319,331 ---- protected final void performSafeUpdateXMLDB(Item item) { logger.info("Performing safe update for item: " + item.getLocalId()); ! try { ! this.xmlDBAccess.updateWholeDocument(item.getItemAsXML(false, false), ! String.valueOf(item.getLocalId())); ! } catch (XMLDBException e) { ! logger.warn("Fatal problem while trying safe update", e); ! } catch (CobricksException e) { ! logger.warn("Can't update - db offline"); ! } ! } Index: Item.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/item/Item.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Item.java 2 Mar 2004 17:57:41 -0000 1.6 --- Item.java 6 Mar 2004 21:35:04 -0000 1.7 *************** *** 60,64 **** this.xmlEncoding = itemManager.getXMLEncoding(); ! HashMap attrs = itemManager.extractFromXML(xml); if (attrs == null) { --- 60,64 ---- this.xmlEncoding = itemManager.getXMLEncoding(); ! Map attrs = itemManager.extractFromXML(xml); if (attrs == null) { *************** *** 274,284 **** attrs.remove("globalid"); } - if ((attrs.get("itemclass") != null) && - (attrs.get("itemclass") instanceof String)) { - this.itemclass = (String) attrs.get("itemclass"); - attrs.remove("itemclass"); } ! */ this.attrs = attrs; } --- 274,284 ---- attrs.remove("globalid"); } + */ + if ((attrs.get("itemclass") != null) + && (attrs.get("itemclass") instanceof String)) { + this.itemclass = (String) attrs.remove("itemclass"); } ! this.attrs = attrs; } Index: ItemManagerImpl.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/item/ItemManagerImpl.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ItemManagerImpl.java 2 Mar 2004 17:58:26 -0000 1.6 --- ItemManagerImpl.java 6 Mar 2004 21:35:04 -0000 1.7 *************** *** 2,6 **** package org.cobricks.item; ! import org.apache.log4j.*; import org.cobricks.category.Category; --- 2,6 ---- package org.cobricks.item; ! import org.apache.log4j.Logger; import org.cobricks.category.Category; *************** *** 30,44 **** import org.xml.sax.SAXException; ! import java.io.*; ! ! import java.lang.reflect.Constructor; ! ! import java.net.URI; import java.sql.Timestamp; - import java.text.DateFormat; ! import java.util.*; import javax.xml.parsers.DocumentBuilder; --- 30,49 ---- import org.xml.sax.SAXException; ! import java.io.File; ! import java.io.BufferedInputStream; ! import java.io.ByteArrayInputStream; import java.sql.Timestamp; import java.text.DateFormat; ! import java.util.Map; ! import java.util.Set; ! import java.util.ArrayList; ! import java.util.HashMap; ! import java.util.HashSet; ! import java.util.Iterator; ! import java.util.List; ! import java.util.LinkedList; ! import java.util.Properties; import javax.xml.parsers.DocumentBuilder; *************** *** 57,61 **** --- 62,72 ---- public class ItemManagerImpl extends ComponentManagerAdaptor implements ItemManager { + /** + * Standard logger. + */ private static Logger logger = Logger.getLogger(ItemManagerImpl.class); + /** + * All tables in the relational data base. + */ private static final String[] DB_REL_ALL_TABLES = { *************** *** 63,69 **** "item_attrsitem", "item_attrsuser", "item_title", "item_content", }; ! static String COMP_NAME = "Cobricks-2 Item Manager"; ! static String COMP_VERSION = "V0.1 (Jul. 2003)"; ! private static int DEFAULT_CACHE_SIZE = 50; /** --- 74,89 ---- "item_attrsitem", "item_attrsuser", "item_title", "item_content", }; ! /** ! * Component name ! */ ! private static final String COMP_NAME = "Cobricks-2 Item Manager"; ! /** ! * Component version ! */ ! private static final String COMP_VERSION = "V0.1 (Jul. 2003)"; ! /** ! * The default value for the item cache - used in case no property is found ! */ ! private static final int DEFAULT_CACHE_SIZE = 50; /** *************** *** 73,87 **** /** * What attributes are used for permission checking? Maybe this will be ! * defined in the ontology? * TBD */ ! private static final String [] PERMISSION_ATTRIBUTES = {"creator","category"}; ! ! protected String defaultLanguage = "en"; private Ontology ontology; private CoreManager coreManager; ! Map itemObjects = null; private ItemCache itemCache; ! //private XMLDBAccess xmlDBAccess; private ItemManagerDB itemManagerDB; /** --- 93,122 ---- /** * What attributes are used for permission checking? Maybe this will be ! * defined in the ontology? * TBD */ ! private static final String [] PERMISSION_ATTRIBUTES = {"creator", ! "category"}; ! /** ! * Default language entry. Used for item attributes that are multi language ! */ ! private String defaultLanguage = "en"; ! /** ! * Ontology information about items ! */ private Ontology ontology; + /** + * Reference to the core manager. + */ private CoreManager coreManager; ! //Map itemObjects = null; ! /** ! * Itemcache is a map - based cache structure ! */ private ItemCache itemCache; ! ! /** ! * All database handling is done via the item manager db - adapter. ! */ private ItemManagerDB itemManagerDB; /** *************** *** 90,102 **** */ private String javaEncoding = "UTF-8"; ! /** * This has to be equivalent with the java setting. (Sometimes java encoding * names differ from xml encoding names). */ - private String xmlEncoding = "UTF-8"; - //private org.cobricks.item.xmldb.XMLDBAccess xmlDB; /** --- 125,135 ---- */ private String javaEncoding = "UTF-8"; ! /** * This has to be equivalent with the java setting. (Sometimes java encoding * names differ from xml encoding names). */ private String xmlEncoding = "UTF-8"; /** *************** *** 106,127 **** super(); } ! ! public String getComponentName() { return COMP_NAME; } ! public String getComponentVersion() { return COMP_VERSION; } ! public String getDefaultLanguage() { return defaultLanguage; } /** ! * */ ! public void init(String componentId, String managerId, ! Properties properties, CoreManager coreManager, DBAccess dbAccess) throws Exception { super.init(componentId, managerId, properties, coreManager, dbAccess); --- 139,171 ---- super(); } ! /** ! * @see org.cobricks.core.ComponentManagerInterface#getComponentName() ! */ ! public final String getComponentName() { return COMP_NAME; } + /** + * @see org.cobricks.core.ComponentManagerInterface#getComponentVersion() + */ ! public final String getComponentVersion() { return COMP_VERSION; } ! /** ! * @see org.cobricks.item.ItemManager#getDefaultLanguage() ! */ ! ! public final String getDefaultLanguage() { return defaultLanguage; } /** ! * @see org.cobricks.core.ComponentManagerInterface#init(java.lang.String, java.lang.String, java.util.Properties, org.cobricks.core.CoreManager, org.cobricks.core.db.DBAccess) */ ! public final void init(String componentId, String managerId, ! Properties properties, ! CoreManager coreManager, ! DBAccess dbAccess) throws Exception { super.init(componentId, managerId, properties, coreManager, dbAccess); *************** *** 186,190 **** + componentId + File.separator + "dbxml" + File.separator + "item.xml"); ! /*xmlDBAccess = new XMLDBAccess(properties); xmlDBAccess.init("item", (String) --- 230,234 ---- + componentId + File.separator + "dbxml" + File.separator + "item.xml"); ! /*xmlDBAccess = new XMLDBAccess(properties); xmlDBAccess.init("item", (String) *************** *** 193,205 **** + "item.xml"); */ Thread init = new Thread((Runnable) xmlDBAccess , "init"); - init.start(); ! this.itemManagerDB = new ItemManagerDB(this, coreManager.getDBAccess(), xmlDBAccess); ! if (properties.getProperty("item.java.file.encoding") != null){ this.javaEncoding = properties.getProperty("item.java.file.encoding"); } ! if (properties.getProperty("item.xml.encoding")!= null){ this.xmlEncoding = properties.getProperty("item.xml.encoding"); } --- 237,248 ---- + "item.xml"); */ Thread init = new Thread((Runnable) xmlDBAccess , "init"); init.start(); ! this.itemManagerDB = new ItemManagerDB(this, coreManager.getDBAccess(), xmlDBAccess); ! if (properties.getProperty("item.java.file.encoding") != null) { this.javaEncoding = properties.getProperty("item.java.file.encoding"); } ! if (properties.getProperty("item.xml.encoding")!= null) { this.xmlEncoding = properties.getProperty("item.xml.encoding"); } *************** *** 207,227 **** } ! public Ontology getOntology() { return ontology; } private Item getItemFromCache(int itemLocalId) { logger.info("getItemFrom Cache(int)"); - return itemCache.getItem(itemLocalId); } private Item getItemFromCache(String itemGlobalId) { logger.info("getItemFrom Cache (String based)"); return itemCache.getItem(itemGlobalId); } ! public Item getItem(int itemLocalId) { Item res = this.getItemFromCache(itemLocalId); --- 250,284 ---- } ! protected final Ontology getOntology() { return ontology; } + /** + * This method retries an item out of the local cache. + * @param itemLocalId Needed to find the item. + * @return The item in case it is in the cache, null otherwise + */ private Item getItemFromCache(int itemLocalId) { logger.info("getItemFrom Cache(int)"); return itemCache.getItem(itemLocalId); } + /** + * This method retries an item out of the local cache. + * @param itemGlobalId Needed to find the item. + * @return The item in case it is in the cache, null otherwise + */ private Item getItemFromCache(String itemGlobalId) { + //TBD get out of cache with global id - still needed? logger.info("getItemFrom Cache (String based)"); return itemCache.getItem(itemGlobalId); } + ! /** ! * @see org.cobricks.item.ItemManager#getItem(int) ! */ ! public final Item getItem(int itemLocalId) { Item res = this.getItemFromCache(itemLocalId); *************** *** 237,241 **** } ! public Item getItem(String itemid) { Item res = this.getItemFromCache(itemid); --- 294,301 ---- } ! /** ! * @see org.cobricks.item.ItemManager#getItem(java.lang.String) ! */ ! public final Item getItem(String itemid) { Item res = this.getItemFromCache(itemid); *************** *** 262,271 **** --- 322,344 ---- } + /** + * @see org.cobricks.item.ItemManager#addItemAnnotation(org.cobricks.item. + * Item, + * org.cobricks.item.ItemAnnotation) + */ public void addItemAnnotation(Item item, ItemAnnotation iann) { } + /** + * @see org.cobricks.item.ItemManager#addItemAttachment(org.cobricks.item. + * Item, + * org.cobricks.item.ItemAttachment) + */ public void addItemAttachment(Item item, ItemAttachment ia) { } + /** + * @see org.cobricks.item.ItemManager#createItem(java.util.Map) + */ public final Item createItem(Map attrs) { //I. Handle the two item ids *************** *** 350,354 **** public Item createItemFromXML(String xml) { ! HashMap attrs = this.extractFromXML(xml); return this.createItem(attrs); --- 423,427 ---- public Item createItemFromXML(String xml) { ! Map attrs = this.extractFromXML(xml); return this.createItem(attrs); *************** *** 1214,1218 **** * @return HashMap filled with extracted Objects from xml */ ! public HashMap extractFromXML(String xml) { logger.debug("extractFromXML"); --- 1287,1291 ---- * @return HashMap filled with extracted Objects from xml */ ! public Map extractFromXML(String xml) { logger.debug("extractFromXML"); Index: ItemManager.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/item/ItemManager.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ItemManager.java 29 Feb 2004 12:03:26 -0000 1.2 --- ItemManager.java 6 Mar 2004 21:35:04 -0000 1.3 *************** *** 1,30 **** ! /** ! * ! * @author mic...@ac... ! * @version $ $ ! * ! * Copyright (c) 2003 Michael Koch, mic...@ac... ! */ package org.cobricks.item; ! import java.util.*; import org.cobricks.core.ComponentManagerInterface; - import org.cobricks.core.util.LogUtil; - import org.cobricks.core.Ontology; - ! public interface ItemManager extends ComponentManagerInterface ! { ! public String getDefaultLanguage(); ! ! public Item getItem(int itemid); ! public Item createItem(Map attrs) ;// minimum: typeid, title_de, publisherid ! public Item createItem(Map attrs, String userid); // check access rights ! public Item getItem(String globalid); public Item getItem(String globalid, String userid); // check access rights public List searchItems(String xpath); //List of Items --- 1,73 ---- ! package org.cobricks.item; ! import java.util.Map; ! import java.util.List; import org.cobricks.core.ComponentManagerInterface; ! //import org.cobricks.core.Ontology; ! /** ! * ! * @author mic...@ac..., ma...@in... ! * @version $ $ ! * ! * Copyright (c) 2003 Michael Koch, mic...@ac... ! */ ! public interface ItemManager extends ComponentManagerInterface { ! /** ! * This method returns the default language; the default language is used in all ! * mutli language attributes if no language is specified. ! * @return An ISO 639-1 language identifier (two letters) of the default language ! * used. ! */ ! String getDefaultLanguage(); ! /** ! * This method is used to get an item out of the backend structure. ! * In case caching is activated, at first a lookup in the cache is performed. ! * If this succeeds, the item will be returned out of the cache. If it fails, ! * the item will be retrieved out of the persistent structure (data base). ! * @param itemid The local id of the item to get. ! * @return An instance of item in case it was found, the null pointer other ! * wise. ! */ + Item getItem(int itemid); + /** + * This method creates a new item object: At first the data is inserted into + * the persistent storage and then instantiated and (if activated) inserted + * into the cache and then returned. + * <i> Important: Because no user is supplied, anonymous will be used </i> + * In case some of the submitted attributes are not valid (according to the + * item ontology) this method tries at first to correct the attributes and if + * this fails, the still invalid attributes are discarded. + * If required attributes are missing, the item won't be created. + * @param attrs Map containing all attributes. All attributes must have the + * correct Java type (according to the item ontology). + * There are some attributes that get a special handling: The ids are + * discarded in the create method (reason: they have to be assigned by the + * system). Second, an attribute named itemclass is necessary to assign the + * correct item ontology class. If none is submitted, the default will be + * used: "item". + * Multi language attributes: The attribute name has to be aname_lang (lang + * as two letters, e.g. en). If the default language attribute value is set + * the _lang can be omitted. + * @return The item which was stored in the database, null if an error + * occurred. + */ + Item createItem(Map attrs); // minimum: typeid, title_de, publisherid + /** + * The same as getItem(int), but with additional user information - access + * right checking with given user id. + * @see ItemManager#getItem(int) + * @param attrs The attributes for the new item + * @param userid Needed to check access rights. + * @return newly instantiated item or null if an error occurs. + */ + Item createItem(Map attrs, String userid); // check access rights ! Item getItem(String globalid); public Item getItem(String globalid, String userid); // check access rights public List searchItems(String xpath); //List of Items *************** *** 52,57 **** public int getLocalIdForGlobalId(String globalid); // get HashMap of Objects from xml-input ! public HashMap extractFromXML(String xml); ! public Ontology getOntology(); /** --- 95,100 ---- public int getLocalIdForGlobalId(String globalid); // get HashMap of Objects from xml-input ! public Map extractFromXML(String xml); ! //public Ontology getOntology(); /** Index: ItemServlet.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/item/ItemServlet.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ItemServlet.java 2 Mar 2004 17:59:05 -0000 1.3 --- ItemServlet.java 6 Mar 2004 21:35:04 -0000 1.4 *************** *** 1,12 **** ! /** ! * ! * @author mic...@co... ! * @version $ $ ! * ! * Copyright (c) 2003 Michael Koch, mic...@co... ! */ package org.cobricks.item; ! import org.apache.log4j.*; import org.cobricks.core.ComponentDirectory; --- 1,6 ---- ! package org.cobricks.item; ! import org.apache.log4j.Logger; import org.cobricks.core.ComponentDirectory; *************** *** 16,45 **** import org.cobricks.portal.PortalUser; ! import java.io.*; ! ! import java.net.URL; ! ! import java.util.*; ! import javax.servlet.*; ! import javax.servlet.http.*; public class ItemServlet extends PortalServletAdaptor { ! static Logger logger = Logger.getLogger(ItemServlet.class); ! protected ItemManager itemManager; /** ! * */ ! public void performLogin(HttpServletRequest request, ! HttpServletResponse response, PrintWriter out, PortalUser user) { logger.info(">>>>>>>>perfomLogin()!!!!!"); } /** ! * */ ! public void init(ServletConfig config) throws ServletException { super.init(config); --- 10,72 ---- import org.cobricks.portal.PortalUser; ! import java.io.PrintWriter; ! import java.util.HashMap; ! import java.util.HashSet; ! import java.util.Iterator; ! import java.util.Map; ! import java.util.Set; + import javax.servlet.ServletConfig; + import javax.servlet.ServletException; + import javax.servlet.http.HttpServletRequest; + import javax.servlet.http.HttpServletResponse; + /** + * + * @author mic...@co..., ma...@in... + * @version $ $ + * + * Copyright (c) 2003 Michael Koch, mic...@co... + */ public class ItemServlet extends PortalServletAdaptor { ! /** ! * This array contains all regex which are not used (directly) for building ! * the ItemAttrsMap ! */ ! private static final String [] FILTERED_ATTRIBUTE_NAMES = { ! "cmd.*", "_.*", ".*_lang", "DD.MM.YY HH:MM", "itemid", "globalid" }; ! /** ! * standard logger ! */ ! private static Logger logger = Logger.getLogger(ItemServlet.class); ! /** ! * the item manager is needed for doing actions in the back end structure ! */ ! private ItemManager itemManager; /** ! * Performs a login TBD ! * @param request TBD ! * @param response TBD ! * @param out TBD ! * @param user TBD */ ! ! public final void performLogin(HttpServletRequest request, ! HttpServletResponse response, ! PrintWriter out, ! PortalUser user) { logger.info(">>>>>>>>perfomLogin()!!!!!"); } /** ! * Initializes the presenter: adding targets, initializing item manager ! * @param config Needed to run init method in PortalServletAdaptor ! * @throws ServletException Is thrown in case init method of ! * PortalServerletAdaptor throws this exception */ ! public final void init(ServletConfig config) throws ServletException { ! super.init(config); *************** *** 57,60 **** --- 84,102 ---- } } + /** + * This method performs item creation out of the request parameter. The + * request parameter must have a special format: + * if a custom itemclass is desired there must be a parameter itemclass + * with a correct item class name. + * All cmd.* are ignored. + * Multi-language attributes: parameter name1 = attribute name + * parameter value1 = attribute value; parameter name2 = attribute name + + * "_lang"; parameter value2=language + * @param prequest Portalrequest to gather the data to create a new item + * @param out Is not used. + * @return "error": In case there are errors, also a context object named + * errors is set (a Set of InputErrors). "success" If everything is o.k., + * a context object named "createdItem" is set (Item object). + */ public final String performCreateItem(PortalRequest prequest, *************** *** 66,69 **** --- 108,112 ---- prequest.setContextObject("errors", attrs.get("errors")); out.write(attrs.get("errors").toString()); + // Set the itemclass in the velocity context, //because the select itemclass is an extra form and is overwritten *************** *** 90,93 **** --- 133,137 ---- } } + /** * This method performs a standard update. It does <b>no</b> handling of *************** *** 95,98 **** --- 139,149 ---- * task, this handling is completely done by the front end structure (item * presenter / templates). It only detects changes of item classes. + * The request parameter must have a special format: + * If a custom itemclass is desired there must be a parameter itemclass + * with a correct item class name. + * All cmd.* are ignored. + * Multi-language attributes: parameter name1 = attribute name + * parameter value1 = attribute value; parameter name2 = attribute name + + * "_lang"; parameter value2=language * @param prequest The portal request this call comes from. * @param out Not needed. *************** *** 100,119 **** * there were illegal attributes, success if everything was o.k. */ - public final String performUpdate(PortalRequest prequest, PrintWriter out) { //Object itemObject = prequest.getVelocityContext().get("item"); String itemid = prequest.getRequestParameter("itemid"); Item item = null; try { item = itemManager.getItem(Integer.parseInt(itemid)); } catch (Exception e) { - //TBD out.write("Fatal: Could'nt find item to update."); ! return null; } - if (item !=null) { //This object must not be null /invalid - //Item item = (Item) itemObject; ! if (item.getItemClass().equals(prequest.getRequestParameter( "itemclass"))) { // There was no change in the item class, go ahead with updating --- 151,180 ---- * there were illegal attributes, success if everything was o.k. */ public final String performUpdate(PortalRequest prequest, PrintWriter out) { //Object itemObject = prequest.getVelocityContext().get("item"); String itemid = prequest.getRequestParameter("itemid"); Item item = null; + try { item = itemManager.getItem(Integer.parseInt(itemid)); } catch (Exception e) { out.write("Fatal: Could'nt find item to update."); ! Set errors = new HashSet(); ! errors.add(new InputError("INTERNAL_PRESENTER_ERROR")); ! prequest.setContextObject("errors", errors); ! return "error"; } ! if (item != null) { //This object must not be null /invalid ! logger.debug("old:" + item.getItemClass() + "new:" + ! prequest.getRequestParameter("itemclass")); ! String previousItemClassName = ! prequest.getRequestParameter("_previousitemclass"); ! if (previousItemClassName == null ! || previousItemClassName.length() == 0) { ! previousItemClassName = item.getItemClass(); ! } ! //Item item = (Item) itemObject; ! if (previousItemClassName.equals(prequest.getRequestParameter( "itemclass"))) { // There was no change in the item class, go ahead with updating *************** *** 129,132 **** --- 190,195 ---- } else { item.setFromMap(changedAttrs); + item.setItemClass( + prequest.getRequestParameter("itemclassname")); itemManager.updateItem(item); *************** *** 134,139 **** --- 197,204 ---- } } else { // There was a change in itemclass --> this has to be managed + //by the item presenter / frontend before. prequest.setContextObject("oldItemClass", item.getItemClass()); + return "changedItemClass"; } *************** *** 142,145 **** --- 207,211 ---- } } + /** * This method builds a map of instantiated attributes out of the portal *************** *** 147,162 **** * In case major errors occurred (wrong user input) only a map with one * set named errors is returned. ! * @param pRequest The portal request. Needed to get the parameters. * @return Map of instantiated attributes in case everything is o.k., other * wise a map only with one set containing InputError objects is returned. */ ! ! private Map buildItemAttrsMap(PortalRequest pRequest) { Set errors = new HashSet(); ! Set parameterNames = pRequest.getRequestParameters().keySet(); Map result = new HashMap(); ! String itemClassName = (String) pRequest.getRequestParameter("itemclass"); ! pRequest.setContextObject("itemclass", itemClassName); logger.debug("ic: " + itemClassName); // (String) tmp.remove("itemclass"); Iterator it = parameterNames.iterator(); --- 213,229 ---- * In case major errors occurred (wrong user input) only a map with one * set named errors is returned. ! * @param prequest The portal request. Needed to get the parameters. * @return Map of instantiated attributes in case everything is o.k., other * wise a map only with one set containing InputError objects is returned. */ ! private Map buildItemAttrsMap(PortalRequest prequest) { Set errors = new HashSet(); ! Set parameterNames = prequest.getRequestParameters().keySet(); Map result = new HashMap(); ! String itemClassName = ! (String) prequest.getRequestParameter("itemclass"); ! prequest.setContextObject("itemclass", itemClassName); logger.debug("ic: " + itemClassName); + // (String) tmp.remove("itemclass"); Iterator it = parameterNames.iterator(); *************** *** 164,178 **** while (it.hasNext()) { String currentParam = (String) it.next(); ! String input = (String) pRequest.getRequestParameter(currentParam); ! if (!currentParam.matches("cmd.*") && !currentParam.matches(".*_lang") ! && (input != null) ! && (input.length() > 0) ! && !ItemPresenter.DATE_FORMAT.equals(input)) { logger.debug(currentParam); Object attr = ItemAttrs.instantiateAttribute(this.itemManager, input, ! currentParam, itemClassName); if (attr instanceof InputError) { //attr is a single error --- 231,242 ---- while (it.hasNext()) { String currentParam = (String) it.next(); ! String input = (String) prequest.getRequestParameter(currentParam); ! if (this.processAttribute(currentParam, input, prequest)) { logger.debug(currentParam); Object attr = ItemAttrs.instantiateAttribute(this.itemManager, input, ! currentParam, itemClassName); if (attr instanceof InputError) { //attr is a single error *************** *** 180,211 **** errors.add(attr); } else if (attr instanceof Set ! && ((Set) attr).iterator().next() instanceof InputError) { //attr has possibly mutliple errors Iterator it2 = ((Set) attr).iterator(); while (it2.hasNext()) { InputError next = (InputError) it2.next(); ! next.setEnvironment(currentParam); ! errors.add(next); } } else if (attr != null) { //it was correct instantiated ! //important: There is no isMultiLanguage-check here. ! //we trust in the front end structure that it is not possible ! //to add wrong language settings. ! if (pRequest.getRequestParameter(currentParam + ! "_lang") == null) { //no multiple language result.put(currentParam, attr); } else { //Multiple language ! result.put(currentParam + "_" + ! pRequest.getRequestParameter(currentParam + "_lang"), ! attr); } } else { //something went wrong that is not covered with an //error message. Looks like a greater problem. logger.warn("can't handle: " + currentParam); } } } if (errors.isEmpty()) { // Everything is fine. return result; } else { //There were user errors... Return only the errors. --- 244,296 ---- errors.add(attr); } else if (attr instanceof Set ! && ((Set) attr).iterator().next() instanceof InputError) { //attr has possibly mutliple errors Iterator it2 = ((Set) attr).iterator(); + while (it2.hasNext()) { InputError next = (InputError) it2.next(); ! next.setEnvironment(currentParam); ! errors.add(next); } } else if (attr != null) { //it was correct instantiated ! ! if (prequest.getRequestParameter(currentParam + "_lang") ! == null) { //no multiple language result.put(currentParam, attr); } else { //Multiple language ! result.put(currentParam + "_" ! + prequest.getRequestParameter(currentParam ! + "_lang"), attr); } } else { //something went wrong that is not covered with an + //error message. Looks like a greater problem. logger.warn("can't handle: " + currentParam); } + } else if (currentParam.matches("_customAname.*")) { + //process custom attributes + String number = currentParam.substring( + currentParam.lastIndexOf("_"), + currentParam.length()); + String aname = prequest.getRequestParameter(currentParam); + String avalue = prequest.getRequestParameter("_customAvalue" + + number); + logger.debug("Handle custom attribute: " + aname + ":" + avalue + + " cust#" + number); + if (avalue != null && avalue.trim().length() > 0) { + Object attr = ItemAttrs.instantiateAttribute(this.itemManager, + avalue, aname, itemClassName); + if (attr instanceof InputError) { + ((InputError) attr).setEnvironment(aname); + errors.add(attr); + } else { + result.put(aname, attr); + } + } } } if (errors.isEmpty()) { // Everything is fine. + return result; } else { //There were user errors... Return only the errors. *************** *** 216,218 **** --- 301,323 ---- } } + + private boolean processAttribute(String aname, + String input, + PortalRequest prequest) { + boolean process = //should this attribute be processed? Every test is + //a show stopper. + (prequest.getRequestParameter("_subDel_" + aname) != null + && prequest.getRequestParameter("_subDel_" + + aname).equals("delete")); + + int i = 0; + while (process && i < FILTERED_ATTRIBUTE_NAMES.length) { + //if one of the filter matches, set process to false + process = !aname.matches(FILTERED_ATTRIBUTE_NAMES[i]); + i++; } + if (process) { + process = (input != null && input.length() > 0); + } + return process; + } } Index: ItemPresenter.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/item/ItemPresenter.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ItemPresenter.java 2 Mar 2004 17:58:53 -0000 1.3 --- ItemPresenter.java 6 Mar 2004 21:35:04 -0000 1.4 *************** *** 56,59 **** --- 56,60 ---- }; private static String[] LONG_DATATYPES = { "xml" }; + private static String[] UNCHANGED_ATTRIBUTES = {"itemid", "globalid", "creator", "creationtime", "updater", "creationtime"}; protected static String DATE_FORMAT = "DD.MM.YY HH:MM"; private Map errors; *************** *** 76,80 **** (ItemManager) coreManager.getComponentDirectory().getManager("itemManager"); this.coreManager = coreManager; ! ontology = itemManager.getOntology(); File file = new File((String) properties.get("configdir") + File.separator + "org.cobricks.item" + File.separator --- 77,81 ---- (ItemManager) coreManager.getComponentDirectory().getManager("itemManager"); this.coreManager = coreManager; ! ontology = ((ItemManagerImpl)itemManager).getOntology(); File file = new File((String) properties.get("configdir") + File.separator + "org.cobricks.item" + File.separator *************** *** 107,116 **** public String printAttrInput(String itemClass, String aname, ! String requestVal, int rows, int cols) { String result = ""; OntologyClassAttr oca = this.ontology.getClass(itemClass).getAttribute(aname); OntologyDataType odat = oca.getOntologyDataType(); ! String defaultVal = oca.getDefault(); if (rows == -1) { --- 108,123 ---- public String printAttrInput(String itemClass, String aname, ! String requestVal, int rows, int cols, boolean readonly) { String result = ""; OntologyClassAttr oca = this.ontology.getClass(itemClass).getAttribute(aname); + if(oca.isMultiLanguage()){ + aname = aname.split("_")[0]; + } OntologyDataType odat = oca.getOntologyDataType(); ! String defaultVal = null; ! if(requestVal != null && requestVal.length() > 0){ ! defaultVal = oca.getDefault(); ! } if (rows == -1) { *************** *** 120,128 **** } } } if (!oca.getValues().isEmpty()) { //There are possible values ! result += ("<select name=\"" + aname + "\" size=\"1\">\n"); ! List options = oca.getValues(); Iterator it = options.iterator(); --- 127,142 ---- } } + if((requestVal != null) && ((requestVal.length() > MAX_NUMBER_COLS) + || (requestVal.matches("\n")))){ + rows = 10; + } } if (!oca.getValues().isEmpty()) { //There are possible values ! result += "<select name=\"" + aname + "\" size=\"1\""; ! if(readonly){ ! result += " disabled=\"disabled\""; ! } ! result += ">\n"; List options = oca.getValues(); Iterator it = options.iterator(); *************** *** 141,156 **** result += (">" + next + "</option>\n"); } ! ! result += "</select>"; } else if (odat.getTypeName().equals("boolean")) { ! result += ("<input type=\"checkbox\" name=\"" + aname + "\" value=" + "\"true\""); - if (((defaultVal != null) && defaultVal.equals("true")) || ((requestVal != null) && requestVal.equals("true"))) { result += " checked=\"checked\""; } ! ! result += "/>"; } else if (odat.getTypeName().equals("datetime")) { result += ("<input name=\"" + aname + "\" type=\"text\" size=\"" --- 155,190 ---- result += (">" + next + "</option>\n"); } ! result += "<option value=\"\">no value</option></select>"; } else if (odat.getTypeName().equals("boolean")) { ! result += ("<input type=\"radio\" name=\"" + aname + "\" value=" + "\"true\""); if (((defaultVal != null) && defaultVal.equals("true")) || ((requestVal != null) && requestVal.equals("true"))) { result += " checked=\"checked\""; } ! if(readonly){ ! result += " readonly=\"redonly\""; ! } ! result += "> true</input>\n"; ! result += ("<input type=\"radio\" name=\"" + aname + "\" value=" ! + "\"false\""); ! if (((defaultVal != null) && defaultVal.equals("false")) ! || ((requestVal != null) && requestVal.equals("false"))) { ! result += " checked=\"checked\""; ! } ! if(readonly){ ! result += " readonly=\"redonly\""; ! } ! result += "> false</input>\n"; ! result += ("<input type=\"radio\" name=\"" + aname + "\" value=" ! + "\"\""); ! if ((requestVal != null) && (requestVal == "")) { ! result += " checked=\"checked\""; ! } ! if(readonly){ ! result += " readonly=\"redonly\""; ! } ! result += "> no value</input>"; ! } else if (odat.getTypeName().equals("datetime")) { result += ("<input name=\"" + aname + "\" type=\"text\" size=\"" *************** *** 164,168 **** result += (" value=\"" + DATE_FORMAT + "\""); } ! result += "/>"; } else if ((rows <= 1)) { --- 198,204 ---- result += (" value=\"" + DATE_FORMAT + "\""); } ! if(readonly){ ! result += " readonly=\"redonly\""; ! } result += "/>"; } else if ((rows <= 1)) { *************** *** 174,178 **** return printAttrInput(itemClass, aname, requestVal, rows, ! MAX_NUMBER_COLS); } else { result += (" size=\"" + odat.getMaxLength() --- 210,214 ---- return printAttrInput(itemClass, aname, requestVal, rows, ! MAX_NUMBER_COLS, readonly); } else { result += (" size=\"" + odat.getMaxLength() *************** *** 188,197 **** result += (" value=\"" + defaultVal + "\""); } ! result += "/>"; } else { result += ("<textarea name=\"" + aname + "\" cols=\"" + cols ! + "\" rows=\"" + rows + "\">"); ! if ((requestVal != null) && (requestVal.length() > 0)) { result += requestVal; --- 224,238 ---- result += (" value=\"" + defaultVal + "\""); } ! if(readonly){ ! result += " readonly=\"redonly\""; ! } result += "/>"; } else { result += ("<textarea name=\"" + aname + "\" cols=\"" + cols ! + "\" rows=\"" + rows + "\""); ! if(readonly){ ! result += "\" readonly=\"redonly\""; ! } ! result += ">"; if ((requestVal != null) && (requestVal.length() > 0)) { result += requestVal; *************** *** 199,206 **** result += defaultVal; } - result += "</textarea>"; } - return result; } --- 240,245 ---- *************** *** 208,212 **** public String printDescription(String icname, String aname, String lang) { String desc = null; ! if (aname == null) { desc = ontology.getClass(icname).getDescription(lang); --- 247,252 ---- public String printDescription(String icname, String aname, String lang) { String desc = null; ! try{ ! if (aname == null) { desc = ontology.getClass(icname).getDescription(lang); *************** *** 215,218 **** --- 255,259 ---- ontology.getClass(icname).getAttribute(aname).getDescription(lang); } + }catch(Exception e){} if (desc == null) { *************** *** 224,237 **** public String printMultiLangDropDown(String icname, String aname, ! String defaultLang) { String result = ""; ! if (this.ontology.getClass(icname).getAttribute(aname).isMultiLanguage()) { ! result += ("<select name=\"" + aname + "_lang\" size=1>\n"); for (int i = 0; i < LANGUAGES.length; i++) { result += ("<option value=\"" + LANGUAGES[i][0] + "\""); ! if (LANGUAGES[i][0].equals(defaultLang)) { result += " selected=\"selected\""; } --- 265,298 ---- public String printMultiLangDropDown(String icname, String aname, ! String defaultLang, String requestLang) { String result = ""; + String[] temp = aname.split("_"); + String attrName = temp[0]; + String lang = ""; + if(temp.length > 1){ + lang += temp[1]; + defaultLang = ""; + requestLang = ""; + } + if((requestLang != null) && (requestLang.length() > 0)){ + defaultLang = ""; + } ! try{ ! OntologyClass ic = this.ontology.getClass(icname); ! OntologyClassAttr ica = ic.getAttribute(attrName); ! if (ica.isMultiLanguage()) { ! result += ("<select name=\"" + attrName + "_lang\" size=1>\n"); for (int i = 0; i < LANGUAGES.length; i++) { result += ("<option value=\"" + LANGUAGES[i][0] + "\""); ! if(LANGUAGES[i][0].equals(lang)){ ! result += " selected=\"selected\""; ! } ! else if ((requestLang != null) && (LANGUAGES[i][0].equals(requestLang))) { ! result += " selected=\"selected\""; ! } ! else if (LANGUAGES[i][0].equals(defaultLang)) { result += " selected=\"selected\""; } *************** *** 242,245 **** --- 303,309 ---- result += "</select>"; } + }catch(Exception e){ + e.printStackTrace(); + } return result; *************** *** 247,254 **** public String printItemClassesDropDown(String selectName, ! String defaultClassName, String selectedClassName) { String result = ! "<select name=\"" + selectName ! + "\" onChange=\"form.submit()\" size=\"1\">\n"; Collection classes = this.ontology.getClasses(); Iterator iter = classes.iterator(); --- 311,318 ---- public String printItemClassesDropDown(String selectName, ! String defaultClassName, String selectedClassName, boolean submit) { String result = ! "<select name=\"" + selectName + "\""; if(submit){ ! result += " onChange=\"form.submit()\""; } result += " size=\"1\">\n"; Collection classes = this.ontology.getClasses(); Iterator iter = classes.iterator(); *************** *** 289,294 **** } ! public Set getAttributeNames(String itemClassName) { ! OntologyClass oc = ontology.getClass(itemClassName); if ((oc == null) --- 353,358 ---- } ! public Set getAttributeNames(final String itemClassName) { ! final OntologyClass oc = ontology.getClass(itemClassName); if ((oc == null) *************** *** 307,320 **** } ! public Set removeAttributeDuplicates(Set attributes, String toRemove) { ! attributes.removeAll(getAttributeNames(toRemove)); ! ! return attributes; } ! public Set getCommonAttributes(Set attributes1, Set attributes2) { ! attributes1.retainAll(attributes2); ! ! return attributes1; } --- 371,407 ---- } ! public Set removeAttributeDuplicates(final Set attributes, final String toRemove) { ! Iterator iter = attributes.iterator(); ! Set result = new HashSet(); ! Set remove = this.getAttributeNames(toRemove); ! while(iter.hasNext()){ ! String temp = (String)iter.next(); ! if(!remove.contains(temp)){ ! result.add(temp); ! } ! } ! return result; ! } ! ! public Set removeUnchangedAttributes(Set attributes){ ! Set result = new HashSet(attributes); ! for(int i=0; i< UNCHANGED_ATTRIBUTES.length; i++){ ! if(result.contains(UNCHANGED_ATTRIBUTES[i])){ ! result.add(UNCHANGED_ATTRIBUTES[i]); ! } ! } ! return result; } ! public Set getCommonAttributes(final Set attributes1, final Set attributes2) { ! Iterator iter = attributes1.iterator(); ! Set result = new HashSet(); ! while(iter.hasNext()){ ! String temp = (String)iter.next(); ! if(attributes2.contains(temp)){ ! result.add(temp); ! } ! } ! return result; } *************** *** 330,334 **** public Item getItem(String itemID) { - logger.debug("Try to get item with itemid=" + itemID); Item item = null; --- 417,420 ---- *************** *** 343,353 **** } - public String printItemIDInput(String itemID, int cols) { - String result = - "<input name=\"itemid\" type=\"text\" size=\"" + cols - + "\" value=\"" + itemID + "\" readonly=\"readonly\"/>"; - - return result; - } public String printStateInput(String itemClass, String selected) { --- 429,432 ---- *************** *** 376,379 **** --- 455,486 ---- } + public String printNewAttrInput(String aname, String requestVal, int cols){ + String result = "<input name=\"" + aname + "\" type=\"text\" size=\"" + cols + "\""; + if((requestVal != null) && (requestVal.length() > 0)){ + result += " value=\"" + requestVal + "\""; + } + result += "/>"; + return result; + } + + public String printRadioSubDel(String aname, String defaultVal){ + String result = "<input type=\"radio\" name=\"_subDel_" + aname + "\" value=\"delete\""; + if(defaultVal.equals("delete")){ + result += "checked=\"checked\""; } + result += "> Delete attribute</input></br><input type=\"radio\" name=\"_subDel_" + aname + "\" value=\"submit\""; if(defaultVal.equals("submit")){ + result += "checked=\"checked\""; + } + result += "> Maintain attribute</input>"; + return result; + } + + public String concat(String s1, String s2){ + return s1 + s2; + } + + public String getDateFormat(){ + return DATE_FORMAT; + } + private Map loadErrorInfos(File file) { Map result = new HashMap(); Index: ItemAttrs.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/item/ItemAttrs.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ItemAttrs.java 2 Mar 2004 17:57:57 -0000 1.6 --- ItemAttrs.java 6 Mar 2004 21:35:04 -0000 1.7 *************** *** 768,772 **** + lang + "']/"; } else { ! xp = "/item[globalid='" + localid + "']/" + aname + "/"; } --- 768,772 ---- + lang + "']/"; } else { ! xp = "/item[itemid='" + localid + "']/" + aname + "/"; } *************** *** 1034,1038 **** String aname, String itemClassName) { OntologyClassAttr oca = ! getItemClass(im.getOntology(), itemClassName).getAttribute(aname); OntologyDataType ontType; --- 1034,1039 ---- String aname, String itemClassName) { OntologyClassAttr oca = ! getItemClass(((ItemManagerImpl) im).getOntology(), ! itemClassName).getAttribute(aname); OntologyDataType ontType; *************** *** 1288,1303 **** HashSet set = new HashSet(); String[] tokenized = input.split(COLLECTION_SEPARATOR); ! for (int i = 0; i < tokenized.length; i++) { Object temp = handleInt(tokenized[i], ontType.getCollectionElementType()); ! if (temp != null) { set.add(temp); } } ! if (!set.isEmpty()) { return set; } else { return null; --- 1289,1309 ---- HashSet set = new HashSet(); String[] tokenized = input.split(COLLECTION_SEPARATOR); ! HashSet errors = new HashSet(); for (int i = 0; i < tokenized.length; i++) { Object temp = handleInt(tokenized[i], ontType.getCollectionElementType()); ! if (!(temp instanceof InputError)) { set.add(temp); + } else { + ((InputError) temp).setFurtherInfo("Integer:" + tokenized[i]); + errors.add(temp); } } ! if (errors.isEmpty() && !set.isEmpty()) { return set; + } else if (!errors.isEmpty()) { + return errors; } else { return null; *************** *** 1309,1314 **** return null; } else { //int (->Integer) ! ! return Integer.valueOf(input); } } --- 1315,1323 ---- return null; } else { //int (->Integer) ! try { Integer res = Integer.valueOf(input); ! return res; ! } catch (Exception e) { ! return new InputError("ILLEGAL_INTEGER"); ! } } } |
|
From: <j_m...@us...> - 2004-03-06 21:57:30
|
Update of /cvsroot/cobricks/cobricks2/src/org/cobricks/item/xmldb In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17155/src/org/cobricks/item/xmldb Modified Files: XMLDBCollectionDescriptor.java XMLDBAccess.java Log Message: Index: XMLDBCollectionDescriptor.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/item/xmldb/XMLDBCollectionDescriptor.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** XMLDBCollectionDescriptor.java 11 Feb 2004 14:32:28 -0000 1.1 --- XMLDBCollectionDescriptor.java 6 Mar 2004 21:34:28 -0000 1.2 *************** *** 1,25 **** ! /** ! * Schema information for a particular table in the database. ! * Both the information from the config files and from the database ! * itself can be stored here (and be compoared). ! * ! * @author mic...@ac... ! * @version $ $ ! * ! * Copyright (c) 2003 Michael Koch, mic...@ac... ! */ package org.cobricks.item.xmldb; import org.cobricks.core.util.LogUtil; ! import org.apache.log4j.*; ! import org.w3c.dom.*; ! import org.xml.sax.*; ! import java.io.*; ! import java.util.*; import javax.xml.parsers.DocumentBuilder; --- 1,21 ---- ! package org.cobricks.item.xmldb; import org.cobricks.core.util.LogUtil; ! import org.apache.log4j.Logger; ! import org.w3c.dom.Node; ! import org.w3c.dom.Element; ! import org.w3c.dom.Document; ! import org.xml.sax.ErrorHandler; ! import org.xml.sax.SAXException; ! import org.xml.sax.SAXParseException; ! import java.io.File; ! import java.util.Map; ! import java.util.HashMap; import javax.xml.parsers.DocumentBuilder; *************** *** 28,39 **** import javax.xml.parsers.ParserConfigurationException; public class XMLDBCollectionDescriptor implements ErrorHandler { static Logger logger = Logger.getLogger(XMLDBCollectionDescriptor.class); String collectionname; ! // column descriptor from database ! // colname - DBColumnDescriptor ! HashMap DbIndexes; Map DbCollectionVersions; --- 24,49 ---- import javax.xml.parsers.ParserConfigurationException; + /** + * Schema information for a particular collection in the database. + * @author ma...@in... + * @version $ $ + * + * Copyright (c) 2003 Michael Koch, mic...@ac... + */ public class XMLDBCollectionDescriptor implements ErrorHandler { + /** + * Standard logger + */ static Logger logger = Logger.getLogger(XMLDBCollectionDescriptor.class); + /** + * The name of the collection to describe + */ String collectionname; ! /** ! * The Indexers of the database ! */ ! Map DbIndexes; Map DbCollectionVersions; *************** *** 53,57 **** } ! public HashMap getIndexes() { return DbIndexes; } --- 63,67 ---- } ! public Map getIndexes() { return DbIndexes; } Index: XMLDBAccess.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/item/xmldb/XMLDBAccess.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** XMLDBAccess.java 29 Feb 2004 12:06:38 -0000 1.4 --- XMLDBAccess.java 6 Mar 2004 21:34:28 -0000 1.5 *************** *** 4,7 **** --- 4,8 ---- import org.apache.xindice.client.xmldb.services.CollectionManager; import org.apache.xindice.xml.dom.DocumentImpl; + import org.cobricks.core.CobricksException; import org.w3c.dom.Document; *************** *** 509,516 **** * @param key The key / document id under which the information should be * stored */ ! public final void insertDocument(String xmlData, String key) { if (this.online) { - try { XMLResource document = (XMLResource) collection.createResource(String.valueOf(key), --- 510,519 ---- * @param key The key / document id under which the information should be * stored + * @throws XMLDBException May occur in case the inserting fails + * @throws CobricksException Is thrown if database is offline */ ! public final void insertDocument(String xmlData, String key) ! throws XMLDBException, CobricksException { if (this.online) { XMLResource document = (XMLResource) collection.createResource(String.valueOf(key), *************** *** 520,529 **** logger.debug("Data inserted, id is:" + key); logger.debug("inserted:" + xmlData); ! } catch (Exception e) { ! logger.warn("Exception occured while trying to insert data" ! + (key), e); ! } } else { logger.warn("DBAccess status is offline-can't insert" + (key)); } } --- 523,531 ---- logger.debug("Data inserted, id is:" + key); logger.debug("inserted:" + xmlData); ! } else { logger.warn("DBAccess status is offline-can't insert" + (key)); + throw new CobricksException("org.cobricks.item.xmldb", "3001", + "Offline while changing"); } } *************** *** 719,723 **** * (both Strings) * @param useInsertAfter Perform insert-after: true, perform append: false; ! * @throws XMLDBException */ public final void insertEntry(String xPath, String xmlData, --- 721,726 ---- * (both Strings) * @param useInsertAfter Perform insert-after: true, perform append: false; ! * @throws XMLDBException May occur in case the inserting failed because e.g. ! * the xml was not valid. */ public final void insertEntry(String xPath, String xmlData, *************** *** 871,875 **** * @param attributeName The name of the attribute to remove * @param newval Simple string (no xml) The new value of the attribute ! * @throws XMLDBException TBD! */ private void updateAttribute(String xPath, String attributeName, --- 874,879 ---- * @param attributeName The name of the attribute to remove * @param newval Simple string (no xml) The new value of the attribute ! * @throws XMLDBException This method is a low level helper method - throw ! * all occurring exceptions */ private void updateAttribute(String xPath, String attributeName, *************** *** 1029,1035 **** * @param baseXPath The XPath which points <b>exactly</b> to the node to * update, it must not match to several nodes. */ public final void update(final String oldXML, final String newXML, ! final String baseXPath) throws XMLDBException{ Document oldDoc = null; Document newDoc = null; --- 1033,1043 ---- * @param baseXPath The XPath which points <b>exactly</b> to the node to * update, it must not match to several nodes. + * @throws XMLDBException This may be the case if this relatively + * sophisticated method has a major problem (e.g. the old XML data is not + * equal to the XML in the database) or in case there are XUpdate problems + * (bugs in Xindice). */ public final void update(final String oldXML, final String newXML, ! final String baseXPath) throws XMLDBException { Document oldDoc = null; Document newDoc = null; *************** *** 1418,1424 **** * @throws XMLDBException Low-level helper method, may throw Exceptions * from underlying engine. */ ! private void normalizeNodes(String docKey) throws XMLDBException { XMLResource current = (XMLResource) collection.getResource(docKey); --- 1426,1434 ---- * @throws XMLDBException Low-level helper method, may throw Exceptions * from underlying engine. + * @throws CobricksException Is thrown if database is offline */ ! private void normalizeNodes(String docKey) throws XMLDBException, ! CobricksException { XMLResource current = (XMLResource) collection.getResource(docKey); *************** *** 1475,1478 **** --- 1485,1491 ---- } catch (XMLDBException e) { logger.warn("Exception while trying to norm: " + e.toString()); + } catch (CobricksException e) { + logger.error("Database went offline during data normalizing. " + "Data maybe lost. "); + return; } *************** *** 1489,1499 **** * */ ! public final void updateWholeDocument(String xmlData, String key) { ! try { this.removeDocument(key); ! } catch (XMLDBException e) { ! logger.warn("An exception occured while trying to delete old data" ! + "for updating."); ! } this.insertDocument(xmlData, key); } --- 1502,1512 ---- * */ ! public final void updateWholeDocument(String xmlData, String key) throws ! XMLDBException, CobricksException { this.removeDocument(key); ! // } catch (XMLDBException e) { ! // logger.warn("An exception occured while trying to delete old data" ! // + "for updating."); ! // } this.insertDocument(xmlData, key); } |
|
From: <j_m...@us...> - 2004-03-06 21:56:31
|
Update of /cvsroot/cobricks/cobricks2/web/item In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16991/web/item Modified Files: itemcreate_error.html index.html itemcreate.html Added Files: itemupdate_error.html itemupdate.html itemupdate_changedIC.html itemupdate_success.html itemupdate_selectItem.html Log Message: --- NEW FILE: itemupdate_error.html --- #parse ("pageheader.html") <h1>Cobricks-2 - Item Update</h1> <p> <b>The following error(s) ocurred:</b><br/> <ul>#foreach($error in $errors) <li>$itemPresenter.printErrorMessage($error, $lang)</li> #end </ul><br/> <b>Please try again.</b> </p> <hr/> #set($itemid = $portalRequest.getRequestParameter("itemid")) #set($item = $itemPresenter.getItem($itemid)) #set($itemClass = $item.getItemClass()) <form action="/ITEM" method="get"> <h2>Change attributes:</h2> <p> <table cellspacing="10"> <tr valign="top"> <td><b>Item class</b></td> <td>$itemPresenter.printItemClassesDropDown("itemClass", "item", $itemClass, false)</td> <td colspan="2">Description for item class "$itemClass": $itemPresenter.printDescription($itemClass, null, $lang)</td> </tr> <tr valign="top"> <td><b>Item ID</b><td/> <td>$itemPresenter.printAttrInput($itemClass, "itemid", $itemid, 1, 15, true)</td> <td colspan="2">$itemPresenter.printDescription($itemClass, "itemid", $lang)</td> </tr> <tr valign="top"> <td colspan="2"><table> <tr><td><b>Title</b></td> <td>(in language $itemPresenter.printMultiLangDropDown($itemClass, "title", $lang, $portalRequest.getRequestParameter("title_lang")))</td></tr> <tr><td colspan="2">$itemPresenter.printDescription($itemClass, "title", $lang)</td></tr> </table></td> <td colspan="2">$itemPresenter.printAttrInput("item", "title", $portalRequest.getRequestParameter("title"), 1, 50, false)</td> </tr><tr valign="top"> <td colspan="2"><table> <tr><td><b>Content</b></td> <td>(in language $itemPresenter.printMultiLangDropDown($itemClass, "content", $lang, $portalRequest.getRequestParameter("content_lang")))</td></tr> <tr><td colspan="2">$itemPresenter.printDescription($itemClass, "content", $lang)</td></tr> </table></td> <td colspan="2">$itemPresenter.printAttrInput("item", "content", $portalRequest.getRequestParameter("content"), 15, 80, false)</td> </tr></table> <table cellspacing="10"><tr valign="top"> <td><b>Location</b><br/>$itemPresenter.printDescription($itemClass, "location", $lang)</td> <td>$itemPresenter.printAttrInput("item", "location", $portalRequest.getRequestParameter("location"), 1, 50, false)</td> <td align="right"><b>Origin</b><br/>$itemPresenter.printDescription($itemClass, "origin", $lang)</td> <td>$itemPresenter.printAttrInput("item", "origin", $portalRequest.getRequestParameter("origin"), 1, 20, false)</td> </tr><tr valign="top"> <td><b>State</b><br/>$itemPresenter.printDescription($itemClass, "state", $lang)</td> <td>$itemPresenter.printStateInput($itemClass, $portalRequest.getRequestParameter("state"))</td> <td align="right"><b>Expiration time</b><br/>$itemPresenter.printDescription($itemClass, "expirationtime", $lang)</td> <td>$itemPresenter.printAttrInput("item", "expirationtime", $portalRequest.getRequestParameter("expirationtime"), 1, 15, false)</td> </tr></table> </p> $itemPresenter.printHiddenAttr("updater", $userId) $itemPresenter.printHiddenAttr("updatetime", $itemPresenter.getCurrentDateTime()) $itemPresenter.printHiddenAttr("cmd", "updateitem") $itemPresenter.printHiddenAttr("cmd.success", "/item/itemupdate_success.html") $itemPresenter.printHiddenAttr("cmd.error", "/item/itemupdate_error.html") $itemPresenter.printHiddenAttr("cmd.changedItemClass", "/item/itemupdate_changedIC.html") #if(!($itemClass == "item" || $itemClass == "")) #set($attrs = $itemPresenter.getAttributeNames($itemClass)) #set($attrs = $itemPresenter.removeAttributeDuplicates($attrs, "item")) #if(!$attrs.isEmpty()) <p> <table cellspacing="10"> #foreach($attr in $attrs) <tr valign="top"> <td><b>$attr</b><br/>$itemPresenter.printDescription($itemClass, $attr, $lang)</td> <td>$itemPresenter.printMultiLangDropDown($itemClass, $attr, $lang, "") $itemPresenter.printAttrInput($itemClass, $attr, $portalRequest.getRequestParameter($attr), -1, 80, false)</td> </tr> #end </table> </p> #end <hr/> #end <p> <h2>Change/add custom attributes:</h2> <table cellspacing="10"> <tr valign="top"> <td><b>Attribute name</b></td> <td>$itemPresenter.printNewAttrInput("_customAname_1", $portalRequest.getRequestParameter("newattribute1"), 10)</td> <td><b>Attribute value</b></td> <td>$itemPresenter.printNewAttrInput("_customAvalue_1", $portalRequest.getRequestParameter("newvalue1"), 80)</td> </tr> <tr valign="top"> <td><b>Attribute name</b></td> <td>$itemPresenter.printNewAttrInput("_customAname_2", $portalRequest.getRequestParameter("newattribute2"), 10)</td> <td><b>Attribute value</b></td> <td>$itemPresenter.printNewAttrInput("_customAvalue_2", $portalRequest.getRequestParameter("newvalue2"), 80)</td> </tr> <tr valign="top"> <td><b>Attribute name</b></td> <td>$itemPresenter.printNewAttrInput("_customAname_3", $portalRequest.getRequestParameter("newattribute3"), 10)</td> <td><b>Attribute value</b></td> <td>$itemPresenter.printNewAttrInput("_customAvalue_3", $portalRequest.getRequestParameter("newvalue3"), 80)</td> </tr> </table> </p> <hr/></br> <input type="submit" value="Submit"/> </form> <form action="/item/itemupdate.html" method="get"> $itemPresenter.printHiddenAttr("itemid", $itemid) <input type="submit" value="Reset all values"/> </form> #parse ("pagefooter.html") --- NEW FILE: itemupdate.html --- #parse ("pageheader.html") <h1>Cobricks-2 - Item Update</h1> #set($itemid = $portalRequest.getRequestParameter("itemid")) #set($item = $itemPresenter.getItem($itemid)) #if(!$itemPresenter.isInteger($itemid)) <p><h2>Entered item ID $!itemid is not an integer, please enter another ID</h2> <form action="/item/itemupdate_selectItem.html" method="get"> <input type="submit" value="back"/> </form> </p> #elseif(!$item) <p><h2>Item with item ID $!itemid does not exist, please enter another ID</h2> <form action="/item/itemupdate_selectItem.html" method="get"> <input type="submit" value="back"/> </form> </p> #else #set($itemClass = $item.getItemClass()) <form action="/ITEM" method="get"> <h2>Change attributes:</h2> <p> <table cellspacing="10"> <tr valign="top"> <td><b>Item class</b></td> <td>$itemPresenter.printItemClassesDropDown("itemclass", "item", $itemClass, false)</td> <td colspan="2">Description for item class "$itemClass": $itemPresenter.printDescription($itemClass, null, $lang)</td> </tr> <tr valign="top"> <td><b>Item ID</b></td> <td>$itemPresenter.printAttrInput($itemClass, "itemid", $itemid, 1, 15, true)</td> <td colspan="2">$itemPresenter.printDescription($itemClass, "itemid", $lang)</td> </tr> <tr valign="top"> <td colspan="2"> <table> <tr><td><b>Title</b></td> <td>(in language $itemPresenter.printMultiLangDropDown($itemClass, "title", $lang, ""))</td></tr> <tr><td colspan="2">$itemPresenter.printDescription($itemClass, "title", $lang)</td></tr> </table></td> <td colspan="2">$itemPresenter.printAttrInput("item", "title", $item.getStringAttribute("title"), 1, 50, false)</td> </tr><tr valign="top"> <td colspan="2"><table> <tr><td><b>Content</b></td> <td>(in language $itemPresenter.printMultiLangDropDown($itemClass, "content", $lang, ""))</td></tr> <tr><td colspan="2">$itemPresenter.printDescription($itemClass, "content", $lang)</td></tr> </table></td> <td colspan="2">$itemPresenter.printAttrInput("item", "content", $item.getStringAttribute("content"), 15, 80, false)</td> </tr></table> <table cellspacing="10"><tr valign="top"> <td><b>Location</b><br/>$itemPresenter.printDescription($itemClass, "location", $lang)</td> <td>$itemPresenter.printAttrInput("item", "location", $item.getStringAttribute("location"), 1, 50, false)</td> <td align="right"><b>Origin</b><br/>$itemPresenter.printDescription($itemClass, "origin", $lang)</td> <td>$itemPresenter.printAttrInput("item", "origin", $item.getStringAttribute("origin"), 1, 20, false)</td> </tr><tr valign="top"> <td><b>State</b><br/>$itemPresenter.printDescription($itemClass, "state", $lang)</td> <td>$itemPresenter.printStateInput($itemClass, $item.getStringAttribute("state"))</td> <td align="right"><b>Expiration time</b><br/>$itemPresenter.printDescription($itemClass, "expirationtime", $lang)</td> <td>$itemPresenter.printAttrInput("item", "expirationtime", $item.getStringAttribute("expirationtime"), 1, 15, false)</td> </tr></table> </p> $itemPresenter.printHiddenAttr("updater", $userId) $itemPresenter.printHiddenAttr("updatetime", $itemPresenter.getCurrentDateTime()) $itemPresenter.printHiddenAttr("cmd", "updateitem") $itemPresenter.printHiddenAttr("cmd.success", "/item/itemupdate_success.html") $itemPresenter.printHiddenAttr("cmd.error", "/item/itemupdate_error.html") $itemPresenter.printHiddenAttr("cmd.changedItemClass", "/item/itemupdate_changedIC.html") #if(!($itemClass == "item" || $itemClass == "")) #set($attrs = $itemPresenter.getAttributeNames($itemClass)) #set($attrs = $itemPresenter.removeAttributeDuplicates($attrs, "item")) #if(!$attrs.isEmpty()) <p> <table cellspacing="10"> #foreach($attr in $attrs) <tr valign="top"> <td><b>$attr</b><br/>$itemPresenter.printDescription($itemClass, $attr, $lang)</td> <td>$itemPresenter.printMultiLangDropDown($itemClass, $attr, $lang, "") $itemPresenter.printAttrInput($itemClass, $attr, $item.getStringAttribute($attr), -1, 80, false)</td> </tr> #end </table> </p> #end <hr/> #end <p> <h2>Define new attributes:</h2> <table cellspacing="10"> <tr valign="top"> <td><b>Attribute name</b></td> <td>$itemPresenter.printNewAttrInput("_customAname_1", null, 10)</td> <td><b>Attribute value</b></td> <td>$itemPresenter.printNewAttrInput("_customAvalue_1", null, 80)</td> </tr> <tr valign="top"> <td><b>Attribute name</b></td> <td>$itemPresenter.printNewAttrInput("_customAname_2", null, 10)</td> <td><b>Attribute value</b></td> <td>$itemPresenter.printNewAttrInput("_customAvalue_2", null, 80)</td> </tr> <tr valign="top"> <td><b>Attribute name</b></td> <td>$itemPresenter.printNewAttrInput("_customAname_3", null, 10)</td> <td><b>Attribute value</b></td> <td>$itemPresenter.printNewAttrInput("_customAvalue_3", null, 80)</td> </tr> </table> </p> <hr/> <p> <table><tr> <td><input type="submit" value="Submit"/></td> <td><input type="reset" value="Cancel"/></td> </tr></table> </p> </form> <form action="/item/itemupdate_selectItem.html" method="get"> <input type="submit" value="Select new item"/> </form> #end #parse ("pagefooter.html") --- NEW FILE: itemupdate_changedIC.html --- #parse ("pageheader.html") <h1>Cobricks-2 - Item Update</h1> #set($itemid = $portalRequest.getRequestParameter("itemid")) #set($itemClass = $portalRequest.getRequestParameter("itemclass")) <h2>Item class has been changed from "$oldItemClass" to "$itemClass"</h2> <form action="/ITEM" method="get"> <table cellspacing="10"> <tr valign="top"> <td colspan="2"><b>Item ID</b><br/>$itemPresenter.printDescription($itemClass, "itemid", $lang)</td> <td colspan="2">$itemPresenter.printAttrInput($itemClass, "itemid", $itemid, 1, 15, true)</td> </tr> </table> <br/><hr/> #set($oldattrs = $itemPresenter.getAttributeNames($oldItemClass)) #set($attrs = $itemPresenter.getAttributeNames($itemClass)) #set($temp1 = $itemPresenter.removeAttributeDuplicates($attrs, $oldItemClass)) #set($additional = $itemPresenter.removeUnchangedAttributes($temp1)) #if(!$additional.isEmpty()) <h2>The following attributes are additional attributes of item class "$itemClass".</h2> <h3>Change additional attributes:</h3> <p> <table cellspacing="10"> #foreach($attradd in $additional) <tr valign="top"> <td><b>$attradd</b><br/>$itemPresenter.printDescription($itemClass, $attradd, $lang)</td> <td>$itemPresenter.printMultiLangDropDown($itemClass, $attradd, $lang, $portalRequest.getRequestParameter($itemPresenter.concat($attradd, "_lang"))) $itemPresenter.printAttrInput($itemClass, $attradd, null, -1, 80, false)</td> </tr> #end </table> </p> <hr/> #end #set($temp2 = $itemPresenter.removeAttributeDuplicates($oldattrs, $itemClass)) #set($lost = $itemPresenter.removeUnchangedAttributes($temp2)) #if(!$lost.isEmpty()) <h2>The following attributes do not exist in item class "$itemClass".</h2> <h3>You may either delete them or submit them as custon attributes (values are transformed into String):</h3> <p> <table cellspacing="10"> #foreach($attrlost in $lost) #set($temp21 = $portalRequest.getRequestParameter($attrlost)) #if(!(($temp21 == "") || ($temp21 == $itemPresenter.getDateFormat()))) <tr valign="top"> <td><b>$attrlost</b><br/>$itemPresenter.printDescription($oldItemClass, $attrlost, $lang)</td> <td>$itemPresenter.printMultiLangDropDown($oldItemClass, $attrlost, $lang, $portalRequest.getRequestParameter($itemPresenter.concat($attrlost, "_lang"))) $itemPresenter.printAttrInput($oldItemClass, $attrlost, $portalRequest.getRequestParameter($attrlost), -1, 80, false)</td> <td>$itemPresenter.printRadioSubDel($attrlost, "delete")</td> </tr> #end #end </table> </p> <hr/> #end #set($temp3 = $itemPresenter.getCommonAttributes($oldattrs, $attrs)) #set($remain = $itemPresenter.removeUnchangedAttributes($temp3)) #if(!$remain.isEmpty()) <h2>The following attributes exist in both item classes "$oldItemClass" and "$itemClass" and will be maintained.</h2> <h3>Change remaining attributes again:</h3> <p> <table cellspacing="10"> #foreach($attr in $remain) <tr valign="top"> <td><b>$attr</b><br/>$itemPresenter.printDescription($itemClass, $attr, $lang)</td> <td>$itemPresenter.printMultiLangDropDown($itemClass, $attr, $lang, $portalRequest.getRequestParameter($itemPresenter.concat($attr, "_lang"))) $itemPresenter.printAttrInput($itemClass, $attr, $portalRequest.getRequestParameter($attr), -1, 80, false)</td> </tr> #end </table> #end <h3>Custom attributes:</h3> <table cellspacing="10"> <tr valign="top"> <td><b>Attribute name: $!portalRequest.getRequestParameter("_customAname_1")</b></td> <td>$itemPresenter.printNewAttrInput("_customAname_1", $portalRequest.getRequestParameter("_customAname_1"), 10)</td> <td><b>Attribute value</b></td> <td>$itemPresenter.printNewAttrInput("_customAvalue_1", $portalRequest.getRequestParameter("_customAvalue_1"), 80)</td> </tr> <tr valign="top"> <td><b>Attribute name: $!portalRequest.getRequestParameter("_customAname_2")</b></td> <td>$itemPresenter.printNewAttrInput("_customAname_2", $portalRequest.getRequestParameter("_customAname_2"), 10)</td> <td><b>Attribute value</b></td> <td>$itemPresenter.printNewAttrInput("_customAvalue_2", $portalRequest.getRequestParameter("_customAvalue_2"), 80)</td> </tr> <tr valign="top"> <td><b>Attribute name: $!portalRequest.getRequestParameter("_customAname_3")</b></td> <td>$itemPresenter.printNewAttrInput("_customAname_3", $portalRequest.getRequestParameter("_customAname_3"), 10)</td> <td><b>Attribute value</b></td> <td>$itemPresenter.printNewAttrInput("_customAvalue_3", $portalRequest.getRequestParameter("_customAvalue_3"), 80)</td> </tr> </table> </p> <hr/> $itemPresenter.printHiddenAttr("updater", $userId) $itemPresenter.printHiddenAttr("updatetime", $itemPresenter.getCurrentDateTime()) $itemPresenter.printHiddenAttr("cmd", "updateitem") $itemPresenter.printHiddenAttr("cmd.success", "/item/itemupdate_success.html") $itemPresenter.printHiddenAttr("cmd.error", "/item/itemupdate_error.html") $itemPresenter.printHiddenAttr("cmd.changedItemClass", "/item/itemupdate_changedIC.html") $itemPresenter.printHiddenAttr("_previousitemclass", $itemClass) <p> <b>Change item class again?</b> (Original item class was <b>$oldItemClass</b>)<br/> <table cellspacing="10"><tr valign="top"> <td>$itemPresenter.printItemClassesDropDown("itemclass", "item", $itemClass, false)</td> <td>Description for item class "$itemClass": $itemPresenter.printDescription($itemClass, null, $lang)</td> </tr></table> </p> <hr/><br/> <input type="submit" value="Continue"/> </form> <form action="/item/itemupdate.html" method="get"> $itemPresenter.printHiddenAttr("itemid", $itemid) <input type="submit" value="Reset all values"/> </form> #parse ("pagefooter.html") --- NEW FILE: itemupdate_success.html --- #parse ("pageheader.html") <h1>Cobricks-2 - Item Update</h1> #set($itemid = $portalRequest.getRequestParameter("itemid")) <h2>Item $itemid successfully uupdated</h2> <p><b>Further updates?</b> <table><tr> <td><form action="/item/itemupdate.html" method="get"> $itemPresenter.printHiddenAttr("itemid", $itemid) <input type="submit" value="same item"/> </form></td> <td><form action="/item/itemupdate_selectItem.html" method="get"> <input type="submit" value="change item ID"/> </form></td> </tr></table> </p> #parse ("pagefooter.html") --- NEW FILE: itemupdate_selectItem.html --- #parse ("pageheader.html") <h1>Cobricks-2 - Item Update</h1> <h2>Enter item ID</h2> <form action="/item/itemupdate.html" method="get"> <input name="itemid" type="text" size="15"/> <p> <table><tr> <td><input type="submit" value="Submit"/></td> <td><input type="reset" value="Cancel"/></td> </tr></table> </p> </form> #parse ("pagefooter.html") Index: itemcreate_error.html =================================================================== RCS file: /cvsroot/cobricks/cobricks2/web/item/itemcreate_error.html,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** itemcreate_error.html 2 Mar 2004 17:44:49 -0000 1.1 --- itemcreate_error.html 6 Mar 2004 21:33:28 -0000 1.2 *************** *** 5,9 **** <p> ! <b>The following error(s) ocurred:</b><br/> <ul>#foreach($error in $errors) <li>$itemPresenter.printErrorMessage($error, $lang)</li> --- 5,9 ---- <p> ! <h2>The following error(s) ocurred:</h2> <ul>#foreach($error in $errors) <li>$itemPresenter.printErrorMessage($error, $lang)</li> *************** *** 12,16 **** <b>Please try again.</b> </p> ! <hr/><br/> --- 12,16 ---- <b>Please try again.</b> </p> ! <hr/> *************** *** 21,65 **** #end - <form action="/item/itemcreate.html" method="get"> <p> ! <table> ! <tr><td colspan="2"><b>Select item class:</b></td></tr> ! <tr> ! <td>$itemPresenter.printItemClassesDropDown("itemClass", "item", $itemClass)</td> ! <td>Description for item class "$itemClass": $itemPresenter.printDescription($itemClass, null, $lang)</td> ! </tr> ! <tr><td colspan="2"><input type="submit" value="Submit"/></td></tr> ! </table> ! </p> ! </form> ! <hr/><br/> ! <h2>Enter attributes</h2> <form action="/ITEM" method="get"> ! <p> <table cellspacing="10"><tr valign="top"> <td colspan="2"><table> <tr><td><b>Title</b></td> ! <td>(in language $itemPresenter.printMultiLangDropDown($itemClass, "title", $lang))</td></tr> <tr><td colspan="2">$itemPresenter.printDescription($itemClass, "title", $lang)</td></tr> </table></td> ! <td colspan="2">$itemPresenter.printAttrInput("item", "title", $portalRequest.getRequestParameter("title"), 1, 50)</td> </tr><tr valign="top"> <td colspan="2"><table> <tr><td><b>Content</b></td> ! <td>(in language $itemPresenter.printMultiLangDropDown($itemClass, "content", $lang))</td></tr> <tr><td colspan="2">$itemPresenter.printDescription($itemClass, "content", $lang)</td></tr> </table></td> ! <td colspan="2">$itemPresenter.printAttrInput("item", "content", $portalRequest.getRequestParameter("content"), 15, 80)</td> </tr></table> <table cellspacing="10"><tr valign="top"> <td><b>Location</b><br/>$itemPresenter.printDescription($itemClass, "location", $lang)</td> ! <td>$itemPresenter.printAttrInput("item", "location", $portalRequest.getRequestParameter("location"), 1, 50)</td> <td align="right"><b>Origin</b><br/>$itemPresenter.printDescription($itemClass, "origin", $lang)</td> ! <td>$itemPresenter.printAttrInput("item", "origin", $portalRequest.getRequestParameter("origin"), 1, 20)</td> </tr><tr valign="top"> <td><b>State</b><br/>$itemPresenter.printDescription($itemClass, "state", $lang)</td> <td>$itemPresenter.printStateInput($itemClass, $portalRequest.getRequestParameter("state"))</td> <td align="right"><b>Expiration time</b><br/>$itemPresenter.printDescription($itemClass, "expirationtime", $lang)</td> ! <td>$itemPresenter.printAttrInput("item", "expirationtime", $portalRequest.getRequestParameter("expirationtime"), 1, 15)</td> </tr></table> </p> --- 21,53 ---- #end <p> ! <h2>Change attributes (item class is "$!itemClass"):</h2> <form action="/ITEM" method="get"> ! <table cellspacing="10"><tr valign="top"> <td colspan="2"><table> <tr><td><b>Title</b></td> ! <td>(in language $itemPresenter.printMultiLangDropDown($itemClass, "title", $lang, $portalRequest.getRequestParameter("title_lang")))</td></tr> <tr><td colspan="2">$itemPresenter.printDescription($itemClass, "title", $lang)</td></tr> </table></td> ! <td colspan="2">$itemPresenter.printAttrInput("item", "title", $portalRequest.getRequestParameter("title"), 1, 50, false)</td> </tr><tr valign="top"> <td colspan="2"><table> <tr><td><b>Content</b></td> ! <td>(in language $itemPresenter.printMultiLangDropDown($itemClass, "content", $lang, $portalRequest.getRequestParameter("content_lang")))</td></tr> <tr><td colspan="2">$itemPresenter.printDescription($itemClass, "content", $lang)</td></tr> </table></td> ! <td colspan="2">$itemPresenter.printAttrInput("item", "content", $portalRequest.getRequestParameter("content"), 15, 80, false)</td> </tr></table> <table cellspacing="10"><tr valign="top"> <td><b>Location</b><br/>$itemPresenter.printDescription($itemClass, "location", $lang)</td> ! <td>$itemPresenter.printAttrInput("item", "location", $portalRequest.getRequestParameter("location"), 1, 50, false)</td> <td align="right"><b>Origin</b><br/>$itemPresenter.printDescription($itemClass, "origin", $lang)</td> ! <td>$itemPresenter.printAttrInput("item", "origin", $portalRequest.getRequestParameter("origin"), 1, 20, false)</td> </tr><tr valign="top"> <td><b>State</b><br/>$itemPresenter.printDescription($itemClass, "state", $lang)</td> <td>$itemPresenter.printStateInput($itemClass, $portalRequest.getRequestParameter("state"))</td> <td align="right"><b>Expiration time</b><br/>$itemPresenter.printDescription($itemClass, "expirationtime", $lang)</td> ! <td>$itemPresenter.printAttrInput("item", "expirationtime", $portalRequest.getRequestParameter("expirationtime"), 1, 15, false)</td> </tr></table> </p> *************** *** 76,87 **** #if(!$attrs.isEmpty()) <p> - <hr/><br/> - <b>Further Attributes</b><br/> <table cellspacing="10"> #foreach($attr in $attrs) <tr valign="top"> <td><b>$attr</b><br/>$itemPresenter.printDescription($itemClass, $attr, $lang)</td> ! <td>$itemPresenter.printMultiLangDropDown($itemClass, $attr, $lang) ! $itemPresenter.printAttrInput($itemClass, $attr, $portalRequest.getRequestParameter($attr), -1, 80)</td> </tr> #end --- 64,73 ---- #if(!$attrs.isEmpty()) <p> <table cellspacing="10"> #foreach($attr in $attrs) <tr valign="top"> <td><b>$attr</b><br/>$itemPresenter.printDescription($itemClass, $attr, $lang)</td> ! <td>$itemPresenter.printMultiLangDropDown($itemClass, $attr, $lang, "") ! $itemPresenter.printAttrInput($itemClass, $attr, $portalRequest.getRequestParameter($attr), -1, 80, false)</td> </tr> #end *************** *** 90,100 **** #end #end ! <p> ! <table><tr> ! <td><input type="submit" value="Submit"/></td> ! <td><input type="reset" value="Cancel"/></td> ! </tr></table> </p> </form> --- 76,110 ---- #end #end ! <hr/> ! <p> ! <h2>Change/add custom attributes:</h2> ! <table cellspacing="10"> ! <tr valign="top"> ! <td><b>Attribute name</b></td> ! <td>$itemPresenter.printNewAttrInput("_customAname_1", $portalRequest.getRequestParameter("newattribute1"), 10)</td> ! <td><b>Attribute value</b></td> ! <td>$itemPresenter.printNewAttrInput("_customAvalue_1", $portalRequest.getRequestParameter("newvalue1"), 80)</td> ! </tr> ! <tr valign="top"> ! <td><b>Attribute name</b></td> ! <td>$itemPresenter.printNewAttrInput("_customAname_2", $portalRequest.getRequestParameter("newattribute2"), 10)</td> ! <td><b>Attribute value</b></td> ! <td>$itemPresenter.printNewAttrInput("_customAvalue_2", $portalRequest.getRequestParameter("newvalue2"), 80)</td> ! </tr> ! <tr valign="top"> ! <td><b>Attribute name</b></td> ! <td>$itemPresenter.printNewAttrInput("_customAname_3", $portalRequest.getRequestParameter("newattribute3"), 10)</td> ! <td><b>Attribute value</b></td> ! <td>$itemPresenter.printNewAttrInput("_customAvalue_3", $portalRequest.getRequestParameter("newvalue3"), 80)</td> ! </tr> ! </table> </p> + <hr/></br> + <input type="submit" value="Submit"/> + </form> + + <form action="/item/itemcreate.html" method="get"> + <input type="submit" value="Reset all values"/> </form> Index: index.html =================================================================== RCS file: /cvsroot/cobricks/cobricks2/web/item/index.html,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** index.html 2 Mar 2004 17:44:49 -0000 1.3 --- index.html 6 Mar 2004 21:33:28 -0000 1.4 *************** *** 16,19 **** --- 16,20 ---- <li><a href="itemlist.html?itemclass=item">Item list</a></li> <li><a href="itemcreate.html">Create a new item</a></li> + <li><a href="itemupdate_selectItem.html">Update an existing item</a></li> </ul> Index: itemcreate.html =================================================================== RCS file: /cvsroot/cobricks/cobricks2/web/item/itemcreate.html,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** itemcreate.html 2 Mar 2004 17:44:49 -0000 1.1 --- itemcreate.html 6 Mar 2004 21:33:28 -0000 1.2 *************** *** 6,14 **** #if($createdItem) <p> ! <b>Item successfully created:</b><br/> Item ID: $!createdItem.getLocalId()<br/> Item title: $!createdItem.getTitle() </p> ! <hr/><br/> #end --- 6,14 ---- #if($createdItem) <p> ! <h2>Item was successfully created:</h2> Item ID: $!createdItem.getLocalId()<br/> Item title: $!createdItem.getTitle() </p> ! <hr/> #end *************** *** 21,28 **** <form action="/item/itemcreate.html" method="get"> <p> <table> - <tr><td colspan="2"><b>Select item class:</b></td></tr> <tr> ! <td>$itemPresenter.printItemClassesDropDown("itemClass", "item", $itemClass)</td> <td>Description for item class "$itemClass": $itemPresenter.printDescription($itemClass, null, $lang)</td> </tr> --- 21,28 ---- <form action="/item/itemcreate.html" method="get"> <p> + <h2>Select item class:</h2> <table> <tr> ! <td>$itemPresenter.printItemClassesDropDown("itemClass", "item", $itemClass, true)</td> <td>Description for item class "$itemClass": $itemPresenter.printDescription($itemClass, null, $lang)</td> </tr> *************** *** 31,63 **** </p> </form> ! <hr/><br/> ! <h2>Enter attributes</h2> ! <form action="/ITEM" method="get"> <p> <table cellspacing="10"><tr valign="top"> <td colspan="2"><table> <tr><td><b>Title</b></td> ! <td>(in language $itemPresenter.printMultiLangDropDown($itemClass, "title", $lang))</td></tr> <tr><td colspan="2">$itemPresenter.printDescription($itemClass, "title", $lang)</td></tr> </table></td> ! <td colspan="2">$itemPresenter.printAttrInput("item", "title", null, 1, 50)</td> </tr><tr valign="top"> <td colspan="2"><table> <tr><td><b>Content</b></td> ! <td>(in language $itemPresenter.printMultiLangDropDown($itemClass, "content", $lang))</td></tr> <tr><td colspan="2">$itemPresenter.printDescription($itemClass, "content", $lang)</td></tr> </table></td> ! <td colspan="2">$itemPresenter.printAttrInput("item", "content", null, 15, 80)</td> </tr></table> <table cellspacing="10"><tr valign="top"> <td><b>Location</b><br/>$itemPresenter.printDescription($itemClass, "location", $lang)</td> ! <td>$itemPresenter.printAttrInput("item", "location", null, 1, 50)</td> <td align="right"><b>Origin</b><br/>$itemPresenter.printDescription($itemClass, "origin", $lang)</td> ! <td>$itemPresenter.printAttrInput("item", "origin", null, 1, 20)</td> </tr><tr valign="top"> <td><b>State</b><br/>$itemPresenter.printDescription($itemClass, "state", $lang)</td> <td>$itemPresenter.printStateInput($itemClass, "")</td> <td align="right"><b>Expiration time</b><br/>$itemPresenter.printDescription($itemClass, "expirationtime", $lang)</td> ! <td>$itemPresenter.printAttrInput("item", "expirationtime", null, 1, 15)</td> </tr></table> </p> --- 31,64 ---- </p> </form> ! <hr/> <p> + <h2>Enter attributes:</h2> + <form action="/ITEM" method="get"> + <table cellspacing="10"><tr valign="top"> <td colspan="2"><table> <tr><td><b>Title</b></td> ! <td>(in language $itemPresenter.printMultiLangDropDown($itemClass, "title", $lang, ""))</td></tr> <tr><td colspan="2">$itemPresenter.printDescription($itemClass, "title", $lang)</td></tr> </table></td> ! <td colspan="2">$itemPresenter.printAttrInput("item", "title", null, 1, 50, false)</td> </tr><tr valign="top"> <td colspan="2"><table> <tr><td><b>Content</b></td> ! <td>(in language $itemPresenter.printMultiLangDropDown($itemClass, "content", $lang, ""))</td></tr> <tr><td colspan="2">$itemPresenter.printDescription($itemClass, "content", $lang)</td></tr> </table></td> ! <td colspan="2">$itemPresenter.printAttrInput("item", "content", null, 15, 80, false)</td> </tr></table> <table cellspacing="10"><tr valign="top"> <td><b>Location</b><br/>$itemPresenter.printDescription($itemClass, "location", $lang)</td> ! <td>$itemPresenter.printAttrInput("item", "location", null, 1, 50, false)</td> <td align="right"><b>Origin</b><br/>$itemPresenter.printDescription($itemClass, "origin", $lang)</td> ! <td>$itemPresenter.printAttrInput("item", "origin", null, 1, 20, false)</td> </tr><tr valign="top"> <td><b>State</b><br/>$itemPresenter.printDescription($itemClass, "state", $lang)</td> <td>$itemPresenter.printStateInput($itemClass, "")</td> <td align="right"><b>Expiration time</b><br/>$itemPresenter.printDescription($itemClass, "expirationtime", $lang)</td> ! <td>$itemPresenter.printAttrInput("item", "expirationtime", null, 1, 15, false)</td> </tr></table> </p> *************** *** 74,85 **** #if(!$attrs.isEmpty()) <p> ! <hr/><br/> ! <b>Further Attributes</b><br/> <table cellspacing="10"> #foreach($attr in $attrs) <tr valign="top"> <td><b>$attr</b><br/>$itemPresenter.printDescription($itemClass, $attr, $lang)</td></td> ! <td>$itemPresenter.printMultiLangDropDown($itemClass, $attr, $lang) ! $itemPresenter.printAttrInput($itemClass, $attr, null, -1, 80)</td> </tr> #end --- 75,85 ---- #if(!$attrs.isEmpty()) <p> ! <h3>Further Attributes:</h3> <table cellspacing="10"> #foreach($attr in $attrs) <tr valign="top"> <td><b>$attr</b><br/>$itemPresenter.printDescription($itemClass, $attr, $lang)</td></td> ! <td>$itemPresenter.printMultiLangDropDown($itemClass, $attr, $lang, "") ! $itemPresenter.printAttrInput($itemClass, $attr, null, -1, 80, false)</td> </tr> #end *************** *** 88,92 **** #end #end ! <p> <table><tr> --- 88,117 ---- #end #end ! <hr/> ! ! <p> ! <h2>Define new attributes:</h2> ! <table cellspacing="10"> ! <tr valign="top"> ! <td><b>Attribute name</b></td> ! <td>$itemPresenter.printNewAttrInput("_customAname_1", null, 10)</td> ! <td><b>Attribute value</b></td> ! <td>$itemPresenter.printNewAttrInput("_customAvalue_1", null, 80)</td> ! </tr> ! <tr valign="top"> ! <td><b>Attribute name</b></td> ! <td>$itemPresenter.printNewAttrInput("_customAname_2", null, 10)</td> ! <td><b>Attribute value</b></td> ! <td>$itemPresenter.printNewAttrInput("_customAvalue_2", null, 80)</td> ! </tr> ! <tr valign="top"> ! <td><b>Attribute name</b></td> ! <td>$itemPresenter.printNewAttrInput("_customAname_3", null, 10)</td> ! <td><b>Attribute value</b></td> ! <td>$itemPresenter.printNewAttrInput("_customAvalue_3", null, 80)</td> ! </tr> ! </table> ! </p> ! <hr/> <p> <table><tr> |
|
From: <j_m...@us...> - 2004-03-06 21:55:51
|
Update of /cvsroot/cobricks/cobricks2/conf/org.cobricks.item In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16902/conf/org.cobricks.item Modified Files: inputerrors.xml Log Message: added descriptions Index: inputerrors.xml =================================================================== RCS file: /cvsroot/cobricks/cobricks2/conf/org.cobricks.item/inputerrors.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** inputerrors.xml 2 Mar 2004 17:38:23 -0000 1.1 --- inputerrors.xml 6 Mar 2004 21:32:49 -0000 1.2 *************** *** 34,37 **** --- 34,43 ---- </desc> </error> + <error name="ILLEGAL_INTEGER" serverity="1"> + <desc> + The data you entered was alphanumeric. Please enter only digits (or in case it is + a list: the numbers separated with ";") + </desc> + </error> <error name="ILLEGAL_BOOLEAN" serverity="1"> <desc> |
|
From: <sap...@us...> - 2004-03-03 18:11:23
|
Update of /cvsroot/cobricks/cobricks2/src/org/cobricks/util/migration In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6656/src/org/cobricks/util/migration Added Files: MigrationTool.java Log Message: Initial Version --- NEW FILE: MigrationTool.java --- /* * Copyright (c) 2003 Cobricks Group. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted under the terms of the Cobricks Software * License, either version 1.0 of the License, or (at your option) any * later version (see www.cobricks.org). * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. */ package org.cobricks.util.migration; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Properties; import org.apache.log4j.*; import org.cobricks.core.ComponentDirectory; import org.cobricks.core.CoreManager; import org.cobricks.core.db.DBAccess; import org.cobricks.core.util.PropertiesUtil; import org.cobricks.user.*; import org.cobricks.core.db.*; /** * This Class is used for the migration of the user data from cobricks1 to * cobricks2. * * @author il...@sa... * @version $Date: 2004/03/03 17:50:48 $ */ public class MigrationTool { static Logger logger = Logger.getLogger(MigrationTool.class); private DBAccess fromDBAccess; private List inData ; private UserManager userManager; private Properties migToolProps; public static void main(String[] args) { Properties migToolProps = new Properties(); try { migToolProps.load(new FileInputStream("migtool.conf")); } catch(IOException ioe) { ioe.printStackTrace(); } new MigrationTool(migToolProps); } public MigrationTool(Properties migToolProps) { this.migToolProps = migToolProps; initSourceDB(); initDestinationDB(); migrateUserMainTable(); migrateUserAttriTable(); } private void initDestinationDB(){ // configure logger String configDir = migToolProps.getProperty("cobricks2configdir"); PropertyConfigurator.configure(configDir+File.separator+"log.properties"); /* SimpleLayout layout = new SimpleLayout(); FileAppender appender = null; try { appender = new FileAppender(layout,"output1.txt",false); } catch(Exception e) {} logger.addAppender(appender); logger.setLevel((Level) Level.DEBUG); */ logger.info("Starting Migrationtool Initialization"); logger.info("configDir = "+configDir); // load Cobricks configuration (properties) Properties properties = new Properties(); properties.put("configdir", configDir); PropertiesUtil.loadProperties(configDir, properties); // initialize CoreManager object ... CoreManager coreManager = new CoreManager(); coreManager.init(properties); // initialize all the other components // this call instantiates all manager and presenter objects coreManager.initComponents(properties); ComponentDirectory cd = coreManager.getComponentDirectory(); if (cd != null) { userManager = (UserManager) cd.getManager("userManager"); } } private void initSourceDB(){ // Adding a Propeperty to the the configuration file. Used as Workarround for DBAccessImpl. migToolProps.setProperty("component.init","org.cobricks.core,org.cobricks.user,org.cobricks.context,org.cobricks.item,org.cobricks.category,org.cobricks.message,org.cobricks.portal"); try { fromDBAccess = new DBAccessImpl(migToolProps); } catch(Exception e) { e.printStackTrace(); } } private void migrateUserMainTable() { List result = fromDBAccess.sqlQuery("SELECT * FROM usermain;"); Iterator resIter = result.iterator(); int cnt = 0; while(resIter.hasNext()){ cnt++; // if(cnt > 100) break; // used for testing purposes, if you don't need to test with all the records from the table Map fromMap = (Map)resIter.next(); Map toMap = new HashMap(); String lastName = (String)fromMap.get("basic_personal_lastname"); String firstName = (String)fromMap.get("basic_personal_firstname"); String passCrypt = (String)fromMap.get("credentials_password_crypt"); String basicStatus = (String)fromMap.get("basic_status"); String userLogin = (String)fromMap.get("userid"); String regTime = (String)fromMap.get("regtime"); if(userLogin.endsWith("@localhost")) { //cuts the "@localhost" from the logins userLogin = userLogin.substring(0,userLogin.indexOf("@localhost")); } if(firstName!=null) { toMap.put("basic.personal.firstname",firstName); } if(lastName!=null) { toMap.put("basic.personal.lastname",lastName); } if(passCrypt!=null) { toMap.put("basic.credentials.password.crypt",passCrypt); } if(basicStatus!=null) { toMap.put("basic.university.status",basicStatus); } if(regTime!=null) { toMap.put("basic.regtime",regTime); } if(userLogin!=null) { logger.info(">> Inserting User... "+firstName+" "+lastName+" "+passCrypt+" "+basicStatus+" "+userLogin+" "+regTime); try { userManager.createUser(userLogin, toMap); } catch(Exception ex) { ex.printStackTrace(); } } } logger.info(">> Inserted "+cnt+" Users."); } private void migrateUserAttriTable() { //Gets all the attributes from userattri table, without the emtpy ones. List result = fromDBAccess.sqlQuery("SELECT * FROM userattri WHERE value != '' AND aname !='' AND userid !='' AND value != 'NULL' AND aname !='NULL' AND userid !='NULL';"); Iterator resIter = result.iterator(); int cnt = 0; int cnt2 = 0; while(resIter.hasNext()){ cnt++; // if(cnt > 100) break; // used for testing purposes, if you don't need to test with all the records from the table Map fromMap = (Map)resIter.next(); Map toMap = new HashMap(); String attrName = (String)fromMap.get("aname"); String userLogin = (String)fromMap.get("userid"); String attrValue = fromMap.get("value").toString(); String newAttrName = null; if(userLogin.endsWith("@localhost")) { userLogin = userLogin.substring(0,userLogin.indexOf("@localhost")); } // gets the new attribute name, from the configuration properties file if(migToolProps.containsKey(attrName)) { newAttrName = migToolProps.getProperty(attrName); } if( newAttrName!=null ) { logger.info(">> Inserting Attribute ... "+userLogin+" "+attrName+" "+attrValue); try { if(userManager.checkUser(userLogin)){ userManager.setUserAttr(userManager.getUserIdForUserLogin(userLogin),newAttrName,attrValue); cnt2++; } } catch(Exception ex) { ex.printStackTrace(); } } } logger.info(">> Inserted "+cnt2+" from "+cnt+" Attributes."); } private void getDistincAttNames() { List result = fromDBAccess.sqlQuery("SELECT DISTINCT aname FROM userattri;"); Iterator resIter = result.iterator(); while(resIter.hasNext()){ System.out.println(resIter.next().toString()); } } } |
|
From: <sap...@us...> - 2004-03-03 18:11:12
|
Update of /cvsroot/cobricks/cobricks2/src/org/cobricks/util/migration In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6619/src/org/cobricks/util/migration Log Message: Directory /cvsroot/cobricks/cobricks2/src/org/cobricks/util/migration added to the repository |
|
From: <sap...@us...> - 2004-03-03 18:11:12
|
Update of /cvsroot/cobricks/cobricks2/src/org/cobricks/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6619/src/org/cobricks/util Log Message: Directory /cvsroot/cobricks/cobricks2/src/org/cobricks/util added to the repository |
|
From: <sap...@us...> - 2004-03-03 18:06:36
|
Update of /cvsroot/cobricks/cobricks2/conf/org.cobricks.user In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5792/conf/org.cobricks.user Modified Files: userontology.xml Log Message: Added regtime attribute Index: userontology.xml =================================================================== RCS file: /cvsroot/cobricks/cobricks2/conf/org.cobricks.user/userontology.xml,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** userontology.xml 3 Mar 2004 17:42:23 -0000 1.5 --- userontology.xml 3 Mar 2004 17:46:02 -0000 1.6 *************** *** 43,48 **** <attr name="basic.contact[work].telecom.fax" type="string(25)"/> - <attr name="basic.contact.timezone" type="date"/> - <attr name="basic.credentials.password.crypt" type="string(30)"/> --- 43,46 ---- *************** *** 62,65 **** --- 60,65 ---- <attr name="history.org.cobricks.lastlogin" type="date"/> + <attr name="history.org.cobricks.regtime" type="date"/> + <attr name="preference.language" type="string(2)"/> |
|
From: <sap...@us...> - 2004-03-03 18:02:57
|
Update of /cvsroot/cobricks/cobricks2/conf/org.cobricks.user In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4940/conf/org.cobricks.user Modified Files: userontology.xml Log Message: Added regtime attribute Index: userontology.xml =================================================================== RCS file: /cvsroot/cobricks/cobricks2/conf/org.cobricks.user/userontology.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** userontology.xml 24 Feb 2004 14:02:13 -0000 1.4 --- userontology.xml 3 Mar 2004 17:42:23 -0000 1.5 *************** *** 43,46 **** --- 43,48 ---- <attr name="basic.contact[work].telecom.fax" type="string(25)"/> + <attr name="basic.contact.timezone" type="date"/> + <attr name="basic.credentials.password.crypt" type="string(30)"/> |
|
From: <ko...@us...> - 2004-03-01 07:27:45
|
Update of /cvsroot/cobricks/cobricks2/src/org/cobricks/portal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1451/src/org/cobricks/portal Modified Files: PageAccessHandler.java PageCache.java PortalManager.java PortalManagerImpl.java PortalPresenter.java PortalServlet.java Added Files: PageFolderAccessHandler.java PortalFolder.java PortalPage.java Removed Files: Page.java PageFolder.java Log Message: --- NEW FILE: PageFolderAccessHandler.java --- /* * Copyright (c) 2004 Cobricks Group. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted under the terms of the Cobricks Software * License, either version 1.0 of the License, or (at your option) any * later version (see www.cobricks.org). * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. */ package org.cobricks.portal; import java.util.*; import org.apache.log4j.*; import org.cobricks.core.CoreManager; import org.cobricks.core.db.DBAccess; import org.cobricks.user.AccessHandler; import org.cobricks.user.AccessHandlerAdaptor; /** * * @author mic...@ac... * @version $Date: 2004/03/01 07:09:04 $ */ public class PageFolderAccessHandler extends AccessHandlerAdaptor implements AccessHandler { static Logger logger = Logger.getLogger(PageFolderAccessHandler.class); static final String domain = "pagefolder"; static final String[] domainactions = { "create", "delete" }; static final String[][] domainactionattrs = { // create { "catid" }, // delete { "catid" } }; List actions; Map actionAttrs; /** * */ public PageFolderAccessHandler() { super(); } /** * */ public void init(CoreManager coreManager, DBAccess dbAccess) { logger.info("Initializing pagefolder access handler"); super.init(coreManager, dbAccess); actions = new ArrayList(); actionAttrs = new HashMap(); for (int i=0; i<domainactions.length; i++) { actions.add(domainactions[i]); List attrs = new ArrayList(); String[] sarr = domainactionattrs[i]; for (int j=0; j<sarr.length; j++) { attrs.add(sarr[j]); } actionAttrs.put(domainactions[i], attrs); } } public String getDomain() { return domain; } public List getDomainActions() { return actions; } public List getDomainActionAttributes(String action) { return (List)actionAttrs.get(action); } /** * */ public boolean checkPermission(int userid, String domain, String action, Map attrs) { // check capabilities of roles with status = "all" // tbd // anonymous user? //if (userid == 0) return false; // get capabilities of roles with status = "login" // get capabilities of roles with user as member (inclusive // parent roles of those) // check if access is covered by any of the capabilities return true; } } --- NEW FILE: PortalFolder.java --- /* * Copyright (c) 2003 Cobricks Group. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted under the terms of the Cobricks Software * License, either version 1.0 of the License, or (at your option) any * later version (see www.cobricks.org). * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. */ package org.cobricks.portal; import java.io.*; import java.util.*; import org.apache.log4j.*; import org.cobricks.core.util.LogUtil; import org.cobricks.user.User; /** * Category class for organizing page sets. * * @author mic...@ac... * @version $Date: 2004/03/01 07:09:04 $ */ public class PortalFolder extends org.cobricks.category.Category { static Logger logger = Logger.getLogger(PortalFolder.class); public PortalFolder() { super(0); } public String getPath() { return (String)super.getAttribute("path"); } public void setPath(String path) { super.setAttribute("path", path); } } --- NEW FILE: PortalPage.java --- /* * Copyright (c) 2003 Cobricks Group. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted under the terms of the Cobricks Software * License, either version 1.0 of the License, or (at your option) any * later version (see www.cobricks.org). * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. */ package org.cobricks.portal; import java.io.*; import java.util.*; import org.apache.log4j.*; import org.cobricks.core.util.LogUtil; import org.cobricks.user.User; /** * Class for storing (web) pages. The class is derived from Item, since * web pages are a special class of item (if they are stored in the * database). If the page is not available in the database the itemid * in the object will be 0. * * @author mic...@ac... * @version $Date: 2004/03/01 07:09:04 $ */ public class PortalPage extends org.cobricks.item.Item { static Logger logger = Logger.getLogger(PortalPage.class); String pageName = ""; String pagePath = ""; int pageitemid; // just temporary ... this info should be stored // in the parent class Map pageContents; // lang - String content Map pageContentSource; // lang - "file:*"|"item:*" String defaultLang; public PortalPage() { super(); init(null); } public PortalPage(String pagePath, String pageName, String defaultLang) { this(); init(defaultLang); this.pagePath = pagePath; if (pagePath == null) pagePath = "/"; this.pageName = pageName; } public PortalPage(int itemid, String defaultLang) { super(); init(defaultLang); this.pageitemid = itemid; } protected void init(String defaultLang) { this.pageContents = new HashMap(); this.pageContentSource = new HashMap(); if (defaultLang!=null) this.defaultLang = defaultLang; } public String getPagePath() { return pagePath; } public void setPagePath(String pagePath) { this.pagePath = pagePath; } public String getPageName() { return pageName; } public void setPageName(String pageName) { this.pageName = pageName; } public int getItemId() { return pageitemid; // tbd } public Object getContent(String lang) { return pageContents.get(lang); } public void setContent(String lang, String content, Object source) { pageContents.put(lang, content); if (source != null) pageContentSource.put(lang, source); } /** * Return the content of a web page as a String. The functions takes * a list of language identifiers that represent the preferences of * the user (from the PortalRequest). The return value is a * String object and a String representing the laguage of this * content. */ public Map getStringContent(String lang) { Map result = new HashMap(); if (lang==null || lang.length()<1) lang = defaultLang; Object content = pageContents.get(lang); if (content != null) { result.put(lang, content.toString()); return result; } content = pageContents.get(defaultLang); if (content != null) { result.put(defaultLang, content.toString()); return result; } content = pageContents.get("default"); if (content != null) { result.put(defaultLang, content.toString()); return result; } // any other? just take first ... Iterator iterator = pageContents.keySet().iterator(); if (iterator == null || !iterator.hasNext()) return null; lang = (String)iterator.next(); content = pageContents.get(lang); result.put(lang, content.toString()); return result; } /** * */ public List getLanguages() { List result = new ArrayList(); Iterator i = pageContents.keySet().iterator(); while (i.hasNext()) { String lang = (String)i.next(); if (lang.equals("default")) lang = defaultLang; result.add(lang); } return result; } /** * */ public String getDefaultLanguage() { return defaultLang; } /** * Check if the content of a given language has been loaded from * the database or from the file system. */ public boolean isFromDatabase(String lang) { if (lang==null) lang = "default"; Object source = pageContentSource.get(lang); if (source == null) return false; if (source instanceof String) { return false; } else { return true; } } /** * Return true if there are antries in pageContents and false otherwise. * This function can be used to check if the page exists after it has * been tried to load the page both from database and file system * (using the loadFromDatabase() and loadFromFilesystem() functions in * this class). */ public boolean exists() { if (pageContents==null || pageContents.size()<1) return false; return true; } /** * */ public String toString() { StringBuffer sb = new StringBuffer("page("); sb.append(pagePath); sb.append(pageName); sb.append(","); sb.append(Integer.toString(pageitemid)); sb.append(","); Iterator i = pageContentSource.keySet().iterator(); while (i.hasNext()) { String lang = (String)i.next(); sb.append(lang); sb.append("="); sb.append(pageContentSource.get(lang)); if (i.hasNext()) sb.append(","); } sb.append(")"); return sb.toString(); } } Index: PageAccessHandler.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/portal/PageAccessHandler.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PageAccessHandler.java 12 Feb 2004 06:25:26 -0000 1.2 --- PageAccessHandler.java 1 Mar 2004 07:09:04 -0000 1.3 *************** *** 41,48 **** static final String[] domainactions = { "create", "delete" }; static final String[][] domainactionattrs = { ! // create ! { "pageid" }, ! // delete ! { "pageid" } }; --- 41,48 ---- static final String[] domainactions = { "create", "delete" }; static final String[][] domainactionattrs = { ! // create ! { "pageid" }, ! // delete ! { "pageid" } }; *************** *** 54,59 **** * */ ! public PageAccessHandler() { ! super(); } --- 54,60 ---- * */ ! public PageAccessHandler() ! { ! super(); } *************** *** 62,91 **** * */ ! public void init(CoreManager coreManager, DBAccess dbAccess) { ! logger.info("Initializing page access handler"); ! super.init(coreManager, dbAccess); ! actions = new ArrayList(); ! actionAttrs = new HashMap(); ! for (int i=0; i<domainactions.length; i++) { ! actions.add(domainactions[i]); ! List attrs = new ArrayList(); ! String[] sarr = domainactionattrs[i]; ! for (int j=0; j<sarr.length; j++) { ! attrs.add(sarr[j]); ! } ! actionAttrs.put(domainactions[i], attrs); ! } } ! public String getDomain() { ! return domain; } ! public List getDomainActions() { ! return actions; } ! public List getDomainActionAttributes(String action) { ! return (List)actionAttrs.get(action); } --- 63,96 ---- * */ ! public void init(CoreManager coreManager, DBAccess dbAccess) ! { ! logger.info("Initializing page access handler"); ! super.init(coreManager, dbAccess); ! actions = new ArrayList(); ! actionAttrs = new HashMap(); ! for (int i=0; i<domainactions.length; i++) { ! actions.add(domainactions[i]); ! List attrs = new ArrayList(); ! String[] sarr = domainactionattrs[i]; ! for (int j=0; j<sarr.length; j++) { ! attrs.add(sarr[j]); ! } ! actionAttrs.put(domainactions[i], attrs); ! } } ! public String getDomain() ! { ! return domain; } ! public List getDomainActions() ! { ! return actions; } ! public List getDomainActionAttributes(String action) ! { ! return (List)actionAttrs.get(action); } *************** *** 95,113 **** */ public boolean checkPermission(int userid, String domain, String action, ! Map attrs) { ! // check capabilities of roles with status = "all" ! // tbd ! // anonymous user? ! //if (userid == 0) return false; ! // get capabilities of roles with status = "login" ! // get capabilities of roles with user as member (inclusive ! // parent roles of those) ! // check if access is covered by any of the capabilities ! return true; } --- 100,119 ---- */ public boolean checkPermission(int userid, String domain, String action, ! Map attrs) ! { ! // check capabilities of roles with status = "all" ! // tbd ! // anonymous user? ! //if (userid == 0) return false; ! // get capabilities of roles with status = "login" ! // get capabilities of roles with user as member (inclusive ! // parent roles of those) ! // check if access is covered by any of the capabilities ! return true; } Index: PageCache.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/portal/PageCache.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PageCache.java 12 Feb 2004 06:25:26 -0000 1.2 --- PageCache.java 1 Mar 2004 07:09:04 -0000 1.3 *************** *** 21,25 **** /** ! * Class for caching Page object. * * @author mic...@ac... --- 21,25 ---- /** ! * Class for caching PortalPage objects. * * @author mic...@ac... *************** *** 40,88 **** * */ ! public PageCache() { ! pathCache = new HashMap(); ! itemidCache = new HashMap(); } ! public Page getPage(String path, String name) { ! String key = path+"/"+name; ! return (Page)pathCache.get(key); } ! public Page getPage(int itemid) { // tbd: when this works with the itemmanager, then rely on // itemmanager cache ... ! return (Page)itemidCache.get(new Integer(itemid)); } ! public void setPage(Page p) { ! String key = p.getPagePath()+"/"+p.getPageName(); ! pathCache.put(key, p); if (p.getItemId()>0) { itemidCache.put(new Integer(p.getItemId()), p); } ! // page objects cache garbage collection ! int cacheSize = pathCache.size(); ! if (cacheSize % 10 == 0) ! logger.info("Page objects cache size is "+cacheSize); ! if (cacheSize > 500) { ! logger.info("Page objects cache size is bigger than limit (" ! +cacheSize+")"); ! int toDelete = cacheSize - 300; ! Iterator iter = pathCache.keySet().iterator(); ! for (int i=0; i<toDelete; i++) { ! Object key2 = iter.next(); pathCache.remove(key2); ! } ! logger.info("Page objects cache reduced to "+pathCache.size() ! +" entries"); ! } } ! public void removePage(int itemid) { ! itemidCache.remove(new Integer(itemid)); } --- 40,93 ---- * */ ! public PageCache() ! { ! pathCache = new HashMap(); ! itemidCache = new HashMap(); } ! public PortalPage getPage(String path, String name) ! { ! String key = path+"/"+name; ! return (PortalPage)pathCache.get(key); } ! public PortalPage getPage(int itemid) ! { // tbd: when this works with the itemmanager, then rely on // itemmanager cache ... ! return (PortalPage)itemidCache.get(new Integer(itemid)); } ! public void setPage(PortalPage p) ! { ! String key = p.getPagePath()+"/"+p.getPageName(); ! pathCache.put(key, p); if (p.getItemId()>0) { itemidCache.put(new Integer(p.getItemId()), p); } ! // page objects cache garbage collection ! int cacheSize = pathCache.size(); ! if (cacheSize % 10 == 0) ! logger.info("Page objects cache size is "+cacheSize); ! if (cacheSize > 500) { ! logger.info("Page objects cache size is bigger than limit (" ! +cacheSize+")"); ! int toDelete = cacheSize - 300; ! Iterator iter = pathCache.keySet().iterator(); ! for (int i=0; i<toDelete; i++) { ! Object key2 = iter.next(); pathCache.remove(key2); ! } ! logger.info("Page objects cache reduced to "+pathCache.size() ! +" entries"); ! } } ! public void removePage(int itemid) ! { ! itemidCache.remove(new Integer(itemid)); } Index: PortalManager.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/portal/PortalManager.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PortalManager.java 12 Feb 2004 06:25:26 -0000 1.2 --- PortalManager.java 1 Mar 2004 07:09:04 -0000 1.3 *************** *** 1,4 **** /* ! * Copyright (c) 2003 Cobricks Group. All rights reserved. * * Redistribution and use in source and binary forms, with or without --- 1,4 ---- /* ! * Copyright (c) 2003, 2004 Cobricks Group. All rights reserved. * * Redistribution and use in source and binary forms, with or without *************** *** 44,49 **** public void printPage(PortalRequest portalRequest, PrintWriter out); ! public Page getPage(String pagePath, String pageName); ! public Page getPage(int itemid); public int getPageItemId(String pagePath, String pageName); --- 44,49 ---- public void printPage(PortalRequest portalRequest, PrintWriter out); ! public PortalPage getPage(String pagePath, String pageName); ! public PortalPage getPage(int itemid); public int getPageItemId(String pagePath, String pageName); *************** *** 54,64 **** String title, String content, boolean fullcontext, User creator) ! throws CobricksException; public void updatePage(int itemid, String lang, String title, String content, boolean fullcontext, User updater) ! throws CobricksException; public void deletePage(int itemid, String lang, User user) ! throws CobricksException; public PortalStats getPortalStats(); --- 54,68 ---- String title, String content, boolean fullcontext, User creator) ! throws CobricksException; public void updatePage(int itemid, String lang, String title, String content, boolean fullcontext, User updater) ! throws CobricksException; public void deletePage(int itemid, String lang, User user) ! throws CobricksException; ! ! public int createFolder(String parentPath, String name, ! String title, User creator) ! throws CobricksException; public PortalStats getPortalStats(); *************** *** 69,71 **** --- 73,79 ---- public void resetPageUpdateHistory(int itemid); + public PortalFolder getPortalFolder(int catid); + public PortalFolder getPortalFolder(String path); + public List getPortalFolderPaths(); + } Index: PortalManagerImpl.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/portal/PortalManagerImpl.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PortalManagerImpl.java 23 Feb 2004 08:20:59 -0000 1.4 --- PortalManagerImpl.java 1 Mar 2004 07:09:04 -0000 1.5 *************** *** 15,19 **** import java.io.*; import java.net.URL; ! import java.util.*; import javax.servlet.*; import javax.servlet.http.*; --- 15,29 ---- import java.io.*; import java.net.URL; ! import java.util.ArrayList; ! import java.util.Collections; [...1172 lines suppressed...] } --- 983,1000 ---- class PortalFilenameFilter implements java.io.FilenameFilter { ! String prefix; ! PortalFilenameFilter(String prefix) { ! this.prefix = prefix; ! } ! public boolean accept(File dir, String name) { ! if ((name!=null) && (name.startsWith(prefix))) ! return true; ! return false; ! } } } + + + Index: PortalPresenter.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/portal/PortalPresenter.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PortalPresenter.java 23 Feb 2004 08:20:59 -0000 1.4 --- PortalPresenter.java 1 Mar 2004 07:09:04 -0000 1.5 *************** *** 49,68 **** * */ ! public PortalPresenter() { } public void init(String presenterId, Properties properties, ! CoreManager coreManager) ! throws Exception { ! logger.info("Initializing portal presenter."); ! this.properties = properties; ! ComponentDirectory componentDirectory = ! coreManager.getComponentDirectory(); ! portalManager = (PortalManager)componentDirectory. ! getManager("portalManager"); ! if (portalManager == null) { ! logger.error("Did not find portal manager in ComponentDirectory!"); ! } } --- 49,70 ---- * */ ! public PortalPresenter() ! { } public void init(String presenterId, Properties properties, ! CoreManager coreManager) ! throws Exception ! { ! logger.info("Initializing portal presenter."); ! this.properties = properties; ! ComponentDirectory componentDirectory = ! coreManager.getComponentDirectory(); ! portalManager = (PortalManager)componentDirectory. ! getManager("portalManager"); ! if (portalManager == null) { ! logger.error("Did not find portal manager in ComponentDirectory!"); ! } } *************** *** 159,165 **** /** ! * Return a Page object by the itemid which is given as String */ ! public Page getPage(String itemid) { int id = 0; --- 161,167 ---- /** ! * Return a PortalPage object by the itemid which is given as String */ ! public PortalPage getPage(String itemid) { int id = 0; *************** *** 210,215 **** StringBuffer sb = new StringBuffer(""); String lang = portalRequest.getPageLang(); ! Page page = portalManager.getPage(portalRequest.getPagePath(), ! portalRequest.getPageName()); if (page!=null) { List languages = page.getLanguages(); --- 212,217 ---- StringBuffer sb = new StringBuffer(""); String lang = portalRequest.getPageLang(); ! PortalPage page = portalManager.getPage(portalRequest.getPagePath(), ! portalRequest.getPageName()); if (page!=null) { List languages = page.getLanguages(); *************** *** 224,228 **** sb.append(tmps); sb.append("\">"); ! sb.append("<span style=\"margin:2px;\"><img border=0 alt=\""); sb.append(tmps); sb.append("\" src=\"/images/lang-"); --- 226,231 ---- sb.append(tmps); sb.append("\">"); ! sb.append("<span style=\"margin:2px;\">" ! +"<img border=0 alt=\""); sb.append(tmps); sb.append("\" src=\"/images/lang-"); *************** *** 244,252 **** HttpServletRequest request = portalRequest.getHttpServletRequest(); String url = request.getRequestURI(); ! String tmps = request.getQueryString(); ! if (tmps!=null && tmps.trim().length()>0) ! url += ("?"+tmps+"&print=true"); ! else ! url += ("?print=true"); return url; } --- 247,255 ---- HttpServletRequest request = portalRequest.getHttpServletRequest(); String url = request.getRequestURI(); ! String tmps = request.getQueryString(); ! if (tmps!=null && tmps.trim().length()>0) ! url += ("?"+tmps+"&print=true"); ! else ! url += ("?print=true"); return url; } *************** *** 254,259 **** } - - - - --- 257,258 ---- Index: PortalServlet.java =================================================================== RCS file: /cvsroot/cobricks/cobricks2/src/org/cobricks/portal/PortalServlet.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PortalServlet.java 23 Feb 2004 08:20:59 -0000 1.5 --- PortalServlet.java 1 Mar 2004 07:09:04 -0000 1.6 *************** *** 54,58 **** HttpServletResponse response = portalRequest.getHttpServletResponse(); PortalUser portalUser = portalRequest.getPortalUser(); ! // determine which page to display String uri = request.getServletPath(); --- 54,58 ---- HttpServletResponse response = portalRequest.getHttpServletResponse(); PortalUser portalUser = portalRequest.getPortalUser(); ! // determine which page to display String uri = request.getServletPath(); *************** *** 71,78 **** throw new PortalCompletedException(); } ! // print page portalManager.printPage(portalRequest, out); ! return null; } --- 71,78 ---- throw new PortalCompletedException(); } ! // print page portalManager.printPage(portalRequest, out); ! return null; } *************** *** 96,99 **** --- 96,102 ---- this.addTarget("update", "performUpdatePage", "", false); this.addTarget("delete", "performDeletePage", "", false); + this.addTarget("createfolder", "performCreateFolder", "", false); + this.addTarget("updatefolder", "performUpdateFolder", "", false); + this.addTarget("deletefolder", "performDeleteFolder", "", false); } *************** *** 113,121 **** HttpServletRequest request = portalRequest.getHttpServletRequest(); HttpServletResponse response = portalRequest.getHttpServletResponse(); ! String userlogin = request.getParameter("luserlogin"); String userpw = request.getParameter("luserpw"); logger.info("perfomLogin("+userlogin+")"); ! // check if userlogin/userpw combination is correct try { --- 116,124 ---- HttpServletRequest request = portalRequest.getHttpServletRequest(); HttpServletResponse response = portalRequest.getHttpServletResponse(); ! String userlogin = request.getParameter("luserlogin"); String userpw = request.getParameter("luserpw"); logger.info("perfomLogin("+userlogin+")"); ! // check if userlogin/userpw combination is correct try { *************** *** 153,157 **** return "error"; } ! // everything went well ... HttpSession session = request.getSession(true); --- 156,160 ---- return "error"; } ! // everything went well ... HttpSession session = request.getSession(true); *************** *** 181,210 **** */ public String performLogout(PortalRequest portalRequest, PrintWriter out) ! throws PortalCompletedException { ! HttpServletRequest request = portalRequest.getHttpServletRequest(); ! HttpServletResponse response = portalRequest.getHttpServletResponse(); ! logger.info("perfomLogout()"); ! ! // everything went well ... ! HttpSession session = request.getSession(true); sessionHandler.setSession(session); ! session.setAttribute("login.userlogin", "anonymous"); ! ! String target = (String)session.getAttribute("logout.target"); ! if (target==null) ! target = request.getScheme()+"://"+request.getServerName()+":"+ ! request.getServerPort()+"/logout.html"; ! logger.info("sending redirect to "+target); ! try { ! response.sendRedirect(target); ! throw new PortalCompletedException(); ! } catch(IOException e) { ! logger.error(LogUtil.exception("Failed redirecting to " ! +target, e)); ! } ! portalRequest.setReturnCode(2100); ! return "error"; } --- 184,213 ---- */ public String performLogout(PortalRequest portalRequest, PrintWriter out) ! throws PortalCompletedException { ! HttpServletRequest request = portalRequest.getHttpServletRequest(); ! HttpServletResponse response = portalRequest.getHttpServletResponse(); ! ! logger.info("perfomLogout()"); ! // everything went well ... ! HttpSession session = request.getSession(true); sessionHandler.setSession(session); ! session.setAttribute("login.userlogin", "anonymous"); ! ! String target = (String)session.getAttribute("logout.target"); ! if (target==null) ! target = request.getScheme()+"://"+request.getServerName()+":"+ ! request.getServerPort()+"/logout.html"; ! logger.info("sending redirect to "+target); ! try { ! response.sendRedirect(target); ! throw new PortalCompletedException(); ! } catch(IOException e) { ! logger.error(LogUtil.exception("Failed redirecting to " ! +target, e)); ! } ! portalRequest.setReturnCode(2100); ! return "error"; } *************** *** 214,238 **** */ public String performCreatePage(PortalRequest prequest, PrintWriter out) ! throws PortalCompletedException { ! String pagepath = prequest.getRequestParameter("ppath"); ! if (pagepath == null) pagepath = ""; if (!pagepath.endsWith("/")) pagepath += "/"; ! if (pagepath.length()>0 && !(pagepath.startsWith("/"))) pagepath = "/"+pagepath; ! String pagename = prequest.getRequestParameter("pname"); ! String lang = prequest.getRequestParameter("plang"); ! String title = prequest.getRequestParameter("title"); ! String content = prequest.getRequestParameter("content"); ! // check access rights ! PortalUser portalUser = prequest.getPortalUser(); ! if (!userManager.getAccessControl(). ! checkPermission(portalUser.getUserId(), ! "page", "create", null)) { ! prequest.setReturnCode(2000); ! return "noaccess"; ! } try { --- 217,241 ---- */ public String performCreatePage(PortalRequest prequest, PrintWriter out) ! throws PortalCompletedException { ! String pagepath = prequest.getRequestParameter("ppath"); ! if (pagepath == null || pagepath.length()<1) pagepath = "/"; if (!pagepath.endsWith("/")) pagepath += "/"; ! if (!pagepath.startsWith("/")) pagepath = "/"+pagepath; ! String pagename = prequest.getRequestParameter("pname"); ! String lang = prequest.getRequestParameter("plang"); ! String title = prequest.getRequestParameter("title"); ! String content = prequest.getRequestParameter("content"); ! // check access rights ! PortalUser portalUser = prequest.getPortalUser(); ! if (!userManager.getAccessControl(). ! checkPermission(portalUser.getUserId(), ! "page", "create", null)) { ! prequest.setReturnCode(2000); ! return "noaccess"; ! } try { *************** *** 250,257 **** } catch (Exception e) { logger.error(LogUtil.ex("Failed creating page.", e)); ! prequest.setReturnCode(2001); return "error"; } return "success"; } --- 253,261 ---- } catch (Exception e) { logger.error(LogUtil.ex("Failed creating page.", e)); ! prequest.setReturnCode(2001); return "error"; } + prequest.setReturnCode(1001); return "success"; } *************** *** 262,282 **** */ public String performUpdatePage(PortalRequest prequest, PrintWriter out) ! throws PortalCompletedException { ! String tmps = prequest.getRequestParameter("itemid"); int itemid = 0; try { itemid = Integer.parseInt(tmps); } catch (Exception e) { } ! String lang = prequest.getRequestParameter("plang"); ! String title = prequest.getRequestParameter("title"); ! String content = prequest.getRequestParameter("content"); ! // check access rights ! PortalUser portalUser = prequest.getPortalUser(); ! if (!userManager.getAccessControl(). ! checkPermission(portalUser.getUserId(), ! "page", "update", null)) { ! prequest.setReturnCode(2000); ! return "noaccess"; ! } try { --- 266,286 ---- */ public String performUpdatePage(PortalRequest prequest, PrintWriter out) ! throws PortalCompletedException { ! String tmps = prequest.getRequestParameter("itemid"); int itemid = 0; try { itemid = Integer.parseInt(tmps); } catch (Exception e) { } ! String lang = prequest.getRequestParameter("plang"); ! String title = prequest.getRequestParameter("title"); ! String content = prequest.getRequestParameter("content"); ! // check access rights ! PortalUser portalUser = prequest.getPortalUser(); ! if (!userManager.getAccessControl(). ! checkPermission(portalUser.getUserId(), ! "page", "update", null)) { ! prequest.setReturnCode(2000); ! return "noaccess"; ! } try { *************** *** 292,296 **** } catch (Exception e) { logger.error(LogUtil.ex("Failed updating page.", e)); ! prequest.setReturnCode(2001); return "error"; } --- 296,300 ---- } catch (Exception e) { logger.error(LogUtil.ex("Failed updating page.", e)); ! prequest.setReturnCode(2001); return "error"; } *************** *** 304,322 **** */ public String performDeletePage(PortalRequest prequest, PrintWriter out) ! throws PortalCompletedException { ! String tmps = prequest.getRequestParameter("itemid"); int itemid = 0; try { itemid = Integer.parseInt(tmps); } catch (Exception e) { } ! String lang = prequest.getRequestParameter("plang"); ! // check access rights ! PortalUser portalUser = prequest.getPortalUser(); ! if (!userManager.getAccessControl(). ! checkPermission(portalUser.getUserId(), ! "page", "delete", null)) { ! prequest.setReturnCode(2000); ! return "noaccess"; ! } try { --- 308,326 ---- */ public String performDeletePage(PortalRequest prequest, PrintWriter out) ! throws PortalCompletedException { ! String tmps = prequest.getRequestParameter("itemid"); int itemid = 0; try { itemid = Integer.parseInt(tmps); } catch (Exception e) { } ! String lang = prequest.getRequestParameter("plang"); ! // check access rights ! PortalUser portalUser = prequest.getPortalUser(); ! if (!userManager.getAccessControl(). ! checkPermission(portalUser.getUserId(), ! "page", "delete", null)) { ! prequest.setReturnCode(2000); ! return "noaccess"; ! } try { *************** *** 324,328 **** } catch (Exception e) { logger.error(LogUtil.ex("Failed deleting page.", e)); ! prequest.setReturnCode(2001); return "error"; } --- 328,332 ---- } catch (Exception e) { logger.error(LogUtil.ex("Failed deleting page.", e)); ! prequest.setReturnCode(2001); return "error"; } *************** *** 331,333 **** --- 335,377 ---- } + + /** + * + */ + public String performCreateFolder(PortalRequest prequest, PrintWriter out) + throws PortalCompletedException + { + String parentpath = prequest.getRequestParameter("ppath"); + if (parentpath == null || parentpath.length()<1) parentpath = "/"; + if (!parentpath.endsWith("/")) + parentpath += "/"; + if (!parentpath.startsWith("/")) + parentpath = "/"+parentpath; + String name = prequest.getRequestParameter("pname"); + String title = prequest.getRequestParameter("title"); + + // check access rights + PortalUser portalUser = prequest.getPortalUser(); + if (!userManager.getAccessControl(). + checkPermission(portalUser.getUserId(), + "pagefolder", "create", null)) { + prequest.setReturnCode(2000); + return "noaccess"; + } + + try { + int itemid = + portalManager.createFolder(parentpath, name, + title, portalUser.getUser()); + } catch (Exception e) { + logger.error(LogUtil.ex("Failed creating folder.", e)); + prequest.setReturnCode(2001); + return "error"; + } + + prequest.setReturnCode(1001); + return "success"; + } + + } --- Page.java DELETED --- --- PageFolder.java DELETED --- |