public static ScopeType.Scope generateScope(final String scope) throws CouldNotPerformException { ScopeType.Scope.Builder generatedScope = ScopeType.Scope.newBuilder(); for (String component : scope.split("/")) { // check for empty components (/a//b/ = /a/b/) if (component.isEmpty()) { continue; } generatedScope.addComponent(convertIntoValidScopeComponent(component)); } return generatedScope.build(); }
@Override protected Scope getPropertyDefaultValue() { if(JPService.testMode()) { String user = ScopeGenerator.convertIntoValidScopeComponent(System.getProperty("user.name")); return new Scope("/test/"+user); } return new Scope("/"); }
@Override public void init() throws InitializationException, InterruptedException { try { super.init(SCOPE_PREFIX_LAUNCHER + Scope.COMPONENT_SEPARATOR + ScopeGenerator.convertIntoValidScopeComponent(getName())); } catch (NotAvailableException ex) { throw new InitializationException(this, ex); } }
public static ScopeType.Scope generateAuthorizationGroupScope(final UnitConfig authorizationGroupUniConfig) throws CouldNotPerformException { if (authorizationGroupUniConfig == null) { throw new NotAvailableException("authorizationGroupConfig"); } if (!authorizationGroupUniConfig.hasLabel()) { throw new NotAvailableException("authorizationGroupConfig.label"); } if (authorizationGroupUniConfig.getLabel().isEmpty()) { throw new NotAvailableException("Field authorizationGroupConfig.label isEmpty"); } // add manager ScopeType.Scope.Builder scope = ScopeType.Scope.newBuilder().addComponent(convertIntoValidScopeComponent("manager")); // add user scope.addComponent(convertIntoValidScopeComponent("authorization")); // add group scope.addComponent(convertIntoValidScopeComponent("group")); // add user name scope.addComponent(convertIntoValidScopeComponent(authorizationGroupUniConfig.getLabel())); return scope.build(); }
public static ScopeType.Scope generateScope(final String label, final String type, final ScopeType.Scope locationScope) throws CouldNotPerformException { try { ScopeType.Scope.Builder newScope = ScopeType.Scope.newBuilder(); newScope.addAllComponent(locationScope.getComponentList()); newScope.addComponent(convertIntoValidScopeComponent(type)); newScope.addComponent(convertIntoValidScopeComponent(label)); return newScope.build(); } catch (NullPointerException ex) { throw new CouldNotPerformException("Coult not generate scope!", ex); } }
public static ScopeType.Scope generateUserScope(final UnitConfig userUnitConfig) throws CouldNotPerformException { if (userUnitConfig == null) { throw new NotAvailableException("userUnitConfig"); } if (!userUnitConfig.hasUserConfig()) { throw new NotAvailableException("userConfig"); } if (!userUnitConfig.getUserConfig().hasUserName()) { throw new NotAvailableException("userConfig.userName"); } if (userUnitConfig.getUserConfig().getUserName().isEmpty()) { throw new NotAvailableException("Field userConfig.userName isEmpty"); } // add manager ScopeType.Scope.Builder scope = ScopeType.Scope.newBuilder().addComponent(convertIntoValidScopeComponent("manager")); // add unit type scope.addComponent(convertIntoValidScopeComponent(userUnitConfig.getType().name())); // add user name scope.addComponent(convertIntoValidScopeComponent(userUnitConfig.getUserConfig().getUserName())); return scope.build(); }
public static ScopeType.Scope generateConnectionScope(final UnitConfig connectionConfig, final UnitConfig locationConfig) throws CouldNotPerformException { if (connectionConfig == null) { throw new NotAvailableException("connectionConfig"); } if (!connectionConfig.hasLabel()) { throw new NotAvailableException("connectionConfig.label"); } if (connectionConfig.getLabel().isEmpty()) { throw new NotAvailableException("Field connectionConfig.label isEmpty"); } if (locationConfig == null) { throw new NotAvailableException("location"); } if (!locationConfig.hasScope() || locationConfig.getScope().getComponentList().isEmpty()) { throw new NotAvailableException("location scope"); } // add location scope ScopeType.Scope.Builder scope = locationConfig.getScope().toBuilder(); // add unit type scope.addComponent(convertIntoValidScopeComponent(connectionConfig.getType().name().replace("_", ""))); // add unit label scope.addComponent(convertIntoValidScopeComponent(connectionConfig.getLabel())); return scope.build(); }
scope.addComponent(convertIntoValidScopeComponent(appUnitConfig.getType().name())); scope.addComponent(convertIntoValidScopeComponent(appClass.getLabel())); scope.addComponent(convertIntoValidScopeComponent(appUnitConfig.getLabel()));
public static ScopeType.Scope generateUnitScope(final UnitConfig unitConfig, final UnitConfig locationConfig) throws CouldNotPerformException { if (unitConfig == null) { throw new NotAvailableException("unitConfig"); } if (!unitConfig.hasLabel()) { throw new NotAvailableException("unitConfig.label"); } if (unitConfig.getLabel().isEmpty()) { throw new NotAvailableException("Field unitConfig.label isEmpty"); } if (!unitConfig.hasPlacementConfig()) { throw new NotAvailableException("placement config"); } if (locationConfig == null) { throw new NotAvailableException("location"); } if (!locationConfig.hasScope() || locationConfig.getScope().getComponentList().isEmpty()) { throw new NotAvailableException("location scope"); } // add location scope ScopeType.Scope.Builder scope = locationConfig.getScope().toBuilder(); // add unit type scope.addComponent(convertIntoValidScopeComponent(unitConfig.getType().name().replace("_", ""))); // add unit label scope.addComponent(convertIntoValidScopeComponent(unitConfig.getLabel())); return scope.build(); }
public static ScopeType.Scope generateSceneScope(final UnitConfig sceneUnitConfig, final UnitConfig locationConfig) throws CouldNotPerformException { if (sceneUnitConfig == null) { throw new NotAvailableException("sceneConfig"); } if (!sceneUnitConfig.hasLabel()) { throw new NotAvailableException("sceneConfig.label"); } if (sceneUnitConfig.getLabel().isEmpty()) { throw new NotAvailableException("Field sceneConfig.label isEmpty"); } if (locationConfig == null) { throw new NotAvailableException("location"); } if (!locationConfig.hasScope() || locationConfig.getScope().getComponentList().isEmpty()) { throw new NotAvailableException("location scope"); } // add location scope ScopeType.Scope.Builder scope = locationConfig.getScope().toBuilder(); // add unit type scope.addComponent(convertIntoValidScopeComponent(sceneUnitConfig.getType().name())); // add unit label scope.addComponent(convertIntoValidScopeComponent(sceneUnitConfig.getLabel())); return scope.build(); }
scope.addComponent(convertIntoValidScopeComponent("UnitGroup")); scope.addComponent(convertIntoValidScopeComponent(unitGroupConfig.getLabel()));
public static ScopeType.Scope generateDeviceScope(final UnitConfig deviceConfig, final UnitConfig locationConfig) throws CouldNotPerformException { if (deviceConfig == null) { throw new NotAvailableException("deviceConfig"); } if (!deviceConfig.hasLabel()) { throw new NotAvailableException("device label"); } if (!deviceConfig.hasPlacementConfig()) { throw new NotAvailableException("placement config"); } if (locationConfig == null) { throw new NotAvailableException("location"); } if (!locationConfig.hasScope() || locationConfig.getScope().getComponentList().isEmpty()) { throw new NotAvailableException("location scope"); } // add location scope ScopeType.Scope.Builder scope = locationConfig.getScope().toBuilder(); // add type 'device' scope.addComponent(convertIntoValidScopeComponent("device")); // add device scope scope.addComponent(convertIntoValidScopeComponent(deviceConfig.getLabel())); return scope.build(); }
scope.addComponent(convertIntoValidScopeComponent(agentUnitConfig.getType().name())); scope.addComponent(convertIntoValidScopeComponent(agentClass.getLabel())); scope.addComponent(convertIntoValidScopeComponent(agentUnitConfig.getLabel()));
public static ScopeType.Scope generateLocationScope(final UnitConfig unitConfig, final ProtoBufMessageMap<String, UnitConfig, UnitConfig.Builder> registry) throws CouldNotPerformException { if (unitConfig == null) { throw new NotAvailableException("unitConfig"); } if (!unitConfig.hasLocationConfig() || unitConfig.getLocationConfig() == null) { throw new NotAvailableException("locationConfig"); } if (registry == null) { throw new NotAvailableException("registry"); } if (!unitConfig.hasLabel()) { throw new NotAvailableException("location.label"); } if (!unitConfig.hasPlacementConfig()) { throw new NotAvailableException("location.placementconfig"); } if (!unitConfig.getPlacementConfig().hasLocationId() || unitConfig.getPlacementConfig().getLocationId().isEmpty()) { throw new NotAvailableException("location.placementconfig.locationid"); } ScopeType.Scope.Builder scope = ScopeType.Scope.newBuilder(); if (!unitConfig.getLocationConfig().getRoot()) { scope.addAllComponent(registry.get(unitConfig.getPlacementConfig().getLocationId()).getMessage().getScope().getComponentList()); } scope.addComponent(convertIntoValidScopeComponent(unitConfig.getLabel())); return scope.build(); }