List of usage examples for org.joda.time DateTime now
public static DateTime now()
ISOChronology
in the default time zone. From source file:com.citrix.g2w.webdriver.flows.Session.java
License:Open Source License
/** * Method to end webinar/*from ww w. j a v a 2 s . c o m*/ * * @param webinarId * Webinar Id */ public void endWebinar(final Long webinarId) { this.endWebinar(webinarId, DateTime.now()); }
From source file:com.citrix.g2w.webdriver.flows.Session.java
License:Open Source License
/** * Method to start webinar//from w w w . ja va 2 s .co m * * @param bat * BAT/Auth Token of the user * @param userKey * User Key * @param webinarId * Webinar Id */ public void startWebinar(final String bat, final Long userKey, final Long webinarId) { this.startWebinar(bat, userKey, webinarId, DateTime.now()); }
From source file:com.claresco.tinman.json.XapiCredentialsJson.java
License:Open Source License
@Override public XapiCredentials deserialize(JsonElement arg0, Type arg1, JsonDeserializationContext arg2) throws JsonParseException { JsonObject theJsonCredentials = JsonUtility.convertJsonElementToJsonObject(arg0); // Default values XapiPerson thePerson = null;/*from ww w. j a v a 2 s .co m*/ boolean theHistorical = false; ArrayList<String> theScope = new ArrayList<String>(); String theExpiry = null; ArrayList<String> theActivityIDs = new ArrayList<String>(); String theRegistration = null; // Retrieve actor if (JsonUtility.hasElement(theJsonCredentials, ACTORS)) { thePerson = JsonUtility.delegateDeserialization(arg2, JsonUtility.get(theJsonCredentials, ACTORS), XapiPerson.class); } // Retrieve historical if (JsonUtility.hasElement(theJsonCredentials, HISTORICAL)) { theHistorical = JsonUtility.getElementAsBool(theJsonCredentials, HISTORICAL); } // Retrieve expiry if (JsonUtility.hasElement(theJsonCredentials, EXPIRY)) { theExpiry = JsonUtility.getElementAsString(theJsonCredentials, EXPIRY); } //Retrieve registration if (JsonUtility.hasElement(theJsonCredentials, REGISTRATION)) { theRegistration = JsonUtility.getElementAsString(theJsonCredentials, REGISTRATION); } //Retrieve scope if (JsonUtility.hasElement(theJsonCredentials, SCOPE)) { JsonArray theArray = theJsonCredentials.getAsJsonArray(SCOPE); for (JsonElement e : theArray) { theScope.add(e.getAsString()); } } //Retrieve activities if (JsonUtility.hasElement(theJsonCredentials, ACTIVITY)) { JsonArray theArray = theJsonCredentials.getAsJsonArray(ACTIVITY); for (JsonElement e : theArray) { theActivityIDs.add(e.getAsString()); } } DateTime theReceivedTimestamp = DateTime.now(); try { return new XapiCredentials(theScope, theExpiry, theHistorical, thePerson, theActivityIDs, theRegistration, theReceivedTimestamp); } catch (XapiBadParamException e) { throw new XapiBadRequestException(e.getMessage()); } }
From source file:com.claresco.tinman.servlet.XapiAccessManager.java
License:Open Source License
protected void addCrendential(XapiKeySecret theKeySecret, XapiCredentials theCredential) { addLastAccessedTime(theKeySecret, DateTime.now()); myCredentialsList.put(theKeySecret, theCredential); }
From source file:com.claresco.tinman.servlet.XapiAccessManager.java
License:Open Source License
protected void saveCredentialsList(String theList) { DateTime theDate = DateTime.now(); File theFile = new File(myCredentialsListFileName); try {// w w w. java 2 s. co m if (!theFile.exists()) { theFile.createNewFile(); } PrintWriter theWriter = new PrintWriter( new BufferedWriter(new FileWriter(myCredentialsListFileName, false))); theWriter.print(theList); theWriter.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.claresco.tinman.servlet.XapiCredentials.java
License:Open Source License
/** * Constructor // w w w . j av a 2 s . c o m * * Params: * * */ public XapiCredentials(ArrayList<String> theScope, String theExpiry, boolean theHistorical, XapiPerson thePerson, ArrayList<String> theActivityIDs, String theRegistration, DateTime theReceivedTimestamp) throws XapiBadParamException { myScope = theScope; myHistorical = theHistorical; myPerson = thePerson; if (theRegistration != null) { myRegistration = UUID.fromString(theRegistration); } else { theRegistration = null; } myReceivedTimestamp = theReceivedTimestamp; DateTimeFormatter theFormatter = ISODateTimeFormat.dateTimeParser(); if (theExpiry != null) { myExpiry = theFormatter.parseDateTime(theExpiry); } else { // By default, 4 hours myExpiry = DateTime.now().plusHours(4); } for (String s : theActivityIDs) { myActivityIDs.add(new XapiIRI(s)); } populateAcceptedScope(); // Assign appropriate clearance based on its scope for (String scope : theScope) { if (!myAcceptedScope.contains(scope)) { throw new XapiBadParamException("Scope is not accepted"); } else { if (scope.equals("all")) { myReadStatementsClearance = true; myWriteStatementsClearance = true; myReadStateClearance = true; myWriteStateClearance = true; myDefineClearance = true; myReadProfileClearance = true; myWriteProfileClearance = true; myReadAnyoneStatementsClearance = true; } else if (scope.equals("all/read")) { myReadStatementsClearance = true; myReadAnyoneStatementsClearance = true; myReadStateClearance = true; myReadProfileClearance = true; } else if (scope.equals("profile")) { myReadProfileClearance = true; myWriteProfileClearance = true; } else if (scope.equals("state")) { myReadStateClearance = true; myWriteStateClearance = true; } else if (scope.equals("define")) { myDefineClearance = true; } else if (scope.equals("statements/read")) { myReadAnyoneStatementsClearance = true; myReadStatementsClearance = true; } else if (scope.equals("statements/read/mine")) { myReadStatementsClearance = true; } else if (scope.equals("statements/write")) { myWriteStatementsClearance = true; } } } }
From source file:com.claresco.tinman.servlet.XapiServletSimpleErrorLogger.java
License:Open Source License
protected long log(Exception theException, int errorNumber, String errorMessage) { DateTime theDate = DateTime.now(); long theReturnedValue = logID; //String fileName = theDate.year().getAsShortText() + "-" + theDate.monthOfYear() // .getAsString() + "-" +theDate.dayOfMonth().getAsShortText() + ".txt"; String fileName = myFileName; File theLogFile = new File(myPath + fileName); try {//w ww .j a v a 2 s.co m if (!theLogFile.exists()) { theLogFile.createNewFile(); } PrintWriter theWriter = new PrintWriter(new BufferedWriter(new FileWriter(myPath + fileName, true))); theWriter.println("==============================================================="); theWriter.println(logID); theWriter.println(theDate.toString()); logID++; theException.printStackTrace(theWriter); theWriter.println(errorNumber + " : " + errorMessage); theWriter.println("===============================================================\n\n\n"); theWriter.close(); return theReturnedValue; } catch (Exception e) { e.printStackTrace(); } return -1; }
From source file:com.claresco.tinman.servlet.XapiServletSimpleErrorLogger.java
License:Open Source License
protected long log(Exception theException, int errorNumber, String errorMessage, HttpServletRequest req) { DateTime theDate = DateTime.now(); long theReturnedValue = logID; //String fileName = theDate.year().getAsShortText() + "-" + theDate.monthOfYear() // .getAsString() + "-" +theDate.dayOfMonth().getAsShortText() + ".txt"; String fileName = myFileName; File theLogFile = new File(myPath + fileName); try {//from w ww .ja v a 2 s. com if (!theLogFile.exists()) { theLogFile.createNewFile(); } PrintWriter theWriter = new PrintWriter(new BufferedWriter(new FileWriter(myPath + fileName, true))); theWriter.println("==============================================================="); theWriter.println(logID); theWriter.println(theDate.toString()); logID++; theException.printStackTrace(theWriter); theWriter.println(errorNumber + " : " + errorMessage); theWriter.println(); theWriter.println("request.getRequstURI() gives :"); theWriter.println(req.getRequestURI()); theWriter.println("request.getQueryString() gives :"); theWriter.println(req.getQueryString()); theWriter.println("iterating through parameter names gives :"); Enumeration<String> e = req.getParameterNames(); while (e.hasMoreElements()) { String paramName = e.nextElement(); theWriter.println(paramName + " : " + req.getParameter(paramName)); } theWriter.println("\nthe header names :\n"); e = req.getHeaderNames(); while (e.hasMoreElements()) { String headerName = e.nextElement(); theWriter.println(headerName + " : " + req.getHeader(headerName) + "\n"); } theWriter.println(req.getMethod()); theWriter.println("Path info : " + req.getPathInfo()); theWriter.println("Reading from the request's reader gives :"); theWriter.println(XapiServletUtility.getStringFromReader(req.getReader())); theWriter.println("===============================================================\n\n\n"); theWriter.close(); return theReturnedValue; } catch (Exception e) { e.printStackTrace(); } return -1; }
From source file:com.claresco.tinman.sql.XapiActivityProfileSQLWriter.java
License:Open Source License
protected int insertNewActivityProfile(String theActvID, String theProfileKey, String theDocument) throws SQLException, XapiDataIntegrityException, XapiSQLOperationProblemException { int theID = super.fetchId(); myInsertStatement.setInt(1, theID);/* w w w. j a v a 2 s . c o m*/ myInsertStatement.setInt(2, myActivityWriter.insertActivity(new XapiActivity(theActvID), true)); myInsertStatement.setString(3, theProfileKey); myInsertStatement.setInt(4, myDocumentWriter.insertNewDocument(theDocument)); DateTime theStoredTime = DateTime.now(); Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC")); this.myInsertStatement.setTimestamp(5, SQLUtility.getTimestamp(theStoredTime), cal); myInsertStatement.executeUpdate(); return theID; }
From source file:com.claresco.tinman.sql.XapiAgentProfileSQLWriter.java
License:Open Source License
private int insertNewAgentProfile(XapiActor theActor, String theProfileKey, String theDocument) throws SQLException, XapiDataIntegrityException, XapiSQLOperationProblemException { int theID = super.fetchId(); myInsertStatement.setInt(1, theID);/*from ww w .j ava2s .c o m*/ myInsertStatement.setInt(2, myActorWriter.insertNewActor(theActor)); myInsertStatement.setString(3, theProfileKey); myInsertStatement.setInt(4, myDocumentWriter.insertNewDocument(theDocument)); DateTime theStoredTime = DateTime.now(); Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC")); myInsertStatement.setTimestamp(5, SQLUtility.getTimestamp(theStoredTime), cal); myInsertStatement.executeUpdate(); return theID; }