com.frevvo.forms.client
public class Helper extends Object
Modifier and Type | Field and Description |
---|---|
static Pattern |
FORM_INSTANCE_URL_PATTERN |
static String |
HEADER_CONTENT_TYPE |
static String |
MEDIATYPE_APP_ATOM_XML |
static String |
MEDIATYPE_APP_XML |
static String |
MEDIATYPE_SUBMISSION_MULTIPART |
static String |
MEDIATYPE_TEXT_HTML |
static String |
MEDIATYPE_TEXT_JAVASCRIPT |
Constructor and Description |
---|
Helper() |
Modifier and Type | Method and Description |
---|---|
static void |
addParts(org.apache.commons.httpclient.methods.MultipartPostMethod post,
Collection<com.google.gdata.data.media.MediaSource> documents) |
static String |
appendParameter(String url,
String param,
String value)
Append a new parameter to a URL string
|
static void |
cancelInstance(FormsService service,
URL fUrl)
Cancel an instance url
|
static String |
clickControl(FormsService service,
com.google.gdata.data.Link link) |
static URL |
createFormInstance(org.apache.commons.httpclient.HttpClient client,
com.google.gdata.data.Link link,
Map<String,Object> linkParams,
Collection<com.google.gdata.data.media.MediaSource> documents,
boolean embed,
String authHeader,
List<org.apache.commons.httpclient.Cookie> cookies) |
static URL |
createFormInstance(com.google.gdata.client.Service service,
com.google.gdata.data.Link link,
Map<String,Object> linkParams,
Collection<com.google.gdata.data.media.MediaSource> documents,
boolean embed) |
static URL |
createFormInstance(com.google.gdata.client.Service service,
com.google.gdata.data.Link link,
Map<String,Object> linkParams,
Collection<com.google.gdata.data.media.MediaSource> documents,
boolean embed,
String authHeader,
List<org.apache.commons.httpclient.Cookie> cookies) |
protected static String |
decode(String s) |
static <F extends com.google.gdata.data.BaseFeed<F,E>,E extends com.google.gdata.data.BaseEntry<E>> |
deleteEntry(F feed,
String id)
Delete an entry by id
|
static <F extends com.google.gdata.data.BaseFeed<F,E>,E extends com.google.gdata.data.BaseEntry<E>> |
deleteEntryByTitle(F feed,
String title)
Delete an entry by title
|
static void |
deleteScript(FormsService service,
com.google.gdata.data.Link link) |
protected static String |
encode(String s)
Encodes a string using UTF-8.
|
static String |
extractFlowId(URL fUrl) |
static String |
extractFormEntryId(URL formInstanceUrl)
Extract the FormEntry.id from a form instance url returned by the
FormTypeEntry.createFormInstance() method
|
static String |
extractFormId(URL fUrl) |
static ControlEntry |
findControlEntry(FormEntry fEntry,
String name)
Find a ControlEntry by it's name
|
static ControlEntry |
findControlEntry(FormEntry fEntry,
String name,
int index)
Find a repeating ControlEntry by it's name and the repeat item index
|
static ControlEntry |
findControlEntryById(FormEntry fEntry,
String id)
Finds the
ControlEntry by id
Useful when the form has duplicate controls with the same name for some
reason. |
static <F extends com.google.gdata.data.BaseFeed<F,E>,E extends com.google.gdata.data.BaseEntry<E>> |
findEntry(F feed,
String id)
Find an entry by id
|
static <F extends com.google.gdata.data.BaseFeed<F,E>,E extends com.google.gdata.data.BaseEntry<E>> |
findEntryByTitle(F feed,
String title)
Find an entry by title
|
static String |
generateData(Map<String,Object> data)
Generate a data value that can be used to initialize controls in a form
|
static URL |
getApplicationFeedURL(FormsService fs,
String owner) |
static com.google.gdata.data.Link |
getFirstLink(List<com.google.gdata.data.Link> links,
String rel,
String type) |
static String |
getFormEntryIdFromInstance(URL formInstanceUrl)
Given the url to a form instance created using the FormTypeEntry.createFormInstance() method,
use this method to return the FormEntry id.
|
static String |
getInstanceState(FormsService service,
URL url) |
static String |
getInstanceState(org.apache.commons.httpclient.HttpClient client,
URL url) |
static String |
getInstanceXHTML(FormsService service,
URL url) |
static String |
getInstanceXHTML(org.apache.commons.httpclient.HttpClient client,
URL url) |
static String |
getParameterValue(Object value) |
static String |
getQueryParameters(Map<String,Object> params,
boolean encode) |
static String |
getSubmissionIdFromFormEntry(FormEntry formEntry) |
static String |
getSubmissionIdFromInstance(URL formInstanceUrl)
Given the url to a form instance created using the FormTypeEntry.createFormInstance() method,
use this method to return the SubmissionEntry id.
|
static boolean |
match(com.google.gdata.data.Link link,
String relToMatch,
String typeToMatch)
Does the link matches the given rel and contentType?
|
static void |
nextActivity(FormsService service,
URL formUrl) |
static void |
previousActivity(FormsService service,
URL formUrl) |
static void |
printDataSource(DataSource ds,
PrintStream pw)
Print the given data source
|
static void |
readStream(InputStream is,
OutputStream os)
Reads the given input stream and writes the content to the given output stream
|
static URL |
removeQuery(URL url) |
static FormTypeEntry |
replaceFormType(FormsService fs,
ApplicationEntry appEntry,
String existingFormId,
InputStream newForm)
Replace the FormType identified by
id with the given form stream |
static DataSource |
saveInstance(FormsService service,
URL url) |
static DataSource |
saveInstance(FormsService service,
URL url,
boolean terminateInstance) |
static com.google.gdata.data.Link |
setParameters(com.google.gdata.data.Link link,
Map<String,Object> params) |
static com.google.gdata.data.Link |
setParameters(com.google.gdata.data.Link link,
String name,
Object value) |
static String |
stripParameter(String url,
String parameterKey) |
static void |
submitEditingInstance(com.google.gdata.client.Service service,
URL formUrl,
boolean finish) |
static void |
submitEditingInstance(com.google.gdata.client.Service service,
URL formUrl,
boolean finish,
String authHeader,
List<org.apache.commons.httpclient.Cookie> cookies) |
static DataSource |
submitInstance(com.google.gdata.client.Service service,
URL formUrl)
Submit a form instance URL
|
static DataSource |
submitInstance(com.google.gdata.client.Service service,
URL formUrl,
String authHeader,
List<org.apache.commons.httpclient.Cookie> cookies)
Submit a form instance URL
|
static com.google.gdata.data.media.MediaSource |
toSchemaMediaSource(InputStream is,
String contentType,
String rootXSDFileName,
String schemaName)
Create a media source suitable for inserting into a SchemaFeed
|
static String |
updateControlState(FormsService service,
com.google.gdata.data.Link link,
String state) |
static String |
updateControlValue(FormsService service,
com.google.gdata.data.Link link,
String value) |
static String |
updateControlValue(FormsService service,
URL url,
String id,
String value)
Deprecated.
|
static String |
updateControlValues(FormsService service,
com.google.gdata.data.Link link,
String... values) |
static void |
updateScript(FormsService service,
com.google.gdata.data.Link link,
InputStream script) |
public static final String MEDIATYPE_APP_XML
public static final String MEDIATYPE_TEXT_JAVASCRIPT
public static final String MEDIATYPE_TEXT_HTML
public static final String MEDIATYPE_APP_ATOM_XML
public static final String MEDIATYPE_SUBMISSION_MULTIPART
public static final String HEADER_CONTENT_TYPE
public static final Pattern FORM_INSTANCE_URL_PATTERN
public static com.google.gdata.data.Link getFirstLink(List<com.google.gdata.data.Link> links, String rel, String type)
public static String getQueryParameters(Map<String,Object> params, boolean encode)
public static com.google.gdata.data.Link setParameters(com.google.gdata.data.Link link, String name, Object value)
public static com.google.gdata.data.Link setParameters(com.google.gdata.data.Link link, Map<String,Object> params)
public static com.google.gdata.data.media.MediaSource toSchemaMediaSource(InputStream is, String contentType, String rootXSDFileName, String schemaName) throws IOException
is
- contentType
- rootXSDFileName
- schemaName
- IOException
protected static String encode(String s)
s
- string to be encodedRuntimeException
- when the JVM does not support UTF-8public static String appendParameter(String url, String param, String value)
url
- The urlparam
- The parameter namevalue
- The optional parameter valuepublic static String generateData(Map<String,Object> data)
data
- The Map containing the name of the controls and the values
that should be used to initialize thempublic static void addParts(org.apache.commons.httpclient.methods.MultipartPostMethod post, Collection<com.google.gdata.data.media.MediaSource> documents) throws IOException
IOException
public static URL createFormInstance(com.google.gdata.client.Service service, com.google.gdata.data.Link link, Map<String,Object> linkParams, Collection<com.google.gdata.data.media.MediaSource> documents, boolean embed) throws com.google.gdata.util.ServiceException
com.google.gdata.util.ServiceException
public static URL createFormInstance(com.google.gdata.client.Service service, com.google.gdata.data.Link link, Map<String,Object> linkParams, Collection<com.google.gdata.data.media.MediaSource> documents, boolean embed, String authHeader, List<org.apache.commons.httpclient.Cookie> cookies) throws com.google.gdata.util.ServiceException
com.google.gdata.util.ServiceException
public static URL createFormInstance(org.apache.commons.httpclient.HttpClient client, com.google.gdata.data.Link link, Map<String,Object> linkParams, Collection<com.google.gdata.data.media.MediaSource> documents, boolean embed, String authHeader, List<org.apache.commons.httpclient.Cookie> cookies) throws com.google.gdata.util.ServiceException
com.google.gdata.util.ServiceException
public static void readStream(InputStream is, OutputStream os) throws IOException
is
- os
- IOException
public static void nextActivity(FormsService service, URL formUrl)
public static void previousActivity(FormsService service, URL formUrl)
public static void submitEditingInstance(com.google.gdata.client.Service service, URL formUrl, boolean finish)
public static void submitEditingInstance(com.google.gdata.client.Service service, URL formUrl, boolean finish, String authHeader, List<org.apache.commons.httpclient.Cookie> cookies)
public static DataSource submitInstance(com.google.gdata.client.Service service, URL formUrl) throws com.google.gdata.util.ServiceException
service
- The FormsService
formUrl
- The form instance URLcom.google.gdata.util.ServiceException
public static DataSource submitInstance(com.google.gdata.client.Service service, URL formUrl, String authHeader, List<org.apache.commons.httpclient.Cookie> cookies) throws com.google.gdata.util.ServiceException
service
- The FormsService
formUrl
- The form instance URLauthHeader
- An optional authentication headercookies
- An optional list of cookies to add to the requestcom.google.gdata.util.ServiceException
public static void cancelInstance(FormsService service, URL fUrl) throws com.google.gdata.util.ServiceException
service
- fUrl
- com.google.gdata.util.ServiceException
public static DataSource saveInstance(FormsService service, URL url) throws com.google.gdata.util.ServiceException
com.google.gdata.util.ServiceException
public static DataSource saveInstance(FormsService service, URL url, boolean terminateInstance) throws com.google.gdata.util.ServiceException
com.google.gdata.util.ServiceException
public static String getInstanceXHTML(FormsService service, URL url)
public static String getInstanceXHTML(org.apache.commons.httpclient.HttpClient client, URL url)
public static String getInstanceState(FormsService service, URL url)
public static String getInstanceState(org.apache.commons.httpclient.HttpClient client, URL url)
public static String updateControlState(FormsService service, com.google.gdata.data.Link link, String state) throws com.google.gdata.util.ServiceException
com.google.gdata.util.ServiceException
public static String updateControlValue(FormsService service, com.google.gdata.data.Link link, String value) throws com.google.gdata.util.ServiceException
com.google.gdata.util.ServiceException
public static String updateControlValues(FormsService service, com.google.gdata.data.Link link, String... values) throws com.google.gdata.util.ServiceException
com.google.gdata.util.ServiceException
public static String clickControl(FormsService service, com.google.gdata.data.Link link) throws com.google.gdata.util.ServiceException
com.google.gdata.util.ServiceException
public static String updateControlValue(FormsService service, URL url, String id, String value)
service
- url
- id
- value
- public static void updateScript(FormsService service, com.google.gdata.data.Link link, InputStream script) throws com.google.gdata.util.ServiceException
com.google.gdata.util.ServiceException
public static void deleteScript(FormsService service, com.google.gdata.data.Link link) throws com.google.gdata.util.ServiceException
com.google.gdata.util.ServiceException
public static String getSubmissionIdFromInstance(URL formInstanceUrl)
formInstanceUrl
- public static String getFormEntryIdFromInstance(URL formInstanceUrl)
formInstanceUrl
- public static String extractFormEntryId(URL formInstanceUrl)
formInstanceUrl
- The form instance urlpublic static FormTypeEntry replaceFormType(FormsService fs, ApplicationEntry appEntry, String existingFormId, InputStream newForm) throws com.google.gdata.util.ServiceException, IOException
id
with the given form streamfs
- appEntry
- existingFormId
- newForm
- FormTypeEntry
com.google.gdata.util.ServiceException
IOException
public static URL getApplicationFeedURL(FormsService fs, String owner) throws MalformedURLException
MalformedURLException
public static boolean match(com.google.gdata.data.Link link, String relToMatch, String typeToMatch)
link
- relToMatch
- typeToMatch
- public static ControlEntry findControlEntry(FormEntry fEntry, String name) throws MalformedURLException, IOException, com.google.gdata.util.ServiceException
fEntry
- The FormEntryname
- The control nameMalformedURLException
IOException
com.google.gdata.util.ServiceException
public static ControlEntry findControlEntry(FormEntry fEntry, String name, int index) throws MalformedURLException, IOException, com.google.gdata.util.ServiceException
fEntry
- The FormEntryname
- The control nameindex
- The control indexMalformedURLException
IOException
com.google.gdata.util.ServiceException
public static ControlEntry findControlEntryById(FormEntry fEntry, String id) throws MalformedURLException, IOException, com.google.gdata.util.ServiceException
ControlEntry
by id
Useful when the form has duplicate controls with the same name for some
reason.fEntry
- id
- MalformedURLException
IOException
com.google.gdata.util.ServiceException
public static <F extends com.google.gdata.data.BaseFeed<F,E>,E extends com.google.gdata.data.BaseEntry<E>> E deleteEntry(F feed, String id) throws Exception
feed
- id
- Exception
public static <F extends com.google.gdata.data.BaseFeed<F,E>,E extends com.google.gdata.data.BaseEntry<E>> E deleteEntryByTitle(F feed, String title) throws Exception
feed
- title
- Exception
public static <F extends com.google.gdata.data.BaseFeed<F,E>,E extends com.google.gdata.data.BaseEntry<E>> E findEntry(F feed, String id)
feed
- id
- Exception
public static <F extends com.google.gdata.data.BaseFeed<F,E>,E extends com.google.gdata.data.BaseEntry<E>> E findEntryByTitle(F feed, String title)
feed
- title
- Exception
public static void printDataSource(DataSource ds, PrintStream pw) throws javax.mail.MessagingException
ds
- pw
- javax.mail.MessagingException
Copyright © 2006–2015 frevvo Inc. All rights reserved.