Changeset 1353
- Timestamp:
- 03/08/07 19:09:12 (21 months ago)
- Location:
- trunk/components/blitz/src
- Files:
-
- 3 modified
-
ome/services/icy/impl/Interceptor.java (modified) (1 diff)
-
ome/services/icy/util/IceMethodInvoker.java (modified) (5 diffs)
-
omero/util/IceMapper.java (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/components/blitz/src/ome/services/icy/impl/Interceptor.java
r1306 r1353 103 103 104 104 public Object invoke(MethodInvocation mi) throws Throwable { 105 106 Object retVal = null; 107 try { 108 Object[] args = mi.getArguments(); 109 Ice.Current __current = (Ice.Current) args[args.length-1]; 110 Object[] strippedArgs = strip(args); 105 111 106 Object[] args = mi.getArguments();107 Ice.Current __current = (Ice.Current) args[args.length-1];108 Object[] strippedArgs = strip(args);109 110 IceMapper mapper = new IceMapper();111 ServiceInterface service = servantHelper.getService(key,__current);112 Object retVal = invoker.invoke(service, __current, mapper, strippedArgs);112 IceMapper mapper = new IceMapper(); 113 ServiceInterface service = servantHelper.getService(key,__current); 114 retVal = invoker.invoke(service, __current, mapper, strippedArgs); 115 } catch (Throwable t) { 116 t.printStackTrace(); 117 throw t; 118 } 113 119 servantHelper.throwIfNecessary(retVal); 114 120 return retVal; -
trunk/components/blitz/src/ome/services/icy/util/IceMethodInvoker.java
r1312 r1353 3 3 import java.io.PrintWriter; 4 4 import java.io.StringWriter; 5 import java.lang.reflect.InvocationTargetException; 5 6 import java.lang.reflect.Method; 7 import java.util.ArrayList; 6 8 import java.util.Collection; 7 9 import java.util.Collections; … … 151 153 Object arg = args[i]; 152 154 objs[i] = handleInput(mapper, p, arg); 153 if (null != objs[i] && !isPrimitive(p) && // FIXME need way to check autoboxing. 154 !p.isAssignableFrom(objs[i].getClass())) { 155 throw new IllegalStateException(String.format( 156 "Cannot assign %s to %s",objs[i],p)); 157 } 155 // This check duplicates what should be in handleInput 156 // if (null != objs[i] && !isPrimitive(p) && // FIXME need way to check autoboxing. 157 // !p.isAssignableFrom(objs[i].getClass())) { 158 // throw new IllegalStateException(String.format( 159 // "Cannot assign %s to %s",objs[i],p)); 160 // } 158 161 } 159 162 … … 215 218 return mapper.convert((omero.sys.Parameters) arg); 216 219 } else if (List.class.isAssignableFrom(p)) { 217 return mapper.reverse( new HashSet((List) arg)); // Necessary since Ice doesn't support Sets.220 return mapper.reverse((Collection) arg); 218 221 } else if (Set.class.isAssignableFrom(p)) { 219 return mapper.reverse( (Collection) arg);222 return mapper.reverse(new HashSet((Collection) arg)); // Necessary since Ice doesn't support Sets. 220 223 } else if (Map.class.isAssignableFrom(p)) { 221 224 return mapper.reverse((Map) arg); … … 241 244 } else if (EventContext.class.isAssignableFrom(type)) { 242 245 return mapper.convert((EventContext)o); 246 } else if (Set.class.isAssignableFrom(type)) { 247 return mapper.map(new ArrayList((Set)o)); // Necessary since Ice doesn't support Sets. 243 248 } else if (Collection.class.isAssignableFrom(type)) { 244 249 return mapper.map((Collection) o); … … 254 259 protected Ice.UserException handleException(Throwable t) { 255 260 261 // Getting rid of the reflection wrapper. 262 if (InvocationTargetException.class.isAssignableFrom(t.getClass())) { 263 t = t.getCause(); 264 } 265 256 266 if (log.isInfoEnabled()) { 257 267 log.info("Handling:", t); 258 268 } 259 269 260 270 Class c = t.getClass(); 261 271 if (ome.conditions.ValidationException.class.isAssignableFrom(c)) { -
trunk/components/blitz/src/omero/util/IceMapper.java
r1312 r1353 13 13 import java.lang.reflect.InvocationTargetException; 14 14 import java.lang.reflect.Method; 15 import java.sql.Timestamp; 15 16 import java.util.ArrayList; 16 17 import java.util.Collection; … … 176 177 } 177 178 178 public staticome.parameters.Parameters convert(Parameters params)179 public ome.parameters.Parameters convert(Parameters params) 179 180 throws ApiUsageException { 180 181 … … 182 183 183 184 ome.parameters.Parameters p = new ome.parameters.Parameters(); 184 if (params. p != null) {185 for (Object obj : params. p.values()) {185 if (params.map != null) { 186 for (Object obj : params.map.values()) { 186 187 QueryParam qp = (QueryParam) obj; 187 188 p.add(convert(qp)); 188 189 } 189 190 } 191 if (params.filt != null) { 192 p.setFilter(convert(params.filt)); 193 } 190 194 return p; 191 195 } 192 196 193 public staticome.parameters.QueryParameter convert(QueryParam qParam)197 public ome.parameters.QueryParameter convert(QueryParam qParam) 194 198 throws ApiUsageException { 195 199 … … 229 233 klass = Class.class; 230 234 break; 231 case Type._objectType: // Not currently supported 235 case Type._timeType: 236 omero.RTime rt = qParam.timeVal; 237 value = (rt == null ? null : rt._null ? null : new Timestamp(rt.val.val)); 238 klass = Timestamp.class; 239 break; 240 case Type._objectType: 241 omero.RObject ro = qParam.objectVal; 242 value = (ro == null ? null : ro._null ? null : reverse(ro.val)); 243 klass = IObject.class; 244 break; 232 245 default: 233 246 throw new IllegalArgumentException("Unknown type code:" + t); … … 284 297 } 285 298 286 public Object reverse(Object source) {299 public Object reverse(Object source) throws ApiUsageException { 287 300 if (source == null) { 288 301 return null; … … 293 306 } else if (isImmutable(source)) { 294 307 return source; 308 } else if (QueryParam.class.isAssignableFrom(source.getClass())) { 309 return convert((QueryParam)source); 295 310 } else { 296 311 throw new IllegalArgumentException("Don't know how to reverse "+source); … … 325 340 } 326 341 target2model.put(source, target); 327 for (Object object : source) { 328 target.add(reverse(object)); 342 try { 343 for (Object object : source) { 344 target.add(reverse(object)); 345 } 346 } catch (ApiUsageException aue) { // FIXME reverse can't throw ServerErrors! 347 convertAndThrow(aue); 329 348 } 330 349 } 331 350 return target; 332 351 } 333 352 334 353 public Map reverse(Map map) { 354 if (map == null) return null; 335 355 Map<Object, Object> target = new HashMap<Object, Object>(); 336 for (Object key : map.keySet()) { 337 Object value = map.get(key); 338 Object targetKey = reverse(key); 339 Object targetValue = reverse(value); 340 target.put(targetKey, targetValue); 356 try { 357 for (Object key : map.keySet()) { 358 Object value = map.get(key); 359 Object targetKey = reverse(key); 360 Object targetValue = reverse(value); 361 target.put(targetKey, targetValue); 362 } 363 } catch (ApiUsageException aue) { 364 convertAndThrow(aue); 341 365 } 342 366 return target; … … 405 429 } 406 430 431 private void convertAndThrow(ApiUsageException aue) { 432 InternalException ie = new InternalException(aue.getMessage()); 433 ie.setStackTrace(aue.getStackTrace()); 434 } 435 407 436 }
