Package com.helger.photon.api
Class InvokableAPIDescriptor
- java.lang.Object
-
- com.helger.photon.api.InvokableAPIDescriptor
-
- All Implemented Interfaces:
Serializable
public class InvokableAPIDescriptor extends Object implements Serializable
AnInvokableAPIDescriptorcontains anIAPIDescriptoras well the original path by which it was called as well as any resolved path variables.- Author:
- Philip Helger
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description InvokableAPIDescriptor(IAPIDescriptor aDescriptor, String sPath, com.helger.commons.collection.impl.ICommonsOrderedMap<String,String> aPathVariables)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanExecute(com.helger.web.scope.IRequestWebScopeWithoutResponse aRequestScope, com.helger.commons.mutable.MutableInt aStatusCode)Check if all pre-requisites are handled correctly.com.helger.commons.collection.impl.ICommonsOrderedMap<String,String>getAllPathVariables()IAPIDescriptorgetAPIDescriptor()StringgetPath()voidinvokeAPI(com.helger.web.scope.IRequestWebScopeWithoutResponse aRequestScope, com.helger.servlet.response.UnifiedResponse aUnifiedResponse)Invoke the Java callback underlying this API descriptor.StringtoString()
-
-
-
Constructor Detail
-
InvokableAPIDescriptor
public InvokableAPIDescriptor(@Nonnull IAPIDescriptor aDescriptor, @Nonnull @Nonempty String sPath, @Nonnull com.helger.commons.collection.impl.ICommonsOrderedMap<String,String> aPathVariables)
Constructor- Parameters:
aDescriptor- The matchingIAPIDescriptor. Nevernull.sPath- The URL path requested by the user, relative to the servlet.aPathVariables- All resolved path variables, if the path descriptor contains variable elements.
-
-
Method Detail
-
getAPIDescriptor
@Nonnull public final IAPIDescriptor getAPIDescriptor()
- Returns:
- The original API descriptor. Never
null.
-
getPath
@Nonnull @Nonempty public final String getPath()
- Returns:
- The URL path requested by the user, relative to the servlet. Never
nullnor empty.
-
getAllPathVariables
@Nonnull @ReturnsMutableCopy public final com.helger.commons.collection.impl.ICommonsOrderedMap<String,String> getAllPathVariables()
- Returns:
- All resolved path variables, if the path descriptor contains
variable elements. Never
nullbut maybe empty.
-
canExecute
public boolean canExecute(@Nonnull com.helger.web.scope.IRequestWebScopeWithoutResponse aRequestScope, @Nonnull com.helger.commons.mutable.MutableInt aStatusCode)
Check if all pre-requisites are handled correctly. This checks if all required headers and params are present.- Parameters:
aRequestScope- The request scope to validate.aStatusCode- The mutable int to hold the status code to be returned in case of error. Default is HTTP 400, bad request.- Returns:
trueif all prerequisites are fulfilled.
-
invokeAPI
public void invokeAPI(@Nonnull com.helger.web.scope.IRequestWebScopeWithoutResponse aRequestScope, @Nonnull com.helger.servlet.response.UnifiedResponse aUnifiedResponse) throws Exception
Invoke the Java callback underlying this API descriptor. Note: this method may only be invoked aftercanExecute(IRequestWebScopeWithoutResponse,MutableInt)returnedtrue!- Parameters:
aRequestScope- Current request scope. Nevernull.aUnifiedResponse- Current response. Nevernull.- Throws:
Exception- In case the Java callback throws oneIllegalStateException- In case the executor factory creates anullexecutor.
-
-