java.lang.Object
org.refcodes.hal.HalClientImpl
- All Implemented Interfaces:
HalClient,org.refcodes.web.OauthTokenAccessor,org.refcodes.web.OauthTokenAccessor.OauthTokenBuilder<HalClient>,org.refcodes.web.OauthTokenAccessor.OauthTokenMutator,org.refcodes.web.OauthTokenAccessor.OauthTokenProperty
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.refcodes.web.OauthTokenAccessor
org.refcodes.web.OauthTokenAccessor.OauthTokenBuilder<B extends org.refcodes.web.OauthTokenAccessor.OauthTokenBuilder<B>>, org.refcodes.web.OauthTokenAccessor.OauthTokenMutator, org.refcodes.web.OauthTokenAccessor.OauthTokenProperty -
Constructor Summary
ConstructorsConstructorDescriptionHalClientImpl(String aHalUrl) Instantiates theHalClientwith no authorization credentials passed.HalClientImpl(String aHalUrl, String aOauthUrl, String aOauthClientId, String aOauthClientSecret, String aOauthUserName, String aOauthUserSecret) Instantiates theHalClientwith no authorization credentials passed.HalClientImpl(String aHalUrl, org.refcodes.web.OauthToken aOauthToken) Instantiates theHalClientwith a validOauthTokenpassed.HalClientImpl(org.refcodes.web.Url aHalUrl) Instantiates theHalClientwith no authorization credentials passed.HalClientImpl(org.refcodes.web.Url aHalUrl, org.refcodes.web.OauthToken aOauthToken) Instantiates theHalClientwith a validOauthTokenpassed.HalClientImpl(org.refcodes.web.Url aHalUrl, org.refcodes.web.Url aOauthUrl, String aOauthClientId, String aOauthClientSecret, String aOauthUserName, String aOauthUserSecret) Instantiates theHalClientwith no authorization credentials passed. -
Method Summary
Modifier and TypeMethodDescriptionCreates a new entitie's element (row) at the HAL resource consisting of the properties as of the providedCanonicalMap.booleanDeletes an entitie's element (row) from the HAL resource.String[]entities()Determines the entities provided by the HAL resource.String[]Gets the names of the entities to be excluded by theHalClient.String[]Gets the names of the entities to be included by theHalClient.org.refcodes.web.OauthTokenintrospect(String aEntity, TraversalMode aMode) Introspects the provided entity at the HAL resource and returns an instance of theCanonicalMaprepresenting the reflected data structure.read(String aEntity, Long aId, TraversalMode aMode, org.refcodes.web.FormFields aQueryFields) Retrieves the properties with the according values for the given entity with the given TID from the HAL resource.readAll(String aEntity, TraversalMode aMode, org.refcodes.web.FormFields aQueryFields) Retrieves the properties with the according values of all elements (rows) for the given entity from the HAL resource.voidsetExcludeEntities(String[] theEntities) Sets the names of the entities to be excluded by theHalClient.voidsetIncludeEntities(String[] theEntities) Sets the names of the entities to be included by theHalClient.voidsetOauthToken(org.refcodes.web.OauthToken aOauthToken) Updates an existing entitie's element (row) at the HAL resource using the properties as of the providedCanonicalMap.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.refcodes.hal.HalClient
create, introspect, read, read, read, readAll, readAll, readAll, readPage, readPage, readPage, readPage, update, withExcludeEntities, withIncludeEntities, withOAuthTokenMethods inherited from interface org.refcodes.web.OauthTokenAccessor.OauthTokenProperty
letOauthToken
-
Constructor Details
-
HalClientImpl
Instantiates theHalClientwith no authorization credentials passed.- Parameters:
aHalUrl- The URL pointing to the HAL-Endpoint.- Throws:
MalformedURLException- Thrown to indicate that a malformed OAuth URL has occurred.
-
HalClientImpl
public HalClientImpl(String aHalUrl, org.refcodes.web.OauthToken aOauthToken) throws MalformedURLException Instantiates theHalClientwith a validOauthTokenpassed.- Parameters:
aHalUrl- The URL pointing to the HAL-Endpoint.aOauthToken- The OAuth-Token to be used when authorizing against the HAL-Endpoint.- Throws:
MalformedURLException- Thrown to indicate that a malformed OAuth URL has occurred.
-
HalClientImpl
public HalClientImpl(String aHalUrl, String aOauthUrl, String aOauthClientId, String aOauthClientSecret, String aOauthUserName, String aOauthUserSecret) throws org.refcodes.web.HttpStatusException, MalformedURLException Instantiates theHalClientwith no authorization credentials passed.- Parameters:
aHalUrl- The URL pointing to the HAL-Endpoint.aOauthUrl- The URL pointing to the OAuth authentication endpoint.aOauthClientId- The assigned OAuth client TID.aOauthClientSecret- The client's OAuth secret.aOauthUserName- The OAuth authorization user name.aOauthUserSecret- The OAuth authorization user secret.- Throws:
org.refcodes.web.HttpStatusException- Thrown in case a HTTP response was of an erroneous status when requesting the OAuth URL.MalformedURLException- Thrown to indicate that a malformed OAuth URL has occurred.
-
HalClientImpl
Instantiates theHalClientwith no authorization credentials passed.- Parameters:
aHalUrl- The URL pointing to the HAL-Endpoint.- Throws:
MalformedURLException- Thrown to indicate that a malformed OAuth URL has occurred.
-
HalClientImpl
public HalClientImpl(org.refcodes.web.Url aHalUrl, org.refcodes.web.OauthToken aOauthToken) throws MalformedURLException Instantiates theHalClientwith a validOauthTokenpassed.- Parameters:
aHalUrl- The URL pointing to the HAL-Endpoint.aOauthToken- The OAuth-Token to be used when authorizing against the HAL-Endpoint.- Throws:
MalformedURLException- Thrown to indicate that a malformed OAuth URL has occurred.
-
HalClientImpl
public HalClientImpl(org.refcodes.web.Url aHalUrl, org.refcodes.web.Url aOauthUrl, String aOauthClientId, String aOauthClientSecret, String aOauthUserName, String aOauthUserSecret) throws org.refcodes.web.HttpStatusException, MalformedURLException Instantiates theHalClientwith no authorization credentials passed.- Parameters:
aHalUrl- The URL pointing to the HAL-Endpoint.aOauthUrl- The URL pointing to the OAuth authentication endpoint.aOauthClientId- The assigned OAuth client TID.aOauthClientSecret- The client's OAuth secret.aOauthUserName- The OAuth authorization user name.aOauthUserSecret- The OAuth authorization user secret.- Throws:
org.refcodes.web.HttpStatusException- Thrown in case a HTTP response was of an erroneous status when requesting the OAuth URL.MalformedURLException- Thrown to indicate that a malformed OAuth URL has occurred.
-
-
Method Details
-
create
public HalData create(String aEntity, HalData aProperties) throws org.refcodes.web.HttpStatusException Creates a new entitie's element (row) at the HAL resource consisting of the properties as of the providedCanonicalMap.- Specified by:
createin interfaceHalClient- Parameters:
aEntity- The entity for which to create the element (row).aProperties- TheCanonicalMapcontaining the properties of the entity be created.- Returns:
- A
HalDatawith the newly created element (row). - Throws:
org.refcodes.web.HttpStatusException- Thrown in case a HTTP response was of an erroneous status.
-
read
public HalData read(String aEntity, Long aId, TraversalMode aMode, org.refcodes.web.FormFields aQueryFields) throws org.refcodes.web.HttpStatusException Retrieves the properties with the according values for the given entity with the given TID from the HAL resource.- Specified by:
readin interfaceHalClient- Parameters:
aEntity- The entity for which to retrieve the properties.aId- The TID of the entity for which to retrieve the properties.aMode- The mode for handling HREF resources, e.g. load them as well or ignore them.aQueryFields- The query fields to be appended to the requesting URL.- Returns:
- A
CanonicalMapwith the property names assigned to the according values. - Throws:
org.refcodes.web.HttpStatusException- Thrown in case a HTTP response was of an erroneous status.
-
readAll
public HalDataPage readAll(String aEntity, TraversalMode aMode, org.refcodes.web.FormFields aQueryFields) throws org.refcodes.web.HttpStatusException Retrieves the properties with the according values of all elements (rows) for the given entity from the HAL resource.- Specified by:
readAllin interfaceHalClient- Parameters:
aEntity- The entity for which to retrieve the properties of all elements (rows).aMode- The mode for handling HREF resources, e.g. load them as well or ignore them.aQueryFields- The query fields to be appended to the requesting URL.- Returns:
- A
HalDatalist of typeHalDataPagecontaining oneHalDatainstance per element (row). - Throws:
org.refcodes.web.HttpStatusException- Thrown in case a HTTP response was of an erroneous status.
-
update
public HalData update(String aEntity, String aId, HalData aProperties) throws org.refcodes.web.HttpStatusException Updates an existing entitie's element (row) at the HAL resource using the properties as of the providedCanonicalMap.- Specified by:
updatein interfaceHalClient- Parameters:
aEntity- The entity for which to update the element (row).aId- The TID of the element (row) of the entity to be updated.aProperties- TheCanonicalMapcontaining the properties of the entity to be updated.- Returns:
- The updated representation of the entitie's element (row).
- Throws:
org.refcodes.web.HttpStatusException- Thrown in case a HTTP response was of an erroneous status.
-
delete
Deletes an entitie's element (row) from the HAL resource.- Specified by:
deletein interfaceHalClient- Parameters:
aEntity- The entity for which to delete the element (row).aId- The TID of the element (row) of the entity to be deleted.- Returns:
- True in case the element (row) has been deleted, false if there was none such element (row) at the HAL resource (the expectation is satisfied now as there is no element (row) with the given TID in the HAL resource after the operation).
- Throws:
org.refcodes.web.HttpStatusException- Thrown in case a HTTP response was of an erroneous status.
-
entities
Determines the entities provided by the HAL resource. -
introspect
public HalStruct introspect(String aEntity, TraversalMode aMode) throws org.refcodes.web.HttpStatusException Introspects the provided entity at the HAL resource and returns an instance of theCanonicalMaprepresenting the reflected data structure.- Specified by:
introspectin interfaceHalClient- Parameters:
aEntity- The entity to be introspected.aMode- The mode of operation whilst introspecting an entity: You may include MetaData as ofTraversalMode.IMPORT_CHILDREN_KEEP_DANGLING_HREFSor just retrieve the plain data structure without Meta-Data as ofTraversalMode.IMPORT_CHILDREN.- Returns:
- A
CanonicalMapinstance representing the structure of the entity, e.g. providing the attribute names and the data types as well as other constraints representing the layout of the entity (think of a class defining the layout of its instances). - Throws:
org.refcodes.web.HttpStatusException- Thrown in case a HTTP response was of an erroneous status.
-
getExcludeEntities
Gets the names of the entities to be excluded by theHalClient.- Specified by:
getExcludeEntitiesin interfaceHalClient- Returns:
- The entities to be excluded.
-
getIncludeEntities
Gets the names of the entities to be included by theHalClient.- Specified by:
getIncludeEntitiesin interfaceHalClient- Returns:
- The entities to be included.
-
getOauthToken
public org.refcodes.web.OauthToken getOauthToken()- Specified by:
getOauthTokenin interfaceorg.refcodes.web.OauthTokenAccessor
-
setExcludeEntities
Sets the names of the entities to be excluded by theHalClient.- Specified by:
setExcludeEntitiesin interfaceHalClient- Parameters:
theEntities- The entities to be excluded.
-
setIncludeEntities
Sets the names of the entities to be included by theHalClient.- Specified by:
setIncludeEntitiesin interfaceHalClient- Parameters:
theEntities- The entities to be included.
-
setOauthToken
public void setOauthToken(org.refcodes.web.OauthToken aOauthToken) - Specified by:
setOauthTokenin interfaceorg.refcodes.web.OauthTokenAccessor.OauthTokenMutator
-