@Override public UnitTemplate.UnitType getUnitType() throws NotAvailableException { return getConfig().getType(); }
@Override public String getLabel() throws NotAvailableException { try { UnitConfig tmpConfig = getConfig(); if (!tmpConfig.hasLabel()) { throw new NotAvailableException("unitconfig.label"); } if (tmpConfig.getLabel().isEmpty()) { throw new InvalidStateException("unitconfig.label is empty"); } return getConfig().getLabel(); } catch (CouldNotPerformException ex) { throw new NotAvailableException("label", ex); } }
public boolean isEnabled() { try { return getConfig().getEnablingState().getValue().equals(EnablingState.State.ENABLED); } catch (CouldNotPerformException ex) { ExceptionPrinter.printHistory(ex, logger); } return false; }
@Override public void update(Observable<UnitRegistryData> source, UnitRegistryData data) throws Exception { try { final UnitConfig newUnitConfig = Registries.getUnitRegistry(true).getUnitConfigById(getId()); if (!newUnitConfig.equals(getConfig())) { applyConfigUpdate(newUnitConfig); } } catch (NotAvailableException ex) { // unit config has been removed, probably because of deletion and a higher controller will do the shutdown in this case logger.debug("Could not update unit controller", ex); } catch (CouldNotPerformException ex) { ExceptionPrinter.printHistory("Could not update unit config of " + this, ex, logger); } } };
@Override public final String getId() throws NotAvailableException { try { UnitConfig tmpConfig = getConfig(); if (!tmpConfig.hasId()) { throw new NotAvailableException("unitconfig.id"); } if (tmpConfig.getId().isEmpty()) { throw new InvalidStateException("unitconfig.id is empty"); } return tmpConfig.getId(); } catch (CouldNotPerformException ex) { throw new NotAvailableException("id", ex); } }
if (getConfig().equals(config)) { logger.debug("Skip config update because no config change detected!"); return config;
Map<String, IdentifiableMessage<String, UnitConfig, UnitConfig.Builder>> locations = Registries.getUnitRegistry().getLocationUnitConfigRemoteRegistry().getEntryMap(); if (!AuthorizationHelper.canAccess(getConfig(), null, null, locations)) { throw new PermissionDeniedException("You have no permission to execute this action."); Map<String, IdentifiableMessage<String, UnitConfig, UnitConfig.Builder>> locations = Registries.getUnitRegistry().getLocationUnitConfigRemoteRegistry().getEntryMap(); if (!AuthorizationHelper.canAccess(getConfig(), validatedTicketWrapper.getUserId(), groups, locations)) { throw new PermissionDeniedException("You have no permission to execute this action.");