fac.setLocales(locales);
fac.setLocalPath(getServletContext().getContextPath()+properties.getString("widget.widgetfolder"));
fac.setOutputDirectory(WIDGETFOLDER);
fac.setFeatures(Features.getFeatureNames());
fac.setStartPageProcessor(new StartPageProcessor());
W3CWidget widgetModel = fac.parse(zipFile);
WidgetJavascriptSyntaxAnalyzer jsa = new WidgetJavascriptSyntaxAnalyzer(fac.getUnzippedWidgetDirectory());
if(persistenceManager.findWidgetByGuid(widgetModel.getIdentifier()) == null){
// ADD
IWidget widget = WidgetFactory.addNewWidget(widgetModel, null, zipFile, false);
Object dbkey = widget.getId();
// widget added
request.setAttribute("message_value", "'"+ widgetModel.getLocalName("en") +"' - " + localizedMessages.getString("WidgetAdminServlet.19")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
retrieveServices(request);
request.setAttribute("hasValidated", Boolean.valueOf(true)); //$NON-NLS-1$
request.setAttribute("dbkey", dbkey); //$NON-NLS-1$
}
else{
// UPDATE
// Update the widget metadata and configuration details
WidgetFactory.update(widgetModel, persistenceManager.findWidgetByGuid(widgetModel.getIdentifier()), false, zipFile);
request.setAttribute("message_value", "'"+ widgetModel.getLocalName("en") +"' - " + localizedMessages.getString("WidgetAdminServlet.20")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
}
else{
// no file found to be uploaded - shouldn't happen
request.setAttribute("error_value", localizedMessages.getString("WidgetAdminServlet.24")); //$NON-NLS-1$ //$NON-NLS-2$