Commit a413aa55 authored by Cristina Cocho's avatar Cristina Cocho

Work done related to not configured references

parent abb7e3ba
......@@ -11,7 +11,7 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
......
......@@ -248,7 +248,7 @@ public class ControllerManager implements ServerConfigurationChangeListener {
/**
* H.ORTIZ Sept.2012: remove test on isCommand property because the map "controllerNamesByType" is
* also used for "for-all" plugins in Settings tab. Somehow, it may now result in a inconstistency
* also used for "for-all" plugins in Settings tab. Somehow, it may now result in a inconsistency
* because if one controller of a given type has its attribute isCommand set to false, this controller
* will however appear in "for-all" spy plugins.
*/
......
......@@ -140,8 +140,9 @@ public class PropertyManager {
while (it.hasNext()) {
ClientServantDescriptor descriptor = it.next();
boolean clientFilesExist = readPropertiesClientFilesFor(descriptor.getType());
// Even though the controller does not have a client file descriptor, call method "getController' because it loaded the ControllerServant instance
Controller controller = ControllerManager.getInstance().getController(descriptor.getName());
if (clientFilesExist) {
Controller controller = ControllerManager.getInstance().getController(descriptor.getName());
createPropertiesForController((Servant)controller);
if (dynamicPropertiesByControllerType != null && dynamicPropertiesByControllerType.containsKey(((Servant)controller).getType())) {
createDynamicPropertiesForController((Servant)controller);
......
......@@ -39,6 +39,7 @@ import fr.ill.ics.cameo.RequesterCreationException;
import fr.ill.ics.core.command.CommandManager;
import fr.ill.ics.core.property.PropertyManager;
import fr.ill.ics.nomadserver.common.Common;
import fr.ill.ics.nomadserver.common.Common.UnconfiguredServantData;
import fr.ill.ics.nomadserver.configuration.ServantDataConfiguration;
import fr.ill.ics.nomadserver.configuration.ServantDataConfiguration.CommandStateValue;
import fr.ill.ics.nomadserver.configuration.ServantDataConfiguration.PropertyValue;
......@@ -378,9 +379,9 @@ public class ServantManagerAccessor {
removedDriverIds.add(ERROR);
}
if (response.getServantIDCount() > 0) {
if (response.getDeletedServantIDCount() > 0) {
// Update client managers
removedDriverIds = response.getServantIDList();
removedDriverIds = response.getDeletedServantIDList();
updateManagersOnDriverRemoved(removedDriverIds);
return removedDriverIds;
}
......@@ -407,7 +408,7 @@ public class ServantManagerAccessor {
Common.ServantDeleteResponse response;
try {
response = Common.ServantDeleteResponse.parseFrom(servantManagerRequester.receive());
removedDriverIds = response.getServantIDList();
removedDriverIds = response.getDeletedServantIDList();
if (response.hasError()) {
System.out.println("error when deleting drivers");
......@@ -442,11 +443,19 @@ public class ServantManagerAccessor {
Common.ServantDeleteResponse response = Common.ServantDeleteResponse.parseFrom(servantManagerRequester.receive());
if (response.hasError()) {
return ERROR;
}
}
// The list is used to keep the same method
controllerIDs = response.getServantIDList();
updateManagersOnControllerRemoved(controllerIDs);
controllerIDs = response.getDeletedServantIDList();
updateManagersOnControllerRemoved(controllerIDs);
// Retrieve data about not configured servants
for (UnconfiguredServantData servantData : response.getUnconfiguredServantDataList()) {
int unconfiguredServantID = servantData.getUnconfiguredServantID();
List<String> unconfiguredReferencesRoles = servantData.getRoleOfUnconfiguredReferenceList();
// Update ServantDatabase content
unconfigureControllerReferences(unconfiguredServantID, unconfiguredReferencesRoles);
}
} catch (InvalidProtocolBufferException e) {
}
return controllerIDs.get(0); //The list should contain only one item
......@@ -467,7 +476,7 @@ public class ServantManagerAccessor {
try {
Common.ServantDeleteResponse response = Common.ServantDeleteResponse.parseFrom(servantManagerRequester.receive());
removedControllersIDs = response.getServantIDList();
removedControllersIDs = response.getDeletedServantIDList();
if (response.hasError()) {
removedControllersIDs.add(ERROR);
}
......@@ -595,6 +604,7 @@ public class ServantManagerAccessor {
addDriverChildren((ClientDriverServantDescriptor)descriptor, pbChildren);
} 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());
ServantDatabase.getInstance().addController(descriptor);
......@@ -713,7 +723,13 @@ public class ServantManagerAccessor {
}
}
private void unconfigureControllerReferences(int servantID, List<String> unconfiguredReferencesRoles) {
ClientControllerServantDescriptor controllerDescriptor = (ClientControllerServantDescriptor) ServantDatabase.getInstance().getControllerDescriptor(ServantDatabase.getInstance().getControllerName(servantID));
for (String role : unconfiguredReferencesRoles) {
controllerDescriptor.unconfiguredReferenceInfo(role);
}
}
private void updateAllMaps(List<ServantDataConfiguration.ServantInfo> servants, boolean drivers) {
// iterate over servants
......@@ -744,7 +760,7 @@ public class ServantManagerAccessor {
private void updateManagersOnControllerRemoved(List<Integer> removedControllersIds) {
for (int controllerID : removedControllersIds) {
// Update here DriverManager, PropertyManager and CommandManager when a driver has been successfully removed
// Update here ControllerManager, PropertyManager and CommandManager when a controller has been successfully removed
Servant controller = ControllerManager.getInstance().getController(controllerID);
if (controller != null) {
......@@ -755,7 +771,6 @@ public class ServantManagerAccessor {
ControllerManager.getInstance().removeController(controllerID);
}
}
}
public void addSpyProperties(int servantID) {
......
......@@ -460,7 +460,7 @@ public class DataNotificationClient {
}
}
// copy pending error eventsto unblock any server calls
// copy pending error events to unblock any server calls
Set<ServerErrorEvent> events;
synchronized (pendingServerErrors) {
events = new LinkedHashSet<ServerErrorEvent>(pendingServerErrors);
......
......@@ -22,4 +22,14 @@ public class ClientControllerServantDescriptor extends ClientServantDescriptor {
return referencesInfo;
}
public void unconfiguredReferenceInfo(String role) {
// An unconfigured reference does not have any controller for a specific role
List<String> refNames = referencesInfo.get(role);
String name = "Not Configured";
for (int i = 0; i < refNames.size(); i++) {
// The list should contain only one element
refNames.set(i, name);
}
}
}
......@@ -30,4 +30,8 @@ public class ControllerServant extends Servant {
public Map<String, List<String>> getReferencesInfo() {
return ((ClientControllerServantDescriptor)servantDescriptor).getReferencesInfo();
}
public boolean hasReferences() {
return (((ClientControllerServantDescriptor)servantDescriptor).getReferencesInfo().size() > 0);
}
}
\ No newline at end of file
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