Commit 0bf3042b authored by Cristina Cocho's avatar Cristina Cocho

Corrected some problems found after merge

parent 03e5d06a
......@@ -153,20 +153,17 @@ public class ServantManagerAccessor {
if (error == Common.Error.Type.NO_SUCH_SERVANT) {
LOGGER.logp(Level.SEVERE, this.getClass().getName(), methodName, "UnknownServant with ID " + id);
} else if (error == Common.Error.Type.TOKEN_NOT_OWNED) {
LOGGER.logp(Level.SEVERE, this.getClass().getName(), methodName,
"Token not owned when processing ID " + id);
LOGGER.logp(Level.SEVERE, this.getClass().getName(), methodName, "Token not owned when processing ID " + id);
}
}
private ServantData getWholeConfiguration(int databaseID) throws LoadConfigurationFailure {
// Create the message type.
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder()
.setType(ServantManagerRequest.Message.Type.GetWholeConfiguration).build();
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder().setType(ServantManagerRequest.Message.Type.GetWholeConfiguration).build();
// Create the request.
ServantManagerRequest.GetWholeConfigurationRequest request = ServantManagerRequest.GetWholeConfigurationRequest
.newBuilder().setDatabaseID(databaseID).build();
ServantManagerRequest.GetWholeConfigurationRequest request = ServantManagerRequest.GetWholeConfigurationRequest.newBuilder().setDatabaseID(databaseID).build();
servantManagerRequester.sendTwoParts(type.toByteArray(), request.toByteArray());
......@@ -182,12 +179,10 @@ public class ServantManagerAccessor {
private ServantDataUpdate getWholeConfigurationUpdate(int databaseID) throws LoadConfigurationFailure {
// Create the message type.
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder()
.setType(ServantManagerRequest.Message.Type.GetWholeConfigurationUpdate).build();
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder().setType(ServantManagerRequest.Message.Type.GetWholeConfigurationUpdate).build();
// Create the request.
ServantManagerRequest.GetWholeConfigurationRequest request = ServantManagerRequest.GetWholeConfigurationRequest
.newBuilder().setDatabaseID(databaseID).build();
ServantManagerRequest.GetWholeConfigurationRequest request = ServantManagerRequest.GetWholeConfigurationRequest.newBuilder().setDatabaseID(databaseID).build();
servantManagerRequester.sendTwoParts(type.toByteArray(), request.toByteArray());
......@@ -200,16 +195,13 @@ public class ServantManagerAccessor {
}
}
private ServantDescriptor getControllerConfiguration(int databaseID, int servantID)
throws LoadConfigurationFailure {
private ServantDescriptor getControllerConfiguration(int databaseID, int servantID) throws LoadConfigurationFailure {
// Create the message type.
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder()
.setType(ServantManagerRequest.Message.Type.GetControllerConfiguration).build();
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder().setType(ServantManagerRequest.Message.Type.GetControllerConfiguration).build();
// Create the request.
ServantManagerRequest.ServantRequest request = ServantManagerRequest.ServantRequest.newBuilder()
.setDatabaseID(databaseID).setServantID(servantID).build();
ServantManagerRequest.ServantRequest request = ServantManagerRequest.ServantRequest.newBuilder().setDatabaseID(databaseID).setServantID(servantID).build();
servantManagerRequester.sendTwoParts(type.toByteArray(), request.toByteArray());
......@@ -218,8 +210,7 @@ public class ServantManagerAccessor {
return response;
} catch (InvalidProtocolBufferException e) {
LOGGER.logp(Level.WARNING, this.getClass().getName(), "getControllerConfiguration",
"error in parsing response");
LOGGER.logp(Level.WARNING, this.getClass().getName(), "getControllerConfiguration", "error in parsing response");
throw new LoadConfigurationFailure();
}
}
......@@ -227,12 +218,10 @@ public class ServantManagerAccessor {
private ServantSpyProperties getServantSpyProperties(int databaseID, int servantID) {
// Create the message type.
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder()
.setType(ServantManagerRequest.Message.Type.GetServantSpyProperties).build();
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder().setType(ServantManagerRequest.Message.Type.GetServantSpyProperties).build();
// Create the request.
ServantManagerRequest.ServantRequest request = ServantManagerRequest.ServantRequest.newBuilder()
.setDatabaseID(databaseID).setServantID(servantID).build();
ServantManagerRequest.ServantRequest request = ServantManagerRequest.ServantRequest.newBuilder().setDatabaseID(databaseID).setServantID(servantID).build();
servantManagerRequester.sendTwoParts(type.toByteArray(), request.toByteArray());
......@@ -241,8 +230,7 @@ public class ServantManagerAccessor {
return response;
} catch (InvalidProtocolBufferException e) {
LOGGER.logp(Level.WARNING, this.getClass().getName(), "getServantSpyProperties",
"error in parsing response");
LOGGER.logp(Level.WARNING, this.getClass().getName(), "getServantSpyProperties", "error in parsing response");
}
return null;
......@@ -251,12 +239,10 @@ public class ServantManagerAccessor {
private ServantDynamicProperties getServantDynamicProperties(int databaseID, int servantID) {
// Create the message type.
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder()
.setType(ServantManagerRequest.Message.Type.GetServantDynamicProperties).build();
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder().setType(ServantManagerRequest.Message.Type.GetServantDynamicProperties).build();
// Create the request.
ServantManagerRequest.ServantRequest request = ServantManagerRequest.ServantRequest.newBuilder()
.setDatabaseID(databaseID).setServantID(servantID).build();
ServantManagerRequest.ServantRequest request = ServantManagerRequest.ServantRequest.newBuilder().setDatabaseID(databaseID).setServantID(servantID).build();
servantManagerRequester.sendTwoParts(type.toByteArray(), request.toByteArray());
......@@ -265,8 +251,7 @@ public class ServantManagerAccessor {
return response;
} catch (InvalidProtocolBufferException e) {
LOGGER.logp(Level.WARNING, this.getClass().getName(), "getServantDynamicProperties",
"error in parsing response");
LOGGER.logp(Level.WARNING, this.getClass().getName(), "getServantDynamicProperties", "error in parsing response");
}
return null;
......@@ -275,12 +260,10 @@ public class ServantManagerAccessor {
private int cloneController(int servantID) {
// Create the message type.
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder()
.setType(ServantManagerRequest.Message.Type.CloneController).build();
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder().setType(ServantManagerRequest.Message.Type.CloneController).build();
// Create the request.
ServantManagerRequest.ServantRequest request = ServantManagerRequest.ServantRequest.newBuilder()
.setDatabaseID(0).setServantID(servantID).build();
ServantManagerRequest.ServantRequest request = ServantManagerRequest.ServantRequest.newBuilder().setDatabaseID(0).setServantID(servantID).build();
servantManagerRequester.sendTwoParts(type.toByteArray(), request.toByteArray());
......@@ -294,8 +277,7 @@ public class ServantManagerAccessor {
return response.getValue();
}
} catch (InvalidProtocolBufferException e) {
LOGGER.logp(Level.WARNING, this.getClass().getName(), "cloneController",
"error in parsing response for property with ID " + servantID);
LOGGER.logp(Level.WARNING, this.getClass().getName(), "cloneController", "error in parsing response for property with ID " + servantID);
}
return 0;
......@@ -343,8 +325,7 @@ public class ServantManagerAccessor {
private String getPropertiesForGenericRequest() {
// Create the message type.
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder()
.setType(ServantManagerRequest.Message.Type.GetPropertiesForGeneric).build();
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder().setType(ServantManagerRequest.Message.Type.GetPropertiesForGeneric).build();
// Create the request.
ServantManagerRequest.EmptyRequest request = ServantManagerRequest.EmptyRequest.newBuilder().build();
......@@ -356,8 +337,7 @@ public class ServantManagerAccessor {
return response.getValue();
} catch (InvalidProtocolBufferException e) {
LOGGER.logp(Level.WARNING, this.getClass().getName(), "getPropertiesForGeneric",
"error in parsing response");
LOGGER.logp(Level.WARNING, this.getClass().getName(), "getPropertiesForGeneric", "error in parsing response");
}
return "";
......@@ -415,10 +395,7 @@ public class ServantManagerAccessor {
mode = DriverServant.Mode.SIMULATED;
}
// Uses a new Descriptor in order to keep track of the channel and mode
descriptor = new ClientDriverServantDescriptor(pbServant.getID(), pbServant.getName(),
pbServant.getClientType(), pbServant.getFamily(), pbServant.getSubfamily(), pbServant.getCommand(),
pbServant.getVisible(), pbServant.getEnabled(), false, pbServant.getRoot(), mode,
pbServant.getChannel());
descriptor = new ClientDriverServantDescriptor(pbServant.getID(), pbServant.getName(), pbServant.getClientType(), pbServant.getFamily(), pbServant.getSubfamily(), pbServant.getCommand(), pbServant.getVisible(), pbServant.getEnabled(), false, pbServant.getRoot(), mode, pbServant.getChannel());
ServantDatabase.getInstance().addDriver(descriptor);
servant = createDriver(descriptor, pbServant.getChannel(), mode); // !!!!
......@@ -429,9 +406,7 @@ public class ServantManagerAccessor {
} else {
System.out.println("--> adding controller " + pbServant.getName());
descriptor = new ClientControllerServantDescriptor(pbServant.getID(), pbServant.getName(),
pbServant.getClientType(), pbServant.getFamily(), pbServant.getSubfamily(), pbServant.getCommand(),
pbServant.getVisible(), pbServant.getEnabled(), false, pbServant.getRoot());
descriptor = new ClientControllerServantDescriptor(pbServant.getID(), pbServant.getName(), pbServant.getClientType(), pbServant.getFamily(), pbServant.getSubfamily(), pbServant.getCommand(), pbServant.getVisible(), pbServant.getEnabled(), false, pbServant.getRoot());
ServantDatabase.getInstance().addController(descriptor);
servant = createController(descriptor); //
......@@ -490,13 +465,9 @@ public class ServantManagerAccessor {
}
if (pbProperty.getDynamic()) {
PropertyDatabase.getInstance().addDynamicPropertyDescriptor(descriptor.getId(),
new DynamicPropertyDescriptor(propertyId, ids, pbProperty.getName(), pbProperty.getType(),
enumeratedValuesId, enumeratedLabelsId));
PropertyDatabase.getInstance().addDynamicPropertyDescriptor(descriptor.getId(), new DynamicPropertyDescriptor(propertyId, ids, pbProperty.getName(), pbProperty.getType(), enumeratedValuesId, enumeratedLabelsId));
} else {
PropertyDatabase.getInstance().addStandardPropertyDescriptor(descriptor.getId(),
new StandardPropertyDescriptor(propertyId, pbProperty.getName(), pbProperty.getType(),
enumeratedValuesId, enumeratedLabelsId));
PropertyDatabase.getInstance().addStandardPropertyDescriptor(descriptor.getId(), new StandardPropertyDescriptor(propertyId, pbProperty.getName(), pbProperty.getType(), enumeratedValuesId, enumeratedLabelsId));
}
}
......@@ -504,8 +475,7 @@ public class ServantManagerAccessor {
Iterator<ServantDataConfiguration.CommandDescriptor> d = pbServant.getCommandsList().iterator();
while (d.hasNext()) {
ServantDataConfiguration.CommandDescriptor pbCommand = d.next();
CommandDatabase.getInstance().addCommandDescriptor(descriptor.getId(),
new ClientCommandDescriptor(pbCommand.getID(), pbCommand.getName()));
CommandDatabase.getInstance().addCommandDescriptor(descriptor.getId(), new ClientCommandDescriptor(pbCommand.getID(), pbCommand.getName()));
}
// Add the spy properties
......@@ -527,8 +497,7 @@ public class ServantManagerAccessor {
ServantDataConfiguration.ServantInfo pbServant = s.next();
ClientServantDescriptor descriptor = ServantDatabase.getInstance()
.getServantDescriptorWithId(pbServant.getID());
ClientServantDescriptor descriptor = ServantDatabase.getInstance().getServantDescriptorWithId(pbServant.getID());
descriptor.setFamily(pbServant.getFamily());
descriptor.setVisible(pbServant.getVisible());
......@@ -560,16 +529,13 @@ public class ServantManagerAccessor {
ServantSpyProperties servantSpyProperties = getServantSpyProperties(DATABASE_ID, servantID);
Iterator<ServantDataConfiguration.SpyPropertyDescriptor> p = servantSpyProperties.getPropertiesList()
.iterator();
Iterator<ServantDataConfiguration.SpyPropertyDescriptor> p = servantSpyProperties.getPropertiesList().iterator();
while (p.hasNext()) {
ServantDataConfiguration.SpyPropertyDescriptor pbProperty = p.next();
SpyPropertyDescriptor descriptor = new SpyPropertyDescriptor(pbProperty.getActualID(),
pbProperty.getSetpointID(), pbProperty.getOffsetID(), pbProperty.getUnitID(),
pbProperty.getAlias());
SpyPropertyDescriptor descriptor = new SpyPropertyDescriptor(pbProperty.getActualID(), pbProperty.getSetpointID(), pbProperty.getOffsetID(), pbProperty.getUnitID(), pbProperty.getAlias());
PropertyDatabase.getInstance().addSpyPropertyDescriptor(servantID, descriptor);
}
......@@ -666,8 +632,7 @@ public class ServantManagerAccessor {
}
// iterate the properties
Iterator<ServantDataConfiguration.PropertyDescriptor> p = servantDynamicProperties.getPropertiesList()
.iterator();
Iterator<ServantDataConfiguration.PropertyDescriptor> p = servantDynamicProperties.getPropertiesList().iterator();
while (p.hasNext()) {
......@@ -696,9 +661,7 @@ public class ServantManagerAccessor {
}
if (pbProperty.getDynamic()) {
PropertyDatabase.getInstance().addDynamicPropertyDescriptor(servantID,
new DynamicPropertyDescriptor(propertyId, ids, pbProperty.getName(), pbProperty.getType(),
enumeratedValuesId, enumeratedLabelsId));
PropertyDatabase.getInstance().addDynamicPropertyDescriptor(servantID, new DynamicPropertyDescriptor(propertyId, ids, pbProperty.getName(), pbProperty.getType(), enumeratedValuesId, enumeratedLabelsId));
} else {
System.err.println("properties should be dynamic in updateDynamicProperties");
}
......@@ -717,12 +680,10 @@ public class ServantManagerAccessor {
public synchronized void pauseSpies(boolean isPaused) {
// Create the message type.
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder()
.setType(ServantManagerRequest.Message.Type.PauseSpies).build();
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder().setType(ServantManagerRequest.Message.Type.PauseSpies).build();
// Create the request.
ServantManagerRequest.PauseSpiesRequest request = ServantManagerRequest.PauseSpiesRequest.newBuilder()
.setClientID(getClientID()).setIsPaused(isPaused).build();
ServantManagerRequest.PauseSpiesRequest request = ServantManagerRequest.PauseSpiesRequest.newBuilder().setClientID(getClientID()).setIsPaused(isPaused).build();
servantManagerRequester.sendTwoParts(type.toByteArray(), request.toByteArray());
......@@ -757,12 +718,10 @@ public class ServantManagerAccessor {
public synchronized void reconnectDriver(int databaseID, int servantID) {
// Create the message type.
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder()
.setType(ServantManagerRequest.Message.Type.ReconnectDriver).build();
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder().setType(ServantManagerRequest.Message.Type.ReconnectDriver).build();
// Create the request.
ServantManagerRequest.ModifyServantRequest request = ServantManagerRequest.ModifyServantRequest.newBuilder()
.setClientID(getClientID()).setDatabaseID(0).setServantID(servantID).build();
ServantManagerRequest.ModifyServantRequest request = ServantManagerRequest.ModifyServantRequest.newBuilder().setClientID(getClientID()).setDatabaseID(0).setServantID(servantID).build();
servantManagerRequester.sendTwoParts(type.toByteArray(), request.toByteArray());
......@@ -774,8 +733,7 @@ public class ServantManagerAccessor {
logError("ReconnectDriver", response.getError(), servantID);
}
} catch (InvalidProtocolBufferException e) {
LOGGER.logp(Level.WARNING, this.getClass().getName(), "reconnectDriver",
"error in parsing response for property with ID " + servantID);
LOGGER.logp(Level.WARNING, this.getClass().getName(), "reconnectDriver", "error in parsing response for property with ID " + servantID);
System.err.println("Unable to reconnect driver " + servantID);
}
}
......@@ -783,18 +741,15 @@ public class ServantManagerAccessor {
public synchronized String[] getResourceFilesByExtension(String extension) {
// Create the message type.
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder()
.setType(ServantManagerRequest.Message.Type.GetResourceFilesByExtension).build();
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder().setType(ServantManagerRequest.Message.Type.GetResourceFilesByExtension).build();
// Create the request.
ServantManagerRequest.GetResourceFilesByExtensionRequest request = ServantManagerRequest.GetResourceFilesByExtensionRequest
.newBuilder().setExtension(extension).build();
ServantManagerRequest.GetResourceFilesByExtensionRequest request = ServantManagerRequest.GetResourceFilesByExtensionRequest.newBuilder().setExtension(extension).build();
servantManagerRequester.sendTwoParts(type.toByteArray(), request.toByteArray());
try {
Common.StringArrayResponse response = Common.StringArrayResponse
.parseFrom(servantManagerRequester.receive());
Common.StringArrayResponse response = Common.StringArrayResponse.parseFrom(servantManagerRequester.receive());
int size = response.getValueCount();
String[] result = new String[size];
......@@ -804,23 +759,19 @@ public class ServantManagerAccessor {
return result;
} catch (InvalidProtocolBufferException e) {
LOGGER.logp(Level.WARNING, this.getClass().getName(), "getResourceFilesByExtension",
"error in parsing response");
LOGGER.logp(Level.WARNING, this.getClass().getName(), "getResourceFilesByExtension", "error in parsing response");
}
return null;
}
public synchronized byte[] readBinaryResourceFile(String resourceType, String fileName)
throws ResourceNotFoundException {
public synchronized byte[] readBinaryResourceFile(String resourceType, String fileName) throws ResourceNotFoundException {
// Create the message type.
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder()
.setType(ServantManagerRequest.Message.Type.ReadBinaryResourceFile).build();
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder().setType(ServantManagerRequest.Message.Type.ReadBinaryResourceFile).build();
// Create the request.
ServantManagerRequest.ReadResourceRequest request = ServantManagerRequest.ReadResourceRequest.newBuilder()
.setType(resourceType).setFileName(fileName).build();
ServantManagerRequest.ReadResourceRequest request = ServantManagerRequest.ReadResourceRequest.newBuilder().setType(resourceType).setFileName(fileName).build();
servantManagerRequester.sendTwoParts(type.toByteArray(), request.toByteArray());
......@@ -833,8 +784,7 @@ public class ServantManagerAccessor {
return response.getValue().toByteArray();
} catch (InvalidProtocolBufferException e) {
LOGGER.logp(Level.WARNING, this.getClass().getName(), "readBinaryResourceFile",
"error in parsing response");
LOGGER.logp(Level.WARNING, this.getClass().getName(), "readBinaryResourceFile", "error in parsing response");
}
throw new ResourceNotFoundException(fileName);
......@@ -843,12 +793,10 @@ public class ServantManagerAccessor {
public synchronized String readResourceFile(String resourceType, String fileName) throws ResourceNotFoundException {
// Create the message type.
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder()
.setType(ServantManagerRequest.Message.Type.ReadResourceFile).build();
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder().setType(ServantManagerRequest.Message.Type.ReadResourceFile).build();
// Create the request.
ServantManagerRequest.ReadResourceRequest request = ServantManagerRequest.ReadResourceRequest.newBuilder()
.setType(resourceType).setFileName(fileName).build();
ServantManagerRequest.ReadResourceRequest request = ServantManagerRequest.ReadResourceRequest.newBuilder().setType(resourceType).setFileName(fileName).build();
servantManagerRequester.sendTwoParts(type.toByteArray(), request.toByteArray());
......@@ -861,8 +809,7 @@ public class ServantManagerAccessor {
return response.getValue();
} catch (InvalidProtocolBufferException e) {
LOGGER.logp(Level.WARNING, this.getClass().getName(), "readBinaryResourceFile",
"error in parsing response");
LOGGER.logp(Level.WARNING, this.getClass().getName(), "readBinaryResourceFile", "error in parsing response");
}
throw new ResourceNotFoundException(fileName);
......@@ -871,12 +818,10 @@ public class ServantManagerAccessor {
public synchronized void writeResourceFile(String resourceType, String fileName, String content) {
// Create the message type.
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder()
.setType(ServantManagerRequest.Message.Type.WriteResourceFile).build();
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder().setType(ServantManagerRequest.Message.Type.WriteResourceFile).build();
// Create the request.
ServantManagerRequest.ReadResourceRequest request = ServantManagerRequest.ReadResourceRequest.newBuilder()
.setType(resourceType).setFileName(fileName).build();
ServantManagerRequest.ReadResourceRequest request = ServantManagerRequest.ReadResourceRequest.newBuilder().setType(resourceType).setFileName(fileName).build();
servantManagerRequester.sendTwoParts(type.toByteArray(), request.toByteArray());
......@@ -887,16 +832,13 @@ public class ServantManagerAccessor {
}
}
public synchronized int getResourceFileLastTime(String resourceType, String fileName)
throws ResourceNotFoundException {
public synchronized int getResourceFileLastTime(String resourceType, String fileName) throws ResourceNotFoundException {
// Create the message type.
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder()
.setType(ServantManagerRequest.Message.Type.GetResourceFileLastTime).build();
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder().setType(ServantManagerRequest.Message.Type.GetResourceFileLastTime).build();
// Create the request.
ServantManagerRequest.ReadResourceRequest request = ServantManagerRequest.ReadResourceRequest.newBuilder()
.setType(resourceType).setFileName(fileName).build();
ServantManagerRequest.ReadResourceRequest request = ServantManagerRequest.ReadResourceRequest.newBuilder().setType(resourceType).setFileName(fileName).build();
servantManagerRequester.sendTwoParts(type.toByteArray(), request.toByteArray());
......@@ -918,12 +860,10 @@ public class ServantManagerAccessor {
public synchronized HashMap<String, String> getServantPropertiesValue(int databaseID, int servantID) {
// Create the message type.
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder()
.setType(ServantManagerRequest.Message.Type.GetServantPropertiesValue).build();
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder().setType(ServantManagerRequest.Message.Type.GetServantPropertiesValue).build();
// Create the request.
ServantManagerRequest.ServantRequest request = ServantManagerRequest.ServantRequest.newBuilder()
.setDatabaseID(databaseID).setServantID(servantID).build();
ServantManagerRequest.ServantRequest request = ServantManagerRequest.ServantRequest.newBuilder().setDatabaseID(databaseID).setServantID(servantID).build();
servantManagerRequester.sendTwoParts(type.toByteArray(), request.toByteArray());
......@@ -937,8 +877,7 @@ public class ServantManagerAccessor {
}
return properties;
} catch (InvalidProtocolBufferException e) {
LOGGER.logp(Level.WARNING, this.getClass().getName(), "getServantPropertiesValue",
"error in parsing response");
LOGGER.logp(Level.WARNING, this.getClass().getName(), "getServantPropertiesValue", "error in parsing response");
}
return null;
......@@ -947,12 +886,10 @@ public class ServantManagerAccessor {
public synchronized HashMap<String, Integer> getServantCommandStates(int databaseID, int servantID) {
// Create the message type.
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder()
.setType(ServantManagerRequest.Message.Type.GetServantCommandsState).build();
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder().setType(ServantManagerRequest.Message.Type.GetServantCommandsState).build();
// Create the request.
ServantManagerRequest.ServantRequest request = ServantManagerRequest.ServantRequest.newBuilder()
.setDatabaseID(databaseID).setServantID(servantID).build();
ServantManagerRequest.ServantRequest request = ServantManagerRequest.ServantRequest.newBuilder().setDatabaseID(databaseID).setServantID(servantID).build();
servantManagerRequester.sendTwoParts(type.toByteArray(), request.toByteArray());
......@@ -966,8 +903,7 @@ public class ServantManagerAccessor {
}
return commands;
} catch (InvalidProtocolBufferException e) {
LOGGER.logp(Level.WARNING, this.getClass().getName(), "getServantCommandStates",
"error in parsing response");
LOGGER.logp(Level.WARNING, this.getClass().getName(), "getServantCommandStates", "error in parsing response");
}
return null;
......@@ -976,8 +912,7 @@ public class ServantManagerAccessor {
public synchronized HashMap<String, String> getFamilyImageKeys() {
// Create the message type.
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder()
.setType(ServantManagerRequest.Message.Type.GetFamilyImageKeys).build();
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder().setType(ServantManagerRequest.Message.Type.GetFamilyImageKeys).build();
// Create the request.
ServantManagerRequest.EmptyRequest request = ServantManagerRequest.EmptyRequest.newBuilder().build();
......@@ -1003,8 +938,7 @@ public class ServantManagerAccessor {
public synchronized HashMap<String, String> getControllerIconKeys() {
// Create the message type.
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder()
.setType(ServantManagerRequest.Message.Type.GetControllerIconKeys).build();
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder().setType(ServantManagerRequest.Message.Type.GetControllerIconKeys).build();
// Create the request.
ServantManagerRequest.EmptyRequest request = ServantManagerRequest.EmptyRequest.newBuilder().build();
......@@ -1030,12 +964,10 @@ public class ServantManagerAccessor {
public synchronized void logUserMessage(String userName, String message) {
// Create the message type.
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder()
.setType(ServantManagerRequest.Message.Type.UserLog).build();
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder().setType(ServantManagerRequest.Message.Type.UserLog).build();
// Create the request.
ServantManagerRequest.UserLogRequest request = ServantManagerRequest.UserLogRequest.newBuilder()
.setUserName(userName).setMessage(message).build();
ServantManagerRequest.UserLogRequest request = ServantManagerRequest.UserLogRequest.newBuilder().setUserName(userName).setMessage(message).build();
servantManagerRequester.sendTwoParts(type.toByteArray(), request.toByteArray());
......@@ -1050,18 +982,15 @@ public class ServantManagerAccessor {
public synchronized Set<String> getControllerTypesInheritingType(int databaseID, String controllerType) {
// Create the message type.
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder()
.setType(ServantManagerRequest.Message.Type.GetControllerTypesInheritingType).build();
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder().setType(ServantManagerRequest.Message.Type.GetControllerTypesInheritingType).build();
// Create the request.
ServantManagerRequest.GetControllerTypesInheritingTypeRequest request = ServantManagerRequest.GetControllerTypesInheritingTypeRequest
.newBuilder().setDatabaseID(databaseID).setType(controllerType).build();
ServantManagerRequest.GetControllerTypesInheritingTypeRequest request = ServantManagerRequest.GetControllerTypesInheritingTypeRequest.newBuilder().setDatabaseID(databaseID).setType(controllerType).build();
servantManagerRequester.sendTwoParts(type.toByteArray(), request.toByteArray());
try {
Common.StringArrayResponse response = Common.StringArrayResponse
.parseFrom(servantManagerRequester.receive());
Common.StringArrayResponse response = Common.StringArrayResponse.parseFrom(servantManagerRequester.receive());
HashSet<String> result = new HashSet<String>();
Iterator<String> t = response.getValueList().iterator();
while (t.hasNext()) {
......@@ -1069,8 +998,7 @@ public class ServantManagerAccessor {
}
return result;
} catch (InvalidProtocolBufferException e) {
LOGGER.logp(Level.WARNING, this.getClass().getName(), "getControllerTypesInheritingType",
"error in parsing response");
LOGGER.logp(Level.WARNING, this.getClass().getName(), "getControllerTypesInheritingType", "error in parsing response");
}
return null;
......@@ -1079,8 +1007,7 @@ public class ServantManagerAccessor {
public synchronized boolean hasRunningCommands() {
// Create the message type.
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder()
.setType(ServantManagerRequest.Message.Type.HasRunningCommands).build();
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder().setType(ServantManagerRequest.Message.Type.HasRunningCommands).build();
// Create the request.
ServantManagerRequest.EmptyRequest request = ServantManagerRequest.EmptyRequest.newBuilder().build();
......@@ -1102,8 +1029,7 @@ public class ServantManagerAccessor {
*/
public void loadCatalogue() {
// Create the message type.
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder()
.setType(ServantManagerRequest.Message.Type.LoadCatalogue).build();
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder().setType(ServantManagerRequest.Message.Type.LoadCatalogue).build();
// Create the request.
ServantManagerRequest.EmptyRequest request = ServantManagerRequest.EmptyRequest.newBuilder().build();
......@@ -1123,36 +1049,32 @@ public class ServantManagerAccessor {
*/
public int createDriver(String type, int parentID) {
// Create the message type
ServantManagerRequest.Message messageType = ServantManagerRequest.Message.newBuilder()
.setType(ServantManagerRequest.Message.Type.CreateDriver).build();
ServantManagerRequest.Message messageType = ServantManagerRequest.Message.newBuilder().setType(ServantManagerRequest.Message.Type.CreateDriver).build();
// Create the request
ServantManagerRequest.CreateDriverRequest request = ServantManagerRequest.CreateDriverRequest.newBuilder()
.setType(type).setParentID(parentID).build();
ServantManagerRequest.CreateDriverRequest request = ServantManagerRequest.CreateDriverRequest.newBuilder().setType(type).setParentID(parentID).build();
servantManagerRequester.sendTwoParts(messageType.toByteArray(), request.toByteArray());
int driverID = ERROR;
try {
// NOTE: THE RESPONSE TO THIS MESSAGE HAS TO BE A SERVANTDESCRIPTOR IN ORDER TO
// MERGE WITH NOMADGUI
ServantDescriptorResponse servantDescriptorResponse = ServantDescriptorResponse
.parseFrom(servantManagerRequester.receive());
ServantDescriptorResponse servantDescriptorResponse = ServantDescriptorResponse.parseFrom(servantManagerRequester.receive());
if (servantDescriptorResponse.hasServantDescriptor()) {
if (servantDescriptorResponse.hasError()) {
logError("createDriver", servantDescriptorResponse.getError(), ERROR); // id = -1. Driver has not been created
} else if (servantDescriptorResponse.hasServantDescriptor()) {
ServantDescriptor servantDescriptor = servantDescriptorResponse.getServantDescriptor();
// Add content in ServantDatabase, PropertyDatabase and CommandDatabase
initAllMaps(servantDescriptor, true);
// Add content to propertyManager
PropertyManager.getInstance().createAllPropertiesForDriver(servantDescriptor.getName(),
servantDescriptor.getClientType());
PropertyManager.getInstance().createAllPropertiesForDriver(servantDescriptor.getName(), servantDescriptor.getClientType());
driverID = servantDescriptor.getID();
} else if (servantDescriptorResponse.hasError()) {
// Up to now we do not really treat specific errors
driverID = ERROR;
}
} catch (InvalidProtocolBufferException e) {
// TODO Auto-generated catch block
e.printStackTrace();
......@@ -1168,27 +1090,32 @@ public class ServantManagerAccessor {
*/
public int createController(String type) {
// Create the message type
ServantManagerRequest