+ try {
+ return clientInNewSession(userId, applicationHandle, 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);
+ } 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);
+ } catch (InvalidSessionUrnException e)
+ {
+ throw new InvalidSessionDocumentException("Unexpected exception", e);
+ }