GT-3208 Corrected ability to cancel versioned file checkin/checkout.

Strip domain prefix from default user name if present.  Other minor
usability adjustments.
This commit is contained in:
ghidra1 2019-10-02 16:27:57 -04:00
parent dabaa34e92
commit bb27721a1f
8 changed files with 46 additions and 14 deletions

View File

@ -314,7 +314,8 @@ public class BlockStreamServer extends Thread {
": failed to read stream header");
}
else if (!(e instanceof EOFException)) { // silent on closed connection
log.error("file block stream failed from " + socket.getInetAddress(), e);
log.error("file block stream failed from " + socket.getInetAddress() + ": " +
e.getMessage());
}
}
finally {

View File

@ -67,7 +67,7 @@ public class RemoteInputBlockStreamHandle extends RemoteBlockStreamHandle<InputB
@Override
public void close() throws IOException {
socket.getInputStream().close();
in.close();
socket.close();
}

View File

@ -60,8 +60,10 @@ public class RemoteOutputBlockStreamHandle extends RemoteBlockStreamHandle<Outpu
ClientOutputBlockStream(Socket socket) throws IOException {
this.socket = socket;
out = compressed ? new DeflaterOutputStream(socket.getOutputStream(),
new Deflater(Deflater.BEST_SPEED)) : socket.getOutputStream();
out = compressed
? new DeflaterOutputStream(socket.getOutputStream(),
new Deflater(Deflater.BEST_SPEED))
: socket.getOutputStream();
}
@Override
@ -76,7 +78,8 @@ public class RemoteOutputBlockStreamHandle extends RemoteBlockStreamHandle<Outpu
@Override
public void close() throws IOException {
socket.getOutputStream().close();
out.close();
socket.close();
}
@Override

View File

@ -175,7 +175,13 @@ public class ClientUtil {
* should be obtained from RepositoryServerAdapter.getUser
*/
public static String getUserName() {
return SystemUtilities.getUserName();
String name = SystemUtilities.getUserName();
// exclude domain prefix which may be included
int slashIndex = name.lastIndexOf('\\');
if (slashIndex >= 0) {
name = name.substring(slashIndex + 1);
}
return name;
}
/**

View File

@ -893,6 +893,11 @@ public class GhidraFileData {
catch (InvalidNameException e) {
throw new AssertException("Unexpected error", e);
}
finally {
if (folderItem == null) {
versionedFolderItem.terminateCheckout(checkout.getCheckoutId(), false);
}
}
folderItem.setCheckout(checkout.getCheckoutId(), exclusive, checkoutVersion,
folderItem.getCurrentVersion());

View File

@ -194,10 +194,13 @@ public class DeleteProjectFilesTask extends Task {
.addOption("Yes")
.addOption("No")
.addCancel()
.addApplyToAllOption()
.setMessageType(OptionDialog.WARNING_MESSAGE)
;
//@formatter:on
if (getFileCount() > 1) {
versionedDialogBuilder.addApplyToAllOption();
}
}
String msg =
@ -217,10 +220,13 @@ public class DeleteProjectFilesTask extends Task {
new OptionDialogBuilder("Delete Not Allowed")
.addOption("OK")
.addCancel()
.addDontShowAgainOption()
.setMessageType(OptionDialog.ERROR_MESSAGE)
;
//@formatter:on
if (getFileCount() > 1) {
checkedOutDialogBuilder.addDontShowAgainOption();
}
}
String msg = "The file \"" + file.getName() +
@ -240,9 +246,12 @@ public class DeleteProjectFilesTask extends Task {
.addOption("OK")
.setMessageType(OptionDialog.ERROR_MESSAGE)
.addCancel()
.addDontShowAgainOption()
;
//@formatter:on
if (getFileCount() > 1) {
fileInUseDialogBuilder.addDontShowAgainOption();
}
}
String msg =
@ -263,10 +272,13 @@ public class DeleteProjectFilesTask extends Task {
.addOption("No")
.addCancel()
.setMessageType(OptionDialog.WARNING_MESSAGE)
.addApplyToAllOption()
.setDefaultButton("No")
;
//@formatter:on
if (getFileCount() > 1) {
readOnlyDialogBuilder.addApplyToAllOption();
}
}
String msg = "The file \"" + file.getName() +

View File

@ -28,7 +28,9 @@ import ghidra.framework.main.datatable.DomainFileProvider;
import ghidra.framework.main.datatree.UndoActionDialog;
import ghidra.framework.model.DomainFile;
import ghidra.framework.plugintool.Plugin;
import ghidra.util.Msg;
import ghidra.util.exception.CancelledException;
import ghidra.util.exception.FileInUseException;
import ghidra.util.task.Task;
import ghidra.util.task.TaskMonitor;
import resources.ResourceManager;
@ -177,6 +179,10 @@ public class VersionControlUndoCheckOutAction extends VersionControlAction {
catch (CancelledException e) {
tool.setStatusInfo("Undo check out was canceled");
}
catch (FileInUseException e) {
Msg.showError(this, null, "Action Failed",
"Unable to Undo Checkout while file(s) are open or in use");
}
catch (IOException e) {
ClientUtil.handleException(repository, e, "Undo Check Out", tool.getToolFrame());
}

View File

@ -15,17 +15,16 @@
*/
package ghidra.server;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.*;
import java.io.File;
import org.junit.*;
import ghidra.framework.client.ClientUtil;
import ghidra.framework.remote.User;
import ghidra.test.AbstractGhidraHeadedIntegrationTest;
import ghidra.util.NamingUtilities;
import ghidra.util.SystemUtilities;
import ghidra.util.exception.UserAccessException;
import utilities.util.FileUtilities;
@ -41,7 +40,7 @@ public class RepositoryTest extends AbstractGhidraHeadedIntegrationTest {
@Before
public void setUp() throws Exception {
userName = SystemUtilities.getUserName();
userName = ClientUtil.getUserName();
File parent = createTempDirectory(getClass().getSimpleName());