@Override public UriHelper createUriHelper() { return new UriHelperImpl(); }
@Override public UriHelper createUriHelper() { return new UriHelperImpl(); }
/** * Get the ascii representation of the entity id * or thrown an {@link SerializerException} if id is <code>null</code>. * * @param entity the entity * @param entityType the entity Type * @param name the entity name * @return ascii representation of the entity id */ private String getEntityId(Entity entity, EdmEntityType entityType, String name) throws SerializerException { if(entity.getId() == null) { if((entity == null || entityType == null || entityType.getKeyPredicateNames() == null || name == null)) { throw new SerializerException("Entity id is null.", SerializerException.MessageKeys.MISSING_ID); }else{ final UriHelper uriHelper = new UriHelperImpl(); entity.setId(URI.create(name + '(' + uriHelper.buildKeyPredicate(entityType, entity) + ')')); } } return entity.getId().toASCIIString(); }
/** * Get the ascii representation of the entity id * or thrown an {@link SerializerException} if id is <code>null</code>. * * @param entity the entity * @param entityType * @param name * @return ascii representation of the entity id */ private String getEntityId(Entity entity, EdmEntityType entityType, String name) throws SerializerException { if(entity != null && entity.getId() == null) { if(entityType == null || entityType.getKeyPredicateNames() == null || name == null) { throw new SerializerException("Entity id is null.", SerializerException.MessageKeys.MISSING_ID); }else{ final UriHelper uriHelper = new UriHelperImpl(); entity.setId(URI.create(name + '(' + uriHelper.buildKeyPredicate(entityType, entity) + ')')); } } return entity.getId().toASCIIString(); }
/** * Get the ascii representation of the entity id * or thrown an {@link SerializerException} if id is <code>null</code>. * * @param entity the entity * @param entityType * @param name * @return ascii representation of the entity id */ private String getEntityId(Entity entity, EdmEntityType entityType, String name) throws SerializerException { if(entity != null && entity.getId() == null) { if(entityType == null || entityType.getKeyPredicateNames() == null || name == null) { throw new SerializerException("Entity id is null.", SerializerException.MessageKeys.MISSING_ID); }else{ final UriHelper uriHelper = new UriHelperImpl(); entity.setId(URI.create(name + '(' + uriHelper.buildKeyPredicate(entityType, entity) + ')')); } } return entity.getId().toASCIIString(); }
/** * Get the ascii representation of the entity id * or thrown an {@link SerializerException} if id is <code>null</code>. * * @param entity the entity * @param entityType the entity Type * @param name the entity name * @return ascii representation of the entity id */ private String getEntityId(Entity entity, EdmEntityType entityType, String name) throws SerializerException { if(entity.getId() == null) { if((entity == null || entityType == null || entityType.getKeyPredicateNames() == null || name == null)) { throw new SerializerException("Entity id is null.", SerializerException.MessageKeys.MISSING_ID); }else{ final UriHelper uriHelper = new UriHelperImpl(); entity.setId(URI.create(name + '(' + uriHelper.buildKeyPredicate(entityType, entity) + ')')); } } return entity.getId().toASCIIString(); }
@Override public SerializerResult reference(final ServiceMetadata metadata, final EdmEntitySet edmEntitySet, final Entity entity, final ReferenceSerializerOptions options) throws SerializerException { OutputStream outputStream = null; SerializerException cachedException = null; try { final ContextURL contextURL = checkContextURL(options == null ? null : options.getContextURL()); CircleStreamBuffer buffer = new CircleStreamBuffer(); final UriHelper uriHelper = new UriHelperImpl(); outputStream = buffer.getOutputStream(); final JsonGenerator json = new JsonFactory().createGenerator(outputStream); json.writeStartObject(); writeContextURL(contextURL, json); json.writeStringField(constants.getId(), uriHelper.buildCanonicalURL(edmEntitySet, entity)); json.writeEndObject(); json.close(); outputStream.close(); return SerializerResultImpl.with().content(buffer.getInputStream()).build(); } catch (final IOException e) { cachedException = new SerializerException(IO_EXCEPTION_TEXT, e, SerializerException.MessageKeys.IO_EXCEPTION); throw cachedException; } finally { closeCircleStreamBufferOutput(outputStream, cachedException); } }
/** * Get the ascii representation of the entity id * or thrown an {@link SerializerException} if id is <code>null</code>. * * @param entity the entity * @return ascii representation of the entity id */ private String getEntityId(Entity entity, EdmEntityType entityType, String name) throws SerializerException { try { if (entity != null) { if (entity.getId() == null) { if (entityType == null || entityType.getKeyPredicateNames() == null || name == null) { throw new SerializerException("Entity id is null.", SerializerException.MessageKeys.MISSING_ID); } else { final UriHelper uriHelper = new UriHelperImpl(); entity.setId(URI.create(name + '(' + uriHelper.buildKeyPredicate(entityType, entity) + ')')); return entity.getId().toASCIIString(); } } else { return entity.getId().toASCIIString(); } } return null; } catch (Exception e) { throw new SerializerException("Entity id is null.", SerializerException.MessageKeys.MISSING_ID); } }
@Override public SerializerResult reference(final ServiceMetadata metadata, final EdmEntitySet edmEntitySet, final Entity entity, final ReferenceSerializerOptions options) throws SerializerException { OutputStream outputStream = null; SerializerException cachedException = null; try { final ContextURL contextURL = checkContextURL(options == null ? null : options.getContextURL()); CircleStreamBuffer buffer = new CircleStreamBuffer(); final UriHelper uriHelper = new UriHelperImpl(); outputStream = buffer.getOutputStream(); final JsonGenerator json = new JsonFactory().createGenerator(outputStream); json.writeStartObject(); writeContextURL(contextURL, json); json.writeStringField(constants.getId(), uriHelper.buildCanonicalURL(edmEntitySet, entity)); json.writeEndObject(); json.close(); outputStream.close(); return SerializerResultImpl.with().content(buffer.getInputStream()).build(); } catch (final IOException e) { cachedException = new SerializerException(IO_EXCEPTION_TEXT, e, SerializerException.MessageKeys.IO_EXCEPTION); throw cachedException; } finally { closeCircleStreamBufferOutput(outputStream, cachedException); } }
/** * Get the ascii representation of the entity id * or thrown an {@link SerializerException} if id is <code>null</code>. * * @param entity the entity * @return ascii representation of the entity id */ private String getEntityId(Entity entity, EdmEntityType entityType, String name) throws SerializerException { try { if (entity != null) { if (entity.getId() == null) { if (entityType == null || entityType.getKeyPredicateNames() == null || name == null) { throw new SerializerException("Entity id is null.", SerializerException.MessageKeys.MISSING_ID); } else { final UriHelper uriHelper = new UriHelperImpl(); entity.setId(URI.create(name + '(' + uriHelper.buildKeyPredicate(entityType, entity) + ')')); return entity.getId().toASCIIString(); } } else { return entity.getId().toASCIIString(); } } return null; } catch (Exception e) { throw new SerializerException("Entity id is null.", SerializerException.MessageKeys.MISSING_ID); } }
/** * Get the ascii representation of the entity id * or thrown an {@link SerializerException} if id is <code>null</code>. * * @param entity the entity * @return ascii representation of the entity id */ private String getEntityId(Entity entity, EdmEntityType entityType, String name) throws SerializerException { try { if (entity != null) { if (entity.getId() == null) { if (entityType == null || entityType.getKeyPredicateNames() == null || name == null) { throw new SerializerException("Entity id is null.", SerializerException.MessageKeys.MISSING_ID); } else { final UriHelper uriHelper = new UriHelperImpl(); entity.setId(URI.create(name + '(' + uriHelper.buildKeyPredicate(entityType, entity) + ')')); return entity.getId().toASCIIString(); } } else { return entity.getId().toASCIIString(); } } return null; } catch (Exception e) { throw new SerializerException("Entity id is null.", SerializerException.MessageKeys.MISSING_ID); } }
/** * Get the ascii representation of the entity id * or thrown an {@link SerializerException} if id is <code>null</code>. * * @param entity the entity * @return ascii representation of the entity id */ private String getEntityId(Entity entity, EdmEntityType entityType, String name) throws SerializerException { try { if (entity != null) { if (entity.getId() == null) { if (entityType == null || entityType.getKeyPredicateNames() == null || name == null) { throw new SerializerException("Entity id is null.", SerializerException.MessageKeys.MISSING_ID); } else { final UriHelper uriHelper = new UriHelperImpl(); entity.setId(URI.create(name + '(' + uriHelper.buildKeyPredicate(entityType, entity) + ')')); return entity.getId().toASCIIString(); } } else { return entity.getId().toASCIIString(); } } return null; } catch (Exception e) { throw new SerializerException("Entity id is null.", SerializerException.MessageKeys.MISSING_ID); } }
final ContextURL contextURL = checkContextURL(options == null ? null : options.getContextURL()); CircleStreamBuffer buffer = new CircleStreamBuffer(); final UriHelper uriHelper = new UriHelperImpl(); outputStream = buffer.getOutputStream(); final JsonGenerator json = new JsonFactory().createGenerator(outputStream);
final ContextURL contextURL = checkContextURL(options == null ? null : options.getContextURL()); CircleStreamBuffer buffer = new CircleStreamBuffer(); final UriHelper uriHelper = new UriHelperImpl(); outputStream = buffer.getOutputStream(); final JsonGenerator json = new JsonFactory().createGenerator(outputStream);