diff --git a/modules/apps/static/portal-configuration/portal-configuration-persistence-impl/src/main/java/com/liferay/portal/configuration/persistence/internal/ConfigurationPersistenceManager.java b/modules/apps/static/portal-configuration/portal-configuration-persistence-impl/src/main/java/com/liferay/portal/configuration/persistence/internal/ConfigurationPersistenceManager.java index 627fd315a1ef12..613a0d07ac9cfa 100644 --- a/modules/apps/static/portal-configuration/portal-configuration-persistence-impl/src/main/java/com/liferay/portal/configuration/persistence/internal/ConfigurationPersistenceManager.java +++ b/modules/apps/static/portal-configuration/portal-configuration-persistence-impl/src/main/java/com/liferay/portal/configuration/persistence/internal/ConfigurationPersistenceManager.java @@ -74,8 +74,48 @@ public ConfigurationPersistenceManager( } @Override - public void delete(final String pid) throws IOException { - doDelete(pid); + public void delete(String pid) throws IOException { + ConfigurationModelListener configurationModelListener = null; + + if (!pid.endsWith("factory") && hasPid(pid)) { + Dictionary dictionary = getDictionary(pid); + + String pidKey = (String)dictionary.get( + ConfigurationAdmin.SERVICE_FACTORYPID); + + if (pidKey == null) { + pidKey = (String)dictionary.get(Constants.SERVICE_PID); + } + + if (pidKey == null) { + pidKey = pid; + } + + configurationModelListener = _getConfigurationModelListener(pidKey); + } + + if (configurationModelListener != null) { + configurationModelListener.onBeforeDelete(pid); + } + + Lock lock = _readWriteLock.writeLock(); + + try { + lock.lock(); + + Dictionary dictionary = _dictionaries.remove(pid); + + if ((dictionary != null) && hasPid(pid)) { + deleteFromDatabase(pid); + } + } + finally { + lock.unlock(); + } + + if (configurationModelListener != null) { + configurationModelListener.onAfterDelete(pid); + } } @Override @@ -159,84 +199,6 @@ public void stop() { @Override public void store( - final String pid, - @SuppressWarnings("rawtypes") final Dictionary dictionary) - throws IOException { - - doStore(pid, dictionary); - } - - protected void createConfigurationTable() throws IOException, SQLException { - try (Connection connection = _dataSource.getConnection(); - Statement statement = connection.createStatement()) { - - statement.executeUpdate( - _db.buildSQL( - "create table Configuration_ (configurationId " + - "VARCHAR(255) not null primary key, dictionary TEXT)")); - } - } - - protected void deleteFromDatabase(String pid) throws IOException { - try (Connection connection = _dataSource.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement( - _db.buildSQL( - "delete from Configuration_ where configurationId = ?"))) { - - preparedStatement.setString(1, pid); - - preparedStatement.executeUpdate(); - } - catch (SQLException sqle) { - throw new IOException(sqle); - } - } - - protected void doDelete(String pid) throws IOException { - ConfigurationModelListener configurationModelListener = null; - - if (!pid.endsWith("factory") && hasPid(pid)) { - Dictionary dictionary = getDictionary(pid); - - String pidKey = (String)dictionary.get( - ConfigurationAdmin.SERVICE_FACTORYPID); - - if (pidKey == null) { - pidKey = (String)dictionary.get(Constants.SERVICE_PID); - } - - if (pidKey == null) { - pidKey = pid; - } - - configurationModelListener = _getConfigurationModelListener(pidKey); - } - - if (configurationModelListener != null) { - configurationModelListener.onBeforeDelete(pid); - } - - Lock lock = _readWriteLock.writeLock(); - - try { - lock.lock(); - - Dictionary dictionary = _dictionaries.remove(pid); - - if ((dictionary != null) && hasPid(pid)) { - deleteFromDatabase(pid); - } - } - finally { - lock.unlock(); - } - - if (configurationModelListener != null) { - configurationModelListener.onAfterDelete(pid); - } - } - - protected void doStore( String pid, @SuppressWarnings("rawtypes") Dictionary dictionary) throws IOException { @@ -292,6 +254,32 @@ protected void doStore( } } + protected void createConfigurationTable() throws IOException, SQLException { + try (Connection connection = _dataSource.getConnection(); + Statement statement = connection.createStatement()) { + + statement.executeUpdate( + _db.buildSQL( + "create table Configuration_ (configurationId " + + "VARCHAR(255) not null primary key, dictionary TEXT)")); + } + } + + protected void deleteFromDatabase(String pid) throws IOException { + try (Connection connection = _dataSource.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement( + _db.buildSQL( + "delete from Configuration_ where configurationId = ?"))) { + + preparedStatement.setString(1, pid); + + preparedStatement.executeUpdate(); + } + catch (SQLException sqle) { + throw new IOException(sqle); + } + } + protected Dictionary getDictionary(String pid) throws IOException { try (Connection connection = _dataSource.getConnection(); PreparedStatement preparedStatement = connection.prepareStatement(