*/
protected void setItemOrTopicProperties(Resource itemOrTopic, EnhancedRequest request)
throws HandlerException {
//get request body
MultiPartBody requestBody = (MultiPartBody) request.getBody();
// URL baseURL = new URL(target.getURI());
URL baseURL = request.getRequestURLWithoutParams();
String uri = requestBody.getParameter("uri");
if (uri != null) {
try {
//try to create a new resource itemOrTopic
itemOrTopic = model.createResource(new URL(baseURL, uri).toString());
} catch (MalformedURLException e) {
throw new HandlerException(e);
}
}
//retrieve parameters from body:
String language = requestBody.getParameter("language");
String title = requestBody.getParameter("title");
String summary = requestBody.getParameter("description");
if (!"yes".equals(requestBody.getParameter("custom_summary"))) {
summary = null;
}
String creator = requestBody.getParameter("creator");
String date = requestBody.getParameter("date");
String content = requestBody.getParameter("body");
String[] permissions = requestBody.getParameterValues("permission");
String[] maxShowInlineLength = requestBody.getParameterValues("maxShowInlineLength");
if ((maxShowInlineLength != null) && (maxShowInlineLength.length > 0)) {
Literal maxShowInlineLengthLiteral = model.createTypedLiteral(maxShowInlineLength[0], XSDDatatype.XSDdecimal);
itemOrTopic.removeAll(KNOBOT.maxShowInlineLength);
itemOrTopic.addProperty(KNOBOT.maxShowInlineLength, maxShowInlineLengthLiteral);
}
addPermissions(itemOrTopic, permissions);
//shop
boolean shop = "checked".equals(requestBody.getParameter("shop"));
String priceString = requestBody.getParameter("price");
String articleID = requestBody.getParameter("articleID");
boolean commentable = "yes"
.equals(requestBody.getParameter("comments"));
float price = 0;
if ((priceString != null) && (!priceString.equals(""))) {
price = Float.parseFloat(priceString);
}
//custom shipping costs parameter (has to be float):
String customShippingCostsString = requestBody.getParameter("customShippingCosts");
String useDefaultShippingCosts = requestBody.getParameter("useShippingCosts");
float customShippingCosts = 0;
if ((customShippingCostsString != null) && (!customShippingCostsString.equals(""))) {
customShippingCosts = Float.parseFloat(customShippingCostsString);
}