public MetadataType getOutputType(MetadataContext context, String key) throws MetadataResolvingException { throw new MetadataResolvingException("Failing keysResolver retriever", FailureCode.CONNECTION_FAILURE); } }
public Set<MetadataKey> getKeys(MetadataContext context) throws MetadataResolvingException { throw new MetadataResolvingException("Failing keysResolver retriever", FailureCode.CONNECTION_FAILURE); }
public MetadataType getInputMetadata(MetadataContext context, String key) throws MetadataResolvingException { throw new MetadataResolvingException("Failing keysResolver retriever", FailureCode.CONNECTION_FAILURE); }
private MetadataResolvingException buildException(String message, Exception cause) { return cause == null ? new MetadataResolvingException(message, INVALID_METADATA_KEY) : new MetadataResolvingException(message, INVALID_METADATA_KEY, cause); }
ForwardingSoapClient getConnection(MetadataContext context) throws MetadataResolvingException, ConnectionException { return context.<ForwardingSoapClient>getConnection() .orElseThrow(() -> new MetadataResolvingException("Cannot obtain connection", CONNECTION_FAILURE)); } }
@Override public MetadataType getInputMetadata(MetadataContext context, Boolean key) throws MetadataResolvingException, ConnectionException { if (key) { return loader.load(SwordFish.class); } throw new MetadataResolvingException("false key", INVALID_METADATA_KEY); } }
private void checkLocationKey(LocationKey key) throws MetadataResolvingException { boolean injectedProperly = key != null && key.getContinent().equals(AMERICA) && key.getCountry().equals(USA) && key.getCity().equals(SAN_FRANCISCO); if (!injectedProperly) { throw new MetadataResolvingException(ERROR_MESSAGE, FailureCode.INVALID_METADATA_KEY); } } }
@Override public MetadataType getInputMetadata(MetadataContext context, AnimalClade key) throws MetadataResolvingException, ConnectionException { switch (key) { case MAMMAL: return loader.load(Bear.class); case FISH: return loader.load(SwordFish.class); default: throw new MetadataResolvingException("Cannot identify animal", INVALID_METADATA_KEY); } } }
@Override public MetadataType getInputMetadata(MetadataContext context, String key) throws MetadataResolvingException, ConnectionException { MetadataCache cache = context.getCache(); Optional<? extends Serializable> element = cache.get(BRAND); if (!element.isPresent()) { throw new MetadataResolvingException(MISSING_ELEMENT_ERROR_MESSAGE, FailureCode.RESOURCE_UNAVAILABLE); } return buildMetadataType((String) element.get()); }
@Override public MetadataType getEntityMetadata(MetadataContext context, String key) throws MetadataResolvingException, ConnectionException { switch (key) { case CIRCLE: return LOADER.load(Circle.class); case SQUARE: return LOADER.load(Square.class); default: throw new MetadataResolvingException("Invalid metadata key: " + key, INVALID_METADATA_KEY); } }
private MetadataContext getMetadataContext(MetadataCache cache) throws MetadataResolvingException { CoreEvent fakeEvent = null; try { fakeEvent = getInitialiserEvent(muleContext); Optional<ConfigurationInstance> configuration = getConfiguration(fakeEvent); if (configuration.isPresent()) { ConfigurationProvider configurationProvider = findConfigurationProvider() .orElseThrow(() -> new MetadataResolvingException("Failed to create the required configuration for Metadata retrieval", INVALID_CONFIGURATION)); if (configurationProvider instanceof DynamicConfigurationProvider) { throw new MetadataResolvingException("Configuration used for Metadata fetch cannot be dynamic", INVALID_CONFIGURATION); } } return new DefaultMetadataContext(() -> configuration, connectionManager, cache, typeLoader); } finally { if (fakeEvent != null) { ((BaseEventContext) fakeEvent.getContext()).success(); } } }
private MetadataType wrapInMessageType(MetadataType type, Object key, MetadataContext context, Optional<MetadataType> staticAttributes) throws MetadataResolvingException { MessageMetadataTypeBuilder message = new MessageMetadataTypeBuilder().payload(type); staticAttributes.ifPresent(message::attributes); if (((HasOutputModel) component).getOutputAttributes().hasDynamicType()) { MetadataResult<MetadataType> attributes = resolveOutputAttributesMetadata(context, key, Objects::nonNull); if (!attributes.isSuccess()) { throw new MetadataResolvingException("Could not resolve attributes of List<Message> output", attributes.getFailures().stream() .map(MetadataFailure::getFailureCode) .findFirst() .orElse(UNKNOWN)); } message.attributes(attributes.get()); } return message.build(); }
throw new MetadataResolvingException("Could not construct Metadata Key part for parameter " + p.getName(), FailureCode.INVALID_METADATA_KEY, e);
@Override public MetadataKey resolveChilds(MetadataContext context, LocationKey partial) throws MetadataResolvingException, ConnectionException { // This is incomplete but you get the idea if (AMERICA.equalsIgnoreCase(partial.getContinent())) { if (ARGENTINA.equalsIgnoreCase(partial.getCountry())) { return newKey(AMERICA).withDisplayName(AMERICA) .withChild(newKey(ARGENTINA) .withChild(newKey(BUENOS_AIRES)) .withChild(newKey(LA_PLATA))) .build(); } return buildAmericaKey(); } else if (EUROPE.equalsIgnoreCase(partial.getContinent())) { return buildEuropeKey(); } else { throw new MetadataResolvingException("Invalid Continent", FailureCode.INVALID_METADATA_KEY); } }
public MetadataType getOutputType(MetadataContext context, String key) throws MetadataResolvingException { throw new MetadataResolvingException("Failing keysResolver retriever", FailureCode.CONNECTION_FAILURE); } }
public MetadataType getInputMetadata(MetadataContext context, String key) throws MetadataResolvingException { throw new MetadataResolvingException("Failing keysResolver retriever", FailureCode.CONNECTION_FAILURE); }
@Override public MetadataType getInputMetadata(MetadataContext context, Boolean key) throws MetadataResolvingException, ConnectionException { if (key) { return loader.load(SwordFish.class); } throw new MetadataResolvingException("false key", INVALID_METADATA_KEY); } }
MetadataType buildPartMetadataType(Part part) throws MetadataResolvingException { if (part.getElementName() != null) { String partName = part.getElementName().toString(); return loader.load(partName) .orElseThrow(() -> new MetadataResolvingException(format("Could not load part element name [%s]", partName), UNKNOWN)); } throw new MetadataResolvingException("Trying to resolve metadata for a nameless part, probably the provided WSDL is invalid", INVALID_CONFIGURATION); }
@Override public MetadataType getInputMetadata(MetadataContext context, String key) throws MetadataResolvingException, ConnectionException { MetadataCache cache = context.getCache(); Optional<? extends Serializable> element = cache.get(BRAND); if (!element.isPresent()) { throw new MetadataResolvingException(MISSING_ELEMENT_ERROR_MESSAGE, FailureCode.RESOURCE_UNAVAILABLE); } return buildMetadataType((String) element.get()); }
public static MetadataType getMetadata(String key) throws MetadataResolvingException { final ObjectTypeBuilder objectBuilder = BaseTypeBuilder.create(JAVA).objectType(); switch (key) { case MetadataConnection.CAR: objectBuilder.addField().key(TIRES).value().numberType(); objectBuilder.addField().key(BRAND).value().stringType(); break; case MetadataConnection.HOUSE: objectBuilder.addField().key(DIRECTION).value().stringType(); objectBuilder.addField().key(SIZE).value().numberType(); break; case MetadataConnection.PERSON: objectBuilder.addField().key(NAME).value().stringType(); objectBuilder.addField().key(AGE).value().numberType(); break; case MetadataConnection.NULL: return BaseTypeBuilder.create(JAVA).nullType().build(); case MetadataConnection.VOID: return BaseTypeBuilder.create(JAVA).voidType().build(); default: throw new MetadataResolvingException("Unknown key " + key, INVALID_METADATA_KEY); } return objectBuilder.build(); }