+ try {
+ return clientInNewSession(userId, applicationHandle, null,null);
+ } catch (Exception e) {
+ log.error("Failed to create new session for app and user.", e);
+ }
+ return null;
+ }
+
+ private void checkImportedDocument(File vamsasDocument)
+ throws InvalidSessionDocumentException {
+ if (!vamsasDocument.exists()) {
+ throw new InvalidSessionDocumentException("File " + vamsasDocument
+ + " does not exist");
+ }
+ if (!vamsasDocument.canRead()) {
+ throw new InvalidSessionDocumentException("File " + vamsasDocument
+ + " does not exist");
+ }
+ }
+
+ public IClient openAsNewSessionIClient(ClientHandle applicationHandle,
+ File vamsasDocument) throws InvalidSessionDocumentException {
+ checkImportedDocument(vamsasDocument);
+ try {
+ return clientInNewSession(null, applicationHandle, vamsasDocument,null);
+ } catch (InvalidSessionUrnException e) {
+ throw new InvalidSessionDocumentException("Unexpected exception", e);
+ }
+ }
+
+ public IClient openAsNewSessionIClient(ClientHandle applicationHandle,
+ UserHandle userId, File vamsasDocument)
+ throws InvalidSessionDocumentException {
+ checkImportedDocument(vamsasDocument);
+ try {
+ return clientInNewSession(userId, applicationHandle, vamsasDocument,null);
+ } catch (InvalidSessionUrnException e) {
+ throw new InvalidSessionDocumentException("Unexpected exception", e);
+ }
+ }
+
+ public IClient openAsNewSessionIClient(ClientHandle applicationHandle,
+ File vamsasDocument, String sessionName)
+ throws InvalidSessionDocumentException {
+ checkImportedDocument(vamsasDocument);
+ try {
+ return clientInNewSession(null, applicationHandle, vamsasDocument, sessionName);
+ } catch (InvalidSessionUrnException e) {
+ throw new InvalidSessionDocumentException("Unexpected exception", e);
+ }
+ }
+
+ public IClient openAsNewSessionIClient(ClientHandle applicationHandle,
+ UserHandle userId, File vamsasDocument, String sessionName)
+ throws InvalidSessionDocumentException {
+ checkImportedDocument(vamsasDocument);
+ try {
+ return clientInNewSession(userId, applicationHandle, vamsasDocument, sessionName);
+ } catch (InvalidSessionUrnException e) {
+ throw new InvalidSessionDocumentException("Unexpected exception", e);
+ }