@Override public void onNotFound(BrooklynObjectType type, String id) { if (creationFailedIds.contains(id)) { // already know about this; ignore } else { String errmsg = type.toCamelCase()+" '"+id+"' not found"; exceptions.add(new IllegalStateException(errmsg)); onErrorImpl(errmsg); } }
public Builder putType(BrooklynObjectType type, String id, String javaType) { switch (type) { case ENTITY: throw new IllegalArgumentException(type.toCamelCase()+" requires additional parameters"); case LOCATION: return location(id, javaType); case POLICY: return policy(id, javaType); case ENRICHER: return enricher(id, javaType); case FEED: return feed(id, javaType); case CATALOG_ITEM: case MANAGED_BUNDLE: throw new IllegalArgumentException(type.toCamelCase()+" requires different parameters"); case UNKNOWN: default: throw new IllegalArgumentException(type.toCamelCase()+" not supported"); } }
@Override public void onManageFailed(BrooklynObjectType type, BrooklynObject instance, Exception e) { Exceptions.propagateIfFatal(e); String errmsg = "problem managing "+type.toCamelCase()+" "+instance.getId()+" ("+instance+")"; exceptions.add(new IllegalStateException(errmsg, e)); onErrorImpl(errmsg, e); }
@Override public void onLoadMementoFailed(BrooklynObjectType type, String msg, Exception e) { loadMementoFailures.add(new IllegalStateException("problem loading "+type.toCamelCase()+" memento: "+msg, e)); super.onLoadMementoFailed(type, msg, e); }
@Override public void onRebindFailed(BrooklynObjectType type, BrooklynObject instance, Exception e) { Exceptions.propagateIfFatal(e); String errmsg = "problem rebinding "+type.toCamelCase()+" "+instance.getId()+" ("+instance+")"; switch (type) { case FEED: case ENRICHER: case POLICY: switch (addPolicyFailureMode) { case FAIL_FAST: throw new IllegalStateException("Rebind: aborting due to "+errmsg, e); case FAIL_AT_END: addPolicyFailures.add(new IllegalStateException(errmsg, e)); break; case CONTINUE: warn(errmsg+"; continuing", e); creationFailedIds.add(instance.getId()); break; default: throw new IllegalStateException("Unexpected state '"+addPolicyFailureMode+"' for addPolicyFailureMode"); } break; default: exceptions.add(new IllegalStateException(errmsg, e)); onErrorImpl(errmsg, e); break; } }
@Override public void visit(BrooklynObjectType type, String objectId, String contents) throws Exception { try { Memento memento = (Memento) getSerializerWithCustomClassLoader(lookupContext, type, objectId).fromString(contents); if (memento == null) { LOG.warn("No "+type.toCamelCase()+"-memento deserialized from " + objectId + "; ignoring and continuing"); } else { builder.memento(memento); } } catch (Exception e) { exceptionHandler.onLoadMementoFailed(type, "memento "+objectId+" deserialization error", e); } }
String xmlId = (String) XmlUtil.xpathHandlingIllegalChars(contents, "/"+type.toCamelCase()+"/id"); String safeXmlId = Strings.makeValidFilename(xmlId); if (!Objects.equal(id, safeXmlId)) LOG.warn("ID mismatch on "+type.toCamelCase()+", "+id+" from path, "+safeXmlId+" from xml");
@Override public void onManageFailed(BrooklynObjectType type, BrooklynObject instance, Exception e) { manageFailures.put(instance, new IllegalStateException("problem managing "+type.toCamelCase()+" "+instance.getId()+" ("+instance+")", e)); super.onManageFailed(type, instance, e); }
@Override public void onRebindFailed(BrooklynObjectType type, BrooklynObject instance, Exception e) { rebindFailures.put(instance, new IllegalStateException("problem rebinding "+type.toCamelCase()+" "+instance.getId()+" ("+instance+")", e)); super.onRebindFailed(type, instance, e); }
@Override public void visit(BrooklynObjectType type, String objectId, final String contents) throws Exception { XPathHelper x = new XPathHelper(contents, "/"+type.toCamelCase()+"/"); switch (type) { case ENTITY: CatalogItemMemento memento = (CatalogItemMemento) getSerializerWithStandardClassLoader().fromString(contents); if (memento == null) { LOG.warn("No "+type.toCamelCase()+"-memento deserialized from " + objectId + "; ignoring and continuing"); } else { builder.catalogItem(memento);