From: <fle...@us...> - 2006-10-31 15:56:39
|
Revision: 476 http://svn.sourceforge.net/magicmap/?rev=476&view=rev Author: flederohr Date: 2006-10-31 07:55:58 -0800 (Tue, 31 Oct 2006) Log Message: ----------- added rollbacks for all transactions and removed extensive logging Modified Paths: -------------- trunk/magicmapserver/.settings/org.eclipse.jdt.ui.prefs trunk/magicmapserver/src/net/sf/magicmap/server/facade/MapFacade.java trunk/magicmapserver/src/net/sf/magicmap/server/facade/PositionFacade.java trunk/magicmapserver/src/net/sf/magicmap/server/facade/SessionFacade.java Modified: trunk/magicmapserver/.settings/org.eclipse.jdt.ui.prefs =================================================================== --- trunk/magicmapserver/.settings/org.eclipse.jdt.ui.prefs 2006-10-31 15:16:30 UTC (rev 475) +++ trunk/magicmapserver/.settings/org.eclipse.jdt.ui.prefs 2006-10-31 15:55:58 UTC (rev 476) @@ -1,6 +1,6 @@ -#Sat Jul 08 14:24:10 CEST 2006 +#Tue Oct 31 14:58:24 CET 2006 eclipse.preferences.version=1 -formatter_profile=_MagicMap Coding Conventions +formatter_profile=_'MagicMap Coding Conventions' formatter_settings_version=10 internal.default.compliance=default org.eclipse.jdt.ui.exception.name=e Modified: trunk/magicmapserver/src/net/sf/magicmap/server/facade/MapFacade.java =================================================================== --- trunk/magicmapserver/src/net/sf/magicmap/server/facade/MapFacade.java 2006-10-31 15:16:30 UTC (rev 475) +++ trunk/magicmapserver/src/net/sf/magicmap/server/facade/MapFacade.java 2006-10-31 15:55:58 UTC (rev 476) @@ -64,6 +64,8 @@ } } JDOUtil.commit(tx); + } catch (Exception e) { + if (tx.isActive()) tx.rollback(); } finally { JDOUtil.closePM(pm); } @@ -171,6 +173,8 @@ ++i; } JDOUtil.commit(tx); + } catch (Exception e) { + if (tx.isActive()) tx.rollback(); } finally { JDOUtil.closePM(pm); } @@ -245,6 +249,7 @@ } JDOUtil.commit(tx); } catch (Exception e) { + if (tx.isActive()) tx.rollback(); e.printStackTrace(); if (e instanceof MapException) { throw (MapException) e; @@ -301,6 +306,7 @@ } JDOUtil.commit(tx); } catch (Exception e) { + if (tx.isActive()) tx.rollback(); e.printStackTrace(); if (e instanceof MapException) { throw (MapException) e; @@ -398,6 +404,7 @@ } JDOUtil.commit(tx); } catch (Exception e) { + if (tx.isActive()) tx.rollback(); e.printStackTrace(); if (e instanceof MapException) { throw (MapException) e; @@ -447,6 +454,7 @@ } tx.commit(); } catch (Exception e) { + if (tx.isActive()) tx.rollback(); e.printStackTrace(); if (e instanceof MapException) { throw (MapException) e; Modified: trunk/magicmapserver/src/net/sf/magicmap/server/facade/PositionFacade.java =================================================================== --- trunk/magicmapserver/src/net/sf/magicmap/server/facade/PositionFacade.java 2006-10-31 15:16:30 UTC (rev 475) +++ trunk/magicmapserver/src/net/sf/magicmap/server/facade/PositionFacade.java 2006-10-31 15:55:58 UTC (rev 476) @@ -10,6 +10,7 @@ import javax.jdo.Extent; import javax.jdo.PersistenceManager; import javax.jdo.Query; +import javax.jdo.Transaction; import net.sf.magicmap.db.AccessPoint; import net.sf.magicmap.db.Client; @@ -38,15 +39,18 @@ SignalCharacterDTO character, String positionName, boolean fixed) throws SessionException, MapException{ this.logger.info("createOrUpdatePosition()"); PersistenceManager pm = null; + Transaction tx = null; try { pm = JDOUtil.pmfactory.getPersistenceManager(); - pm.currentTransaction().begin(); + tx = pm.currentTransaction(); + tx.begin(); createOrUpdatePositionInternal(sessionId, mapName, positionX, positionY, positionZ, character, positionName, fixed, pm); - if (pm.currentTransaction().isActive()) { - pm.currentTransaction().commit(); + if (tx.isActive()) { + tx.commit(); } } catch (Exception e) { + if (tx.isActive()) tx.rollback(); e.printStackTrace(); if (e instanceof MapException) { throw (MapException) e; @@ -97,28 +101,6 @@ pos.setPosY(positionY); pos.setPosZ(positionZ); PositionCache.getPositionCache().createOrUpdatePosition(map, pos, client.getMac()); - - String string; - int i = 0; - try { - FileOutputStream fs = new FileOutputStream(new File("referenzpunkt.txt"), true); - PrintWriter pw = new PrintWriter(fs, true); - while (i < character.getSimpleScanResults().length) { - string = "TimeStamp: " + System.currentTimeMillis() + " SessionID: " + sessionId + " PositionName: " - + positionName + " MapName: " + mapName + " Postition.X " + positionX + " Postition.Y " - + positionY + " Postition.Z " + positionZ + " Fixed: " + fixed + " Character.getMacAP " - + character.getSimpleScanResults()[i].getMacAP() + " Character.LastSeen: " - + character.getSimpleScanResults()[i].getLastSeen() + " Character.noise " - + character.getSimpleScanResults()[i].getNoise() + " Character.SignalLevel: " - + character.getSimpleScanResults()[i].getSignalLevel(); - pw.println(string); - ++i; - } - pw.close(); - fs.close(); - } catch (Exception e) { - e.printStackTrace(); - } } /** @@ -145,7 +127,6 @@ } return result; } catch (Exception e) { - // pm.currentTransaction().rollback(); throw new MapException("", e); } @@ -207,7 +188,6 @@ if (results != null && !results.isEmpty()) { result = (Session) results.iterator().next(); } else { - // pm.currentTransaction().rollback(); throw new SessionException("Session mit der id:" + sessionId + " existiert nicht"); } return result; @@ -233,7 +213,6 @@ if (results != null && !results.isEmpty()) { result = (Client) results.iterator().next(); } else { - // pm.currentTransaction().rollback(); throw new MapException("Client mit der mac-adresse:" + mac + " existiert nicht"); } return result; @@ -249,15 +228,18 @@ this.logger.info("createOrUpdateClientPosition()"); PersistenceManager pm = null; + Transaction tx = null; try { pm = JDOUtil.pmfactory.getPersistenceManager(); - pm.currentTransaction().begin(); + tx = pm.currentTransaction(); + tx.begin(); createOrUpdateClientPositionInternal(sessionId, mapName, positionX, positionY, positionZ, character, clientMac, fixed, pm); - if (pm.currentTransaction().isActive()) { - pm.currentTransaction().commit(); + if (tx.isActive()) { + tx.commit(); } } catch (Exception e) { + if (tx.isActive()) tx.rollback(); e.printStackTrace(); if (e instanceof MapException) { throw (MapException) e; @@ -305,31 +287,6 @@ pos.setPosZ(positionZ); logger.info("inside createOrUpdateClientPositionInternal Z-Koordinate: " + positionZ); PositionCache.getPositionCache().createOrUpdatePosition(map, pos); - - String string; - int i = 0; - try { - FileOutputStream fs = new FileOutputStream(new File("client.txt"), true); - PrintWriter pw = new PrintWriter(fs, true); - if (character.getSimpleScanResults() != null) { - while (i < character.getSimpleScanResults().length) { - string = "TimeStamp: " + System.currentTimeMillis() + " SessionID: " + sessionId + " ClientMAC: " - + clientMac + " MapName: " + mapName + " Postition.X " + positionX + " Postition.Y " - + positionY + " Postition.Y " + positionY + " Postition.Z " + positionZ + " Fixed: " - + fixed + " Character.getMacAP " + character.getSimpleScanResults()[i].getMacAP() - + " Character.LastSeen: " - //+ character.getSimpleScanResults()[i].getLastSeen() + " Character.noise " - + character.getSimpleScanResults()[i].getNoise() + " Character.SignalLevel: " - + character.getSimpleScanResults()[i].getSignalLevel(); - pw.println(string); - ++i; - } - } - pw.close(); - fs.close(); - } catch (Exception e) { - e.printStackTrace(); - } } /* (non-Javadoc) @@ -339,9 +296,11 @@ int positionZ, String accessPointMac, boolean fixed) throws SessionException, MapException{ this.logger.info("createOrUpdateAccessPosition()"); PersistenceManager pm = null; + Transaction tx = null; try { pm = JDOUtil.pmfactory.getPersistenceManager(); - pm.currentTransaction().begin(); + tx = pm.currentTransaction(); + tx.begin(); checkSession(sessionId, pm); Map map = checkMap(mapName, positionX, positionY, pm); AccessPoint ap = findOrCreateAccessPoint(accessPointMac, pm); @@ -360,10 +319,11 @@ pos.setPosY(positionY); pos.setPosZ(positionZ); PositionCache.getPositionCache().createOrUpdatePosition(map, pos); - if (pm.currentTransaction().isActive()) { - pm.currentTransaction().commit(); + if (tx.isActive()) { + tx.commit(); } } catch (Exception e) { + if (tx.isActive()) tx.rollback(); e.printStackTrace(); if (e instanceof MapException) { throw (MapException) e; @@ -385,18 +345,21 @@ int newPositionZ, boolean fixed) throws SessionException, MapException{ this.logger.info("movePosition()"); PersistenceManager pm = null; + Transaction tx = null; try { pm = JDOUtil.pmfactory.getPersistenceManager(); - pm.currentTransaction().begin(); + tx = pm.currentTransaction(); + tx.begin(); checkSession(sessionId, pm); Map map = checkMap(mapname, newPositionX, newPositionY, pm); PositionCache.getPositionCache().movePosition(map, positionId, newPositionX, newPositionY, newPositionZ, fixed); //logger.info("Z-Koord.: " + newPositionZ); - if (pm.currentTransaction().isActive()) { - pm.currentTransaction().commit(); + if (tx.isActive()) { + tx.commit(); } } catch (Exception e) { + if (tx.isActive()) tx.rollback(); e.printStackTrace(); if (e instanceof MapException) { throw (MapException) e; @@ -417,16 +380,19 @@ public void deletePosition(long sessionId, String mapname, long positionId) throws SessionException, MapException{ this.logger.info("deletePosition()"); PersistenceManager pm = null; + Transaction tx = null; try { pm = JDOUtil.pmfactory.getPersistenceManager(); - pm.currentTransaction().begin(); + tx = pm.currentTransaction(); + tx.begin(); checkSession(sessionId, pm); Map map = checkMap(mapname, pm); PositionCache.getPositionCache().removePosition(map, positionId); - if (pm.currentTransaction().isActive()) { - pm.currentTransaction().commit(); + if (tx.isActive()) { + tx.commit(); } } catch (Exception e) { + if (tx.isActive()) tx.rollback(); e.printStackTrace(); if (e instanceof MapException) { throw (MapException) e; @@ -450,19 +416,22 @@ this.logger.info("getPositionsForMapSince() " + timeStamp); PositionDTO[] result = null; PersistenceManager pm = null; + Transaction tx = null; try { pm = JDOUtil.pmfactory.getPersistenceManager(); - pm.currentTransaction().begin(); + tx = pm.currentTransaction(); + tx.begin(); checkSession(sessionId, pm); Map map = checkMap(mapName, pm); result = PositionCache.getPositionCache().getPositionsForMapSince(map, timeStamp, timeflag); for (int i = 0; i < result.length; i++) { logger.info("Z in PositionFacade: " + result[i].getPosZ()); } - if (pm.currentTransaction().isActive()) { - pm.currentTransaction().commit(); + if (tx.isActive()) { + tx.commit(); } } catch (Exception e) { + if (tx.isActive()) tx.rollback(); e.printStackTrace(); if (e instanceof MapException) { throw (MapException) e; @@ -484,20 +453,23 @@ SessionException, RemoteException{ this.logger.info("getPositionsForClientOnMap() "); PersistenceManager pm = null; + Transaction tx = null; String positionResult = null; try { pm = JDOUtil.pmfactory.getPersistenceManager(); - pm.currentTransaction().begin(); + tx = pm.currentTransaction(); + tx.begin(); checkSession(sessionId, pm); Map map = checkMap(mapName, pm); checkClient(clientMac, pm); PositionDTO pos = PositionCache.getPositionCache().getPositionForClientOnMap(map, clientMac); positionResult = String.valueOf(pos.getPosX()) + "#" + String.valueOf(pos.getPosY()) + "#" + String.valueOf(pos.isFixed()); - if (pm.currentTransaction().isActive()) { - pm.currentTransaction().commit(); + if (tx.isActive()) { + tx.commit(); } } catch (Exception e) { + if (tx.isActive()) tx.rollback(); e.printStackTrace(); if (e instanceof MapException) { throw (MapException) e; @@ -517,9 +489,11 @@ throws MapException, SessionException, RemoteException{ this.logger.info("setAccessPointHiddenStatus() "); PersistenceManager pm = null; + Transaction tx = null; try { pm = JDOUtil.pmfactory.getPersistenceManager(); - pm.currentTransaction().begin(); + tx = pm.currentTransaction(); + tx.begin(); checkSession(sessionId, pm); AccessPoint ap = findOrCreateAccessPoint(accessPointMac, pm); ap.setHidden(hidden); @@ -546,8 +520,9 @@ PositionCache.getPositionCache().createOrUpdatePosition(map, pos); } - pm.currentTransaction().commit(); + if (tx.isActive()) tx.commit(); } catch (Exception e) { + if (tx.isActive()) tx.rollback(); e.printStackTrace(); if (e instanceof MapException) { throw (MapException) e; Modified: trunk/magicmapserver/src/net/sf/magicmap/server/facade/SessionFacade.java =================================================================== --- trunk/magicmapserver/src/net/sf/magicmap/server/facade/SessionFacade.java 2006-10-31 15:16:30 UTC (rev 475) +++ trunk/magicmapserver/src/net/sf/magicmap/server/facade/SessionFacade.java 2006-10-31 15:55:58 UTC (rev 476) @@ -86,8 +86,9 @@ result = session.getId(); JDOUtil.commit(tx); } catch (Exception e) { + if (tx.isActive()) + tx.rollback(); this.logger.fatal("Fehler", e); - JDOUtil.rollBack(tx); throw new AuthenticationException(e.getMessage(), e); } finally { JDOUtil.closePM(pm); @@ -149,8 +150,9 @@ pm.deletePersistent(session); JDOUtil.commit(tx); } catch (Exception e) { + if (tx.isActive()) + tx.rollback(); this.logger.fatal("Fehler", e); - JDOUtil.rollBack(tx); throw new AuthenticationException(e.getMessage(), e); } finally { JDOUtil.closePM(pm); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |