1 28 29 package ist.coach.itut_q816Components.TerminatorServiceProviderComposition; 30 31 import ist.coach.coachEmfCommon.Utils; 32 import ist.coach.coachEmfCommon.ExceptionMessages; 33 import ist.coach.coachEmfCommon.DeleteErrorInfoTypeImpl; 34 import ist.coach.coachEmfCommon.ApplicationErrorInfoTypeImpl; 35 36 import intt.itu.itut_x780.UIDType; 37 import intt.itu.itut_x780.ApplicationError; 38 import intt.itu.itut_x780.DeleteError; 39 import intt.itu.itut_x780.ManagedObject_F; 40 41 47 public class terminatorSegImpl 48 extends ist.coach.itut_q816Components.TerminatorServiceProviderComposition.terminatorSeg 49 { 50 61 public terminatorSegImpl() 62 { 63 64 } 65 66 72 75 public void 76 deleteByName(org.omg.CosNaming.NameComponent [] name) 77 throws intt.itu.itut_x780.ApplicationError, 78 intt.itu.itut_x780.DeleteError 79 { 80 84 String name_str = Utils.name2string(name); 85 String facade_name = Utils.name2facade(name_str); 86 87 if (facade_name.length() == 0) { 88 ApplicationErrorInfoTypeImpl error_code = 89 new ApplicationErrorInfoTypeImpl(); 90 error_code.error = new UIDType( 91 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 92 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 93 error_code.details = ExceptionMessages.root_delete_error; 94 95 System.err.println("Terminator: Root Object can not be deleted!"); 96 throw new ApplicationError(error_code); 97 } 98 System.err.println("Terminator>deleteByName called for " + name_str + " of " + 99 facade_name); 100 101 intt.itu.itut_q816.Containment c_query = null; 102 103 if ((c_query = get_context().get_connection_containment_query()) == null) { 104 ApplicationErrorInfoTypeImpl error_code = 105 new ApplicationErrorInfoTypeImpl(); 106 error_code.error = new UIDType( 107 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 108 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 109 error_code.details = ExceptionMessages.components_connect_error; 110 111 System.err.println("Terminator:ContainmentQuery can not be located!!"); 112 throw new ApplicationError(error_code); 113 } 114 115 116 117 ist.coach.itut_q816Components. 118 TerminatorServiceProviderPackage.target_facadesConnection [] facades = 119 get_context().get_connections_target_facades(); 120 121 int i = 0; 122 org.omg.CosNaming.NameComponent [] facade_name_comp; 123 for(i = 0; i < facades.length; i++) { 124 facade_name_comp = facades[i].objref.nameGet(); 125 128 int len = facade_name_comp.length; 129 if (len > 0 && 130 facade_name_comp[len - 1].kind.equals(facade_name)) 131 132 break; 133 } 134 135 if (i >= facades.length) { 136 137 ApplicationErrorInfoTypeImpl error_code = 138 new ApplicationErrorInfoTypeImpl(); 139 error_code.error = new UIDType( 140 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 141 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 142 error_code.details = ExceptionMessages.facade_not_exists_error; 143 144 System.err.println("Terminator: Could not locate the facade!"); 145 throw new ApplicationError(error_code); 146 } 147 148 ManagedObject_F facade = facades[i].objref; 149 150 short objectDeletePolicy = facade.deletePolicyGet(name); 151 152 org.omg.CosNaming.NameComponent [][] contained_objects = null; 153 switch (objectDeletePolicy) { 154 155 case intt.itu.itut_x780.notDeletable.value: 156 157 159 DeleteErrorInfoTypeImpl error_code = 160 new DeleteErrorInfoTypeImpl(); 161 error_code.error = new UIDType( 162 intt.itu.itut_x780.DeleteErrorConst.moduleName.value, 163 intt.itu.itut_x780.DeleteErrorConst.notDeletable.value); 164 error_code.details = name_str + ExceptionMessages.manager_delete_error; 165 throw new DeleteError(error_code); 166 167 case intt.itu.itut_x780.deleteOnlyIfNoContainedObjects.value: 168 169 171 contained_objects = c_query.getContained(name); 172 173 if (contained_objects.length > 0) { 174 175 DeleteErrorInfoTypeImpl error_contained = 176 new DeleteErrorInfoTypeImpl(); 177 error_contained.error = new UIDType( 178 intt.itu.itut_x780.DeleteErrorConst.moduleName.value, 179 intt.itu.itut_x780.DeleteErrorConst.containsObjects.value); 180 error_contained.details = ExceptionMessages.contains_object_error + 181 ".\n " + name_str + " contains " + 182 contained_objects.length + " children"; 183 throw new DeleteError(error_contained); 184 } 185 186 delete(name, facade); 187 return; 189 190 case intt.itu.itut_x780.deleteContainedObjects.value: 191 192 194 contained_objects = c_query.getContained(name); 195 196 if (contained_objects.length == 0) { 197 delete(name, facade); 198 return; 200 } 201 202 for(int j = 0; j < contained_objects.length; j++) { 203 deleteByName(contained_objects[j]); 204 } 205 delete(name, facade); 206 return; 208 209 default: return; 211 } 212 } 213 214 public void delete(org.omg.CosNaming.NameComponent [] name, 215 intt.itu.itut_x780.ManagedObject_F facade) 216 throws intt.itu.itut_x780.ApplicationError, intt.itu.itut_x780.DeleteError 217 { 218 219 facade.destroy(name); 221 intt.itu.itut_q816.ContainmentComponent c_admin = null; 223 224 if ((c_admin = get_context().get_connection_containment_admin()) == null) { 225 ApplicationErrorInfoTypeImpl error_code = 226 new ApplicationErrorInfoTypeImpl(); 227 error_code.error = new UIDType( 228 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 229 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 230 error_code.details = ExceptionMessages.components_connect_error; 231 System.err.println("Terminator:ContainmentAdmin can not be located!!"); 232 throw new ApplicationError(error_code); 233 } 234 235 c_admin.removeName(name); 236 System.err.println("delete: Successfully removed object " + 237 Utils.name2string(name) + " from its facade and containment service!"); 238 } 239 240 } 241 | Popular Tags |