rem
stringlengths 0
477k
| add
stringlengths 0
313k
| context
stringlengths 6
599k
|
---|---|---|
if (getLogger().isDebugEnabled()) { getLogger().debug("About to flush"); } | public void flush() throws CalFacadeException { if (exc != null) { // Didn't hear me last time? throw new CalFacadeException(exc); } try { sess.flush(); } catch (Throwable t) { handleException(t); } } |
|
Logger log = getLogger(); if (log.isDebugEnabled()) { log.debug("handleException called"); log.error(this, t); | if (getLogger().isDebugEnabled()) { getLogger().debug("handleException called"); getLogger().error(this, t); | private void handleException(Throwable t) throws CalFacadeException { try { Logger log = getLogger(); if (log.isDebugEnabled()) { log.debug("handleException called"); log.error(this, t); } } catch (Throwable dummy) {} try { if (tx != null) { try { tx.rollback(); } catch (Throwable t1) { rollbackException(t1); } tx = null; } } finally { try { sess.close(); } catch (Throwable t2) {} sess = null; } exc = t; throw new CalFacadeException(t); } |
Logger log = getLogger(); if (log.isDebugEnabled()) { log.debug("Enter rollback"); | if (getLogger().isDebugEnabled()) { getLogger().debug("Enter rollback"); | public void rollback() throws CalFacadeException {/* if (exc != null) { // Didn't hear me last time? throw new CalFacadeException(exc); }*/ Logger log = getLogger(); if (log.isDebugEnabled()) { log.debug("Enter rollback"); } try { if (tx != null && !tx.wasCommitted() && !tx.wasRolledBack()) { if (log.isDebugEnabled()) { log.debug("About to rollback"); } tx.rollback(); } tx = null; } catch (Throwable t) { exc = t; throw new CalFacadeException(t); } } |
if (log.isDebugEnabled()) { log.debug("About to rollback"); | if (getLogger().isDebugEnabled()) { getLogger().debug("About to rollback"); | public void rollback() throws CalFacadeException {/* if (exc != null) { // Didn't hear me last time? throw new CalFacadeException(exc); }*/ Logger log = getLogger(); if (log.isDebugEnabled()) { log.debug("Enter rollback"); } try { if (tx != null && !tx.wasCommitted() && !tx.wasRolledBack()) { if (log.isDebugEnabled()) { log.debug("About to rollback"); } tx.rollback(); } tx = null; } catch (Throwable t) { exc = t; throw new CalFacadeException(t); } } |
Logger log = getLogger(); if (log.isDebugEnabled()) { log.debug("HibSession: ", t); | if (getLogger().isDebugEnabled()) { getLogger().debug("HibSession: ", t); | private void rollbackException(Throwable t) { Logger log = getLogger(); if (log.isDebugEnabled()) { log.debug("HibSession: ", t); } log.error(this, t); } |
log.error(this, t); | getLogger().error(this, t); | private void rollbackException(Throwable t) { Logger log = getLogger(); if (log.isDebugEnabled()) { log.debug("HibSession: ", t); } log.error(this, t); } |
public void changeAccess(Object o, Collection aces) throws CalFacadeException { | public void changeAccess(BwShareableDbentity ent, Collection aces) throws CalFacadeException { | public void changeAccess(Object o, Collection aces) throws CalFacadeException { checkOpen(); throw new CalFacadeUnimplementedException(); } |
public Collection getAces(Object o) throws CalFacadeException { | public Collection getAces(BwShareableDbentity ent) throws CalFacadeException { | public Collection getAces(Object o) throws CalFacadeException { checkOpen(); throw new CalFacadeUnimplementedException(); } |
calendar.setTimeZone(TimeZone.getTimeZone("GMT")); | private int getEventColumn(EventAccess eventAccess) { try { Origin origin = eventAccess.get_preferred_origin(); edu.iris.Fissures.Time time = origin.origin_time; long microSeconds = ( new MicroSecondDate(time)).getMicroSecondTime(); Calendar calendar = Calendar.getInstance(); Date date = new Date(microSeconds/1000); calendar.setTime(date); int minutes = calendar.get(Calendar.MINUTE); int seconds = calendar.get(Calendar.SECOND); float colhours = (minutes * 60 + seconds) / (float) (60 * 60); System.out.println("The value of colhours is "+colhours); int rowvalue = 24/plotrows; int plotwidth = plot_x/plotrows; int rtnvalue = (int)(((float)plotwidth/rowvalue) * colhours); return rtnvalue; } catch(Exception e) { } return -1; } |
|
System.out.println("THe hour of the day is "+hours); | private int getEventRow(EventAccess eventAccess) { try { Origin origin = eventAccess.get_preferred_origin(); edu.iris.Fissures.Time time = origin.origin_time; long microSeconds = ( new MicroSecondDate(time)).getMicroSecondTime(); float colhours = microSeconds/(1000 * 1000 * 60 * 60); Calendar calendar = Calendar.getInstance(); Date date = new Date(microSeconds/1000); calendar.setTime(date); int hours = calendar.get(Calendar.HOUR_OF_DAY); return hours/2; } catch(Exception e) { } return -1; } |
|
this.addSeismogram(curr, ((MicroSecondDate)newData.get(curr))); | this.addSeismogram(curr); | public void setData(HashMap newData){ Iterator e = newData.keySet().iterator(); while(e.hasNext()){ DataSetSeismogram curr = ((DataSetSeismogram)e.next()); this.addSeismogram(curr, ((MicroSecondDate)newData.get(curr))); } updateTimeSyncListeners(); } |
updateTimeSyncListeners(); | public void setData(HashMap newData){ Iterator e = newData.keySet().iterator(); while(e.hasNext()){ DataSetSeismogram curr = ((DataSetSeismogram)e.next()); this.addSeismogram(curr, ((MicroSecondDate)newData.get(curr))); } updateTimeSyncListeners(); } |
|
jdbcCatalog, jdbcContributor, | public static void main(String[] args) { org.omg.CORBA_2_3.ORB orb = null; EventDCImpl ac_impl = null; EventDC ac = null; Connection dcConn = null; Connection checkQuitConn = null; JDBCQuitTable quit = null; QuitChecker quitChecker = null; FissuresNamingService fissuresNamingService = null; try { Properties props = System.getProperties(); // get some defaults String propFilename = "event.prop"; String defaultsFilename = "edu/sc/seis/fissuresUtil/anhinga/event/" + propFilename; for(int i = 0; i < args.length - 1; i++) { if(args[i].equals("-props")) { // override with values in local directory, // but still load defaults with original name propFilename = args[i + 1]; } } try { props.load((EventStart.class).getClassLoader() .getResourceAsStream(defaultsFilename)); } catch(IOException e) { System.err.println("Could not load defaults. " + e); } try { FileInputStream in = new FileInputStream(propFilename); props.load(in); in.close(); } catch(FileNotFoundException f) { System.err.println(" file missing " + f + " using defaults"); } catch(IOException f) { System.err.println(f.toString() + " using defaults"); } // configure logging from properties... PropertyConfigurator.configure(props); logger.info("Logging configured"); Class.forName("org.postgresql.Driver"); String databaseURL = props.getProperty("DatabaseURL", "jdbc:postgresql:sceppevents"); String databaseName = props.getProperty("DatabaseName", "scepp"); String databasePassword = props.getProperty("DatabasePassword", ""); String quitDatabaseURL = props.getProperty("QuitDatabaseURL", "jdbc:postgresql:sceppdata"); String quitDatabaseName = props.getProperty("QuitDatabaseName", "scepp"); String quitDatabasePassword = props.getProperty("QuitDatabasePassword", ""); dcConn = DriverManager.getConnection(databaseURL, databaseName, databasePassword); checkQuitConn = DriverManager.getConnection(quitDatabaseURL, quitDatabaseName, quitDatabasePassword); if(dcConn == null) { throw new SQLException("connection is null"); } JDBCEventAccess jdbcEventAccess = new JDBCEventAccess(dcConn); orb = (org.omg.CORBA_2_3.ORB)ORB.init(args, props); // register valuetype factories edu.iris.Fissures.model.AllVTFactory vt = new AllVTFactory(); vt.register(orb); // // Resolve Root POA // org.omg.PortableServer.POA rootPOA = org.omg.PortableServer.POAHelper.narrow(orb.resolve_initial_references("RootPOA")); // // Get a reference to the POA manager // org.omg.PortableServer.POAManager manager = rootPOA.the_POAManager(); org.omg.CORBA.Policy[] policy_list = new org.omg.CORBA.Policy[5]; policy_list[0] = rootPOA.create_lifespan_policy(org.omg.PortableServer.LifespanPolicyValue.PERSISTENT); policy_list[1] = rootPOA.create_id_assignment_policy(org.omg.PortableServer.IdAssignmentPolicyValue.USER_ID); policy_list[2] = rootPOA.create_implicit_activation_policy(org.omg.PortableServer.ImplicitActivationPolicyValue.NO_IMPLICIT_ACTIVATION); policy_list[3] = rootPOA.create_request_processing_policy(org.omg.PortableServer.RequestProcessingPolicyValue.USE_SERVANT_MANAGER); policy_list[4] = rootPOA.create_servant_retention_policy(org.omg.PortableServer.ServantRetentionPolicyValue.NON_RETAIN); // Create a POA for the EventFinder_impl. org.omg.PortableServer.POA finder_poa = rootPOA.create_POA("finder", manager, policy_list); //NetworkExplorer explorer = // explorerImpl._this(orb); // NetworkFinder finder = // finderImpl._this(orb); ac_impl = new EventDCImpl(); EventFactoryImpl factoryImpl = new EventFactoryImpl(jdbcEventAccess, finder_poa); EventFinderImpl finderImpl = new EventFinderImpl(jdbcEventAccess, finder_poa); EventFinder finder = finderImpl._this(orb); EventFactory factory = factoryImpl._this(orb); finderImpl.setEventFinder(finder); finderImpl.setEventFactory(factory); factoryImpl.setEventFactory(factory); factoryImpl.setEventFinder(finder); //ac_impl.setEventFactory(factoryImpl._this(orb)); ac_impl.setEventFinder(finder); EventLocator_impl eimpl = new EventLocator_impl(jdbcEventAccess, 2, finder_poa); org.omg.PortableServer.ServantManager locator = eimpl._this(orb); // Set servant locator. finder_poa.set_servant_manager(locator); ac = ac_impl._this(orb); serviceName = System.getProperty("anhinga.eventDC.serverName", serviceName); serviceDNS = System.getProperty("anhinga.eventDC.serverDNS", serviceDNS); fissuresNamingService = new FissuresNamingService(orb); String addNS = System.getProperty("anhinga.additionalNameService"); if(addNS != null) { fissuresNamingService.addOtherNameServiceCorbaLoc(addNS); } fissuresNamingService.rebind(serviceDNS, serviceName, ac); // register under old alternate name for backwards // compatibility serviceNameAlt = System.getProperty("anhinga.eventDC.serverNameAlt", serviceName); if(serviceNameAlt != null) { fissuresNamingService.rebind(serviceDNS, serviceNameAlt, ac); } logger.info("Bound to Name Service"); logger.info("will run until quit.val is set to true in DB. "); quit = new JDBCQuitTable(checkQuitConn, serviceDNS + "/" + serviceName + ":" + edu.iris.Fissures.VERSION.value); quitChecker = new QuitChecker(quit, orb); quitChecker.start(); // // Run implementation // manager.activate(); orb.run(); } catch(org.omg.PortableServer.POAManagerPackage.AdapterInactive e) { logger.error("POA problem.", e); } catch(org.omg.CORBA.ORBPackage.InvalidName e) { logger.error("Naming problem.", e); } catch(org.omg.CosNaming.NamingContextPackage.InvalidName e) { logger.error("Naming problem.", e); } catch(org.omg.CosNaming.NamingContextPackage.NotFound e) { logger.error("Naming problem.", e); } catch(CannotProceed e) { logger.error("Naming problem.", e); } catch(SQLException e) { logger.error("SQL problem with connection??? ", e); } catch(ClassNotFoundException e) { logger.error("Couldn't load postgres driver. ", e); } catch(Exception e) { logger.error("Couldn't load postgres driver. ", e); } finally { // unregister with name service try { if(orb != null && fissuresNamingService != null) { fissuresNamingService.unbind(serviceDNS, "EventDC", serviceName); if(serviceNameAlt != null) { fissuresNamingService.unbind(serviceDNS, "EventDC", serviceNameAlt); } } } catch(Exception e) { // who cares } // end of try-catch // make sure to stop the servant if(quitChecker != null) { try { quit.setQuitTime(); } catch(SQLException e) { // who cares } quitChecker.stopThread(); } try { if(dcConn != null) dcConn.close(); } catch(SQLException e) { // who cares??? } try { if(checkQuitConn != null) checkQuitConn.close(); } catch(SQLException e) { // who cares??? } } logger.info("EventStart done."); } |
|
this.jdbcCatalog = jdbcCatalog; this.jdbcContributor = jdbcContributor; | public EventFinderImpl(JDBCEventAccess jdbcEventAccess, org.omg.PortableServer.POA poa) { this.poa = poa; this.jdbcEventAccess = jdbcEventAccess; } |
|
public FissuresNamingService(org.omg.CORBA_2_3.ORB orb) { this.orb = orb; | public FissuresNamingService(java.util.Properties props) { String[] args = new String[0]; orb = (org.omg.CORBA_2_3.ORB)org.omg.CORBA.ORB.init(args, props); AllVTFactory vt = new AllVTFactory(); vt.register(orb); | public FissuresNamingService(org.omg.CORBA_2_3.ORB orb) { this.orb = orb; } |
} else if (argpar("-onlyusers", args, i)) { i++; if (args[i].equals("*")) { } else { globals.onlyUsers = true; String[] users = args[i].split(","); for (int oui = 0; oui < users.length; oui++) { info("Only user: " + users[oui]); globals.onlyUsersMap.put(users[oui], users[oui]); } } | boolean processArgs(String[] args) throws Throwable { if (args == null) { return true; } for (int i = 0; i < args.length; i++) { if (args[i].equals("")) { // null arg generated by ant } else if (args[i].equals("-debug")) { globals.debug = true; } else if (args[i].equals("-ndebug")) { globals.debug = false; } else if (args[i].equals("-debugentity")) { globals.debugEntity = true; } else if (args[i].equals("-ndebugentity")) { globals.debugEntity = false; } else if (args[i].equals("-noarg")) { globals.debug = false; } else if (argpar("-supergroup", args, i)) { i++; globals.superGroupName = args[i]; } else if (argpar("-defaultpubliccal", args, i)) { i++; globals.defaultPublicCalPath = args[i]; trace("Setting null event calendars to " + args[i]); } else if (args[i].equals("-from2p3px")) { globals.from2p3px = true; } else if (argpar("-d", args, i)) { i++; driver = args[i]; } else if (argpar("-i", args, i)) { i++; id = args[i]; } else if (argpar("-p", args, i)) { i++; pw = args[i]; } else if (argpar("-u", args, i)) { i++; url = args[i]; } else if (argpar("-f", args, i)) { i++; fileName = args[i]; } else if (argpar("-timezones", args, i)) { i++; globals.timezonesFilename = args[i]; /* System parameters */ } else if (argpar("-sysname", args, i)) { i++; globals.syspars.setName(args[i]); } else if (argpar("-tzid", args, i)) { i++; globals.syspars.setTzid(args[i]); } else if (argpar("-sysid", args, i)) { i++; globals.syspars.setSystemid(args[i]); } else if (argpar("-publiccalroot", args, i)) { i++; globals.syspars.setPublicCalendarRoot(args[i]); } else if (argpar("-usercalroot", args, i)) { i++; globals.syspars.setUserCalendarRoot(args[i]); } else if (argpar("-defusercal", args, i)) { i++; globals.syspars.setUserDefaultCalendar(args[i]); } else if (argpar("-deftrashcal", args, i)) { i++; globals.syspars.setDefaultTrashCalendar(args[i]); } else if (argpar("-definbox", args, i)) { i++; globals.syspars.setUserInbox(args[i]); } else if (argpar("-defoutbox", args, i)) { i++; globals.syspars.setUserOutbox(args[i]); } else if (argpar("-defuview", args, i)) { i++; globals.syspars.setDefaultUserViewName(args[i]); } else if (argpar("-pu", args, i)) { i++; globals.syspars.setPublicUser(args[i]); } else if (argpar("-httpconnsperuser", args, i)) { i++; globals.syspars.setHttpConnectionsPerUser(intPar(args[i])); globals.sysparsSetHttpConnectionsPerUser = true; } else if (argpar("-httpconnsperhost", args, i)) { i++; globals.syspars.setHttpConnectionsPerHost(intPar(args[i])); globals.sysparsSetHttpConnectionsPerHost = true; } else if (argpar("-httpconns", args, i)) { i++; globals.syspars.setHttpConnections(intPar(args[i])); globals.sysparsSetHttpConnections = true; } else if (argpar("-defuquota", args, i)) { i++; globals.syspars.setDefaultUserQuota(longPar(args[i])); globals.sysparsSetDefaultUserQuota = true; } else if (argpar("-userauthClass", args, i)) { i++; globals.syspars.setUserauthClass(args[i]); } else if (argpar("-mailerClass", args, i)) { i++; globals.syspars.setMailerClass(args[i]); } else if (argpar("-admingroupsClass", args, i)) { i++; globals.syspars.setAdmingroupsClass(args[i]); } else if (argpar("-usergroupsClass", args, i)) { i++; globals.syspars.setUsergroupsClass(args[i]); } else { error("Illegal argument: '" + args[i] + "'"); usage(); return false; } } return true; } |
|
public TPosClient(IWApplicationContext iwc) throws Exception { | public TPosClient(IWApplicationContext iwc, CreditCardMerchant merchant) throws Exception { this._merchant = merchant; | public TPosClient(IWApplicationContext iwc) throws Exception { init(iwc); } |
throw new CreditCardAuthorizationException("Unsupported"); | return (doAuth(cardnumber, monthExpires, yearExpires, amount, currency, "5", null, referenceNumber)); | public String creditcardAuthorization(String nameOnCard, String cardnumber, String monthExpires, String yearExpires, String ccVerifyNumber, double amount, String currency, String referenceNumber) throws CreditCardAuthorizationException{ throw new CreditCardAuthorizationException("Unsupported"); } |
private String doAuth(String cardnumber, String monthExpires, String yearExpires, double amount, String currency, String transactionType, Object parentDataPK) throws TPosException { | private String doAuth(String cardnumber, String monthExpires, String yearExpires, double amount, String currency, String transactionType, Object parentDataPK, String authRspID) throws TPosException { | private String doAuth(String cardnumber, String monthExpires, String yearExpires, double amount, String currency, String transactionType, Object parentDataPK) throws TPosException { if(_client != null) { _client.setProperty(TPOS3Client.PN_USERID, _userId); _client.setProperty(TPOS3Client.PN_PASSWORD, _passwd); _client.setProperty(TPOS3Client.PN_MERCHANTID, _merchantId); _client.setProperty(TPOS3Client.PN_LOCATIONID, _locationId); _client.setProperty(TPOS3Client.PN_POSID, _posId); _client.setProperty(TPOS3Client.PN_PAN, cardnumber); _client.setProperty(TPOS3Client.PN_EXPIRE, monthExpires + yearExpires); //_client.setProperty(TPOS3Client.PN_EXPIRE, yearExpires + monthExpires); amount *= amountMultiplier; String stringAmount = Integer.toString((int)amount); _client.setProperty(TPOS3Client.PN_AMOUNT, stringAmount); _client.setProperty(TPOS3Client.PN_CURRENCY, currency); _client.setProperty(TPOS3Client.PN_TRANSACTIONTYPE, transactionType); if (transactionType.equals("2")) { _client.setProperty(TPOS3Client.PN_CARDHOLDERCODE, "2"); } boolean valid = _client.sendAuthorisationReq(); boolean inserted = false; TPosAuthorisationEntriesBean entry; try { entry = TPosAuthorisationEntriesHome.getInstance().getNewElement(); // entry.setAttachmentCount(_client.getProperty(TPOS3Client.pn)); entry.setAuthorisationAmount(_client.getProperty(TPOS3Client.PN_AUTHORAMOUNT)); entry.setAuthorisationCode(_client.getProperty(TPOS3Client.PN_AUTHORISATIONCODE)); entry.setAuthorisationCurrency(_client.getProperty(TPOS3Client.PN_AUTHORCURRENCY)); entry.setAuthorisationIdRsp(_client.getProperty(TPOS3Client.PN_AUTHORIDENTIFYRSP)); entry.setAuthorisationPathReasonCode(_client.getProperty(TPOS3Client.PN_AUTHPATHREASONCODE)); entry.setBatchNumber(_client.getProperty(TPOS3Client.PN_BATCHNUMBER)); entry.setBrandId(_client.getProperty(TPOS3Client.PN_CARDBRANDID)); entry.setBrandName(_client.getProperty(TPOS3Client.PN_CARDBRANDNAME)); entry.setCardCharacteristics(_client.getProperty(TPOS3Client.PN_CARDCHARACTER)); entry.setCardExpires(_client.getProperty(TPOS3Client.PN_EXPIRE)); entry.setCardName(_client.getProperty(TPOS3Client.PN_CARDTYPENAME)); entry.setCardType(_client.getProperty(TPOS3Client.PN_CARDTYPEID)); entry.setDetailExpected(_client.getProperty(TPOS3Client.PN_DETAILEXPECTED)); entry.setEntryDate(_client.getProperty(TPOS3Client.PN_DATE)); entry.setEntryTime(_client.getProperty(TPOS3Client.PN_TIME)); entry.setErrorNo(_client.getProperty(TPOS3Client.PN_ERRORNUMBER)); entry.setErrorText(_client.getProperty(TPOS3Client.PN_ERRORTEXT)); entry.setLocationNr(_client.getProperty(TPOS3Client.PN_LOCATIONNUMBER)); entry.setMerchantNrAuthorisation(_client.getProperty(TPOS3Client.PN_MERCHANTNUMBERAUTHOR)); entry.setMerchantNrOtherServices(_client.getProperty(TPOS3Client.PN_MERCHANTNUMBEROTHERSERVICES)); entry.setMerchantNrSubmission(_client.getProperty(TPOS3Client.PN_MERCHANTNUMBERSUBMISSION)); // entry.setPan("***********"); entry.setPosNr(_client.getProperty(TPOS3Client.PN_POSNUMBER)); entry.setPosSerialNr(_client.getProperty(TPOS3Client.PN_POSSERIAL)); // entry.setPrintData(_client.getProperty(TPOS3Client.pn_p)); entry.setSubmissionAmount(_client.getProperty(TPOS3Client.PN_SUBMISSIONAMOUNT)); entry.setSubmissionCurrency(_client.getProperty(TPOS3Client.PN_SUBMISSIONCURRENCY)); entry.setTotalResponseCode(_client.getProperty(TPOS3Client.PN_TOTALRESPONSECODE)); entry.setTransactionNr(_client.getProperty(TPOS3Client.PN_TRANSACTIONNUMBER)); entry.setVoidedAuthorisationIdResponse(_client.getProperty(TPOS3Client.PN_VOIDEDAUTHIDRSP)); entry.setVoidedTransactionNr(_client.getProperty(TPOS3Client.PN_VOIDEDTRANSNUMBER)); // entry.setXMLAttachment(_client.getProperty(TPOS3Client.)); entry.setCardNumber(CreditCardBusinessBean.encodeCreditCardNumber(cardnumber)); if (parentDataPK != null) { try { entry.setParentID(((Integer) parentDataPK).intValue()); } catch (Exception e) { System.out.println("TPosClient : could not set parentID : "+parentDataPK); } } inserted = TPosAuthorisationEntriesHome.getInstance().insert(entry); } catch (Exception e) { e.printStackTrace(); } if (!inserted) { System.err.println("Unable to save entry to database"); } if (!valid) { TPosException e = new TPosException("Error in authorisation"); e.setErrorNumber(_client.getProperty(TPOS3Client.PN_ERRORNUMBER)); e.setErrorMessage(_client.getProperty(TPOS3Client.PN_ERRORTEXT)); e.setDisplayError("Error in authorisation (" + _client.getProperty(TPOS3Client.PN_ERRORNUMBER) + ")"); throw e; } TPosException tposEx = null; switch (Integer.parseInt(_client.getProperty(TPOS3Client.PN_TOTALRESPONSECODE), 10)) { case 0: return (_client.getProperty(TPOS3Client.PN_AUTHORIDENTIFYRSP)); case 1: tposEx = new TPosException("Authorisation denied"); tposEx.setErrorNumber(_client.getProperty(TPOS3Client.PN_ERRORNUMBER)); tposEx.setErrorMessage(_client.getProperty(TPOS3Client.PN_ERRORTEXT)); tposEx.setDisplayError("Authorisation denied (" + _client.getProperty(TPOS3Client.PN_ERRORNUMBER) + ")"); throw tposEx; case 2: tposEx = new TPosException("Authorisation denied, pick up card"); tposEx.setErrorNumber(_client.getProperty(TPOS3Client.PN_ERRORNUMBER)); tposEx.setErrorMessage(_client.getProperty(TPOS3Client.PN_ERRORTEXT)); tposEx.setDisplayError("Authorisation denied (" + _client.getProperty(TPOS3Client.PN_ERRORNUMBER) + ")"); throw tposEx; case 3: tposEx = new TPosException("Authorisation denied, call for manual authorisation"); tposEx.setErrorNumber(_client.getProperty(TPOS3Client.PN_ERRORNUMBER)); tposEx.setErrorMessage(_client.getProperty(TPOS3Client.PN_ERRORTEXT)); tposEx.setDisplayError("Authorisation denied (" + _client.getProperty(TPOS3Client.PN_ERRORNUMBER) + ")"); throw tposEx; } } return ("-1"); } |
boolean valid = _client.sendAuthorisationReq(); | boolean valid = false; try { valid = _client.sendAuthorisationReq(); } catch (IllegalArgumentException e) { getKeys(); createNewBatch(); _client.setProperty(TPOS3Client.PN_USERID, _userId); _client.setProperty(TPOS3Client.PN_PASSWORD, _passwd); _client.setProperty(TPOS3Client.PN_MERCHANTID, _merchantId); _client.setProperty(TPOS3Client.PN_LOCATIONID, _locationId); _client.setProperty(TPOS3Client.PN_POSID, _posId); _client.setProperty(TPOS3Client.PN_PAN, cardnumber); _client.setProperty(TPOS3Client.PN_EXPIRE, monthExpires + yearExpires); _client.setProperty(TPOS3Client.PN_AMOUNT, stringAmount); _client.setProperty(TPOS3Client.PN_CURRENCY, currency); _client.setProperty(TPOS3Client.PN_TRANSACTIONTYPE, transactionType); if (transactionType.equals("2")) { _client.setProperty(TPOS3Client.PN_CARDHOLDERCODE, "2"); } valid = _client.sendAuthorisationReq(); } | private String doAuth(String cardnumber, String monthExpires, String yearExpires, double amount, String currency, String transactionType, Object parentDataPK) throws TPosException { if(_client != null) { _client.setProperty(TPOS3Client.PN_USERID, _userId); _client.setProperty(TPOS3Client.PN_PASSWORD, _passwd); _client.setProperty(TPOS3Client.PN_MERCHANTID, _merchantId); _client.setProperty(TPOS3Client.PN_LOCATIONID, _locationId); _client.setProperty(TPOS3Client.PN_POSID, _posId); _client.setProperty(TPOS3Client.PN_PAN, cardnumber); _client.setProperty(TPOS3Client.PN_EXPIRE, monthExpires + yearExpires); //_client.setProperty(TPOS3Client.PN_EXPIRE, yearExpires + monthExpires); amount *= amountMultiplier; String stringAmount = Integer.toString((int)amount); _client.setProperty(TPOS3Client.PN_AMOUNT, stringAmount); _client.setProperty(TPOS3Client.PN_CURRENCY, currency); _client.setProperty(TPOS3Client.PN_TRANSACTIONTYPE, transactionType); if (transactionType.equals("2")) { _client.setProperty(TPOS3Client.PN_CARDHOLDERCODE, "2"); } boolean valid = _client.sendAuthorisationReq(); boolean inserted = false; TPosAuthorisationEntriesBean entry; try { entry = TPosAuthorisationEntriesHome.getInstance().getNewElement(); // entry.setAttachmentCount(_client.getProperty(TPOS3Client.pn)); entry.setAuthorisationAmount(_client.getProperty(TPOS3Client.PN_AUTHORAMOUNT)); entry.setAuthorisationCode(_client.getProperty(TPOS3Client.PN_AUTHORISATIONCODE)); entry.setAuthorisationCurrency(_client.getProperty(TPOS3Client.PN_AUTHORCURRENCY)); entry.setAuthorisationIdRsp(_client.getProperty(TPOS3Client.PN_AUTHORIDENTIFYRSP)); entry.setAuthorisationPathReasonCode(_client.getProperty(TPOS3Client.PN_AUTHPATHREASONCODE)); entry.setBatchNumber(_client.getProperty(TPOS3Client.PN_BATCHNUMBER)); entry.setBrandId(_client.getProperty(TPOS3Client.PN_CARDBRANDID)); entry.setBrandName(_client.getProperty(TPOS3Client.PN_CARDBRANDNAME)); entry.setCardCharacteristics(_client.getProperty(TPOS3Client.PN_CARDCHARACTER)); entry.setCardExpires(_client.getProperty(TPOS3Client.PN_EXPIRE)); entry.setCardName(_client.getProperty(TPOS3Client.PN_CARDTYPENAME)); entry.setCardType(_client.getProperty(TPOS3Client.PN_CARDTYPEID)); entry.setDetailExpected(_client.getProperty(TPOS3Client.PN_DETAILEXPECTED)); entry.setEntryDate(_client.getProperty(TPOS3Client.PN_DATE)); entry.setEntryTime(_client.getProperty(TPOS3Client.PN_TIME)); entry.setErrorNo(_client.getProperty(TPOS3Client.PN_ERRORNUMBER)); entry.setErrorText(_client.getProperty(TPOS3Client.PN_ERRORTEXT)); entry.setLocationNr(_client.getProperty(TPOS3Client.PN_LOCATIONNUMBER)); entry.setMerchantNrAuthorisation(_client.getProperty(TPOS3Client.PN_MERCHANTNUMBERAUTHOR)); entry.setMerchantNrOtherServices(_client.getProperty(TPOS3Client.PN_MERCHANTNUMBEROTHERSERVICES)); entry.setMerchantNrSubmission(_client.getProperty(TPOS3Client.PN_MERCHANTNUMBERSUBMISSION)); // entry.setPan("***********"); entry.setPosNr(_client.getProperty(TPOS3Client.PN_POSNUMBER)); entry.setPosSerialNr(_client.getProperty(TPOS3Client.PN_POSSERIAL)); // entry.setPrintData(_client.getProperty(TPOS3Client.pn_p)); entry.setSubmissionAmount(_client.getProperty(TPOS3Client.PN_SUBMISSIONAMOUNT)); entry.setSubmissionCurrency(_client.getProperty(TPOS3Client.PN_SUBMISSIONCURRENCY)); entry.setTotalResponseCode(_client.getProperty(TPOS3Client.PN_TOTALRESPONSECODE)); entry.setTransactionNr(_client.getProperty(TPOS3Client.PN_TRANSACTIONNUMBER)); entry.setVoidedAuthorisationIdResponse(_client.getProperty(TPOS3Client.PN_VOIDEDAUTHIDRSP)); entry.setVoidedTransactionNr(_client.getProperty(TPOS3Client.PN_VOIDEDTRANSNUMBER)); // entry.setXMLAttachment(_client.getProperty(TPOS3Client.)); entry.setCardNumber(CreditCardBusinessBean.encodeCreditCardNumber(cardnumber)); if (parentDataPK != null) { try { entry.setParentID(((Integer) parentDataPK).intValue()); } catch (Exception e) { System.out.println("TPosClient : could not set parentID : "+parentDataPK); } } inserted = TPosAuthorisationEntriesHome.getInstance().insert(entry); } catch (Exception e) { e.printStackTrace(); } if (!inserted) { System.err.println("Unable to save entry to database"); } if (!valid) { TPosException e = new TPosException("Error in authorisation"); e.setErrorNumber(_client.getProperty(TPOS3Client.PN_ERRORNUMBER)); e.setErrorMessage(_client.getProperty(TPOS3Client.PN_ERRORTEXT)); e.setDisplayError("Error in authorisation (" + _client.getProperty(TPOS3Client.PN_ERRORNUMBER) + ")"); throw e; } TPosException tposEx = null; switch (Integer.parseInt(_client.getProperty(TPOS3Client.PN_TOTALRESPONSECODE), 10)) { case 0: return (_client.getProperty(TPOS3Client.PN_AUTHORIDENTIFYRSP)); case 1: tposEx = new TPosException("Authorisation denied"); tposEx.setErrorNumber(_client.getProperty(TPOS3Client.PN_ERRORNUMBER)); tposEx.setErrorMessage(_client.getProperty(TPOS3Client.PN_ERRORTEXT)); tposEx.setDisplayError("Authorisation denied (" + _client.getProperty(TPOS3Client.PN_ERRORNUMBER) + ")"); throw tposEx; case 2: tposEx = new TPosException("Authorisation denied, pick up card"); tposEx.setErrorNumber(_client.getProperty(TPOS3Client.PN_ERRORNUMBER)); tposEx.setErrorMessage(_client.getProperty(TPOS3Client.PN_ERRORTEXT)); tposEx.setDisplayError("Authorisation denied (" + _client.getProperty(TPOS3Client.PN_ERRORNUMBER) + ")"); throw tposEx; case 3: tposEx = new TPosException("Authorisation denied, call for manual authorisation"); tposEx.setErrorNumber(_client.getProperty(TPOS3Client.PN_ERRORNUMBER)); tposEx.setErrorMessage(_client.getProperty(TPOS3Client.PN_ERRORTEXT)); tposEx.setDisplayError("Authorisation denied (" + _client.getProperty(TPOS3Client.PN_ERRORNUMBER) + ")"); throw tposEx; } } return ("-1"); } |
return doAuth(cardnumber, monthExpires, yearExpires, amount, currency, "3", parentDataPK); | return doAuth(cardnumber, monthExpires, yearExpires, amount, currency, "3", parentDataPK, null); | public String doRefund(String cardnumber, String monthExpires, String yearExpires, String ccVerifyNumber, double amount, String currency, Object parentDataPK, String captureProperties) throws TPosException { System.out.println("Warning : TPosClient is NOT using CVC number"); return doAuth(cardnumber, monthExpires, yearExpires, amount, currency, "3", parentDataPK); } |
return (doAuth(cardnumber, monthExpires, yearExpires, amount, currency, "1", null)); | return (doAuth(cardnumber, monthExpires, yearExpires, amount, currency, "1", null, null)); | public String doSale(String nameOnCard, String cardnumber, String monthExpires, String yearExpires, String ccVerifyNumber, double amount, String currency, String referenceNumber) throws TPosException { return (doAuth(cardnumber, monthExpires, yearExpires, amount, currency, "1", null)); } |
System.out.println("TPosClient : Using default TPosMerchant"); | System.out.println("TPosClient : Using default TPosMerchant, ipset = "+ipset); | private void init(IWApplicationContext iwc) throws Exception{ _iwc = iwc; _iwb = iwc.getIWMainApplication().getBundle(IW_BUNDLE_IDENTIFIER); //if (_iwb != null) { // _iwrb = _iwb.getResourceBundle(iwc); //} String path = _iwb.getPropertiesRealPath(); if (path == null) { throw new Exception("Unable to find properties file"); } String seperator = java.io.File.separator; if (!path.endsWith(seperator)) { path = path + seperator + _iwb.getProperty("properties_file"); } else { path = path + _iwb.getProperty("properties_file"); } try { _client = new TPOS3Client(path); String ipset = _iwb.getProperty(TPOS_IP_SET); _client.setIPSet(Integer.parseInt(ipset)); if (_merchant == null) { System.out.println("TPosClient : Using default TPosMerchant"); _userId = _iwb.getProperty(TPOS_USER_ID); _passwd = _iwb.getProperty(TPOS_PASSWD); _merchantId = _iwb.getProperty(TPOS_MERCHANT_ID); _locationId = _iwb.getProperty(TPOS_LOCATION_ID); _posId = _iwb.getProperty(TPOS_POS_ID); _receivePasswd = _iwb.getProperty(TPOS_KEY_RECEIVE_PASSWD); }else { System.out.println("TPosClient : Using TPosMerchant "+_merchant.getName()); _userId = _merchant.getUser(); _passwd = _merchant.getPassword(); _merchantId = _merchant.getMerchantID(); _locationId = _merchant.getLocation(); _posId = _merchant.getTerminalID(); _receivePasswd = _merchant.getExtraInfo(); } } catch (Exception e) { System.out.println("Got an exception trying to create client"); } } |
System.out.println("TPosClient : Using TPosMerchant "+_merchant.getName()); | System.out.println("TPosClient : Using TPosMerchant "+_merchant.getName()+", ipset = "+ipset); | private void init(IWApplicationContext iwc) throws Exception{ _iwc = iwc; _iwb = iwc.getIWMainApplication().getBundle(IW_BUNDLE_IDENTIFIER); //if (_iwb != null) { // _iwrb = _iwb.getResourceBundle(iwc); //} String path = _iwb.getPropertiesRealPath(); if (path == null) { throw new Exception("Unable to find properties file"); } String seperator = java.io.File.separator; if (!path.endsWith(seperator)) { path = path + seperator + _iwb.getProperty("properties_file"); } else { path = path + _iwb.getProperty("properties_file"); } try { _client = new TPOS3Client(path); String ipset = _iwb.getProperty(TPOS_IP_SET); _client.setIPSet(Integer.parseInt(ipset)); if (_merchant == null) { System.out.println("TPosClient : Using default TPosMerchant"); _userId = _iwb.getProperty(TPOS_USER_ID); _passwd = _iwb.getProperty(TPOS_PASSWD); _merchantId = _iwb.getProperty(TPOS_MERCHANT_ID); _locationId = _iwb.getProperty(TPOS_LOCATION_ID); _posId = _iwb.getProperty(TPOS_POS_ID); _receivePasswd = _iwb.getProperty(TPOS_KEY_RECEIVE_PASSWD); }else { System.out.println("TPosClient : Using TPosMerchant "+_merchant.getName()); _userId = _merchant.getUser(); _passwd = _merchant.getPassword(); _merchantId = _merchant.getMerchantID(); _locationId = _merchant.getLocation(); _posId = _merchant.getTerminalID(); _receivePasswd = _merchant.getExtraInfo(); } } catch (Exception e) { System.out.println("Got an exception trying to create client"); } } |
form.getErr().emit("org.bedework.error.eventnotfound"); | form.getErr().emit("org.bedework.client.error.eventnotfound"); | public String doAction(HttpServletRequest request, BwActionForm form) throws Throwable { int eventId = form.getEventId(); if (eventId < 0) { // Do nothing return "doNothing"; } EventInfo ei = form.getCalSvcI().getEvent(eventId); BwEvent ev = null; if (ei != null) { ev = ei.getEvent(); } form.assignCurrentEvent(ev); if (ei == null) { form.getErr().emit("org.bedework.error.eventnotfound"); return "notFound"; } return "success"; } |
for (int hi = 0; hi <= howchs.length; hi++) { | for (int hi = 0; hi < howchs.length; hi++) { | public String doAction(HttpServletRequest request, HttpServletResponse response, BwSession sess, BwActionFormBase form) throws Throwable { if (form.getGuest()) { return "notFound"; } CalSvcI svci = form.fetchSvci(); BwCalendar cal = null; EventInfo ei = null; BwEvent ev = null; String rpar = getReqPar(request, "guid"); if (rpar != null) { // Assume event ei = findEvent(request, form); if (ei == null) { // Do nothing form.getErr().emit("org.bedework.client.error.nosuchevent"); return "doNothing"; } ev = ei.getEvent(); } else { String calPath = request.getParameter("calPath"); if (calPath == null) { // bogus request return "notFound"; } cal = svci.getCalendar(calPath); if (cal == null) { form.getErr().emit("org.bedework.client.error.nosuchcalendar", calPath); return "notFound"; } } String whoTypeStr = request.getParameter("whoType"); int whoType = -1; if (whoTypeStr == null) { whoType = Ace.whoTypeUser; } else if (whoTypeStr.equals("owner")) { whoType = Ace.whoTypeOwner; } else if (whoTypeStr.equals("user")) { whoType = Ace.whoTypeUser; } else if (whoTypeStr.equals("group")) { whoType = Ace.whoTypeGroup; form.getErr().emit("org.bedework.client.error.unimplemented"); return "error"; } else if (whoTypeStr.equals("unauth")) { whoType = Ace.whoTypeUnauthenticated; } else if (whoTypeStr.equals("other")) { whoType = Ace.whoTypeOther; } else { form.getErr().emit("org.bedework.client.error.badwhotype"); return "error"; } String who = request.getParameter("who"); if (who != null) { BwUser user = svci.findUser(who); if (user == null) { form.getErr().emit("org.bedework.client.error.usernotfound"); return "notFound"; } } else { who = null; } ArrayList aces = new ArrayList(); String how = getReqPar(request, "how"); if (how == null) { form.getErr().emit("org.bedework.client.error.nohowaccess"); return "error"; } char[] howchs = how.toCharArray(); for (int hi = 0; hi <= howchs.length; hi++) { char howch = howchs[hi]; boolean found = false; for (int pi = 0; pi <= PrivilegeDefs.privMaxType; pi++) { if (howch == PrivilegeDefs.privEncoding[pi]) { aces.add(new Ace(who, false, whoType, Privileges.makePriv(pi))); found = true; break; } if (!found) { form.getErr().emit("org.bedework.client.error.badhow"); return "error"; } } } if (ev != null) { svci.changeAccess(ev, aces); svci.updateEvent(ev); } else { svci.changeAccess(cal, aces); svci.updateCalendar(cal); } return "success"; } |
if (!found) { form.getErr().emit("org.bedework.client.error.badhow"); return "error"; } | if (!found) { form.getErr().emit("org.bedework.client.error.badhow"); return "error"; | public String doAction(HttpServletRequest request, HttpServletResponse response, BwSession sess, BwActionFormBase form) throws Throwable { if (form.getGuest()) { return "notFound"; } CalSvcI svci = form.fetchSvci(); BwCalendar cal = null; EventInfo ei = null; BwEvent ev = null; String rpar = getReqPar(request, "guid"); if (rpar != null) { // Assume event ei = findEvent(request, form); if (ei == null) { // Do nothing form.getErr().emit("org.bedework.client.error.nosuchevent"); return "doNothing"; } ev = ei.getEvent(); } else { String calPath = request.getParameter("calPath"); if (calPath == null) { // bogus request return "notFound"; } cal = svci.getCalendar(calPath); if (cal == null) { form.getErr().emit("org.bedework.client.error.nosuchcalendar", calPath); return "notFound"; } } String whoTypeStr = request.getParameter("whoType"); int whoType = -1; if (whoTypeStr == null) { whoType = Ace.whoTypeUser; } else if (whoTypeStr.equals("owner")) { whoType = Ace.whoTypeOwner; } else if (whoTypeStr.equals("user")) { whoType = Ace.whoTypeUser; } else if (whoTypeStr.equals("group")) { whoType = Ace.whoTypeGroup; form.getErr().emit("org.bedework.client.error.unimplemented"); return "error"; } else if (whoTypeStr.equals("unauth")) { whoType = Ace.whoTypeUnauthenticated; } else if (whoTypeStr.equals("other")) { whoType = Ace.whoTypeOther; } else { form.getErr().emit("org.bedework.client.error.badwhotype"); return "error"; } String who = request.getParameter("who"); if (who != null) { BwUser user = svci.findUser(who); if (user == null) { form.getErr().emit("org.bedework.client.error.usernotfound"); return "notFound"; } } else { who = null; } ArrayList aces = new ArrayList(); String how = getReqPar(request, "how"); if (how == null) { form.getErr().emit("org.bedework.client.error.nohowaccess"); return "error"; } char[] howchs = how.toCharArray(); for (int hi = 0; hi <= howchs.length; hi++) { char howch = howchs[hi]; boolean found = false; for (int pi = 0; pi <= PrivilegeDefs.privMaxType; pi++) { if (howch == PrivilegeDefs.privEncoding[pi]) { aces.add(new Ace(who, false, whoType, Privileges.makePriv(pi))); found = true; break; } if (!found) { form.getErr().emit("org.bedework.client.error.badhow"); return "error"; } } } if (ev != null) { svci.changeAccess(ev, aces); svci.updateEvent(ev); } else { svci.changeAccess(cal, aces); svci.updateCalendar(cal); } return "success"; } |
svci.updateEvent(ev); | public String doAction(HttpServletRequest request, HttpServletResponse response, BwSession sess, BwActionFormBase form) throws Throwable { if (form.getGuest()) { return "notFound"; } CalSvcI svci = form.fetchSvci(); BwCalendar cal = null; EventInfo ei = null; BwEvent ev = null; String rpar = getReqPar(request, "guid"); if (rpar != null) { // Assume event ei = findEvent(request, form); if (ei == null) { // Do nothing form.getErr().emit("org.bedework.client.error.nosuchevent"); return "doNothing"; } ev = ei.getEvent(); } else { String calPath = request.getParameter("calPath"); if (calPath == null) { // bogus request return "notFound"; } cal = svci.getCalendar(calPath); if (cal == null) { form.getErr().emit("org.bedework.client.error.nosuchcalendar", calPath); return "notFound"; } } String whoTypeStr = request.getParameter("whoType"); int whoType = -1; if (whoTypeStr == null) { whoType = Ace.whoTypeUser; } else if (whoTypeStr.equals("owner")) { whoType = Ace.whoTypeOwner; } else if (whoTypeStr.equals("user")) { whoType = Ace.whoTypeUser; } else if (whoTypeStr.equals("group")) { whoType = Ace.whoTypeGroup; form.getErr().emit("org.bedework.client.error.unimplemented"); return "error"; } else if (whoTypeStr.equals("unauth")) { whoType = Ace.whoTypeUnauthenticated; } else if (whoTypeStr.equals("other")) { whoType = Ace.whoTypeOther; } else { form.getErr().emit("org.bedework.client.error.badwhotype"); return "error"; } String who = request.getParameter("who"); if (who != null) { BwUser user = svci.findUser(who); if (user == null) { form.getErr().emit("org.bedework.client.error.usernotfound"); return "notFound"; } } else { who = null; } ArrayList aces = new ArrayList(); String how = getReqPar(request, "how"); if (how == null) { form.getErr().emit("org.bedework.client.error.nohowaccess"); return "error"; } char[] howchs = how.toCharArray(); for (int hi = 0; hi <= howchs.length; hi++) { char howch = howchs[hi]; boolean found = false; for (int pi = 0; pi <= PrivilegeDefs.privMaxType; pi++) { if (howch == PrivilegeDefs.privEncoding[pi]) { aces.add(new Ace(who, false, whoType, Privileges.makePriv(pi))); found = true; break; } if (!found) { form.getErr().emit("org.bedework.client.error.badhow"); return "error"; } } } if (ev != null) { svci.changeAccess(ev, aces); svci.updateEvent(ev); } else { svci.changeAccess(cal, aces); svci.updateCalendar(cal); } return "success"; } |
|
svci.updateCalendar(cal); | public String doAction(HttpServletRequest request, HttpServletResponse response, BwSession sess, BwActionFormBase form) throws Throwable { if (form.getGuest()) { return "notFound"; } CalSvcI svci = form.fetchSvci(); BwCalendar cal = null; EventInfo ei = null; BwEvent ev = null; String rpar = getReqPar(request, "guid"); if (rpar != null) { // Assume event ei = findEvent(request, form); if (ei == null) { // Do nothing form.getErr().emit("org.bedework.client.error.nosuchevent"); return "doNothing"; } ev = ei.getEvent(); } else { String calPath = request.getParameter("calPath"); if (calPath == null) { // bogus request return "notFound"; } cal = svci.getCalendar(calPath); if (cal == null) { form.getErr().emit("org.bedework.client.error.nosuchcalendar", calPath); return "notFound"; } } String whoTypeStr = request.getParameter("whoType"); int whoType = -1; if (whoTypeStr == null) { whoType = Ace.whoTypeUser; } else if (whoTypeStr.equals("owner")) { whoType = Ace.whoTypeOwner; } else if (whoTypeStr.equals("user")) { whoType = Ace.whoTypeUser; } else if (whoTypeStr.equals("group")) { whoType = Ace.whoTypeGroup; form.getErr().emit("org.bedework.client.error.unimplemented"); return "error"; } else if (whoTypeStr.equals("unauth")) { whoType = Ace.whoTypeUnauthenticated; } else if (whoTypeStr.equals("other")) { whoType = Ace.whoTypeOther; } else { form.getErr().emit("org.bedework.client.error.badwhotype"); return "error"; } String who = request.getParameter("who"); if (who != null) { BwUser user = svci.findUser(who); if (user == null) { form.getErr().emit("org.bedework.client.error.usernotfound"); return "notFound"; } } else { who = null; } ArrayList aces = new ArrayList(); String how = getReqPar(request, "how"); if (how == null) { form.getErr().emit("org.bedework.client.error.nohowaccess"); return "error"; } char[] howchs = how.toCharArray(); for (int hi = 0; hi <= howchs.length; hi++) { char howch = howchs[hi]; boolean found = false; for (int pi = 0; pi <= PrivilegeDefs.privMaxType; pi++) { if (howch == PrivilegeDefs.privEncoding[pi]) { aces.add(new Ace(who, false, whoType, Privileges.makePriv(pi))); found = true; break; } if (!found) { form.getErr().emit("org.bedework.client.error.badhow"); return "error"; } } } if (ev != null) { svci.changeAccess(ev, aces); svci.updateEvent(ev); } else { svci.changeAccess(cal, aces); svci.updateCalendar(cal); } return "success"; } |
|
SeismogramAttr[] seismogramAttrs = getSeismogramAttrs(); ChannelId[] channelIds = new ChannelId[seismogramAttrs.length]; | public ChannelId[] getChannelIds() { SeismogramAttr[] seismogramAttrs = getSeismogramAttrs(); ChannelId[] channelIds = new ChannelId[seismogramAttrs.length]; for(int counter = 0; counter < seismogramAttrs.length; counter++) { channelIds[counter] = ((SeismogramAttrImpl)seismogramAttrs[counter]).getChannelID(); } return channelIds; } |
|
} return channelIds; } | }*/ } | public ChannelId[] getChannelIds() { SeismogramAttr[] seismogramAttrs = getSeismogramAttrs(); ChannelId[] channelIds = new ChannelId[seismogramAttrs.length]; for(int counter = 0; counter < seismogramAttrs.length; counter++) { channelIds[counter] = ((SeismogramAttrImpl)seismogramAttrs[counter]).getChannelID(); } return channelIds; } |
if (finish-start < 8) { | if (finish-start < SPLIT_SUMMING_LIMIT) { | private double dBinaryIndexSum(int start, int finish) { if (finish-start < 8) { double val = 0; for (int i=start; i< finish; i++) { val += i * dSeries[i]; } return val; } else { int middle = (start + finish) / 2; return dBinaryIndexSum(start, middle) + dBinaryIndexSum(middle, finish); } } |
if (finish-start < 8) { | if (finish-start < SPLIT_SUMMING_LIMIT) { | private double dBinarySum(int start, int finish) { if (finish-start < 8) { double val = 0; for (int i=start; i< finish; i++) { val += dSeries[i]; } return val; } else { int middle = (start + finish) / 2; return dBinarySum(start, middle) + dBinarySum(middle, finish); } } |
if (finish-start < lag+8) { | if (finish-start < lag+SPLIT_SUMMING_LIMIT) { | private double dBinarySumDevLag(int start, int finish, double mean, int lag) { if (finish-start < lag+8) { double val = 0; for (int i=start; i< finish && i<getLength()-lag; i++) { val += (dSeries[i]-mean)*(dSeries[i+lag]-mean); } return val; } else { int middle = (start + finish) / 2; return dBinarySumDevLag(start, middle, mean, lag) + dBinarySumDevLag(middle, finish, mean, lag); } } |
if (finish-start < 8) { | if (finish-start < SPLIT_SUMMING_LIMIT) { | private double dBinarySumDevSqr(int start, int finish, double mean) { if (finish-start < 8) { double val = 0; for (int i=start; i< finish; i++) { val += (dSeries[i]-mean)*(dSeries[i]-mean); } return val; } else { int middle = (start + finish) / 2; return dBinarySumDevSqr(start, middle, mean) + dBinarySumDevSqr(middle, finish, mean); } } |
if (finish-start < 8) { | if (finish-start < SPLIT_SUMMING_LIMIT) { | private double fBinaryIndexSum(int start, int finish) { if (finish-start < 8) { double val = 0; for (int i=start; i< finish; i++) { val += i * fSeries[i]; } return val; } else { int middle = (start + finish) / 2; return fBinaryIndexSum(start, middle) + fBinaryIndexSum(middle, finish); } } |
if (finish-start < 8) { | if (finish-start < SPLIT_SUMMING_LIMIT) { | private double fBinarySum(int start, int finish) { if (finish-start < 8) { double val = 0; for (int i=start; i< finish; i++) { val += fSeries[i]; } return val; } else { int middle = (start + finish) / 2; return fBinarySum(start, middle) + fBinarySum(middle, finish); } } |
if (finish-start < lag+8) { | if (finish-start < lag+SPLIT_SUMMING_LIMIT) { | private double fBinarySumDevLag(int start, int finish, double mean, int lag) { if (finish-start < lag+8) { double val = 0; for (int i=start; i< finish && i<getLength()-lag; i++) { val += (fSeries[i]-mean)*(fSeries[i+lag]-mean); } return val; } else { int middle = (start + finish) / 2; return fBinarySumDevLag(start, middle, mean, lag) + fBinarySumDevLag(middle, finish, mean, lag); } } |
if (finish-start < 8) { | if (finish-start < SPLIT_SUMMING_LIMIT) { | private double fBinarySumDevSqr(int start, int finish, double mean) { if (finish-start < 8) { double val = 0; for (int i=start; i< finish; i++) { val += (fSeries[i]-mean)*(fSeries[i]-mean); } return val; } else { int middle = (start + finish) / 2; return fBinarySumDevSqr(start, middle, mean) + fBinarySumDevSqr(middle, finish, mean); } } |
if (finish-start < 8) { | if (finish-start < SPLIT_SUMMING_LIMIT) { | private double iBinaryIndexSum(int start, int finish) { if (finish-start < 8) { double val = 0; for (int i=start; i< finish; i++) { val += i * iSeries[i]; } return val; } else { int middle = (start + finish) / 2; return iBinaryIndexSum(start, middle) + iBinaryIndexSum(middle, finish); } } |
if (finish-start < 8) { | if (finish-start < SPLIT_SUMMING_LIMIT) { | private double iBinarySum(int start, int finish) { if (finish-start < 8) { double val = 0; for (int i=start; i< finish; i++) { val += iSeries[i]; } return val; } else { int middle = (start + finish) / 2; return iBinarySum(start, middle) + iBinarySum(middle, finish); } } |
if (finish-start < lag+8) { | if (finish-start < lag+SPLIT_SUMMING_LIMIT) { | private double iBinarySumDevLag(int start, int finish, double mean, int lag) { if (finish-start < lag+8) { double val = 0; for (int i=start; i< finish && i<getLength()-lag; i++) { val += (iSeries[i]-mean)*(iSeries[i+lag]-mean); } return val; } else { int middle = (start + finish) / 2; return iBinarySumDevLag(start, middle, mean, lag) + iBinarySumDevLag(middle, finish, mean, lag); } } |
if (finish-start < 8) { | if (finish-start < SPLIT_SUMMING_LIMIT) { | private double iBinarySumDevSqr(int start, int finish, double mean) { if (finish-start < 8) { double val = 0; for (int i=start; i< finish; i++) { val += (iSeries[i]-mean)*(iSeries[i]-mean); } return val; } else { int middle = (start + finish) / 2; return iBinarySumDevSqr(start, middle, mean) + iBinarySumDevSqr(middle, finish, mean); } } |
int sumToN = n*(n+1)/2; int sumSqrToN = n*(n+1)*(2*n+1)/6; | double sumToN = 1.0*n*(n+1)/2; double sumSqrToN = 1.0*n*(n+1)*(2*n+1)/6; | public double[] linearLeastSquares() { int n = getLength()-1; // use zero based, so n => n-1 int sumToN = n*(n+1)/2; int sumSqrToN = n*(n+1)*(2*n+1)/6; double sumValues = binarySum(0, getLength()); double indexSumValues = binaryIndexSum(0, getLength()); double d = (n+1)*sumSqrToN - sumToN*sumToN; double[] out = new double[2]; out[0] = (sumSqrToN * sumValues - sumToN * indexSumValues)/d; out[1] = ((n+1) * indexSumValues - sumToN * sumValues)/d; return out; } |
if (finish-start < 8) { | if (finish-start < SPLIT_SUMMING_LIMIT) { | private double sBinaryIndexSum(int start, int finish) { if (finish-start < 8) { double val = 0; for (int i=start; i< finish; i++) { val += i * sSeries[i]; } return val; } else { int middle = (start + finish) / 2; return sBinaryIndexSum(start, middle) + sBinaryIndexSum(middle, finish); } } |
if (finish-start < 8) { | if (finish-start < SPLIT_SUMMING_LIMIT) { | private double sBinarySum(int start, int finish) { if (finish-start < 8) { double val = 0; for (int i=start; i< finish; i++) { val += sSeries[i]; } return val; } else { int middle = (start + finish) / 2; return sBinarySum(start, middle) + sBinarySum(middle, finish); } } |
if (finish-start < lag+8) { | if (finish-start < lag+SPLIT_SUMMING_LIMIT) { | private double sBinarySumDevLag(int start, int finish, double mean, int lag) { if (finish-start < lag+8) { double val = 0; for (int i=start; i< finish && i<getLength()-lag; i++) { val += (sSeries[i]-mean)*(sSeries[i+lag]-mean); } return val; } else { int middle = (start + finish) / 2; return sBinarySumDevLag(start, middle, mean, lag) + sBinarySumDevLag(middle, finish, mean, lag); } } |
if (finish-start < 8) { | if (finish-start < SPLIT_SUMMING_LIMIT) { | private double sBinarySumDevSqr(int start, int finish, double mean) { if (finish-start < 8) { double val = 0; for (int i=start; i< finish; i++) { val += (sSeries[i]-mean)*(sSeries[i]-mean); } return val; } else { int middle = (start + finish) / 2; return sBinarySumDevSqr(start, middle, mean) + sBinarySumDevSqr(middle, finish, mean); } } |
public PSNEventRecord(PSNHeader header, DataInputStream data) throws IOException{ dis = data; fixedHeader = header; varHeader = new PSNVariableHeader(dis, (int)header.getVarHeadLength()); readSampleData(); if(fixedHeader.getFlags() == 1){ if(dis.readShort() != 0){ throw new IOException("CRC-16 check has wrong value!"); } } else{ dis.skipBytes(2); } | public PSNEventRecord(DataInputStream data) throws IOException{ this(new PSNHeader(data), data); | public PSNEventRecord(PSNHeader header, DataInputStream data) throws IOException{ dis = data; fixedHeader = header; varHeader = new PSNVariableHeader(dis, (int)header.getVarHeadLength()); readSampleData(); if(fixedHeader.getFlags() == 1){ if(dis.readShort() != 0){ throw new IOException("CRC-16 check has wrong value!"); } } else{ dis.skipBytes(2); } } |
throw new XDuplicateSlot("method", name.getText().asNativeText().javaValue); | throw new XDuplicateSlot("method", name.base_getText().asNativeText().javaValue); | public ATNil meta_addMethod(ATMethod method) throws NATException { ATSymbol name = method.base_getName(); if (methodDictionary_.containsKey(name)) { throw new XDuplicateSlot("method", name.getText().asNativeText().javaValue); } else { // first check whether the method dictionary is shared if (this.isFlagSet(_SHARE_DCT_FLAG_)) { methodDictionary_ = (HashMap) methodDictionary_.clone(); this.unsetFlag(_SHARE_DCT_FLAG_); } methodDictionary_.put(name, method); } return NATNil._INSTANCE_; } |
int xvalue; | int xvalue = 0; | protected static int[][] compressYvalues(LocalSeismogram seismogram, TimePlotConfig config, Dimension size)throws UnsupportedDataEncoding { int[][] uncomp = scaleXvalues(seismogram, config, size); // enough points to take the extra time to compress the line int[][] comp = new int[2][]; int pixels = size.width; int numValuesperPixel = uncomp[0].length/size.width; comp[0] = new int[2*pixels]; comp[1] = new int[2*pixels]; int j=0, i, startIndex, endIndex; int xvalue; startIndex = 0; if(uncomp[0].length != 0) xvalue = umcomp[0][0];; for(i = 1, j = 0; i < uncomp[0].length; i++) { if(uncomp[0][i] != xvalue) { endIndex = i-1; comp[1][j] = getMinValue(uncomp[1], startIndex, endIndex); comp[1][j+1] = (int)getMaxValue(uncomp[1], startIndex, endIndex); comp[0][j] = uncomp[0][endIndex]; comp[0][j+1] = uncomp[0][endIndex]; j = j + 2; startIndex = endIndex + 1; xvalue = uncomp[0][i]; } } return comp; } |
if(uncomp[0].length != 0) xvalue = umcomp[0][0];; | endIndex = 0; if(uncomp[0].length != 0) xvalue = uncomp[0][0];; | protected static int[][] compressYvalues(LocalSeismogram seismogram, TimePlotConfig config, Dimension size)throws UnsupportedDataEncoding { int[][] uncomp = scaleXvalues(seismogram, config, size); // enough points to take the extra time to compress the line int[][] comp = new int[2][]; int pixels = size.width; int numValuesperPixel = uncomp[0].length/size.width; comp[0] = new int[2*pixels]; comp[1] = new int[2*pixels]; int j=0, i, startIndex, endIndex; int xvalue; startIndex = 0; if(uncomp[0].length != 0) xvalue = umcomp[0][0];; for(i = 1, j = 0; i < uncomp[0].length; i++) { if(uncomp[0][i] != xvalue) { endIndex = i-1; comp[1][j] = getMinValue(uncomp[1], startIndex, endIndex); comp[1][j+1] = (int)getMaxValue(uncomp[1], startIndex, endIndex); comp[0][j] = uncomp[0][endIndex]; comp[0][j+1] = uncomp[0][endIndex]; j = j + 2; startIndex = endIndex + 1; xvalue = uncomp[0][i]; } } return comp; } |
comp[1][j] = getMinValue(uncomp[1], startIndex, endIndex); comp[1][j+1] = (int)getMaxValue(uncomp[1], startIndex, endIndex); comp[0][j] = uncomp[0][endIndex]; comp[0][j+1] = uncomp[0][endIndex]; | protected static int[][] compressYvalues(LocalSeismogram seismogram, TimePlotConfig config, Dimension size)throws UnsupportedDataEncoding { int[][] uncomp = scaleXvalues(seismogram, config, size); // enough points to take the extra time to compress the line int[][] comp = new int[2][]; int pixels = size.width; int numValuesperPixel = uncomp[0].length/size.width; comp[0] = new int[2*pixels]; comp[1] = new int[2*pixels]; int j=0, i, startIndex, endIndex; int xvalue; startIndex = 0; if(uncomp[0].length != 0) xvalue = umcomp[0][0];; for(i = 1, j = 0; i < uncomp[0].length; i++) { if(uncomp[0][i] != xvalue) { endIndex = i-1; comp[1][j] = getMinValue(uncomp[1], startIndex, endIndex); comp[1][j+1] = (int)getMaxValue(uncomp[1], startIndex, endIndex); comp[0][j] = uncomp[0][endIndex]; comp[0][j+1] = uncomp[0][endIndex]; j = j + 2; startIndex = endIndex + 1; xvalue = uncomp[0][i]; } } return comp; } |
|
out[1][numAdded] = getMinValue(tempYvalues, 0, j-1); out[1][numAdded+1] = (int)getMaxValue(tempYvalues, 0, j-1); | out[1][numAdded] = tempYvalues[j-1]; out[1][numAdded+1] = tempYvalues[j-1]; | protected static int[][] scaleXvalues(LocalSeismogram seismogram, TimePlotConfig config, Dimension size) throws UnsupportedDataEncoding { LocalSeismogramImpl seis = (LocalSeismogramImpl)seismogram; int[][] out = new int[2][]; int seisIndex = 0; int pixelIndex = 0; int numAdded = 0; if ( seis.getEndTime().before(config.getBeginTime()) || seis.getBeginTime().after(config.getEndTime()) ) { out[0] = new int[0]; out[1] = new int[0]; logger.info("The end time is before the beginTime in simple seismogram"); return out; } MicroSecondDate tMin = config.getBeginTime(); MicroSecondDate tMax = config.getEndTime(); UnitRangeImpl ampRange = config.getAmpRange().convertTo(seis.getUnit()); double yMin = ampRange.getMinValue(); double yMax = ampRange.getMaxValue(); int seisStartIndex = getPixel(seis.getNumPoints(), seis.getBeginTime(), seis.getEndTime(), config.getBeginTime()); int seisEndIndex = getPixel(seis.getNumPoints(), seis.getBeginTime(), seis.getEndTime(), config.getEndTime()); seisStartIndex--; seisEndIndex++; if (seisStartIndex < 0) { seisStartIndex = 0; } if (seisEndIndex >= seis.getNumPoints()) { seisEndIndex = seis.getNumPoints()-1; } MicroSecondDate tempdate = getValue(seis.getNumPoints(), seis.getBeginTime(), seis.getEndTime(), seisStartIndex); int pixelStartIndex = getPixel(size.width, config.getBeginTime(), config.getEndTime(), tempdate); tempdate = getValue(seis.getNumPoints(), seis.getBeginTime(), seis.getEndTime(), seisEndIndex); int pixelEndIndex = getPixel(size.width, config.getBeginTime(), config.getEndTime(), tempdate); int pixels = size.width; out[0] = new int[2*pixels]; out[1] = new int[out[0].length]; int tempYvalues[] = new int [out[0].length]; seisIndex = seisStartIndex; numAdded = 0; int xvalue = 0; int tempValue; xvalue = Math.round((float)(linearInterp(seisStartIndex, pixelStartIndex, seisEndIndex, pixelEndIndex, seisIndex))); seisIndex++; int j; j = 0; while (seisIndex <= seisEndIndex) { tempValue = Math.round((float)(linearInterp(seisStartIndex, pixelStartIndex, seisEndIndex, pixelEndIndex, seisIndex))); tempYvalues[j++] = (int)seis.getValueAt(seisIndex).getValue(); if(tempValue != xvalue) { out[0][numAdded] = xvalue; out[0][numAdded+1] = xvalue; out[1][numAdded] = getMinValue(tempYvalues, 0, j-1); out[1][numAdded+1] = (int)getMaxValue(tempYvalues, 0, j-1); j = 0; xvalue = tempValue; numAdded = numAdded+2; } seisIndex++; } int temp[][] = new int[2][]; temp[0] = new int[numAdded]; temp[1] = new int[numAdded]; System.arraycopy(out[0], 0, temp[0], 0, numAdded); System.arraycopy(out[1], 0, temp[1], 0, numAdded); return temp; } |
out[0][numAdded] = xvalue; out[0][numAdded+1] = xvalue; out[1][numAdded] = tempYvalues[j-1]; out[1][numAdded+1] = tempYvalues[j-1]; | protected static int[][] scaleXvalues(LocalSeismogram seismogram, TimePlotConfig config, Dimension size) throws UnsupportedDataEncoding { LocalSeismogramImpl seis = (LocalSeismogramImpl)seismogram; int[][] out = new int[2][]; int seisIndex = 0; int pixelIndex = 0; int numAdded = 0; if ( seis.getEndTime().before(config.getBeginTime()) || seis.getBeginTime().after(config.getEndTime()) ) { out[0] = new int[0]; out[1] = new int[0]; logger.info("The end time is before the beginTime in simple seismogram"); return out; } MicroSecondDate tMin = config.getBeginTime(); MicroSecondDate tMax = config.getEndTime(); UnitRangeImpl ampRange = config.getAmpRange().convertTo(seis.getUnit()); double yMin = ampRange.getMinValue(); double yMax = ampRange.getMaxValue(); int seisStartIndex = getPixel(seis.getNumPoints(), seis.getBeginTime(), seis.getEndTime(), config.getBeginTime()); int seisEndIndex = getPixel(seis.getNumPoints(), seis.getBeginTime(), seis.getEndTime(), config.getEndTime()); seisStartIndex--; seisEndIndex++; if (seisStartIndex < 0) { seisStartIndex = 0; } if (seisEndIndex >= seis.getNumPoints()) { seisEndIndex = seis.getNumPoints()-1; } MicroSecondDate tempdate = getValue(seis.getNumPoints(), seis.getBeginTime(), seis.getEndTime(), seisStartIndex); int pixelStartIndex = getPixel(size.width, config.getBeginTime(), config.getEndTime(), tempdate); tempdate = getValue(seis.getNumPoints(), seis.getBeginTime(), seis.getEndTime(), seisEndIndex); int pixelEndIndex = getPixel(size.width, config.getBeginTime(), config.getEndTime(), tempdate); int pixels = size.width; out[0] = new int[2*pixels]; out[1] = new int[out[0].length]; int tempYvalues[] = new int [out[0].length]; seisIndex = seisStartIndex; numAdded = 0; int xvalue = 0; int tempValue; xvalue = Math.round((float)(linearInterp(seisStartIndex, pixelStartIndex, seisEndIndex, pixelEndIndex, seisIndex))); seisIndex++; int j; j = 0; while (seisIndex <= seisEndIndex) { tempValue = Math.round((float)(linearInterp(seisStartIndex, pixelStartIndex, seisEndIndex, pixelEndIndex, seisIndex))); tempYvalues[j++] = (int)seis.getValueAt(seisIndex).getValue(); if(tempValue != xvalue) { out[0][numAdded] = xvalue; out[0][numAdded+1] = xvalue; out[1][numAdded] = getMinValue(tempYvalues, 0, j-1); out[1][numAdded+1] = (int)getMaxValue(tempYvalues, 0, j-1); j = 0; xvalue = tempValue; numAdded = numAdded+2; } seisIndex++; } int temp[][] = new int[2][]; temp[0] = new int[numAdded]; temp[1] = new int[numAdded]; System.arraycopy(out[0], 0, temp[0], 0, numAdded); System.arraycopy(out[1], 0, temp[1], 0, numAdded); return temp; } |
|
BwFreeBusyComponent fbc = new BwFreeBusyComponent(); | public BwFreeBusy getFreeBusy(BwCalendar cal, BwPrincipal who, BwDateTime start, BwDateTime end, BwDuration granularity, boolean returnAll) throws CalFacadeException { if (!(who instanceof BwUser)) { throw new CalFacadeException("Unsupported: non user principal for free-busy"); } BwUser u = (BwUser)who; Collection subs; if (cal != null) { getCal().checkAccess(cal, PrivilegeDefs.privReadFreeBusy, false); BwSubscription sub = BwSubscription.makeSubscription(cal); subs = new ArrayList(); subs.add(sub); } else if (currentUser().equals(who)) { subs = getSubscriptions(); } else { cal = getCal().getCalendars(u, PrivilegeDefs.privReadFreeBusy); if (cal == null) { throw new CalFacadeAccessException(); } getCal().checkAccess(cal, PrivilegeDefs.privReadFreeBusy, false); subs = dbi.fetchPreferences(u).getSubscriptions(); } BwFreeBusy fb = new BwFreeBusy(who, start, end); Collection events = new TreeSet(); Iterator subit = subs.iterator(); while (subit.hasNext()) { BwSubscription sub = (BwSubscription)subit.next(); if (!sub.getAffectsFreeBusy()) { continue; } // XXX If it's an external subscription we probably just get free busy and // merge it in. Collection evs = getEvents(sub, null, start, end, CalFacadeDefs.retrieveRecurExpanded, true); // Filter out transparent events Iterator it = evs.iterator(); while (it.hasNext()) { EventInfo ei = (EventInfo)it.next(); BwEvent ev = ei.getEvent(); // XXX Need to add sub.ignoreTransparency if (BwEvent.transparencyTransparent.equals(ev.getTransparency())) { continue; } events.add(ei); } } try { if (granularity != null) { // chunked. GetPeriodsPars gpp = new GetPeriodsPars(); gpp.events = events; gpp.startDt = start; gpp.dur = granularity; gpp.tzcache = getTimezones(); BwFreeBusyComponent fbc = null; if (!returnAll) { // One component fbc = new BwFreeBusyComponent(); fb.addTime(fbc); } int limit = 10000; // XXX do this better /* endDt is null first time through, then represents end of last * segment. */ while ((gpp.endDt == null) || (gpp.endDt.before(end))) { //if (debug) { // trace("gpp.startDt=" + gpp.startDt + " end=" + end); //} if (limit < 0) { throw new CalFacadeException("org.bedework.svci.limit.exceeded"); } limit--; Collection periodEvents = CalFacadeUtil.getPeriodsEvents(gpp); if (returnAll) { fbc = new BwFreeBusyComponent(); fb.addTime(fbc); DateTime psdt = new DateTime(gpp.startDt.getDtval()); DateTime pedt = new DateTime(gpp.endDt.getDtval()); psdt.setUtc(true); pedt.setUtc(true); fbc.addPeriod(new Period(psdt, pedt)); if (periodEvents.size() == 0) { fbc.setType(BwFreeBusyComponent.typeFree); } } else if (periodEvents.size() != 0) { // Some events fall in the period. Add an entry. DateTime psdt = new DateTime(gpp.startDt.getDtval()); DateTime pedt = new DateTime(gpp.endDt.getDtval()); psdt.setUtc(true); pedt.setUtc(true); fbc.addPeriod(new Period(psdt, pedt)); } } return fb; } /* For the moment just build a single BwFreeBusyComponent */ BwFreeBusyComponent fbc = new BwFreeBusyComponent(); Iterator it = events.iterator(); TreeSet eventPeriods = new TreeSet(); while (it.hasNext()) { EventInfo ei = (EventInfo)it.next(); BwEvent ev = ei.getEvent(); // Ignore if times were specified and this event is outside the times BwDateTime estart = ev.getDtstart(); BwDateTime eend = ev.getDtend(); /* Don't report out of the requested period */ String dstart; String dend; if (estart.before(start)) { dstart = start.getDtval(); } else { dstart = estart.getDtval(); } if (eend.after(end)) { dend = end.getDtval(); } else { dend = eend.getDtval(); } eventPeriods.add(new EventPeriod(new DateTime(dstart), new DateTime(dend))); } /* iterate through the sorted periods combining them where they are adjacent or overlap */ Period p = null; it = eventPeriods.iterator(); while (it.hasNext()) { EventPeriod ep = (EventPeriod)it.next(); if (p == null) { p = new Period(ep.start, ep.end); } else if (ep.start.after(p.getEnd())) { // Non adjacent periods fbc.addPeriod(p); p = new Period(ep.start, ep.end); } else if (ep.end.after(p.getEnd())) { // Extend the current period p = new Period(p.getStart(), ep.end); } // else it falls within the existing period } if (p != null) { fbc.addPeriod(p); } fb.addTime(fbc); } catch (Throwable t) { throw new CalFacadeException(t); } return fb; } |
|
eventPeriods.add(new EventPeriod(new DateTime(dstart), new DateTime(dend))); | DateTime psdt = new DateTime(dstart); DateTime pedt = new DateTime(dend); psdt.setUtc(true); pedt.setUtc(true); eventPeriods.add(new EventPeriod(psdt, pedt)); | public BwFreeBusy getFreeBusy(BwCalendar cal, BwPrincipal who, BwDateTime start, BwDateTime end, BwDuration granularity, boolean returnAll) throws CalFacadeException { if (!(who instanceof BwUser)) { throw new CalFacadeException("Unsupported: non user principal for free-busy"); } BwUser u = (BwUser)who; Collection subs; if (cal != null) { getCal().checkAccess(cal, PrivilegeDefs.privReadFreeBusy, false); BwSubscription sub = BwSubscription.makeSubscription(cal); subs = new ArrayList(); subs.add(sub); } else if (currentUser().equals(who)) { subs = getSubscriptions(); } else { cal = getCal().getCalendars(u, PrivilegeDefs.privReadFreeBusy); if (cal == null) { throw new CalFacadeAccessException(); } getCal().checkAccess(cal, PrivilegeDefs.privReadFreeBusy, false); subs = dbi.fetchPreferences(u).getSubscriptions(); } BwFreeBusy fb = new BwFreeBusy(who, start, end); Collection events = new TreeSet(); Iterator subit = subs.iterator(); while (subit.hasNext()) { BwSubscription sub = (BwSubscription)subit.next(); if (!sub.getAffectsFreeBusy()) { continue; } // XXX If it's an external subscription we probably just get free busy and // merge it in. Collection evs = getEvents(sub, null, start, end, CalFacadeDefs.retrieveRecurExpanded, true); // Filter out transparent events Iterator it = evs.iterator(); while (it.hasNext()) { EventInfo ei = (EventInfo)it.next(); BwEvent ev = ei.getEvent(); // XXX Need to add sub.ignoreTransparency if (BwEvent.transparencyTransparent.equals(ev.getTransparency())) { continue; } events.add(ei); } } try { if (granularity != null) { // chunked. GetPeriodsPars gpp = new GetPeriodsPars(); gpp.events = events; gpp.startDt = start; gpp.dur = granularity; gpp.tzcache = getTimezones(); BwFreeBusyComponent fbc = null; if (!returnAll) { // One component fbc = new BwFreeBusyComponent(); fb.addTime(fbc); } int limit = 10000; // XXX do this better /* endDt is null first time through, then represents end of last * segment. */ while ((gpp.endDt == null) || (gpp.endDt.before(end))) { //if (debug) { // trace("gpp.startDt=" + gpp.startDt + " end=" + end); //} if (limit < 0) { throw new CalFacadeException("org.bedework.svci.limit.exceeded"); } limit--; Collection periodEvents = CalFacadeUtil.getPeriodsEvents(gpp); if (returnAll) { fbc = new BwFreeBusyComponent(); fb.addTime(fbc); DateTime psdt = new DateTime(gpp.startDt.getDtval()); DateTime pedt = new DateTime(gpp.endDt.getDtval()); psdt.setUtc(true); pedt.setUtc(true); fbc.addPeriod(new Period(psdt, pedt)); if (periodEvents.size() == 0) { fbc.setType(BwFreeBusyComponent.typeFree); } } else if (periodEvents.size() != 0) { // Some events fall in the period. Add an entry. DateTime psdt = new DateTime(gpp.startDt.getDtval()); DateTime pedt = new DateTime(gpp.endDt.getDtval()); psdt.setUtc(true); pedt.setUtc(true); fbc.addPeriod(new Period(psdt, pedt)); } } return fb; } /* For the moment just build a single BwFreeBusyComponent */ BwFreeBusyComponent fbc = new BwFreeBusyComponent(); Iterator it = events.iterator(); TreeSet eventPeriods = new TreeSet(); while (it.hasNext()) { EventInfo ei = (EventInfo)it.next(); BwEvent ev = ei.getEvent(); // Ignore if times were specified and this event is outside the times BwDateTime estart = ev.getDtstart(); BwDateTime eend = ev.getDtend(); /* Don't report out of the requested period */ String dstart; String dend; if (estart.before(start)) { dstart = start.getDtval(); } else { dstart = estart.getDtval(); } if (eend.after(end)) { dend = end.getDtval(); } else { dend = eend.getDtval(); } eventPeriods.add(new EventPeriod(new DateTime(dstart), new DateTime(dend))); } /* iterate through the sorted periods combining them where they are adjacent or overlap */ Period p = null; it = eventPeriods.iterator(); while (it.hasNext()) { EventPeriod ep = (EventPeriod)it.next(); if (p == null) { p = new Period(ep.start, ep.end); } else if (ep.start.after(p.getEnd())) { // Non adjacent periods fbc.addPeriod(p); p = new Period(ep.start, ep.end); } else if (ep.end.after(p.getEnd())) { // Extend the current period p = new Period(p.getStart(), ep.end); } // else it falls within the existing period } if (p != null) { fbc.addPeriod(p); } fb.addTime(fbc); } catch (Throwable t) { throw new CalFacadeException(t); } return fb; } |
fb.addTime(fbc); | if (fbc != null) { fb.addTime(fbc); } | public BwFreeBusy getFreeBusy(BwCalendar cal, BwPrincipal who, BwDateTime start, BwDateTime end, BwDuration granularity, boolean returnAll) throws CalFacadeException { if (!(who instanceof BwUser)) { throw new CalFacadeException("Unsupported: non user principal for free-busy"); } BwUser u = (BwUser)who; Collection subs; if (cal != null) { getCal().checkAccess(cal, PrivilegeDefs.privReadFreeBusy, false); BwSubscription sub = BwSubscription.makeSubscription(cal); subs = new ArrayList(); subs.add(sub); } else if (currentUser().equals(who)) { subs = getSubscriptions(); } else { cal = getCal().getCalendars(u, PrivilegeDefs.privReadFreeBusy); if (cal == null) { throw new CalFacadeAccessException(); } getCal().checkAccess(cal, PrivilegeDefs.privReadFreeBusy, false); subs = dbi.fetchPreferences(u).getSubscriptions(); } BwFreeBusy fb = new BwFreeBusy(who, start, end); Collection events = new TreeSet(); Iterator subit = subs.iterator(); while (subit.hasNext()) { BwSubscription sub = (BwSubscription)subit.next(); if (!sub.getAffectsFreeBusy()) { continue; } // XXX If it's an external subscription we probably just get free busy and // merge it in. Collection evs = getEvents(sub, null, start, end, CalFacadeDefs.retrieveRecurExpanded, true); // Filter out transparent events Iterator it = evs.iterator(); while (it.hasNext()) { EventInfo ei = (EventInfo)it.next(); BwEvent ev = ei.getEvent(); // XXX Need to add sub.ignoreTransparency if (BwEvent.transparencyTransparent.equals(ev.getTransparency())) { continue; } events.add(ei); } } try { if (granularity != null) { // chunked. GetPeriodsPars gpp = new GetPeriodsPars(); gpp.events = events; gpp.startDt = start; gpp.dur = granularity; gpp.tzcache = getTimezones(); BwFreeBusyComponent fbc = null; if (!returnAll) { // One component fbc = new BwFreeBusyComponent(); fb.addTime(fbc); } int limit = 10000; // XXX do this better /* endDt is null first time through, then represents end of last * segment. */ while ((gpp.endDt == null) || (gpp.endDt.before(end))) { //if (debug) { // trace("gpp.startDt=" + gpp.startDt + " end=" + end); //} if (limit < 0) { throw new CalFacadeException("org.bedework.svci.limit.exceeded"); } limit--; Collection periodEvents = CalFacadeUtil.getPeriodsEvents(gpp); if (returnAll) { fbc = new BwFreeBusyComponent(); fb.addTime(fbc); DateTime psdt = new DateTime(gpp.startDt.getDtval()); DateTime pedt = new DateTime(gpp.endDt.getDtval()); psdt.setUtc(true); pedt.setUtc(true); fbc.addPeriod(new Period(psdt, pedt)); if (periodEvents.size() == 0) { fbc.setType(BwFreeBusyComponent.typeFree); } } else if (periodEvents.size() != 0) { // Some events fall in the period. Add an entry. DateTime psdt = new DateTime(gpp.startDt.getDtval()); DateTime pedt = new DateTime(gpp.endDt.getDtval()); psdt.setUtc(true); pedt.setUtc(true); fbc.addPeriod(new Period(psdt, pedt)); } } return fb; } /* For the moment just build a single BwFreeBusyComponent */ BwFreeBusyComponent fbc = new BwFreeBusyComponent(); Iterator it = events.iterator(); TreeSet eventPeriods = new TreeSet(); while (it.hasNext()) { EventInfo ei = (EventInfo)it.next(); BwEvent ev = ei.getEvent(); // Ignore if times were specified and this event is outside the times BwDateTime estart = ev.getDtstart(); BwDateTime eend = ev.getDtend(); /* Don't report out of the requested period */ String dstart; String dend; if (estart.before(start)) { dstart = start.getDtval(); } else { dstart = estart.getDtval(); } if (eend.after(end)) { dend = end.getDtval(); } else { dend = eend.getDtval(); } eventPeriods.add(new EventPeriod(new DateTime(dstart), new DateTime(dend))); } /* iterate through the sorted periods combining them where they are adjacent or overlap */ Period p = null; it = eventPeriods.iterator(); while (it.hasNext()) { EventPeriod ep = (EventPeriod)it.next(); if (p == null) { p = new Period(ep.start, ep.end); } else if (ep.start.after(p.getEnd())) { // Non adjacent periods fbc.addPeriod(p); p = new Period(ep.start, ep.end); } else if (ep.end.after(p.getEnd())) { // Extend the current period p = new Period(p.getStart(), ep.end); } // else it falls within the existing period } if (p != null) { fbc.addPeriod(p); } fb.addTime(fbc); } catch (Throwable t) { throw new CalFacadeException(t); } return fb; } |
particleWindow.setLocation(400 * particleDisplays, tk.getScreenSize().height); | if(400*particleDisplays < tk.getScreenSize().width){ particleWindow.setLocation(400 * particleDisplays, tk.getScreenSize().height - 400); }else{ particleWindow.setLocation(tk.getScreenSize().width - 400, tk.getScreenSize().height - 400); } | public void createParticleDisplay(BasicSeismogramDisplay creator){ if(particleDisplay == null){ logger.debug("creating particle display"); particleWindow = new JFrame(); LocalSeismogramImpl seis = (((LocalSeismogramImpl)((DataSetSeismogram)creator.getSeismograms().getFirst()).getSeismogram())); particleDisplay = new ParticleMotionDisplay(seis, creator.getTimeRegistrar(), creator.getAmpRegistrar(), creator.getAmpRegistrar(), ((DataSetSeismogram)creator.getSeismograms().getFirst()).getDataSet()); particleDisplay.addAzimuthLine(15); particleDisplay.addSector(10, 20); JPanel displayPanel = new JPanel(); JButton zoomIn = new JButton("zoomIn"); JButton zoomOut = new JButton("zoomOut"); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new FlowLayout()); buttonPanel.add(zoomIn); buttonPanel.add(zoomOut); displayPanel.setLayout(new BorderLayout()); displayPanel.add(particleDisplay, java.awt.BorderLayout.CENTER); displayPanel.add(buttonPanel, java.awt.BorderLayout.SOUTH); java.awt.Dimension size = new java.awt.Dimension(400, 400); displayPanel.setSize(size); particleWindow.getContentPane().add(displayPanel); //particleWindow.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); particleWindow.setSize(size); zoomIn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { particleDisplay.setZoomIn(true); // particleDisplay.setZoomOut(false); } }); zoomOut.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { particleDisplay.setZoomOut(true); // particleDisplay.setZoomIn(false); } }); Toolkit tk = Toolkit.getDefaultToolkit(); particleWindow.setLocation(400 * particleDisplays, tk.getScreenSize().height); particleDisplays++; particleWindow.setVisible(true); } } |
selectionWindow.setLocation(tk.getScreenSize().width, tk.getScreenSize().height - selectionDisplays * 250); | if((selectionDisplays + 1) * 220 < tk.getScreenSize().height){ selectionWindow.setLocation(tk.getScreenSize().width - 400, tk.getScreenSize().height - (selectionDisplays + 1) * 220); }else{ selectionWindow.setLocation(tk.getScreenSize().width - 400, 0); } | public void createSelectionDisplay(BasicSeismogramDisplay creator){ if(selectionDisplay == null){ logger.debug("creating selection display"); selectionWindow = new JFrame(); //selectionWindow.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); selectionWindow.setSize(400, 220); JToolBar infoBar = new JToolBar(); infoBar.add(new FilterSelection(selectionDisplay)); infoBar.setFloatable(false); selectionWindow.getContentPane().add(infoBar, BorderLayout.SOUTH); Iterator e = creator.getSeismograms().iterator(); TimeConfigRegistrar tr = creator.getCurrentSelection().getInternalConfig(); DataSetSeismogram first = ((DataSetSeismogram)e.next()); AmpConfigRegistrar ar = new AmpConfigRegistrar(new OffsetMeanAmpConfig(((LocalSeismogramImpl)first.getSeismogram()), tr.getTimeRange(first.getSeismogram()))); ar.visibleAmpCalc(tr); selectionDisplay = new VerticalSeismogramDisplay(mouseForwarder, motionForwarder); creator.getCurrentSelection().setDisplay(selectionDisplay.addDisplay(first, tr, creator.getName() + "." + creator.getCurrentSelection().getColor())); while(e.hasNext()){ selectionDisplay.addSeismogram(((DataSetSeismogram)e.next()), 0); } selectionWindow.getContentPane().add(selectionDisplay); Toolkit tk = Toolkit.getDefaultToolkit(); selectionWindow.setLocation(tk.getScreenSize().width, tk.getScreenSize().height - selectionDisplays * 250); selectionDisplays++; selectionWindow.setVisible(true); }else{ logger.debug("adding another selection"); Iterator e = creator.getSeismograms().iterator(); TimeConfigRegistrar tr = creator.getCurrentSelection().getInternalConfig(); DataSetSeismogram first = ((DataSetSeismogram)e.next()); AmpConfigRegistrar ar = new AmpConfigRegistrar(new OffsetMeanAmpConfig(((LocalSeismogramImpl)first.getSeismogram()), tr.getTimeRange(first.getSeismogram()))); ar.visibleAmpCalc(tr); creator.getCurrentSelection().setDisplay(selectionDisplay.addDisplay(first, tr, creator.getName() + "." + creator.getCurrentSelection().getColor())); while(e.hasNext()){ selectionDisplay.addSeismogram(((DataSetSeismogram)e.next()), 0); } } } |
original.setSize(new Dimension(45, 10)); | public FilterSelection(VerticalSeismogramDisplay listener){ this.add(original); this.add(teleseismic); this.add(smoothTeleseismic); this.add(vSmoothTeleseismic); this.add(regional); this.add(local); original.addItemListener(filterCheck); teleseismic.addItemListener(filterCheck); smoothTeleseismic.addItemListener(filterCheck); vSmoothTeleseismic.addItemListener(filterCheck); regional.addItemListener(filterCheck); local.addItemListener(filterCheck); this.listener = listener; } |
|
queryMap.put(queryAttr, "awp9"); | queryMap.put(queryAttr, "susan"); | public void testDefaultAttrMap() { final String queryAttr = "uid"; final List queryAttrList = new LinkedList(); queryAttrList.add(queryAttr); LdapPersonAttributeDao impl = new LdapPersonAttributeDao(); Map ldapAttribsToPortalAttribs = new HashMap(); ldapAttribsToPortalAttribs.put("mail", null); impl.setLdapAttributesToPortalAttributes(ldapAttribsToPortalAttribs); impl.setContextSource(this.contextSource); impl.setQuery("(uid={0})"); impl.setQueryAttributes(queryAttrList); Map queryMap = new HashMap(); queryMap.put(queryAttr, "awp9"); try { Map attribs = impl.getUserAttributes(queryMap); assertEquals("[email protected]", attribs.get("mail")); } catch (DataAccessResourceFailureException darfe) { //OK, No net connection } } |
assertEquals("[email protected]", attribs.get("mail")); | assertEquals("[email protected]", attribs.get("mail")); | public void testDefaultAttrMap() { final String queryAttr = "uid"; final List queryAttrList = new LinkedList(); queryAttrList.add(queryAttr); LdapPersonAttributeDao impl = new LdapPersonAttributeDao(); Map ldapAttribsToPortalAttribs = new HashMap(); ldapAttribsToPortalAttribs.put("mail", null); impl.setLdapAttributesToPortalAttributes(ldapAttribsToPortalAttribs); impl.setContextSource(this.contextSource); impl.setQuery("(uid={0})"); impl.setQueryAttributes(queryAttrList); Map queryMap = new HashMap(); queryMap.put(queryAttr, "awp9"); try { Map attribs = impl.getUserAttributes(queryMap); assertEquals("[email protected]", attribs.get("mail")); } catch (DataAccessResourceFailureException darfe) { //OK, No net connection } } |
queryMap.put(queryAttr1, "awp9"); | queryMap.put(queryAttr1, "susan"); | public void testInsufficientAttrQuery() { final String queryAttr1 = "uid"; final String queryAttr2 = "alias"; final List queryAttrList = new LinkedList(); queryAttrList.add(queryAttr1); queryAttrList.add(queryAttr2); LdapPersonAttributeDao impl = new LdapPersonAttributeDao(); Map ldapAttribsToPortalAttribs = new HashMap(); ldapAttribsToPortalAttribs.put("mail", "email"); impl.setLdapAttributesToPortalAttributes(ldapAttribsToPortalAttribs); impl.setContextSource(this.contextSource); impl.setQuery("(&(uid={0})(alias={1}))"); impl.setQueryAttributes(queryAttrList); Map queryMap = new HashMap(); queryMap.put(queryAttr1, "awp9"); queryMap.put("email", "[email protected]"); Map attribs = impl.getUserAttributes(queryMap); assertNull(attribs); } |
queryMap.put(queryAttr, "awp9"); | queryMap.put(queryAttr, "susan"); | public void testInvalidAttrMap() { final String queryAttr = "uid"; final List queryAttrList = new LinkedList(); queryAttrList.add(queryAttr); LdapPersonAttributeDao impl = new LdapPersonAttributeDao(); Map ldapAttribsToPortalAttribs = new HashMap(); ldapAttribsToPortalAttribs.put("email", "email"); impl.setLdapAttributesToPortalAttributes(ldapAttribsToPortalAttribs); impl.setContextSource(this.contextSource); impl.setQuery("(uid={0})"); impl.setQueryAttributes(queryAttrList); Map queryMap = new HashMap(); queryMap.put(queryAttr, "awp9"); try { Map attribs = impl.getUserAttributes(queryMap); assertNull(attribs.get("email")); } catch (DataAccessResourceFailureException darfe) { //OK, No net connection } } |
queryMap.put(queryAttr1, "awp9"); queryMap.put(queryAttr2, "andrew.petro"); | queryMap.put(queryAttr1, "susan"); queryMap.put(queryAttr2, "susan.bramhall"); | public void testMultiAttrQuery() { final String queryAttr1 = "uid"; final String queryAttr2 = "alias"; final List queryAttrList = new LinkedList(); queryAttrList.add(queryAttr1); queryAttrList.add(queryAttr2); LdapPersonAttributeDao impl = new LdapPersonAttributeDao(); Map ldapAttribsToPortalAttribs = new HashMap(); ldapAttribsToPortalAttribs.put("mail", "email"); impl.setLdapAttributesToPortalAttributes(ldapAttribsToPortalAttribs); impl.setContextSource(this.contextSource); impl.setQuery("(&(uid={0})(alias={1}))"); impl.setQueryAttributes(queryAttrList); Map queryMap = new HashMap(); queryMap.put(queryAttr1, "awp9"); queryMap.put(queryAttr2, "andrew.petro"); queryMap.put("email", "[email protected]"); try { Map attribs = impl.getUserAttributes(queryMap); assertEquals("[email protected]", attribs.get("email")); } catch (DataAccessResourceFailureException darfe) { //OK, No net connection } } |
assertEquals("[email protected]", attribs.get("email")); | assertEquals("[email protected]", attribs.get("email")); | public void testMultiAttrQuery() { final String queryAttr1 = "uid"; final String queryAttr2 = "alias"; final List queryAttrList = new LinkedList(); queryAttrList.add(queryAttr1); queryAttrList.add(queryAttr2); LdapPersonAttributeDao impl = new LdapPersonAttributeDao(); Map ldapAttribsToPortalAttribs = new HashMap(); ldapAttribsToPortalAttribs.put("mail", "email"); impl.setLdapAttributesToPortalAttributes(ldapAttribsToPortalAttribs); impl.setContextSource(this.contextSource); impl.setQuery("(&(uid={0})(alias={1}))"); impl.setQueryAttributes(queryAttrList); Map queryMap = new HashMap(); queryMap.put(queryAttr1, "awp9"); queryMap.put(queryAttr2, "andrew.petro"); queryMap.put("email", "[email protected]"); try { Map attribs = impl.getUserAttributes(queryMap); assertEquals("[email protected]", attribs.get("email")); } catch (DataAccessResourceFailureException darfe) { //OK, No net connection } } |
queryMap.put(queryAttr, "awp9"); | queryMap.put(queryAttr, "susan"); | public void testSingleAttrQuery() { final String queryAttr = "uid"; final List queryAttrList = new LinkedList(); queryAttrList.add(queryAttr); LdapPersonAttributeDao impl = new LdapPersonAttributeDao(); Map ldapAttribsToPortalAttribs = new HashMap(); ldapAttribsToPortalAttribs.put("mail", "email"); impl.setLdapAttributesToPortalAttributes(ldapAttribsToPortalAttribs); impl.setContextSource(this.contextSource); impl.setQuery("(uid={0})"); impl.setQueryAttributes(queryAttrList); Map queryMap = new HashMap(); queryMap.put(queryAttr, "awp9"); try { Map attribs = impl.getUserAttributes(queryMap); assertEquals("[email protected]", attribs.get("email")); } catch (DataAccessResourceFailureException darfe) { //OK, No net connection } } |
assertEquals("[email protected]", attribs.get("email")); | assertEquals("[email protected]", attribs.get("email")); | public void testSingleAttrQuery() { final String queryAttr = "uid"; final List queryAttrList = new LinkedList(); queryAttrList.add(queryAttr); LdapPersonAttributeDao impl = new LdapPersonAttributeDao(); Map ldapAttribsToPortalAttribs = new HashMap(); ldapAttribsToPortalAttribs.put("mail", "email"); impl.setLdapAttributesToPortalAttributes(ldapAttribsToPortalAttribs); impl.setContextSource(this.contextSource); impl.setQuery("(uid={0})"); impl.setQueryAttributes(queryAttrList); Map queryMap = new HashMap(); queryMap.put(queryAttr, "awp9"); try { Map attribs = impl.getUserAttributes(queryMap); assertEquals("[email protected]", attribs.get("email")); } catch (DataAccessResourceFailureException darfe) { //OK, No net connection } } |
} else if (MethodBase.nodeMatches(curnode, CaldavTags.expandRecurrenceSet) || MethodBase.nodeMatches(curnode, CaldavTags.expand)) { | } else if (MethodBase.nodeMatches(curnode, CaldavTags.expand)) { | public void parse(Node nd) throws WebdavException { /* Either empty - show everything or comp + optional (expand-recurrence-set or limit-recurrence-set) */ NamedNodeMap nnm = nd.getAttributes(); if ((nnm != null) && (nnm.getLength() > 1)) { throw new WebdavBadRequest(); } if (nnm != null) { if (nnm.getLength() == 1) { returnContentType = XmlUtil.getAttrVal(nnm, "return-content-type"); if (returnContentType == null) { throw new WebdavBadRequest(); } } else if (nnm.getLength() > 0) { // Bad attribute(s) throw new WebdavBadRequest(); } } Element[] children = getChildren(nd); try { for (int i = 0; i < children.length; i++) { Node curnode = children[i]; if (debug) { trace("calendar-data node type: " + curnode.getNodeType() + " name:" + curnode.getNodeName()); } if (MethodBase.nodeMatches(curnode, CaldavTags.comp)) { if (comp != null) { throw new WebdavBadRequest(); } comp = parseComp(curnode); } else if (MethodBase.nodeMatches(curnode, CaldavTags.expandRecurrenceSet) || MethodBase.nodeMatches(curnode, CaldavTags.expand)) { if (ers != null) { throw new WebdavBadRequest(); } ers = new ExpandRecurrenceSet(); parseTimeRange(curnode, ers); } else if (MethodBase.nodeMatches(curnode, CaldavTags.limitRecurrenceSet)) { if (lrs != null) { throw new WebdavBadRequest(); } lrs = new LimitRecurrenceSet(); parseTimeRange(curnode, lrs); } else { throw new WebdavBadRequest(); } } } catch (WebdavBadRequest wbr) { throw wbr; } catch (Throwable t) { throw new WebdavBadRequest(); } } |
} else if (MethodBase.nodeMatches(curnode, CaldavTags.limitFreebusySet)) { if (lfs != null) { throw new WebdavBadRequest(); } lfs = new LimitFreebusySet(); parseTimeRange(curnode, lfs); | public void parse(Node nd) throws WebdavException { /* Either empty - show everything or comp + optional (expand-recurrence-set or limit-recurrence-set) */ NamedNodeMap nnm = nd.getAttributes(); if ((nnm != null) && (nnm.getLength() > 1)) { throw new WebdavBadRequest(); } if (nnm != null) { if (nnm.getLength() == 1) { returnContentType = XmlUtil.getAttrVal(nnm, "return-content-type"); if (returnContentType == null) { throw new WebdavBadRequest(); } } else if (nnm.getLength() > 0) { // Bad attribute(s) throw new WebdavBadRequest(); } } Element[] children = getChildren(nd); try { for (int i = 0; i < children.length; i++) { Node curnode = children[i]; if (debug) { trace("calendar-data node type: " + curnode.getNodeType() + " name:" + curnode.getNodeName()); } if (MethodBase.nodeMatches(curnode, CaldavTags.comp)) { if (comp != null) { throw new WebdavBadRequest(); } comp = parseComp(curnode); } else if (MethodBase.nodeMatches(curnode, CaldavTags.expandRecurrenceSet) || MethodBase.nodeMatches(curnode, CaldavTags.expand)) { if (ers != null) { throw new WebdavBadRequest(); } ers = new ExpandRecurrenceSet(); parseTimeRange(curnode, ers); } else if (MethodBase.nodeMatches(curnode, CaldavTags.limitRecurrenceSet)) { if (lrs != null) { throw new WebdavBadRequest(); } lrs = new LimitRecurrenceSet(); parseTimeRange(curnode, lrs); } else { throw new WebdavBadRequest(); } } } catch (WebdavBadRequest wbr) { throw wbr; } catch (Throwable t) { throw new WebdavBadRequest(); } } |
|
if (sess.transactionStarted()) { sess.rollback(); } | public synchronized void close() throws CalFacadeException { if (!isOpen) { if (debug) { log.debug("Close for " + objTimestamp + " closed session"); } return; } if (debug) { log.debug("Close for " + objTimestamp); } try { if (sess != null) { sess.disconnect(); } } catch (Throwable t) { try { sess.close(); } finally {} sess = null; // Discard on error } finally { isOpen = false; } if (access != null) { access.close(); } } |
|
return bldr.build(new StringReader(val), true); | UnfoldingReader ufrdr = new UnfoldingReader(new StringReader(val), true); return bldr.build(ufrdr); | public static Calendar getCalendar(String val) throws CalFacadeException { try { CalendarBuilder bldr = new CalendarBuilder(new CalendarParserImpl()); return bldr.build(new StringReader(val), true); } catch (Throwable t) { throw new CalFacadeException(t); } } |
AccessUtil(boolean superUser, boolean debug) throws CalFacadeException { this.superUser = superUser; | AccessUtil(boolean debug) throws CalFacadeException { | AccessUtil(boolean superUser, boolean debug) throws CalFacadeException { this.superUser = superUser; this.debug = debug; try { access = new Access(debug); } catch (Throwable t) { throw new CalFacadeException(t); } } |
public EventProperties(CalintfImpl cal, | public EventProperties(Calintf cal, AccessUtil access, BwUser user, | public EventProperties(CalintfImpl cal, String keyFieldName, String className, String refQuery, int minId, boolean debug) { this.cal = cal; this.keyFieldName = keyFieldName; this.className = className; this.refQuery = refQuery; this.minId = minId; this.debug = debug; } |
this.cal = cal; | super(cal, access, user, debug); | public EventProperties(CalintfImpl cal, String keyFieldName, String className, String refQuery, int minId, boolean debug) { this.cal = cal; this.keyFieldName = keyFieldName; this.className = className; this.refQuery = refQuery; this.minId = minId; this.debug = debug; } |
this.debug = debug; | public EventProperties(CalintfImpl cal, String keyFieldName, String className, String refQuery, int minId, boolean debug) { this.cal = cal; this.keyFieldName = keyFieldName; this.className = className; this.refQuery = refQuery; this.minId = minId; this.debug = debug; } |
|
this.debug = debug; | CalTimezonesImpl(Calintf cal, BwStats stats, boolean publicAdmin, boolean debug) throws CalFacadeException { this.cal = cal; this.stats = (BwRWStats)stats; this.publicAdmin = publicAdmin; this.debug = debug; // Force fetch of timezones //lookup("not-a-timezone"); } |
|
return "success"; | return "notFound"; | public String doAction(HttpServletRequest request, HttpServletResponse response, BwSession sess, BwActionFormBase form) throws Throwable { if (!form.getUserAuth().isSuperUser()) { return "noAccess"; // First line of defence } CalSvcI svc = form.fetchSvci(); String str = getReqPar(request, "user"); if (str == null) { return "success"; } BwUser user = svc.findUser(str); if (user == null) { form.getErr().emit("org.bedework.client.error.nosuchuserid", str); return "notFound"; } form.setUserPreferences(svc.getUserPrefs(user)); return "success"; } |
public boolean init(String url, | public boolean init(String systemName, String url, | public boolean init(String url, String authenticatedUser, String user, boolean publicAdmin, Groups groups, String synchId, boolean debug) throws CalFacadeException { boolean userAdded = super.init(url, authenticatedUser, user, publicAdmin, groups, synchId, debug); if (httpManager == null) { synchronized (this) { if (httpManager == null) { httpManager = new HttpManager("org.bedework.http.client.caldav.CaldavClient"); } } } return userAdded; } |
boolean userAdded = super.init(url, authenticatedUser, user, publicAdmin, | boolean userAdded = super.init(systemName, url, authenticatedUser, user, publicAdmin, | public boolean init(String url, String authenticatedUser, String user, boolean publicAdmin, Groups groups, String synchId, boolean debug) throws CalFacadeException { boolean userAdded = super.init(url, authenticatedUser, user, publicAdmin, groups, synchId, debug); if (httpManager == null) { synchronized (this) { if (httpManager == null) { httpManager = new HttpManager("org.bedework.http.client.caldav.CaldavClient"); } } } return userAdded; } |
public BwUser getUser(int id) throws CalFacadeException { checkOpen(); throw new CalFacadeUnimplementedException(); | public BwUser getUser() throws CalFacadeException { return user; | public BwUser getUser(int id) throws CalFacadeException { checkOpen(); throw new CalFacadeUnimplementedException(); } |
public void updateUser(BwUser user) throws CalFacadeException { checkOpen(); throw new CalFacadeUnimplementedException(); | public void updateUser() throws CalFacadeException { updateUser(getUser()); | public void updateUser(BwUser user) throws CalFacadeException { checkOpen(); throw new CalFacadeUnimplementedException(); } |
MicroSecondDate now = new MicroSecondDate(); | MicroSecondDate now = ClockUtil.now(); | public static void main(String[] args) { /* Initializes the corba orb, finds the naming service and other startup * tasks. See AbstractClient for the code in this method. */ init(args); try { /** This step is not required, but sometimes helps to determine if * a server is down. if this call succedes but the next fails, then * the nameing service is up and functional, but the network server * is not reachable for some reason. */ Object obj = fisName.getEventDCObject("edu/iris/dmc", "IRIS_EventDC"); logger.info("Got as corba object, the name service is ok"); /** This connectts to the actual server, as oposed to just getting * the reference to it. The naming convention is that the first * part is the reversed DNS of the organization and the second part * is the individual server name. The dmc lists their servers under * the edu/iris/dmc and their main network server is IRIS_EventDC.*/ EventDC eventDC = fisName.getEventDC("edu/iris/dmc", "IRIS_EventDC"); logger.info("got EventDC"); /** The EventFinder is one of the choices at this point. It * allows you to query for individual events, and then retrieve * information about them. */ EventFinder finder = eventDC.a_finder(); logger.info("got EventFinder"); MicroSecondDate now = new MicroSecondDate(); MicroSecondDate yesterday = now.subtract(new TimeInterval(7, UnitImpl.DAY)); TimeRange timeRange = new TimeRange(yesterday.getFissuresTime(), now.getFissuresTime()); String[] magTypes = new String[1]; magTypes[0] = "%"; String[] catalogs = new String[1]; catalogs[0] = "FINGER"; String[] contributors = new String[1]; contributors[0] = "NEIC"; EventSeqIterHolder iter = new EventSeqIterHolder(); EventAccess[] events = finder.query_events(new GlobalAreaImpl(), new QuantityImpl(0, UnitImpl.KILOMETER), new QuantityImpl(1000, UnitImpl.KILOMETER), timeRange, magTypes, 5.0f, 10.0f, catalogs, contributors, 500, iter); logger.info("Got "+events.length+" events."); for (int i = 0; i < events.length; i++) { EventAttr attr = events[i].get_attributes(); try { Origin origin = events[i].get_preferred_origin(); logger.info("Event "+i+" occurred in FE region "+attr.region.number+ " at "+origin.origin_time.date_time+ " mag="+origin.magnitudes[0].type+" "+origin.magnitudes[0].value+ " at ("+origin.my_location.latitude+", "+origin.my_location.longitude+") "+ "with depth of "+origin.my_location.depth.value+" "+origin.my_location.depth.the_units); } catch (NoPreferredOrigin e) { logger.warn("No preferred origin for event "+i, e); } } /** Here are someof the possible problems that can occur. */ }catch (org.omg.CORBA.ORBPackage.InvalidName e) { logger.error("Problem with name service: ", e); }catch (org.omg.CosNaming.NamingContextPackage.InvalidName e) { logger.error("Problem with name service: ", e); }catch (NotFound e) { logger.error("Problem with name service: ", e); }catch (CannotProceed e) { logger.error("Problem with name service: ", e); } /** All done... */ } |
public int sort(DataSetSeismogram[] seismograms, String name){ | public int sort(DataSetSeismogram[] seismograms){ | public int sort(DataSetSeismogram[] seismograms, String name){ int i = 0; while(i < names.size() && ((String)names.get(i)).compareToIgnoreCase(name) < 0){ i++; } names.add(i, name); return i; } |
while(i < names.size() && ((String)names.get(i)).compareToIgnoreCase(name) < 0){ | while(i < names.size() && ((String)names.get(i)).compareToIgnoreCase(seismograms[i].getName()) < 0){ | public int sort(DataSetSeismogram[] seismograms, String name){ int i = 0; while(i < names.size() && ((String)names.get(i)).compareToIgnoreCase(name) < 0){ i++; } names.add(i, name); return i; } |
names.add(i, name); | names.add(i, seismograms[i].getName()); | public int sort(DataSetSeismogram[] seismograms, String name){ int i = 0; while(i < names.size() && ((String)names.get(i)).compareToIgnoreCase(name) < 0){ i++; } names.add(i, name); return i; } |
repaint(); | public void removeDisplay(BasicSeismogramDisplay display){ seismograms.remove(display); basicDisplays.remove(display); ((SeismogramDisplay)basicDisplays.getFirst()).addTopTimeBorder(); ((SeismogramDisplay)basicDisplays.getLast()).addBottomTimeBorder(); seismograms.revalidate(); } |
|
return getFont(key, Font.decode(null)); | return getFont(key, new Font("SansSerif", 12, Font.PLAIN)); | public Font getFont(String key) { return getFont(key, Font.decode(null)); } |
public EventProperties(Calintf cal, AccessUtil access, BwUser user, | public EventProperties(Calintf cal, AccessUtil access, | public EventProperties(Calintf cal, AccessUtil access, BwUser user, int currentMode, boolean ignoreCreator, String keyFieldName, String className, String refQuery, int minId, boolean debug) { super(cal, access, user, currentMode, ignoreCreator, debug); this.keyFieldName = keyFieldName; this.className = className; this.refQuery = refQuery; this.minId = minId; } |
super(cal, access, user, currentMode, ignoreCreator, debug); | super(cal, access, currentMode, ignoreCreator, debug); | public EventProperties(Calintf cal, AccessUtil access, BwUser user, int currentMode, boolean ignoreCreator, String keyFieldName, String className, String refQuery, int minId, boolean debug) { super(cal, access, user, currentMode, ignoreCreator, debug); this.keyFieldName = keyFieldName; this.className = className; this.refQuery = refQuery; this.minId = minId; } |
clicked.removeAllSeismograms(); | clicked.remove(me); | public void removeSeismogram(MouseEvent me){ BasicSeismogramDisplay clicked = ((BasicSeismogramDisplay)me.getComponent()); clicked.removeAllSeismograms(); seismograms.remove(clicked); basicDisplays.remove(clicked); ((SeismogramDisplay)basicDisplays.getFirst()).addTopTimeBorder(); ((SeismogramDisplay)basicDisplays.getLast()).addBottomTimeBorder(); } |
this.time.setText(" Time: " + output.format(calendar.getTime())); | if(output.format(calendar.getTime()).length() == 21) this.time.setText(" Time: " + output.format(calendar.getTime()) + "00"); else if(output.format(calendar.getTime()).length() == 22) this.time.setText(" Time: " + output.format(calendar.getTime()) + "0"); else this.time.setText(" Time: " + output.format(calendar.getTime())); | public void setLabels(MicroSecondDate time, double amp){ calendar.setTime(time); this.time.setText(" Time: " + output.format(calendar.getTime())); if(amp < 0) if(Math.abs(amp) < 10) this.amp.setText(" Amplitude: -000" + Math.abs(Math.round(amp))); else if(Math.abs(amp) < 100) this.amp.setText(" Amplitude: -00" + Math.abs(Math.round(amp))); else if(Math.abs(amp) < 1000) this.amp.setText(" Amplitude: -0" + Math.abs(Math.round(amp))); else this.amp.setText(" Amplitude: -" + Math.abs(Math.round(amp))); else if(Math.abs(amp) < 10) this.amp.setText(" Amplitude: 000" + Math.round(amp)); else if(Math.abs(amp) < 100) this.amp.setText(" Amplitude: 00" + Math.round(amp)); else if(Math.abs(amp) < 1000) this.amp.setText(" Amplitude: 0" + Math.round(amp)); else this.amp.setText(" Amplitude: " + Math.round(amp)); } |
public void addNewCalendars() throws CalFacadeException { | public void addNewCalendars(BwUser user) throws CalFacadeException { | public void addNewCalendars() throws CalFacadeException { HibSession sess = getSess(); /* Add a user collection to the userCalendarRoot and then a default calendar collection. */ sess.namedQuery("getCalendarByPath"); String path = userCalendarRootPath; sess.setString("path", path); BwCalendar userrootcal = (BwCalendar)sess.getUnique(); if (userrootcal == null) { throw new CalFacadeException("No user root at " + path); } path += "/" + user.getAccount(); sess.namedQuery("getCalendarByPath"); sess.setString("path", path); BwCalendar usercal = (BwCalendar)sess.getUnique(); if (usercal != null) { throw new CalFacadeException("User calendar already exists at " + path); } /* Create a folder for the user */ usercal = new BwCalendar(); usercal.setName(user.getAccount()); usercal.setCreator(user); usercal.setOwner(user); usercal.setPublick(false); usercal.setPath(path); usercal.setCalendar(userrootcal); userrootcal.addChild(usercal); sess.save(userrootcal); /* Create a default calendar */ BwCalendar cal = new BwCalendar(); cal.setName(getSyspars().getUserDefaultCalendar()); cal.setCreator(user); cal.setOwner(user); cal.setPublick(false); cal.setPath(path + "/" + getSyspars().getUserDefaultCalendar()); cal.setCalendar(usercal); cal.setCalendarCollection(true); usercal.addChild(cal); /* Add the trash calendar */ cal = new BwCalendar(); cal.setName(getSyspars().getDefaultTrashCalendar()); cal.setCreator(user); cal.setOwner(user); cal.setPublick(false); cal.setPath(path + "/" + getSyspars().getDefaultTrashCalendar()); cal.setCalendar(usercal); cal.setCalendarCollection(true); usercal.addChild(cal); /* Add the inbox */ cal = new BwCalendar(); cal.setName(getSyspars().getUserInbox()); cal.setCreator(user); cal.setOwner(user); cal.setPublick(false); cal.setPath(path + "/" + getSyspars().getUserInbox()); cal.setCalendar(usercal); cal.setCalendarCollection(true); usercal.addChild(cal); /* Add the outbox */ cal = new BwCalendar(); cal.setName(getSyspars().getUserOutbox()); cal.setCreator(user); cal.setOwner(user); cal.setPublick(false); cal.setPath(path + "/" + getSyspars().getUserOutbox()); cal.setCalendar(usercal); cal.setCalendarCollection(true); usercal.addChild(cal); sess.save(usercal); sess.update(user); } |
public BwFreeBusy getFreeBusy(CalSvcI svci, String account) throws WebdavException { | public BwFreeBusy getFreeBusy(CalSvcI svci, BwCalendar cal, String account) throws WebdavException { | public BwFreeBusy getFreeBusy(CalSvcI svci, String account) throws WebdavException { try { BwUser user = svci.findUser(account); if (user == null) { throw WebdavIntfException.unauthorized(); } BwFreeBusy fb = svci.getFreeBusy(null, user, timeRange.getStart(), timeRange.getEnd(), null, false); if (debug) { trace("Got " + fb); } return fb; } catch (Throwable t) { throw new WebdavException(t); } } |
BwFreeBusy fb = svci.getFreeBusy(null, user, | BwFreeBusy fb = svci.getFreeBusy(cal, user, | public BwFreeBusy getFreeBusy(CalSvcI svci, String account) throws WebdavException { try { BwUser user = svci.findUser(account); if (user == null) { throw WebdavIntfException.unauthorized(); } BwFreeBusy fb = svci.getFreeBusy(null, user, timeRange.getStart(), timeRange.getEnd(), null, false); if (debug) { trace("Got " + fb); } return fb; } catch (Throwable t) { throw new WebdavException(t); } } |
CalSvcIPars pars = new CalSvcIPars(account, UserAuth.noPrivileges, | CalSvcIPars pars = new CalSvcIPars(account, | public CalSvcI getSvci() throws WebdavIntfException { boolean publicMode = (account == null); if (svci != null) { if (!svci.isOpen()) { try { svci.open(); svci.beginTransaction(); } catch (Throwable t) { throw new WebdavIntfException(t); } } return svci; } try { svci = new CalSvc(); /* account is what we authenticated with. * user, if non-null, is the user calendar we want to access. */ CalSvcIPars pars = new CalSvcIPars(account, UserAuth.noPrivileges, account, envPrefix, publicMode, true, // caldav null, // synchId debug); svci.init(pars); svci.open(); svci.beginTransaction(); trans = new IcalTranslator(svci.getIcalCallback(), debug); } catch (Throwable t) { throw new WebdavIntfException(t); } return svci; } |
seisName = seisName.substring(seisName.length()-4); | seisName = seisName.substring(0,seisName.length()-4); | void process() throws ParserConfigurationException { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = factory.newDocumentBuilder(); String userName = System.getProperty("user.name"); URL dirURL = base; System.out.println(" dirURL is "+dirURL.toString()); try { dirURL = new URL(dirURL, directory.getName()+"/"); System.out.println("updated dirURL is "+dirURL.toString()); } catch (MalformedURLException e) { e.printStackTrace(); return; } // end of try-catch dataset = new XMLDataSet(docBuilder, dirURL, "genid"+Math.round(Math.random()*Integer.MAX_VALUE), dsName, userName); Iterator it = paramRefs.keySet().iterator(); while (it.hasNext()) { String key = (String)it.next(); AuditInfo[] audit = new AuditInfo[1]; audit[0] = new AuditInfo(userName, "Added parameter "+key); try { dataset.addParameter(key,new URL(dirURL, (String)paramRefs.get(key)).toString(), audit); } catch (MalformedURLException e) { //can't happen? e.printStackTrace(); System.err.println("Caught exception on parameterRef " +key+", continuing..."); } // end of try-catch } // end of while (it.hasNext()) File[] sacFiles = directory.listFiles(); for (int i=0; i<sacFiles.length; i++) { if (excludes.contains(sacFiles[i].getName())) { continue; } // end of if (excludes.contains(sacFiles[i].getName())) if (paramRefs.containsValue(sacFiles[i].getName())) { continue; } // end of if (excludes.contains(sacFiles[i].getName())) try { SacTimeSeries sac = new SacTimeSeries(); sac.read(sacFiles[i].getCanonicalPath()); AuditInfo[] audit = new AuditInfo[1]; audit[0] = new AuditInfo(userName+" via SacDirToDataSet", "seismogram loaded from "+sacFiles[i].getCanonicalPath()); URL seisURL = new URL(dirURL, sacFiles[i].getName()); // System.out.println(" the seisURL is "+seisURL.toString()); // DataInputStream dis = new DataInputStream(new BufferedInputStream(seisURL.openStream())); // SacTimeSeries sac = new SacTimeSeries(); //sac.read(dis); edu.iris.Fissures.seismogramDC.LocalSeismogramImpl seis = SacToFissures.getSeismogram(sac); edu.sc.seis.fissuresUtil.cache.CacheEvent event = SacToFissures.getEvent(sac); if (event != null && dataset.getParameter(EVENT) == null) { // add event AuditInfo[] eventAudit = new AuditInfo[1]; eventAudit[0] = new AuditInfo(System.getProperty("user.name"), "event loaded from sac file."); dataset.addParameter( EVENT, event, eventAudit); } // end of if (event != null) Channel channel = SacToFissures.getChannel(sac); String channelParamName = CHANNEL+ChannelIdUtil.toString(seis.channel_id); if (channel != null && dataset.getParameter(channelParamName) == null) { // add event AuditInfo[] chanAudit = new AuditInfo[1]; chanAudit[0] = new AuditInfo(System.getProperty("user.name"), "channel loaded from sac file."); dataset.addParameter(channelParamName, channel, chanAudit); } String seisName = sacFiles[i].getName(); if (seisName.endsWith(".SAC")) { seisName = seisName.substring(seisName.length()-4); } // end of if (seisName.endsWith(".SAC")) dataset.addSeismogramRef(seis, seisURL, seisName, new Property[0], new ParameterRef[0], audit); } catch (Exception e) { e.printStackTrace(); System.err.println("Caught exception on " +sacFiles[i].getName()+", continuing..."); } // end of try-catch } // end of for (int i=0; i<sacFiles.length; i++) } |
seis.setName(seisName); | void process() throws ParserConfigurationException { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = factory.newDocumentBuilder(); String userName = System.getProperty("user.name"); URL dirURL = base; System.out.println(" dirURL is "+dirURL.toString()); try { dirURL = new URL(dirURL, directory.getName()+"/"); System.out.println("updated dirURL is "+dirURL.toString()); } catch (MalformedURLException e) { e.printStackTrace(); return; } // end of try-catch dataset = new XMLDataSet(docBuilder, dirURL, "genid"+Math.round(Math.random()*Integer.MAX_VALUE), dsName, userName); Iterator it = paramRefs.keySet().iterator(); while (it.hasNext()) { String key = (String)it.next(); AuditInfo[] audit = new AuditInfo[1]; audit[0] = new AuditInfo(userName, "Added parameter "+key); try { dataset.addParameter(key,new URL(dirURL, (String)paramRefs.get(key)).toString(), audit); } catch (MalformedURLException e) { //can't happen? e.printStackTrace(); System.err.println("Caught exception on parameterRef " +key+", continuing..."); } // end of try-catch } // end of while (it.hasNext()) File[] sacFiles = directory.listFiles(); for (int i=0; i<sacFiles.length; i++) { if (excludes.contains(sacFiles[i].getName())) { continue; } // end of if (excludes.contains(sacFiles[i].getName())) if (paramRefs.containsValue(sacFiles[i].getName())) { continue; } // end of if (excludes.contains(sacFiles[i].getName())) try { SacTimeSeries sac = new SacTimeSeries(); sac.read(sacFiles[i].getCanonicalPath()); AuditInfo[] audit = new AuditInfo[1]; audit[0] = new AuditInfo(userName+" via SacDirToDataSet", "seismogram loaded from "+sacFiles[i].getCanonicalPath()); URL seisURL = new URL(dirURL, sacFiles[i].getName()); // System.out.println(" the seisURL is "+seisURL.toString()); // DataInputStream dis = new DataInputStream(new BufferedInputStream(seisURL.openStream())); // SacTimeSeries sac = new SacTimeSeries(); //sac.read(dis); edu.iris.Fissures.seismogramDC.LocalSeismogramImpl seis = SacToFissures.getSeismogram(sac); edu.sc.seis.fissuresUtil.cache.CacheEvent event = SacToFissures.getEvent(sac); if (event != null && dataset.getParameter(EVENT) == null) { // add event AuditInfo[] eventAudit = new AuditInfo[1]; eventAudit[0] = new AuditInfo(System.getProperty("user.name"), "event loaded from sac file."); dataset.addParameter( EVENT, event, eventAudit); } // end of if (event != null) Channel channel = SacToFissures.getChannel(sac); String channelParamName = CHANNEL+ChannelIdUtil.toString(seis.channel_id); if (channel != null && dataset.getParameter(channelParamName) == null) { // add event AuditInfo[] chanAudit = new AuditInfo[1]; chanAudit[0] = new AuditInfo(System.getProperty("user.name"), "channel loaded from sac file."); dataset.addParameter(channelParamName, channel, chanAudit); } String seisName = sacFiles[i].getName(); if (seisName.endsWith(".SAC")) { seisName = seisName.substring(seisName.length()-4); } // end of if (seisName.endsWith(".SAC")) dataset.addSeismogramRef(seis, seisURL, seisName, new Property[0], new ParameterRef[0], audit); } catch (Exception e) { e.printStackTrace(); System.err.println("Caught exception on " +sacFiles[i].getName()+", continuing..."); } // end of try-catch } // end of for (int i=0; i<sacFiles.length; i++) } |
|
System.out.println("Sample rate: " + seismogramData.sample_rate); | private PacketType finalizeSeismogramCreation(PacketType seismogramData, PacketType stateOfHealthData, boolean gapInData) { if(gapInData) { System.out.println("The data collecting unit stopped recording data on channel " + seismogramData.channel_number); System.out.println("for a period of time longer than allowed."); System.out.println("A new seismogram will be created to hold the rest of the data."); } if(stateOfHealthData == null || stateOfHealthData.begin_time_from_state_of_health_file == null) { System.err.println("The begin time for the channel is not present in the state of health data."); } else { seismogramData.begin_time_from_state_of_health_file = stateOfHealthData.begin_time_from_state_of_health_file; } if(stateOfHealthData == null || stateOfHealthData.latitude_ == 0) { System.err.println("The latitude for the channel is not present in the state of health data."); } else { seismogramData.latitude_ = stateOfHealthData.latitude_; } if(stateOfHealthData == null || stateOfHealthData.longitude_ == 0) { System.err.println("The longitude for the channel is not present in the state of health data."); } else { seismogramData.longitude_ = stateOfHealthData.longitude_; } if(stateOfHealthData == null || stateOfHealthData.channel_name == null) { System.err.println("The channel name for the channel is not present in the state of health data."); } else { seismogramData.channel_name = stateOfHealthData.channel_name; } if(seismogramData.sample_rate == 0){ seismogramData.sample_rate = 40; System.out.println("The Event Header and Event Trailer Packets for channel " + seismogramData.channel_number + " were missing " + "from the beginning and end of the data file."); System.out.println("This rare occurance is handled by using " + "the header information from the first " + "data packet instead."); System.out.println("The only information unable to be recovered " + "is the data sample rate. A sample rate of " + seismogramData.sample_rate + " samples per second will be assumed."); } System.out.println("Sample rate: " + seismogramData.sample_rate); return seismogramData; } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.