protected void processPorts(Instance instance) { Set<String> portSpecs = new HashSet<>(); for (Port port : objectManager.children(instance, Port.class)) { if (port.getRemoved() != null) { continue; } portSpecs.add(new PortSpec(port).toSpec()); } objectManager.setFields(instance, InstanceConstants.FIELD_PORTS, new ArrayList<>(portSpecs)); instanceDao.clearCacheInstanceData(instance.getId()); }
@Override public HandlerResult handle(ProcessState state, ProcessInstance process) { Account account = (Account) state.getResource(); for (Certificate cert : getObjectManager().children(account, Certificate.class)) { if (cert.getRemoved() != null) { continue; } deactivateThenRemove(cert, state.getData()); } for (Credential cred : getObjectManager().children(account, Credential.class)) { if (cred.getRemoved() != null) { continue; } deactivateThenRemove(cred, state.getData()); } for (Host host : getObjectManager().children(account, Host.class)) { try { deactivateThenRemove(host, state.getData()); } catch (ProcessCancelException e) { // ignore } purge(host, null); } for (PhysicalHost host : getObjectManager().children(account, PhysicalHost.class)) { try { getObjectProcessManager().executeStandardProcess(StandardProcess.REMOVE, host, null); } catch (ProcessCancelException e) { // ignore } } for (Agent agent : getObjectManager().children(account, Agent.class)) { if (agent.getRemoved() != null) { continue; } deactivateThenRemove(agent, state.getData()); } for (Environment env : getObjectManager().children(account, Environment.class)) { if (env.getRemoved() != null) { continue; } objectProcessManager.scheduleStandardProcessAsync(StandardProcess.REMOVE, env, null); } for (Instance instance : instanceDao.listNonRemovedInstances(account, false)) { deleteAgentAccount(instance.getAgentId(), state.getData()); try { objectProcessManager.scheduleStandardProcess(StandardProcess.REMOVE, instance, null); } catch (ProcessCancelException e) { objectProcessManager.scheduleProcessInstance( InstanceConstants.PROCESS_STOP, instance, CollectionUtils.asMap(InstanceConstants.REMOVE_OPTION, true)); } } accountDao.deleteProjectMemberEntries(account); return null; }