public static Message getMessage(final Locale language, final MessageReference context) { Object[] contentAsArray = context.getContent().toArray(new Object[0]); return getMessage(language, context.getKey(), contentAsArray); }
public static Message getMessage(final Locale language, final MessageReference context) { Object[] contentAsArray = context.getContent().toArray(new Object[0]); return getMessage(language, context.getKey(), contentAsArray); }
public static Message getMessage(final Locale language, final MessageReference context) { Object[] contentAsArray = context.getContent().toArray(new Object[0]); return getMessage(language, context.getKey(), contentAsArray); }
@Override public String getLocalizedMessage(final MessageReference context, final Throwable exception) { Object[] contentAsArray = context.getContent().toArray(new Object[0]); if (contentAsArray.length == 0 && exception != null) { contentAsArray = new Object[2]; contentAsArray[0] = exception.getStackTrace()[1].getClassName(); contentAsArray[1] = exception.getMessage(); } String value = null; String key = context.getKey(); try { value = getMessage(key); StringBuilder builder = new StringBuilder(); Formatter f = null; if (lanLocale == null) { f = new Formatter(); } else { f = new Formatter(builder, lanLocale); } f.format(value, contentAsArray); f.close(); return builder.toString(); } catch (MissingResourceException e) { return "Missing message for key '" + key + "'!"; } catch (MissingFormatArgumentException e) { return "Missing replacement for place holder in value '" + value + "' for following arguments '" + Arrays.toString(contentAsArray) + "'!"; } }
@Override public String getLocalizedMessage(final MessageReference context, final Throwable exception) { Object[] contentAsArray = context.getContent().toArray(new Object[0]); if (contentAsArray.length == 0 && exception != null) { contentAsArray = new Object[2]; contentAsArray[0] = exception.getStackTrace()[1].getClassName(); contentAsArray[1] = exception.getMessage(); } String value = null; String key = context.getKey(); try { value = getMessage(key); StringBuilder builder = new StringBuilder(); Formatter f = null; if (lanLocale == null) { f = new Formatter(); } else { f = new Formatter(builder, lanLocale); } f.format(value, contentAsArray); f.close(); return builder.toString(); } catch (MissingResourceException e) { return "Missing message for key '" + key + "'!"; } catch (MissingFormatArgumentException e) { return "Missing replacement for place holder in value '" + value + "' for following arguments '" + Arrays.toString(contentAsArray) + "'!"; } }
private static UriSyntaxException convertEdmLiteralException(final EdmLiteralException e) { final MessageReference messageReference = e.getMessageReference(); if (EdmLiteralException.LITERALFORMAT.equals(messageReference)) { return new UriSyntaxException(UriSyntaxException.LITERALFORMAT.addContent(messageReference.getContent()), e); } else if (EdmLiteralException.NOTEXT.equals(messageReference)) { return new UriSyntaxException(UriSyntaxException.NOTEXT.addContent(messageReference.getContent()), e); } else if (EdmLiteralException.UNKNOWNLITERAL.equals(messageReference)) { return new UriSyntaxException(UriSyntaxException.UNKNOWNLITERAL.addContent(messageReference.getContent()), e); } else { return new UriSyntaxException(ODataBadRequestException.COMMON, e); } }
private static UriSyntaxException convertEdmLiteralException(final EdmLiteralException e) { final MessageReference messageReference = e.getMessageReference(); if (EdmLiteralException.LITERALFORMAT.equals(messageReference)) { return new UriSyntaxException(UriSyntaxException.LITERALFORMAT.addContent(messageReference.getContent()), e); } else if (EdmLiteralException.NOTEXT.equals(messageReference)) { return new UriSyntaxException(UriSyntaxException.NOTEXT.addContent(messageReference.getContent()), e); } else if (EdmLiteralException.UNKNOWNLITERAL.equals(messageReference)) { return new UriSyntaxException(UriSyntaxException.UNKNOWNLITERAL.addContent(messageReference.getContent()), e); } else { return new UriSyntaxException(ODataBadRequestException.COMMON, e); } }
private static UriSyntaxException convertEdmLiteralException(final EdmLiteralException e) { final MessageReference messageReference = e.getMessageReference(); if (EdmLiteralException.LITERALFORMAT.equals(messageReference)) { return new UriSyntaxException(UriSyntaxException.LITERALFORMAT.addContent(messageReference.getContent()), e); } else if (EdmLiteralException.NOTEXT.equals(messageReference)) { return new UriSyntaxException(UriSyntaxException.NOTEXT.addContent(messageReference.getContent()), e); } else if (EdmLiteralException.UNKNOWNLITERAL.equals(messageReference)) { return new UriSyntaxException(UriSyntaxException.UNKNOWNLITERAL.addContent(messageReference.getContent()), e); } else { return new UriSyntaxException(ODataBadRequestException.COMMON, e); } }
private static String createEntryKey(final EntityInfoAggregator entityInfo, final Map<String, Object> data) throws EntityProviderException { final List<EntityPropertyInfo> keyPropertyInfos = entityInfo.getKeyPropertyInfos(); StringBuilder keys = new StringBuilder(); for (final EntityPropertyInfo keyPropertyInfo : keyPropertyInfos) { if (keys.length() > 0) { keys.append(','); } final String name = keyPropertyInfo.getName(); if (keyPropertyInfos.size() > 1) { keys.append(Encoder.encode(name)).append('='); } final EdmSimpleType type = (EdmSimpleType) keyPropertyInfo.getType(); try { keys.append(Encoder.encode(type.valueToString(data.get(name), EdmLiteralKind.URI, keyPropertyInfo.getFacets()))); } catch (final EdmSimpleTypeException e) { throw new EntityProviderProducerException( EdmSimpleTypeException.getMessageReference(e.getMessageReference()). updateContent(e.getMessageReference().getContent(), name), e); } } return keys.toString(); }
private static String createEntryKey(final EntityInfoAggregator entityInfo, final Map<String, Object> data) throws EntityProviderException { final List<EntityPropertyInfo> keyPropertyInfos = entityInfo.getKeyPropertyInfos(); StringBuilder keys = new StringBuilder(); for (final EntityPropertyInfo keyPropertyInfo : keyPropertyInfos) { if (keys.length() > 0) { keys.append(','); } final String name = keyPropertyInfo.getName(); if (keyPropertyInfos.size() > 1) { keys.append(Encoder.encode(name)).append('='); } final EdmSimpleType type = (EdmSimpleType) keyPropertyInfo.getType(); try { keys.append(Encoder.encode(type.valueToString(data.get(name), EdmLiteralKind.URI, keyPropertyInfo.getFacets()))); } catch (final EdmSimpleTypeException e) { throw new EntityProviderProducerException( EdmSimpleTypeException.getMessageReference(e.getMessageReference()). updateContent(e.getMessageReference().getContent(), name), e); } } return keys.toString(); }
throw new EntityProviderProducerException( EdmSimpleTypeException.getMessageReference(e.getMessageReference()). updateContent(e.getMessageReference().getContent(), titleInfo.getName()), e);
} catch (EdmSimpleTypeException e) { throw new EntityProviderProducerException(EdmSimpleTypeException.getMessageReference( e.getMessageReference()).updateContent(e.getMessageReference().getContent(), titleInfo.getName()), e);
throw new EntityProviderProducerException( EdmSimpleTypeException.getMessageReference(e.getMessageReference()). updateContent(e.getMessageReference().getContent(), name), e);
String getUpdatedString(final EntityInfoAggregator eia, final Map<String, Object> data) throws EdmSimpleTypeException, EntityProviderProducerException { Object updateDate = null; EdmFacets updateFacets = null; EntityPropertyInfo updatedInfo = eia.getTargetPathInfo(EdmTargetPath.SYNDICATION_UPDATED); if (updatedInfo != null) { updateDate = data.get(updatedInfo.getName()); if (updateDate != null) { updateFacets = updatedInfo.getFacets(); } } if (updateDate == null) { updateDate = new Date(); } try { return EdmDateTimeOffset.getInstance().valueToString(updateDate, EdmLiteralKind.DEFAULT, updateFacets); } catch (final EdmSimpleTypeException e) { throw new EntityProviderProducerException( EdmSimpleTypeException.getMessageReference(e.getMessageReference()). updateContent(e.getMessageReference().getContent(), updatedInfo == null ? null : updatedInfo.getName()), e); } }
String getUpdatedString(final EntityInfoAggregator eia, final Map<String, Object> data) throws EdmSimpleTypeException, EntityProviderProducerException { Object updateDate = null; EdmFacets updateFacets = null; EntityPropertyInfo updatedInfo = eia.getTargetPathInfo(EdmTargetPath.SYNDICATION_UPDATED); if (updatedInfo != null) { updateDate = data.get(updatedInfo.getName()); if (updateDate != null) { updateFacets = updatedInfo.getFacets(); } } if (updateDate == null) { updateDate = new Date(); } try { return EdmDateTimeOffset.getInstance().valueToString(updateDate, EdmLiteralKind.DEFAULT, updateFacets); } catch (final EdmSimpleTypeException e) { throw new EntityProviderProducerException( EdmSimpleTypeException.getMessageReference(e.getMessageReference()). updateContent(e.getMessageReference().getContent(), updatedInfo != null ? updatedInfo.getName() : null), e); } }
String getUpdatedString(final EntityInfoAggregator eia, final Map<String, Object> data) throws EdmSimpleTypeException, EntityProviderProducerException { Object updateDate = null; EdmFacets updateFacets = null; EntityPropertyInfo updatedInfo = eia.getTargetPathInfo(EdmTargetPath.SYNDICATION_UPDATED); if (updatedInfo != null) { updateDate = data.get(updatedInfo.getName()); if (updateDate != null) { updateFacets = updatedInfo.getFacets(); } } if (updateDate == null) { updateDate = new Date(); } try { return EdmDateTimeOffset.getInstance().valueToString(updateDate, EdmLiteralKind.DEFAULT, updateFacets); } catch (final EdmSimpleTypeException e) { throw new EntityProviderProducerException( EdmSimpleTypeException.getMessageReference(e.getMessageReference()). updateContent(e.getMessageReference().getContent(), updatedInfo != null ? updatedInfo.getName() : null), e); } }
private String getTargetPathValue(final EntityInfoAggregator eia, final String targetPath, final Map<String, Object> data) throws EntityProviderException { EntityPropertyInfo info = null; try { info = eia.getTargetPathInfo(targetPath); if (info != null) { EdmSimpleType type = (EdmSimpleType) info.getType(); Object value = data.get(info.getName()); return type.valueToString(value, EdmLiteralKind.DEFAULT, info.getFacets()); } return null; } catch (final EdmSimpleTypeException e) { throw new EntityProviderProducerException( EdmSimpleTypeException.getMessageReference(e.getMessageReference()). updateContent(e.getMessageReference().getContent(), info.getName()), e); } }
private String getTargetPathValue(final EntityInfoAggregator eia, final String targetPath, final Map<String, Object> data) throws EntityProviderException { EntityPropertyInfo info = null; try { info = eia.getTargetPathInfo(targetPath); if (info != null) { EdmSimpleType type = (EdmSimpleType) info.getType(); Object value = data.get(info.getName()); return type.valueToString(value, EdmLiteralKind.DEFAULT, info.getFacets()); } return null; } catch (final EdmSimpleTypeException e) { throw new EntityProviderProducerException( EdmSimpleTypeException.getMessageReference(e.getMessageReference()). updateContent(e.getMessageReference().getContent(), info.getName()), e); } }
private String getTargetPathValue(final EntityInfoAggregator eia, final String targetPath, final Map<String, Object> data) throws EntityProviderException { EntityPropertyInfo info = null; try { info = eia.getTargetPathInfo(targetPath); if (info != null) { EdmSimpleType type = (EdmSimpleType) info.getType(); Object value = data.get(info.getName()); return type.valueToString(value, EdmLiteralKind.DEFAULT, info.getFacets()); } return null; } catch (final EdmSimpleTypeException e) { throw new EntityProviderProducerException( EdmSimpleTypeException.getMessageReference(e.getMessageReference()). updateContent(e.getMessageReference().getContent(), info.getName()), e); } }
} catch (EdmSimpleTypeException e) { throw new EntityProviderProducerException(EdmSimpleTypeException.getMessageReference( e.getMessageReference()).updateContent(e.getMessageReference().getContent(), propertyName), e);