@Override public void leftOnly(T left) { // Create changes.linkAdd(fromDnsPointer, linkType, left); }
@Override public void rightOnly(T right) { // Remove changes.linkDelete(fromDnsPointer, linkType, right); } });
public ChangeExecutionLogic(CommonServicesContext commonServicesContext, InternalServicesContext internalServicesContext) { this.commonServicesContext = commonServicesContext; this.ipPluginService = commonServicesContext.getPluginService(); this.ipResourceService = commonServicesContext.getResourceService(); this.internalChangeService = internalServicesContext.getInternalChangeService(); }
private void deleteAllResources() { ChangesContext changes = new ChangesContext(getCommonServicesContext().getResourceService()); for (IPResource resource : getInternalServicesContext().getInternalIPResourceService().resourceFindAll()) { changes.resourceDelete(resource); } getInternalServicesContext().getInternalChangeService().changesExecute(changes); }
@Override public void initialize(CommonServicesContext commonServicesContext) { UnixUserAvailableIdHelper.init(commonServicesContext.getResourceService()); }
private void common(CommonServicesContext services, ChangesContext changes) { IPResourceService resourceService = services.getResourceService(); List<Bind9Server> bind9Servers = resourceService.resourceFindAll(resourceService.createResourceQuery(Bind9Server.class)); bind9Servers.forEach(it -> { changes.resourceRefresh(it); }); }
private void removeApplicationFor(CommonServicesContext services, ChangesContext changes, String machineName) { IPResourceService resourceService = services.getResourceService(); // Application Application backupApplication = new Application(); backupApplication.setDescription("Backup to Google Cloud for " + machineName); backupApplication.setName("backup_google-" + machineName.replaceAll("\\.", "_")); Optional<Application> existingApplicationOptional = resourceService.resourceFindByPk(backupApplication); if (existingApplicationOptional.isPresent()) { Application existingApplication = existingApplicationOptional.get(); logger.info("Removing application {}", existingApplication.getName()); changes.resourceDelete(existingApplication); } }
public void resourceUpdate(IPResource resource) { resourceUpdate(resource.getInternalId(), resource); }
/** * Add a recurrent timer. * * @param handler * the event handler * @param timerName * the name of the timer * @param calendarUnit * the unit of the delta that is a constant on {@link Calendar} * @param deltaTime * the delta between events */ public void addTimer(TimerEventHandler handler, String timerName, int calendarUnit, int deltaTime) { timers.add(new TimerEventContext(handler, timerName, calendarUnit, deltaTime)); }
public static void init(CommonServicesContext commonServicesContext, InternalServicesContext internalServicesContext) { // Load all the plugins commonServicesContext.getPluginService().loadPlugins(commonServicesContext, internalServicesContext); }
/** * Add a resource editor. * * @param editor * the form page definition editor * @param editorName * a unique name for this editor */ public void addResourceEditor(ResourceEditor<?> editor, String editorName) { resourceEditors.add(new ResourceEditorContext(editor, editorName)); }
/** * Add an update event handler. * * @param handler * the event handler * @param updateHandlerName * the name of the handler */ public void addUpdateHandler(UpdateEventHandler<?> handler, String updateHandlerName) { updateHandlers.add(new UpdateEventContext(handler, updateHandlerName)); }
@Override public void timerHandler(CommonServicesContext services, ChangesContext changes, TimerEventContext event) { logger.info("Event {} triggered", event.getTimerName()); }
@Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append("TimerEventContext [timerName="); builder.append(timerName); builder.append(", calendarUnit="); builder.append(getCalendarUnitInText()); builder.append(", deltaTime="); builder.append(deltaTime); builder.append("]"); return builder.toString(); }
@Override public void updateHandler(CommonServicesContext services, ChangesContext changes, Machine previousResource, Machine newResource) { createUnixUserIfMissing(services.getResourceService(), changes); }
protected void commonHandlerExecute(CommonServicesContext services, ChangesContext changes) { IPResourceService resourceService = services.getResourceService(); resourceService.resourceFindAll(resourceService.createResourceQuery(Machine.class)).forEach(machine -> changes.resourceRefresh(machine)); }
public void resourceUpdate(IPResource resource, IPResource updatedResource) { resourceUpdate(resource.getInternalId(), updatedResource); }
@Override public void initialize(CommonServicesContext commonServicesContext) { UnixUserAvailableIdHelper.init(commonServicesContext.getResourceService()); }
@Override public void addHandler(CommonServicesContext services, ChangesContext changes, Machine resource) { createUnixUserIfMissing(services.getResourceService(), changes); }
protected void detachManagedResources(CommonServicesContext services, ChangesContext changes, IPResource resource, List<Tuple3<IPResource, String, IPResource>> previousLinks) { IPResourceService resourceService = services.getResourceService(); // Get the currently managed resources List<IPResource> currentlyManagedResources = linkFindAllByFromResourceAndLinkType(previousLinks, resource, LinkTypeConstants.MANAGES); // Detach them for (IPResource currentlyManagedResource : currentlyManagedResources) { removeManagedLinkAndDeleteIfNotManagedByAnyoneElse(resourceService, changes, currentlyManagedResource, resource); } }