If there isn't a valid keystore file, then maybe rather than skip signature verification, it should instead generate a new empty keystore?
On 15 Aug 2012, at 15:00, [email protected] wrote: > Author: psharples > Date: Wed Aug 15 14:00:20 2012 > New Revision: 1373413 > > URL: http://svn.apache.org/viewvc?rev=1373413&view=rev > Log: > Fixed bug where there was a NPE when the keystore file could not be loaded > for the DigSig processor > > Modified: > > incubator/wookie/trunk/src/org/apache/wookie/controller/WidgetsController.java > incubator/wookie/trunk/src/org/apache/wookie/messages.properties > incubator/wookie/trunk/src/org/apache/wookie/messages_nl.properties > incubator/wookie/trunk/src/org/apache/wookie/server/ContextListener.java > > Modified: > incubator/wookie/trunk/src/org/apache/wookie/controller/WidgetsController.java > URL: > http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/controller/WidgetsController.java?rev=1373413&r1=1373412&r2=1373413&view=diff > ============================================================================== > --- > incubator/wookie/trunk/src/org/apache/wookie/controller/WidgetsController.java > (original) > +++ > incubator/wookie/trunk/src/org/apache/wookie/controller/WidgetsController.java > Wed Aug 15 14:00:20 2012 > @@ -268,66 +268,70 @@ public class WidgetsController extends C > fac.setFeatures(Features.getFeatureNames()); > fac.setStartPageProcessor(new StartPageProcessor()); > if (VERIFYSIGNATURE) { > - InputStream stream = getServletContext().getResourceAsStream( > - "/WEB-INF/classes/" + KEYSTORE); > - KeyStore keyStore = KeyStore.getInstance("JKS"); > - keyStore.load(stream, PASSWORD.toCharArray()); > - stream.close(); > - fac.setDigitalSignatureParser(new DigitalSignatureProcessor(keyStore, > - REJECTINVALID, REJECTUNTRUSTED)); > - } > - W3CWidget widgetModel = fac.parse(zipFile); > + InputStream stream = getServletContext().getResourceAsStream( > + "/WEB-INF/classes/" + KEYSTORE); > + if(stream != null){ > + KeyStore keyStore = KeyStore.getInstance("JKS"); > + keyStore.load(stream, PASSWORD.toCharArray()); > + stream.close(); > + fac.setDigitalSignatureParser(new > DigitalSignatureProcessor(keyStore, > + REJECTINVALID, REJECTUNTRUSTED)); > + }else{ > + > _logger.error(localizedMessages.getString("WidgetHotDeploy.4") + > + " (/WEB-INF/classes/" + KEYSTORE+") " + > localizedMessages.getString("WidgetHotDeploy.5")); > + } > + } > + W3CWidget widgetModel = fac.parse(zipFile); > new WidgetJavascriptSyntaxAnalyzer(fac.getUnzippedWidgetDirectory()); > - // File f = new File(); > // > // Check if the widget model corresponds to an existing installed > widget > // > IPersistenceManager persistenceManager = > PersistenceManagerFactory.getPersistenceManager(); > if (persistenceManager.findWidgetByGuid(widgetModel.getIdentifier()) > == null) { > - > - // > - // A new widget was created, so return 201 > - // > - WidgetFactory.addNewWidget(widgetModel, zipFile,false); > - NewWidgetBroadcaster.broadcast(properties, > widgetModel.getIdentifier()); > - returnXml(WidgetImportHelper.createXMLWidgetDocument(widgetModel, > new File(fac.getUnzippedWidgetDirectory(), "config.xml"), > getWookieServerURL(request, "").toString(), true), response); > - return true; > - > + > + // > + // A new widget was created, so return 201 > + // > + WidgetFactory.addNewWidget(widgetModel, zipFile,false); > + NewWidgetBroadcaster.broadcast(properties, > widgetModel.getIdentifier()); > + > returnXml(WidgetImportHelper.createXMLWidgetDocument(widgetModel, new > File(fac.getUnzippedWidgetDirectory(), "config.xml"), > getWookieServerURL(request, "").toString(), true), response); > + return true; > + > } else { > - > - // > - // Widget already exists, so update the widget metadata and > configuration details > - // and return 200 > - // > - > WidgetFactory.update(widgetModel,persistenceManager.findWidgetByGuid(widgetModel.getIdentifier()),false, > zipFile); > - returnXml(WidgetImportHelper.createXMLWidgetDocument(widgetModel, > new File(fac.getUnzippedWidgetDirectory(), "config.xml"), > getWookieServerURL(request, "").toString(), true), response); > - return false; > - > + > + // > + // Widget already exists, so update the widget metadata and > configuration details > + // and return 200 > + // > + > WidgetFactory.update(widgetModel,persistenceManager.findWidgetByGuid(widgetModel.getIdentifier()),false, > zipFile); > + > returnXml(WidgetImportHelper.createXMLWidgetDocument(widgetModel, new > File(fac.getUnzippedWidgetDirectory(), "config.xml"), > getWookieServerURL(request, "").toString(), true), response); > + return false; > + > } > - > + > // > // Catch specific parsing and validation errors and throw exception > with error message > // > } catch (InvalidStartFileException ex) { > - _logger.error(ex); > - throw new InvalidParametersException( > - localizedMessages.getString("widgets.no-start-file") + "\n" + > ex.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ > + _logger.error(ex); > + throw new InvalidParametersException( > + localizedMessages.getString("widgets.no-start-file") + "\n" > + ex.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ > } catch (BadManifestException ex) { > - _logger.error(ex); > - String message = ex.getMessage(); > - if (ex.getMessage() == null || ex.getMessage().equals(""))message = > localizedMessages.getString("widgets.invalid-config-xml"); //$NON-NLS-1$ > - if (ex instanceof InvalidContentTypeException) > - message = > localizedMessages.getString("widgets.unsupported-content-type");//$NON-NLS-1$ > - throw new InvalidParametersException(message); > + _logger.error(ex); > + String message = ex.getMessage(); > + if (ex.getMessage() == null || ex.getMessage().equals(""))message = > localizedMessages.getString("widgets.invalid-config-xml"); //$NON-NLS-1$ > + if (ex instanceof InvalidContentTypeException) > + message = > localizedMessages.getString("widgets.unsupported-content-type");//$NON-NLS-1$ > + throw new InvalidParametersException(message); > } catch (BadWidgetZipFileException ex) { > - _logger.error(ex); > - String message = ex.getMessage(); > - if (ex.getMessage() == null || ex.getMessage().equals(""))message = > localizedMessages.getString("widgets.bad-zip-file"); //$NON-NLS-1$ > - throw new InvalidParametersException(message); > + _logger.error(ex); > + String message = ex.getMessage(); > + if (ex.getMessage() == null || ex.getMessage().equals(""))message = > localizedMessages.getString("widgets.bad-zip-file"); //$NON-NLS-1$ > + throw new InvalidParametersException(message); > } catch (Exception ex) { > - _logger.error(ex); > - throw new InvalidParametersException( > - localizedMessages.getString("widgets.cant-parse-config-xml") + > "\n" + ex.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ > + _logger.error(ex); > + throw new InvalidParametersException( > + localizedMessages.getString("widgets.cant-parse-config-xml") > + "\n" + ex.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ > } > > } > > Modified: incubator/wookie/trunk/src/org/apache/wookie/messages.properties > URL: > http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/messages.properties?rev=1373413&r1=1373412&r2=1373413&view=diff > ============================================================================== > --- incubator/wookie/trunk/src/org/apache/wookie/messages.properties > (original) > +++ incubator/wookie/trunk/src/org/apache/wookie/messages.properties Wed Aug > 15 14:00:20 2012 > @@ -41,6 +41,8 @@ WidgetHotDeploy.0=Hot deploy disabled > WidgetHotDeploy.1=Hot deploy error: Unable to move dropped .wgt file to > upload folder > WidgetHotDeploy.2=Hot deploy error: file is not a valid widget package > WidgetHotDeploy.3=Hot deploy error: widget has invalid manifest > +WidgetHotDeploy.4=Unable to load specified key file. > +WidgetHotDeploy.5=Digital Signature Verification is not enabled. > > WidgetServiceServlet.0=No valid requestid was found. > WidgetServiceServlet.1=completed > > Modified: incubator/wookie/trunk/src/org/apache/wookie/messages_nl.properties > URL: > http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/messages_nl.properties?rev=1373413&r1=1373412&r2=1373413&view=diff > ============================================================================== > --- incubator/wookie/trunk/src/org/apache/wookie/messages_nl.properties > (original) > +++ incubator/wookie/trunk/src/org/apache/wookie/messages_nl.properties Wed > Aug 15 14:00:20 2012 > @@ -41,6 +41,8 @@ WidgetHotDeploy.0=Hot deploy disabled (d > WidgetHotDeploy.1=Hot deploy error: Unable to move dropped .wgt file to > upload folder (dutch) > WidgetHotDeploy.2=Hot deploy error: file is not a valid widget package (dutch) > WidgetHotDeploy.3=Hot deploy error: widget has invalid manifest (dutch) > +WidgetHotDeploy.4=Unable to load specified key file.(dutch) > +WidgetHotDeploy.5=Digital Signature Verification is not enabled.(dutch) > > WidgetServiceServlet.0=No valid requestid was found.(dutch) > WidgetServiceServlet.1=completed(dutch) > > Modified: > incubator/wookie/trunk/src/org/apache/wookie/server/ContextListener.java > URL: > http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/server/ContextListener.java?rev=1373413&r1=1373412&r2=1373413&view=diff > ============================================================================== > --- incubator/wookie/trunk/src/org/apache/wookie/server/ContextListener.java > (original) > +++ incubator/wookie/trunk/src/org/apache/wookie/server/ContextListener.java > Wed Aug 15 14:00:20 2012 > @@ -57,211 +57,216 @@ import org.apache.wookie.w3c.util.Widget > * > */ > public class ContextListener implements ServletContextListener { > - /* > - * In the case of the 'log4j.properties' file used within a server > environment > - * there is no need to explicitly load the file. It will be > automatically loaded as > - * long as it is placed at the root of the source code. This way it > eventually is found under... > - * > - * '/webappname/WEB-INF/classes' ...at runtime. > - */ > - static Logger _logger = > Logger.getLogger(ContextListener.class.getName()); > - public static Boolean usePreferenceInstanceQueues; > - public static Boolean useSharedDataInstanceQueues; > - > + /* > + * In the case of the 'log4j.properties' file used within a server > environment > + * there is no need to explicitly load the file. It will be > automatically loaded as > + * long as it is placed at the root of the source code. This way it > eventually is found under... > + * > + * '/webappname/WEB-INF/classes' ...at runtime. > + */ > + static Logger _logger = > Logger.getLogger(ContextListener.class.getName()); > + public static Boolean usePreferenceInstanceQueues; > + public static Boolean useSharedDataInstanceQueues; > + > public void contextInitialized(ServletContextEvent event) { > - try { > - ServletContext context = event.getServletContext(); > - > WidgetRuntimeHelper.setWebContextPath(context.getContextPath()); > - /* > - * load the widgetserver.properties and > local.widget.properties file > - * and put it into this context as an attribute > 'properties' available to all resources > - */ > - File localPropsFile = new File(System.getProperty("user.dir") + > File.separator + "local.widgetserver.properties"); > - PropertiesConfiguration localConfiguration = new > PropertiesConfiguration(localPropsFile); > - CompositeConfiguration configuration = new CompositeConfiguration(); > - configuration.addConfiguration(localConfiguration); > - configuration.addConfiguration(new > PropertiesConfiguration("widgetserver.properties")); > - > - context.setAttribute("properties", (Configuration) configuration); > - > - // load these up now so we don't have to do it on every > request(i.e. filter) in the future > - usePreferenceInstanceQueues = > configuration.getBoolean(WidgetRuntimeHelper.USE_PREFERENCE_INSTANCE_QUEUES); > > - useSharedDataInstanceQueues = > configuration.getBoolean(WidgetRuntimeHelper.USE_SHAREDDATA_INSTANCE_QUEUES); > > - > - /* > - * Merge in system properties overrides > - */ > - Iterator<Object> systemKeysIter = > System.getProperties().keySet().iterator(); > - while (systemKeysIter.hasNext()) { > - String key = systemKeysIter.next().toString(); > - if (configuration.containsKey(key) || > key.startsWith("widget.")) { > - String setting = configuration.getString(key); > - String override = System.getProperty(key); > - if ((override != null) && (override.length() > > 0) && !override.equals(setting)) { > - configuration.setProperty(key, override); > - if (setting != null) { > - _logger.info("Overridden server > configuration property: " + key + "=" +override); > - } > - } > - } > - } > - > - /* > - * Initialize persistence manager factory now, not on > first request > - */ > - PersistenceManagerFactory.initialize(configuration); > - > - /* > - * Initialise the locale handler > - */ > - LocaleHandler.getInstance().initialize(configuration); > - final Locale locale = new > Locale(configuration.getString("widget.default.locale")); > - final Messages localizedMessages = > LocaleHandler.getInstance().getResourceBundle(locale); > - > - /* > - * load the opensocial.properties file and put it into > this context > - * as an attribute 'opensocial' available to all > resources > - */ > - File localOpenSocialPropsFile = new > File(System.getProperty("user.dir") + File.separator + > "local.opensocial.properties"); > + try { > + ServletContext context = event.getServletContext(); > + WidgetRuntimeHelper.setWebContextPath(context.getContextPath()); > + /* > + * load the widgetserver.properties and local.widget.properties > file > + * and put it into this context as an attribute 'properties' > available to all resources > + */ > + File localPropsFile = new File(System.getProperty("user.dir") + > File.separator + "local.widgetserver.properties"); > + PropertiesConfiguration localConfiguration = new > PropertiesConfiguration(localPropsFile); > + CompositeConfiguration configuration = new > CompositeConfiguration(); > + configuration.addConfiguration(localConfiguration); > + configuration.addConfiguration(new > PropertiesConfiguration("widgetserver.properties")); > + > + context.setAttribute("properties", (Configuration) > configuration); > + > + // load these up now so we don't have to do it on every > request(i.e. filter) in the future > + usePreferenceInstanceQueues = > configuration.getBoolean(WidgetRuntimeHelper.USE_PREFERENCE_INSTANCE_QUEUES); > > + useSharedDataInstanceQueues = > configuration.getBoolean(WidgetRuntimeHelper.USE_SHAREDDATA_INSTANCE_QUEUES); > > + > + /* > + * Merge in system properties overrides > + */ > + Iterator<Object> systemKeysIter = > System.getProperties().keySet().iterator(); > + while (systemKeysIter.hasNext()) { > + String key = systemKeysIter.next().toString(); > + if (configuration.containsKey(key) || > key.startsWith("widget.")) { > + String setting = configuration.getString(key); > + String override = System.getProperty(key); > + if ((override != null) && (override.length() > 0) && > !override.equals(setting)) { > + configuration.setProperty(key, override); > + if (setting != null) { > + _logger.info("Overridden server configuration > property: " + key + "=" +override); > + } > + } > + } > + } > + > + /* > + * Initialize persistence manager factory now, not on first > request > + */ > + PersistenceManagerFactory.initialize(configuration); > + > + /* > + * Initialise the locale handler > + */ > + LocaleHandler.getInstance().initialize(configuration); > + final Locale locale = new > Locale(configuration.getString("widget.default.locale")); > + final Messages localizedMessages = > LocaleHandler.getInstance().getResourceBundle(locale); > + > + /* > + * load the opensocial.properties file and put it into this > context > + * as an attribute 'opensocial' available to all resources > + */ > + File localOpenSocialPropsFile = new > File(System.getProperty("user.dir") + File.separator + > "local.opensocial.properties"); > PropertiesConfiguration localOpenSocialConfiguration = new > PropertiesConfiguration(localOpenSocialPropsFile); > CompositeConfiguration opensocialConfiguration = new > CompositeConfiguration(); > > opensocialConfiguration.addConfiguration(localOpenSocialConfiguration); > opensocialConfiguration.addConfiguration(new > PropertiesConfiguration("opensocial.properties")); > - context.setAttribute("opensocial", (Configuration) > opensocialConfiguration); > - > - /* > - * Load installed features > - */ > - Features.loadFeatures(context); > - > - /* > - * Run diagnostics > - */ > - Diagnostics.run(context, configuration); > - > - /* > - * Start hot-deploy widget watcher > - */ > - if (configuration.getBoolean("widget.hot_deploy")) { > - startWatcher(context, configuration, > localizedMessages); > - } else { > - > _logger.info(localizedMessages.getString("WidgetHotDeploy.0")); > - } > - } > - catch (ConfigurationException ex) { > - _logger.error("ConfigurationException thrown: "+ > ex.toString()); > - } > - } > - > - /** > - * Starts a watcher thread for hot-deploy of new widgets dropped into > the deploy folder > - * this is controlled using the > <code>widget.hot_deploy=true|false</code> property > - * and configured to look in the folder specified by the > <code>widget.deployfolder</code> property > - * @param context the current servlet context > - * @param configuration the configuration properties > - */ > - private void startWatcher(final ServletContext context, final > Configuration configuration, final Messages localizedMessages){ > - /* > - * Start watching for widget deployment > - */ > - final File deploy = new > File(WidgetPackageUtils.convertPathToPlatform(context.getRealPath(configuration.getString("widget.deployfolder")))); > - final String UPLOADFOLDER = > context.getRealPath(configuration.getString("widget.useruploadfolder")); > - final String WIDGETFOLDER = > context.getRealPath(configuration.getString("widget.widgetfolder")); > - final String localWidgetFolderPath = > configuration.getString("widget.widgetfolder"); > - final String[] locales = > configuration.getStringArray("widget.locales"); > - final String contextPath = context.getContextPath(); > - // Digital signature settings > - final boolean VERIFYSIGNATURE = > configuration.getBoolean("widget.deployment.verifysignature");//$NON-NLS-1$ > - final boolean REJECTINVALID= > configuration.getBoolean("widget.deployment.rejectinvalidsignatures"); > - final boolean REJECTUNTRUSTED= > configuration.getBoolean("widget.deployment.rejectuntrustedsignatures"); > - final String PASSWORD = > configuration.getString("widget.deployment.trustedkeystore.password"); > - final String KEYSTORE = > configuration.getString("widget.deployment.trustedkeystore");//$NON-NLS-1$ > - > - > - Thread thr = new Thread(){ > - public void run() { > - int interval = 5000; > - WgtWatcher watcher = new WgtWatcher(); > - watcher.setWatchDir(deploy); > - watcher.setListener(new > WgtWatcher.FileChangeListener(){ > - public void fileModified(File f) { > - // get persistence manager for this > thread > + context.setAttribute("opensocial", (Configuration) > opensocialConfiguration); > + > + /* > + * Load installed features > + */ > + Features.loadFeatures(context); > + > + /* > + * Run diagnostics > + */ > + Diagnostics.run(context, configuration); > + > + /* > + * Start hot-deploy widget watcher > + */ > + if (configuration.getBoolean("widget.hot_deploy")) { > + startWatcher(context, configuration, localizedMessages); > + } else { > + > _logger.info(localizedMessages.getString("WidgetHotDeploy.0")); > + } > + } > + catch (ConfigurationException ex) { > + _logger.error("ConfigurationException thrown: "+ ex.toString()); > + } > + } > + > + /** > + * Starts a watcher thread for hot-deploy of new widgets dropped into > the deploy folder > + * this is controlled using the > <code>widget.hot_deploy=true|false</code> property > + * and configured to look in the folder specified by the > <code>widget.deployfolder</code> property > + * @param context the current servlet context > + * @param configuration the configuration properties > + */ > + private void startWatcher(final ServletContext context, final > Configuration configuration, final Messages localizedMessages){ > + /* > + * Start watching for widget deployment > + */ > + final File deploy = new > File(WidgetPackageUtils.convertPathToPlatform(context.getRealPath(configuration.getString("widget.deployfolder")))); > + final String UPLOADFOLDER = > context.getRealPath(configuration.getString("widget.useruploadfolder")); > + final String WIDGETFOLDER = > context.getRealPath(configuration.getString("widget.widgetfolder")); > + final String localWidgetFolderPath = > configuration.getString("widget.widgetfolder"); > + final String[] locales = > configuration.getStringArray("widget.locales"); > + final String contextPath = context.getContextPath(); > + // Digital signature settings > + final boolean VERIFYSIGNATURE = > configuration.getBoolean("widget.deployment.verifysignature");//$NON-NLS-1$ > + final boolean REJECTINVALID= > configuration.getBoolean("widget.deployment.rejectinvalidsignatures"); > + final boolean REJECTUNTRUSTED= > configuration.getBoolean("widget.deployment.rejectuntrustedsignatures"); > + final String PASSWORD = > configuration.getString("widget.deployment.trustedkeystore.password"); > + final String KEYSTORE = > configuration.getString("widget.deployment.trustedkeystore");//$NON-NLS-1$ > + > + > + Thread thr = new Thread(){ > + public void run() { > + int interval = 5000; > + WgtWatcher watcher = new WgtWatcher(); > + watcher.setWatchDir(deploy); > + watcher.setListener(new WgtWatcher.FileChangeListener(){ > + public void fileModified(File f) { > + // get persistence manager for this thread > IPersistenceManager persistenceManager = > PersistenceManagerFactory.getPersistenceManager(); > - try{ > - > persistenceManager.begin(); > - File upload = > WidgetFileUtils.dealWithDroppedFile(UPLOADFOLDER, f); > - W3CWidgetFactory fac = > new W3CWidgetFactory(); > - fac.setLocales(locales); > - > fac.setLocalPath(contextPath+localWidgetFolderPath); > - > fac.setOutputDirectory(WIDGETFOLDER); > - > fac.setFeatures(Features.getFeatureNames()); > - > fac.setStartPageProcessor(new StartPageProcessor()); > - if (VERIFYSIGNATURE) { > - InputStream stream = context > - .getResourceAsStream("/WEB-INF/classes/" + KEYSTORE); > - KeyStore keyStore = KeyStore.getInstance("JKS"); > - keyStore.load(stream, PASSWORD.toCharArray()); > - stream.close(); > - fac.setDigitalSignatureParser(new DigitalSignatureProcessor( > - keyStore, REJECTINVALID, REJECTUNTRUSTED)); > - } > - > - W3CWidget model = > fac.parse(upload); > - > WidgetJavascriptSyntaxAnalyzer jsa = new > WidgetJavascriptSyntaxAnalyzer(fac.getUnzippedWidgetDirectory()); > - > if(persistenceManager.findWidgetByGuid(model.getIdentifier()) == null) { > - > WidgetFactory.addNewWidget(model, upload, true); > - String message > = model.getLocalName("en") +"' - " + > localizedMessages.getString("WidgetAdminServlet.19"); > - > _logger.info(message); > - } else { > - String message > = model.getLocalName("en") +"' - " + > localizedMessages.getString("WidgetAdminServlet.20"); > - > WidgetFactory.update(model, > persistenceManager.findWidgetByGuid(model.getIdentifier()), true, upload); > - > _logger.info(message); > - } > - > persistenceManager.commit(); > - > NewWidgetBroadcaster.broadcast(configuration, model.getIdentifier()); > - } catch (IOException e) { > + try{ > + persistenceManager.begin(); > + File upload = > WidgetFileUtils.dealWithDroppedFile(UPLOADFOLDER, f); > + W3CWidgetFactory fac = new W3CWidgetFactory(); > + fac.setLocales(locales); > + > fac.setLocalPath(contextPath+localWidgetFolderPath); > + fac.setOutputDirectory(WIDGETFOLDER); > + fac.setFeatures(Features.getFeatureNames()); > + fac.setStartPageProcessor(new > StartPageProcessor()); > + if (VERIFYSIGNATURE) { > + InputStream stream = context > + .getResourceAsStream("/WEB-INF/classes/" + > KEYSTORE); > + if(stream != null){ > + KeyStore keyStore = > KeyStore.getInstance("JKS"); > + keyStore.load(stream, > PASSWORD.toCharArray()); > + stream.close(); > + fac.setDigitalSignatureParser(new > DigitalSignatureProcessor( > + keyStore, REJECTINVALID, > REJECTUNTRUSTED)); > + }else{ > + > _logger.error(localizedMessages.getString("WidgetHotDeploy.4") + > + " (/WEB-INF/classes/" + > KEYSTORE+") " + localizedMessages.getString("WidgetHotDeploy.5")); > + } > + } > + > + W3CWidget model = fac.parse(upload); > + WidgetJavascriptSyntaxAnalyzer jsa = new > WidgetJavascriptSyntaxAnalyzer(fac.getUnzippedWidgetDirectory()); > + > if(persistenceManager.findWidgetByGuid(model.getIdentifier()) == null) { > + WidgetFactory.addNewWidget(model, upload, > true); > + String message = model.getLocalName("en") > +"' - " + localizedMessages.getString("WidgetAdminServlet.19"); > + _logger.info(message); > + } else { > + String message = model.getLocalName("en") > +"' - " + localizedMessages.getString("WidgetAdminServlet.20"); > + WidgetFactory.update(model, > persistenceManager.findWidgetByGuid(model.getIdentifier()), true, upload); > + _logger.info(message); > + } > + persistenceManager.commit(); > + NewWidgetBroadcaster.broadcast(configuration, > model.getIdentifier()); > + } catch (IOException e) { > persistenceManager.rollback(); > - String error = > f.getName()+":"+localizedMessages.getString("WidgetHotDeploy.1") + " - " + > e.getLocalizedMessage(); > - _logger.error(error, e); > - } catch > (BadWidgetZipFileException e) { > + String error = > f.getName()+":"+localizedMessages.getString("WidgetHotDeploy.1") + " - " + > e.getLocalizedMessage(); > + _logger.error(error, e); > + } catch (BadWidgetZipFileException e) { > persistenceManager.rollback(); > - String error = > f.getName()+":"+localizedMessages.getString("WidgetHotDeploy.2") + " - " + > e.getLocalizedMessage(); > - _logger.error(error, e); > - } catch (BadManifestException > e) { > + String error = > f.getName()+":"+localizedMessages.getString("WidgetHotDeploy.2") + " - " + > e.getLocalizedMessage(); > + _logger.error(error, e); > + } catch (BadManifestException e) { > persistenceManager.rollback(); > - String error = > f.getName()+":"+localizedMessages.getString("WidgetHotDeploy.3") + " - " + > e.getLocalizedMessage(); > - _logger.error(error, e); > - } catch (Exception e) { > + String error = > f.getName()+":"+localizedMessages.getString("WidgetHotDeploy.3") + " - " + > e.getLocalizedMessage(); > + _logger.error(error, e); > + } catch (Exception e) { > persistenceManager.rollback(); > - String error = > f.getName()+":"+e.getLocalizedMessage(); > - _logger.error(error, e); > - } finally { > - // close thread persistence manager > - > PersistenceManagerFactory.closePersistenceManager(); > > - } > - } > - public void fileRemoved(File f) { > - // Not implemented - the .wgt > files are removed as part of the deployment process > - } > - }); > - try { > - while (true) { > - watcher.check(); > - Thread.sleep(interval); > - } > - } catch (InterruptedException iex) { > - } > - } > - }; > - > - thr.start(); > - > - } > + String error = > f.getName()+":"+e.getLocalizedMessage(); > + _logger.error(error, e); > + } finally { > + // close thread persistence manager > + > PersistenceManagerFactory.closePersistenceManager(); > > + } > + } > + public void fileRemoved(File f) { > + // Not implemented - the .wgt files are removed as > part of the deployment process > + } > + }); > + try { > + while (true) { > + watcher.check(); > + Thread.sleep(interval); > + } > + } catch (InterruptedException iex) { > + } > + } > + }; > + > + thr.start(); > + > + } > > - public void contextDestroyed(ServletContextEvent event){ > + public void contextDestroyed(ServletContextEvent event){ > /* > * Terminate persistence manager factory > */ > - PersistenceManagerFactory.terminate(); > - } > + PersistenceManagerFactory.terminate(); > + } > } > >
