Search in sources :

Example 1 with SentLockMessageException

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());
}
Also used : SentLockMessageException(net.sourceforge.processdash.util.lock.SentLockMessageException) BridgedWorkingDirectory(net.sourceforge.processdash.tool.bridge.client.BridgedWorkingDirectory) HttpException(net.sourceforge.processdash.util.HttpException) IOException(java.io.IOException) File(java.io.File) TeamSettingsFile(net.sourceforge.processdash.team.setup.TeamSettingsFile) LockFailureException(net.sourceforge.processdash.util.lock.LockFailureException) ReadOnlyLockFailureException(net.sourceforge.processdash.util.lock.ReadOnlyLockFailureException)

Example 2 with SentLockMessageException

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;
    }
}
Also used : SentLockMessageException(net.sourceforge.processdash.util.lock.SentLockMessageException) BridgedWorkingDirectory(net.sourceforge.processdash.tool.bridge.client.BridgedWorkingDirectory) CompressedWorkingDirectory(net.sourceforge.processdash.tool.bridge.client.CompressedWorkingDirectory) WorkingDirectory(net.sourceforge.processdash.tool.bridge.client.WorkingDirectory) CompressedWorkingDirectory(net.sourceforge.processdash.tool.bridge.client.CompressedWorkingDirectory) HttpException(net.sourceforge.processdash.util.HttpException) IOException(java.io.IOException) File(java.io.File) LockFailureException(net.sourceforge.processdash.util.lock.LockFailureException) ReadOnlyLockFailureException(net.sourceforge.processdash.util.lock.ReadOnlyLockFailureException)

Aggregations

File (java.io.File)2 IOException (java.io.IOException)2 BridgedWorkingDirectory (net.sourceforge.processdash.tool.bridge.client.BridgedWorkingDirectory)2 HttpException (net.sourceforge.processdash.util.HttpException)2 LockFailureException (net.sourceforge.processdash.util.lock.LockFailureException)2 ReadOnlyLockFailureException (net.sourceforge.processdash.util.lock.ReadOnlyLockFailureException)2 SentLockMessageException (net.sourceforge.processdash.util.lock.SentLockMessageException)2 TeamSettingsFile (net.sourceforge.processdash.team.setup.TeamSettingsFile)1 CompressedWorkingDirectory (net.sourceforge.processdash.tool.bridge.client.CompressedWorkingDirectory)1 WorkingDirectory (net.sourceforge.processdash.tool.bridge.client.WorkingDirectory)1