Commit 046c21ff authored by ics's avatar ics
Browse files

new method: appendToFile

parent f70e1d63
......@@ -121,6 +121,10 @@ public class ResourceManager {
CommandZoneAccessor.getInstance(serverId).createDirectory(parent, fileName);
}
public void appendToFile(String fileName, String stringToAppend) {
CommandZoneAccessor.getInstance(serverId).appendToFile(fileName, stringToAppend);
}
public HashMap<String, String> getFamilyImageKeys() {
return ServantManagerAccessor.getInstance(serverId).getFamilyImageKeys();
}
......
......@@ -1567,13 +1567,13 @@ public class CommandZoneAccessor {
} else if (boxType == CommandZoneRequests.CommandBoxDescriptor.CommandBoxType.GENERIC) {
content.add(new ServerGenericCommandBox(serverId, id));
} else if (boxType == CommandZoneRequests.CommandBoxDescriptor.CommandBoxType.IFTHEN) {
content.add(new ServerIfCommandBox(serverId, id));
} else if (boxType == CommandZoneRequests.CommandBoxDescriptor.CommandBoxType.BREAK) {
content.add(new ServerBreakCommandBox(serverId, id));
} else if (boxType == CommandZoneRequests.CommandBoxDescriptor.CommandBoxType.IFTHENELSE) {
content.add(new ServerIfCommandBox(serverId, id));
}
......@@ -3241,16 +3241,16 @@ public class CommandZoneAccessor {
public String getTree(String rootDirectory, String extension) {
// Create the message type.
CommandZoneRequests.Message type = CommandZoneRequests.Message.newBuilder()
.setType(CommandZoneRequests.Message.Type.GetTree)
.build();
.setType(CommandZoneRequests.Message.Type.GetTree)
.build();
// Create the request.
CommandZoneRequests.GetTreeRequest request = CommandZoneRequests.GetTreeRequest.newBuilder()
.setRootDirectory(rootDirectory)
.setExtension(extension)
.build();
.setRootDirectory(rootDirectory)
.setExtension(extension)
.build();
commandBoxRequester.sendTwoParts(type.toByteArray(), request.toByteArray());
......@@ -3270,13 +3270,13 @@ public class CommandZoneAccessor {
// Create the message type.
CommandZoneRequests.Message type = CommandZoneRequests.Message.newBuilder()
.setType(CommandZoneRequests.Message.Type.DeleteFile)
.build();
.setType(CommandZoneRequests.Message.Type.DeleteFile)
.build();
// Create the request.
CommandZoneRequests.DeleteFileRequest request = CommandZoneRequests.DeleteFileRequest.newBuilder()
.setClientID(getClientID())
.setFileName(fileName)
.build();
.setClientID(getClientID())
.setFileName(fileName)
.build();
commandBoxRequester.sendTwoParts(type.toByteArray(), request.toByteArray());
......@@ -3294,13 +3294,13 @@ public class CommandZoneAccessor {
// Create the message type.
CommandZoneRequests.Message type = CommandZoneRequests.Message.newBuilder()
.setType(CommandZoneRequests.Message.Type.CreateDirectory)
.build();
.setType(CommandZoneRequests.Message.Type.CreateDirectory)
.build();
// Create the request.
CommandZoneRequests.CreateDirectoryRequest request = CommandZoneRequests.CreateDirectoryRequest.newBuilder()
.setParentDirectory(parent)
.setFileName(fileName)
.build();
.setParentDirectory(parent)
.setFileName(fileName)
.build();
commandBoxRequester.sendTwoParts(type.toByteArray(), request.toByteArray());
......@@ -3311,4 +3311,26 @@ public class CommandZoneAccessor {
LOGGER.logp(Level.WARNING, this.getClass().getName(), "createDirectory", "error in parsing response");
}
}
}
\ No newline at end of file
public void appendToFile(String fileName, String stringToAppend) {
// Create the message type.
CommandZoneRequests.Message type = CommandZoneRequests.Message.newBuilder()
.setType(CommandZoneRequests.Message.Type.AppendToFile)
.build();
// Create the request.
CommandZoneRequests.AppendToFileRequest request = CommandZoneRequests.AppendToFileRequest.newBuilder()
.setFileName(fileName)
.setStringToAppend(stringToAppend)
.build();
commandBoxRequester.sendTwoParts(type.toByteArray(), request.toByteArray());
try {
Common.BooleanResponse.parseFrom(commandBoxRequester.receive());
}
catch (InvalidProtocolBufferException e) {
LOGGER.logp(Level.WARNING, this.getClass().getName(), "appendToFile", "error in parsing response");
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment