Package org.rapidcontext.app.web
Class AppWebService
java.lang.Object
org.rapidcontext.core.storage.StorableObject
org.rapidcontext.core.type.WebService
org.rapidcontext.app.web.FileWebService
org.rapidcontext.app.web.AppWebService
- All Implemented Interfaces:
HttpUtil
An app web service. This service extends the file web service with
a RapidContext API and a default app launcher page. All provided
APIs are available under the "rapidcontext/" sub-path.
- Version:
- 1.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.rapidcontext.util.HttpUtil
HttpUtil.HEADER, HttpUtil.Helper, HttpUtil.METHOD, HttpUtil.STATUS
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
The dictionary key for the app identifier.static final String
The dictionary key for additional HTML headers.static final String
The dictionary key for the page language meta-data.static final String
The dictionary key for the login app identifier.static final String
The dictionary key for the page title.static final String
The dictionary key for the page viewport meta-data.protected LogWebService
The log web service used for the "rapidcontext/log" URL.protected ProcedureWebService
The procedure web service used for the "rapidcontext/procedure/" URLs.protected StatusWebService
The status web service used for the "rapidcontext/status" URL.protected StorageWebService
The storage web service used for the "rapidcontext/storage/" URLs.Fields inherited from class org.rapidcontext.app.web.FileWebService
KEY_PATH
Fields inherited from class org.rapidcontext.core.type.WebService
KEY_DESCRIPTION, KEY_MATCH, matchers, METHODS_GET, METHODS_GET_POST, METHODS_POST, PATH
Fields inherited from class org.rapidcontext.core.storage.StorableObject
dict, KEY_ACTIVATED_TIME, KEY_CLASSNAME, KEY_ID, KEY_TYPE, PREFIX_COMPUTED, PREFIX_HIDDEN
-
Constructor Summary
ConstructorsConstructorDescriptionAppWebService
(String id, String type, Dict dict) Creates a new app web service from a serialized representation. -
Method Summary
Modifier and TypeMethodDescriptionappId()
Returns the app identifier for the default launcher.protected void
Processes an HTTP GET request.protected void
Processes an HTTP POST request.Returns the list of optional HTML headers.lang()
Returns the page language ISO code.loginId()
Returns the app identifier for non-authenticated users.protected String[]
methodsImpl
(Request request) Returns the HTTP methods implemented for the specified request.void
Processes a request for this handler.protected void
processApp
(Request request, String appId, String baseUrl) Processes an app launch request.protected String
processAppTemplate
(Binary template, String baseUrl, String appId) Processes an HTML template file for a app and returns the text.protected void
processDownload
(Request request) Processes a file download request.protected void
processUpload
(Request request) Processes a file upload request.protected static String[]
Finds binary files of a specified type from the storage.title()
Returns the title for the HTML web page.viewport()
Returns the page viewport meta data.Methods inherited from class org.rapidcontext.app.web.FileWebService
lookupPaths, path, processFile
Methods inherited from class org.rapidcontext.core.type.WebService
all, description, doDelete, doHead, doOptions, doPatch, doPut, doTrace, errorBadRequest, errorForbidden, errorInternal, errorMethodNotAllowed, errorNotFound, errorUnauthorized, headerAllow, init, matchers, methods, session
Methods inherited from class org.rapidcontext.core.storage.StorableObject
activate, activatedTime, destroy, id, isActive, isModified, passivate, serialize, sterilize, toString, type
-
Field Details
-
KEY_APP
The dictionary key for the app identifier.- See Also:
-
KEY_LOGIN
The dictionary key for the login app identifier.- See Also:
-
KEY_TITLE
The dictionary key for the page title.- See Also:
-
KEY_LANG
The dictionary key for the page language meta-data.- See Also:
-
KEY_VIEWPORT
The dictionary key for the page viewport meta-data.- See Also:
-
KEY_HEADER
The dictionary key for additional HTML headers.- See Also:
-
logger
The log web service used for the "rapidcontext/log" URL. -
statusService
The status web service used for the "rapidcontext/status" URL. -
procedureService
The procedure web service used for the "rapidcontext/procedure/" URLs. -
storageService
The storage web service used for the "rapidcontext/storage/" URLs.
-
-
Constructor Details
-
AppWebService
Creates a new app web service from a serialized representation.- Parameters:
id
- the object identifiertype
- the object type namedict
- the serialized representation
-
-
Method Details
-
resources
Finds binary files of a specified type from the storage. The file type is both used as a subdirectory (i.e. "files/css") and as a suffix (i.e. "*.css") when performing the search. The returned files will be prefixed with the proper path (e.g. "rapidcontext/files/") relative to the specified base path for the web service. The current platform version will be added as a parameter to the file URL:s.- Parameters:
type
- the file type to findbase
- the web service root path- Returns:
- a sorted list of all matching files found in storage
-
appId
Returns the app identifier for the default launcher.- Returns:
- the app identifier for the default launcher, or null if the "index.html" file contains the app
-
loginId
Returns the app identifier for non-authenticated users.- Returns:
- the login app identifier, or "login" if not specified
-
title
Returns the title for the HTML web page.- Returns:
- the configured page title, or "RapidContext" if not defined
-
lang
Returns the page language ISO code.- Returns:
- the page language ISO code, or "en" if not defined
-
viewport
Returns the page viewport meta data.- Returns:
- the page viewport meta data, or a full device width setting if not defined
-
headerLines
Returns the list of optional HTML headers.- Returns:
- the list of HTML headers, or an empty list if none defined
-
methodsImpl
Returns the HTTP methods implemented for the specified request. The OPTIONS or HEAD methods doesn't have to be added to the result (added automatically later).- Overrides:
methodsImpl
in classFileWebService
- Parameters:
request
- the request to check- Returns:
- the array of HTTP method names supported
- See Also:
-
process
Processes a request for this handler. This method assumes local request paths (removal of the mapped URL base).- Overrides:
process
in classWebService
- Parameters:
request
- the request to process- See Also:
-
doGet
Processes an HTTP GET request.- Overrides:
doGet
in classFileWebService
- Parameters:
request
- the request to process
-
doPost
Processes an HTTP POST request.- Overrides:
doPost
in classWebService
- Parameters:
request
- the request to process
-
processApp
Processes an app launch request. This loads the app launcher template from storage and replaces all template variables with their corresponding search results and values.- Parameters:
request
- the request to processappId
- the app identifier to launchbaseUrl
- the base URL for requests
-
processAppTemplate
protected String processAppTemplate(Binary template, String baseUrl, String appId) throws IOException Processes an HTML template file for a app and returns the text.- Parameters:
template
- the template file to readbaseUrl
- the base URL for requestsappId
- the app identifier, or null for 'start'- Returns:
- the processed contents of the HTML template file
- Throws:
IOException
- if the template file couldn't be read
-
processDownload
Processes a file download request. This is used when file data is POST:ed to the special download URL, which makes the handler send the data back with the specified MIME type. Optionally, the "Content-Disposition" header is also set to force the browser "save as" dialog.- Parameters:
request
- the request to process
-
processUpload
Processes a file upload request. This is used when files are POST:ed to the special upload URL.- Parameters:
request
- the request to process
-