Source:
<code>public void handlePostModifyEvent(CatalogPostModifyEvent event) throws CatalogException { if (event.getPropertyNames().indexOf("name") == -1) return; if (event.getSource() instanceof WorkspaceInfo) { String oldWorkspaceName = String.valueOf( event.getOldValues().get(event.getPropertyNames().indexOf("name"))); String newWorkspaceName = String.valueOf( event.getNewValues().get(event.getPropertyNames().indexOf("name"))); if (oldWorkspaceName.equalsIgnoreCase(newWorkspaceName)) return; if (workspaceHasSecurityRule(oldWorkspaceName)) { LOGGER.info( String.format( "Updating Security Rules for Renamed Workspace: %s", oldWorkspaceName)); List<DataAccessRule> rulesToModifyList = getDataAccessRule(event.getSource(), oldWorkspaceName); for (DataAccessRule rule : rulesToModifyList) rule.setRoot(newWorkspaceName); try { dao.storeRules(); } catch (IOException e) { LOGGER.log(Level.SEVERE, e.getMessage(), e); } } } else if (event.getSource() instanceof ResourceInfo) { String oldResourceName = String.valueOf( event.getOldValues().get(event.getPropertyNames().indexOf("name"))); String newResourceName = String.valueOf( event.getNewValues().get(event.getPropertyNames().indexOf("name"))); <START> if (oldResourceName.equalsIgnoreCase(newResourceName)) return; <END> ResourceInfo resourceInfo = (ResourceInfo) event.getSource(); String workspaceName = resourceInfo.getStore().getWorkspace().getName(); if (layerHasSecurityRule(workspaceName, oldResourceName)) { LOGGER.info( String.format( "Updating Security Rules for Renamed Feature Type: %s", oldResourceName)); List<DataAccessRule> rulesToModifyList = getDataAccessRule(resourceInfo, oldResourceName); for (DataAccessRule rule : rulesToModifyList) rule.setLayer(newResourceName); try { dao.storeRules(); } catch (IOException e) { LOGGER.log(Level.SEVERE, e.getMessage(), e); } } } }</code><technical_language>logic is for workspace - consolidate move this part of if statements (ultimately important, personal preference, approach a bit more concise)</technical_language>

Target:
public void handlePostModifyEvent(CatalogPostModifyEvent event) throws CatalogException { if (event.getPropertyNames().indexOf("name") == -1) return; String oldName = String.valueOf(event.getOldValues().get(event.getPropertyNames().indexOf("name"))); String newName = String.valueOf(event.getNewValues().get(event.getPropertyNames().indexOf("name"))); if (oldName.equalsIgnoreCase(newName)) return; String resourceWorkSpaceName = null; CatalogInfo resourceInfo = null; if (event.getSource() instanceof WorkspaceInfo) { if (workspaceHasSecurityRule(oldName)) { LOGGER.info( String.format( "Updating Security Rules for Renamed Workspace: %s", oldName)); List<DataAccessRule> rulesToModifyList = getDataAccessRule(event.getSource(), oldName); for (DataAccessRule rule : rulesToModifyList) rule.setRoot(newName); } } else if (event.getSource() instanceof ResourceInfo) { resourceInfo = event.getSource(); resourceWorkSpaceName = ((ResourceInfo) resourceInfo).getStore().getWorkspace().getName(); } else if (event.getSource() instanceof LayerGroupInfo) { resourceInfo = event.getSource(); resourceWorkSpaceName = ((LayerGroupInfo) resourceInfo).getWorkspace().getName(); } if (resourceWorkSpaceName != null && resourceInfo != null) { if (layerHasSecurityRule(resourceWorkSpaceName, oldName)) { LOGGER.info( String.format( "Updating Security Rules for Renamed Feature Type: %s", oldName)); List<DataAccessRule> rulesToModifyList = getDataAccessRule(resourceInfo, oldName); for (DataAccessRule rule : rulesToModifyList) rule.setLayer(newName); } } try { dao.storeRules(); } catch (IOException e) { LOGGER.log(Level.SEVERE, e.getMessage(), e); } }