Saving a New Posting to a Knowledge Base
Saving a new posting to a knowledge base requires all the same parameters as for
executing arbitrary code (cmd, imports,
applet, pre, format and
stylesheet), plus extra parameters to direct
how the code example should be saved. Those extra parameters are all optional except for
kb, method, purpose,
description and subject.
Optional parameters are shown like this, mandatory parameters are shown
like this.
| Parameter name |
Description |
| class |
Class/section name for the code example. Default value is the empty string. |
| closed |
Boolean indication if this is an open issue (help request) or a closed (resolved) issue.
Default value is false. |
| description |
Detailed explanation of the code example. |
| example |
Boolean indication if this is a quality tested code example (user must have author or moderator privilege
for this code example to be accepted). Default value is false. |
| kb |
Knowledge base name to save the code example to |
| method |
Method/subsection name for the code example |
| package |
Package/chapter name for the code example. Default value is the empty string. |
| purpose |
Description of a problem to solve. |
| ranges |
Specifies lines of code to display to the user
(only applies to quality tested code examples). Default is to display all lines. |
| sandbox |
Sandbox code. Default value is jsp |
| priority |
If this code fragment is a support request (closed=false, example=true)
this value is used to indicate the urgency of the need.
The range of values is from 1 (least urgent) to 5 (most urgent).
Default value is 3. Once posted, the person who created the posting can not increase the
priority, only decrease it. At least moderator privilege is required in order to be
able to increase the priority. |
| subject |
All code example postings must have a non-zero length subject |
As with the other REST URIs, you can specify the parameters in an HTTP POST,
and HTTP GET or a combination of POST and URL parameters.
The only response is the new code fragment id unless an error occurs.
Sample Save
Be sure to substitute your Zamples user id and password for myUid and myPwd and change myKb to the name of a valid knowledge base.
You will then need to run the program.
Click on the link, then view the HTML source in order to see the proper formatting.
|
<form action='/JspExplorer/zamples/save' method=post class=formInput target='TomcatMain'>
<input type=hidden name=cmd
value='Zamples says it is now <%=new java.util.Date()%>.'>
<input type=hidden name=imports value=''>
<input type=hidden name=applet value=''>
<input type=hidden name=format value='0'>
<input type=hidden name=pre value='false'>
<input type=hidden name=stylesheet value='false'>
<input type=hidden name=clientUser value='myUid'>
<input type=hidden name=clientPassword value='myPwd'>
<input type=hidden name=kb value='myKb'>
<input type=hidden name=package value='myPkg'>
<input type=hidden name=class value='myClass'>
<input type=hidden name=method value='myMethod'>
<input type=hidden name=subject value='mySubject'>
<input type=hidden name=range value=''>
<input type=hidden name=example value='false'>
<input type=hidden name=purpose value='myPurpose'>
<input type=hidden name=description value='myDescription'>
<input type=hidden name=closed value='false'>
<input type=submit value='Save' class=formInput>
</form> |
The id of the new posting is returned.
For submitting the form for compilation and execution, the action URI may either be /JspExplorer or /JspExplorer/index.jsp - it doesn't matter which is specified. If the Zamples server is on another system be sure to prepend the domain so that a fully qualified URL is specified, like http://zamples.com/JspExplorer/.
Possible error messages
In addition to the common error statuses, this Zamples REST call can generate the following error statuses and messages:
| 404 Zamples knowledge base not found |
The requested knowledge base does not exist. |
| 506 Unspecified Zamples failure |
An error occured when saving the code posting - more information might be available in the error message text |
|