use of net.sourceforge.processdash.util.lock.SentLockMessageException in project processdash by dtuma.
the class ProcessDashboard method configureWorkingDirectory.
private void configureWorkingDirectory(String location) {
workingDirectory = WorkingDirectoryFactory.getInstance().get(location, WorkingDirectoryFactory.PURPOSE_DASHBOARD);
if (JnlpRelauncher.maybeRelaunch(workingDirectory))
System.exit(0);
String locationDescr = workingDirectory.getDescription();
try {
lockMessageHandler = new LockMsgHandler();
workingDirectory.acquireProcessLock(ACTIVATE_MESSAGE, lockMessageHandler);
} catch (SentLockMessageException e) {
System.exit(0);
} catch (LockFailureException e) {
displaySharingError(locationDescr);
System.exit(1);
}
try {
workingDirectory.prepare();
} catch (HttpException.Unauthorized e) {
displayStartupPermissionError("Unauthorized");
System.exit(1);
} catch (HttpException.Forbidden e) {
displayStartupPermissionError("Forbidden");
System.exit(1);
} catch (IOException e) {
String resKey;
if (workingDirectory instanceof BridgedWorkingDirectory) {
resKey = "Errors.Read_File_Error.Data_Server";
} else {
resKey = "Errors.Read_File_Error.Data_Directory";
}
displayStartupIOError(resKey, locationDescr, e);
System.exit(1);
}
// Check to see if a legacy shortcut is being used to launch a dataset
// that is now hosted on a team server. If so, possibly configure the
// team server URL as the "default team server."
TeamServerSelector.maybeSetDefaultTeamServerUrl(workingDirectory);
File cwd = workingDirectory.getDirectory();
System.setProperty("user.dir", cwd.getAbsolutePath());
}
use of net.sourceforge.processdash.util.lock.SentLockMessageException in project processdash by dtuma.
the class WBSEditor method configureWorkingDirectory.
private static WorkingDirectory configureWorkingDirectory(String[] locations, String intent, LockMessageHandler handler) {
DashboardBackupFactory.setKeepBackupsNumDays(30);
WorkingDirectory workingDirectory = WorkingDirectoryFactory.getInstance().get(WorkingDirectoryFactory.PURPOSE_WBS, locations);
try {
workingDirectory.acquireProcessLock(intent, handler);
} catch (SentLockMessageException s) {
// another WBS Editor is running, and it handled the request for us.
maybeDumpStartupError("Process Conflict", new Object[] { //
"Another process on this computer has already locked", "the WBS Editor for this team project." });
return null;
} catch (LockFailureException e) {
e.printStackTrace();
showLockFailureError();
return null;
}
boolean workingDirIsGood = false;
try {
workingDirectory.prepare();
File dir = workingDirectory.getDirectory();
if (workingDirectory instanceof CompressedWorkingDirectory) {
workingDirIsGood = new File(dir, WBS_FILENAME).isFile();
} else {
workingDirIsGood = dir.isDirectory();
}
} catch (HttpException.Unauthorized e) {
displayStartupPermissionError("Unauthorized");
return null;
} catch (HttpException.Forbidden e) {
displayStartupPermissionError("Forbidden");
return null;
} catch (IOException e) {
// do nothing. An exception means that "workingDirIsGood" will
// remain false, so we will display an error message below.
}
if (workingDirIsGood) {
return workingDirectory;
} else {
showCannotOpenError(workingDirectory);
return null;
}
}
Aggregations