/** * Returns the parameter as an array of Strings. If * the parameter is a scalar value its string value is returned as a single * element array. If the parameter is an array, the elements are converted to * String objects and returned as an array. If the parameter is a collection, the * collection elements are converted to String objects and returned as an array. * Otherwise (if the parameter is {@code null}) {@code null} is * returned. * * @param propValue The object to convert. */ public static String[] toStringArray(Object propValue) { return toStringArray(propValue, null); }
/** * Returns the parameter as an array of Strings. If * the parameter is a scalar value its string value is returned as a single * element array. If the parameter is an array, the elements are converted to * String objects and returned as an array. If the parameter is a collection, the * collection elements are converted to String objects and returned as an array. * Otherwise (if the parameter is {@code null}) {@code null} is * returned. * * @param propValue The object to convert. */ public static String[] toStringArray(Object propValue) { return toStringArray(propValue, null); }
/** * Returns the parameter as an array of Strings. If * the parameter is a scalar value its string value is returned as a single * element array. If the parameter is an array, the elements are converted to * String objects and returned as an array. If the parameter is a collection, the * collection elements are converted to String objects and returned as an array. * Otherwise (if the parameter is {@code null}) {@code null} is * returned. * * @param propValue The object to convert. */ public static String[] toStringArray(Object propValue) { return toStringArray(propValue, null); }
private void setPrincipalNames(@NotNull Map<String, Object> properties) { this.principalNames = ImmutableSet.copyOf(PropertiesUtil.toStringArray(properties.get("principalNames"), new String[0])); } }
@SuppressWarnings("UnusedDeclaration") @Activate private void activate(Map<String, Object> properties) { knownPrincipals = PropertiesUtil.toStringArray(properties.get("knownPrincipals"), new String[0]); log.info("CustomPrincipalConfiguration.activate: " + knownPrincipals); }
private void setPrincipalNames(@NotNull Map<String, Object> properties) { this.principalNames = ImmutableSet.copyOf(PropertiesUtil.toStringArray(properties.get("principalNames"), new String[0])); } }
@SuppressWarnings("UnusedDeclaration") @Modified private void modified(Map<String, Object> properties) { knownPrincipals = PropertiesUtil.toStringArray(properties.get("knownPrincipals"), new String[0]); log.info("CustomPrincipalConfiguration.modified: " + knownPrincipals); }
protected void activate(ComponentContext ctx) { invalidNodeType = checkNotNull(PropertiesUtil.toString(ctx.getProperties().get(INVALID_NODE_TYPE), null), INVALID_NODE_TYPE); errorLabel = checkNotNull(PropertiesUtil.toString(ctx.getProperties().get(ERROR_LABEL), null), ERROR_LABEL); excludedNodeTypes = ImmutableSet.copyOf(PropertiesUtil.toStringArray(ctx.getProperties().get(EXCLUDED_NODE_TYPES), new String[0])); }
@Activate protected void activate(ComponentContext componentContext) throws Exception { pathChildrenFieldName = String.valueOf(componentContext.getProperties().get(PATH_CHILDREN_FIELD)); pathParentFieldName = String.valueOf(componentContext.getProperties().get(PATH_PARENT_FIELD)); pathExactFieldName = String.valueOf(componentContext.getProperties().get(PATH_EXACT_FIELD)); collapsedPathField= String.valueOf(componentContext.getProperties().get(COLLAPSED_PATH_FIELD)); pathDescendantsFieldName = String.valueOf(componentContext.getProperties().get(PATH_DESCENDANTS_FIELD)); catchAllField = String.valueOf(componentContext.getProperties().get(CATCH_ALL_FIELD)); depthField = String.valueOf(componentContext.getProperties().get(PATH_DEPTH_FIELD)); rows = Integer.parseInt(String.valueOf(componentContext.getProperties().get(ROWS))); commitPolicy = OakSolrConfiguration.CommitPolicy.valueOf(String.valueOf(componentContext.getProperties().get(COMMIT_POLICY))); useForPathRestrictions = Boolean.valueOf(String.valueOf(componentContext.getProperties().get(PATH_RESTRICTIONS))); useForPropertyRestrictions = Boolean.valueOf(String.valueOf(componentContext.getProperties().get(PROPERTY_RESTRICTIONS))); useForPrimaryTypes = Boolean.valueOf(String.valueOf(componentContext.getProperties().get(PRIMARY_TYPES_RESTRICTIONS))); typeMappings = PropertiesUtil.toStringArray(componentContext.getProperties().get(TYPE_MAPPINGS)); ignoredProperties = PropertiesUtil.toStringArray(componentContext.getProperties().get(IGNORED_PROPERTIES)); usedProperties = PropertiesUtil.toStringArray(componentContext.getProperties().get(USED_PROPERTIES)); propertyMappings = PropertiesUtil.toStringArray(componentContext.getProperties().get(PROPERTY_MAPPINGS)); collapseJcrContentNodes = Boolean.valueOf(String.valueOf(componentContext.getProperties().get(COLLAPSE_JCR_CONTENT_NODES))); }
@Activate protected void activate(ComponentContext componentContext) throws Exception { pathChildrenFieldName = String.valueOf(componentContext.getProperties().get(PATH_CHILDREN_FIELD)); pathParentFieldName = String.valueOf(componentContext.getProperties().get(PATH_PARENT_FIELD)); pathExactFieldName = String.valueOf(componentContext.getProperties().get(PATH_EXACT_FIELD)); collapsedPathField= String.valueOf(componentContext.getProperties().get(COLLAPSED_PATH_FIELD)); pathDescendantsFieldName = String.valueOf(componentContext.getProperties().get(PATH_DESCENDANTS_FIELD)); catchAllField = String.valueOf(componentContext.getProperties().get(CATCH_ALL_FIELD)); depthField = String.valueOf(componentContext.getProperties().get(PATH_DEPTH_FIELD)); rows = Integer.parseInt(String.valueOf(componentContext.getProperties().get(ROWS))); commitPolicy = OakSolrConfiguration.CommitPolicy.valueOf(String.valueOf(componentContext.getProperties().get(COMMIT_POLICY))); useForPathRestrictions = Boolean.valueOf(String.valueOf(componentContext.getProperties().get(PATH_RESTRICTIONS))); useForPropertyRestrictions = Boolean.valueOf(String.valueOf(componentContext.getProperties().get(PROPERTY_RESTRICTIONS))); useForPrimaryTypes = Boolean.valueOf(String.valueOf(componentContext.getProperties().get(PRIMARY_TYPES_RESTRICTIONS))); typeMappings = PropertiesUtil.toStringArray(componentContext.getProperties().get(TYPE_MAPPINGS)); ignoredProperties = PropertiesUtil.toStringArray(componentContext.getProperties().get(IGNORED_PROPERTIES)); usedProperties = PropertiesUtil.toStringArray(componentContext.getProperties().get(USED_PROPERTIES)); propertyMappings = PropertiesUtil.toStringArray(componentContext.getProperties().get(PROPERTY_MAPPINGS)); collapseJcrContentNodes = Boolean.valueOf(String.valueOf(componentContext.getProperties().get(COLLAPSE_JCR_CONTENT_NODES))); }
private Map<String, String[]> getAutoMembership() { Map<String, String[]> autoMembership = new HashMap<>(); for (ServiceReference ref : enablingRefs) { String syncHandlerName = PropertiesUtil.toString(ref.getProperty(DefaultSyncConfigImpl.PARAM_NAME), DefaultSyncConfigImpl.PARAM_NAME_DEFAULT); String[] userAuthMembership = PropertiesUtil.toStringArray(ref.getProperty(DefaultSyncConfigImpl.PARAM_USER_AUTO_MEMBERSHIP), new String[0]); String[] groupAuthMembership = PropertiesUtil.toStringArray(ref.getProperty(DefaultSyncConfigImpl.PARAM_GROUP_AUTO_MEMBERSHIP), new String[0]); String[] membership = ObjectArrays.concat(userAuthMembership, groupAuthMembership, String.class); for (String idpName : mappingTracker.getIdpNames(syncHandlerName)) { String[] previous = autoMembership.put(idpName, membership); if (previous != null) { String msg = (Arrays.equals(previous, membership)) ? "Duplicate" : "Colliding"; log.debug(msg + " auto-membership configuration for IDP '{}'; replacing previous values {} by {} defined by SyncHandler '{}'", idpName, Arrays.toString(previous), Arrays.toString(membership), syncHandlerName); } } } return autoMembership; } }
@Activate protected final void activate(ComponentContext context) throws Exception { Dictionary<?, ?> properties = context.getProperties(); doActivate(context); String[] filters = PropertiesUtil.toStringArray(properties.get(PROP_FILTER_PATTERN)); if (filters == null || filters.length == 0) { throw new ConfigurationException(PROP_FILTER_PATTERN, "At least one filter pattern must be specified."); } for (String pattern : filters) { Dictionary<String, String> filterProps = new Hashtable<String, String>(); log.debug("Adding filter ({}) to pattern: {}", this.toString(), pattern); filterProps.put("pattern", pattern); ServiceRegistration filterReg = context.getBundleContext().registerService(Filter.class.getName(), this, filterProps); filterRegistrations.add(filterReg); } }
@Activate public void activate(Configuration config) { snsStatsMBean.setWriterGroupsForLastMinuteCounts(PropertiesUtil.toStringArray(config.commitsTrackerWriterGroups(), null)); }
private void bootstrapMaster(ComponentContext context) throws CertificateException, SSLException { Dictionary<?, ?> props = context.getProperties(); int port = PropertiesUtil.toInteger(props.get(PORT), PORT_DEFAULT); String[] ranges = PropertiesUtil.toStringArray(props.get(ALLOWED_CLIENT_IP_RANGES), ALLOWED_CLIENT_IP_RANGES_DEFAULT); boolean secure = PropertiesUtil.toBoolean(props.get(SECURE), SECURE_DEFAULT); primary = new StandbyServer(port, segmentStore, ranges, secure); primary.start(); log.info("started primary on port {} with allowed ip ranges {}.", port, ranges); }
return (T) Boolean.valueOf(str); } else if (clazz == String[].class){ return (T) PropertiesUtil.toStringArray(configProperty, (String[]) defaultValue); } else if (clazz == Set.class || Set.class.isAssignableFrom(clazz)) { if (configProperty instanceof Set) { return (T) ImmutableSet.copyOf((Object[]) configProperty); } else { String[] arr = PropertiesUtil.toStringArray(configProperty); if (arr != null) { return (T) ImmutableSet.copyOf(arr);
@Activate private void activate(BundleContext bundleContext, Map<String, ?> config) { String[] paths = PropertiesUtil.toStringArray(config.get(PROP_MOUNT_PATHS)); String mountName = PropertiesUtil.toString(config.get(PROP_MOUNT_NAME), PROP_MOUNT_NAME_DEFAULT); boolean readOnly = PropertiesUtil.toBoolean(config.get(PROP_MOUNT_READONLY), PROP_MOUNT_READONLY_DEFAULT); String[] pathsSupportingFragments = PropertiesUtil.toStringArray(config.get(PROP_PATHS_SUPPORTING_FRAGMENTS), PROP_PATHS_SUPPORTING_FRAGMENTS_DEFAULT); MountInfoProvider mip = Mounts.defaultMountInfoProvider(); if (paths != null) { mip = Mounts.newBuilder() .mount(mountName.trim(), readOnly, trim(pathsSupportingFragments), trim(paths)) .build(); log.info("Enabling mount for {}", mip); } else { log.info("No mount config provided. Mounting would be disabled"); } reg = bundleContext.registerService(MountInfoProvider.class.getName(), mip, null); }
return (T) Boolean.valueOf(str); } else if (clazz == String[].class){ return (T) PropertiesUtil.toStringArray(configProperty, (String[]) defaultValue); } else if (clazz == Set.class || Set.class.isAssignableFrom(clazz)) { if (configProperty instanceof Set) { return (T) ImmutableSet.copyOf((Object[]) configProperty); } else { String[] arr = PropertiesUtil.toStringArray(configProperty); if (arr != null) { return (T) ImmutableSet.copyOf(arr);
@Activate public void activate(Map<String, ?> config) throws Exception { String pathToJoshuaConfig = PropertiesUtil.toString(config.get(CONFIG_PATH), "."); String[] nts = PropertiesUtil.toStringArray(config.get(NODE_TYPES), new String[]{"Oak:unstructured"}); float minScore = (float) PropertiesUtil.toDouble(config.get(MIN_SCORE), DEFAULT_MIN_SCORE); log.info("activating MT FulltextQueryTermProvider from Joshua config at {} on {} nodetypes, minScore {}", pathToJoshuaConfig, nts, minScore); Decoder decoder = null; try { log.debug("reading joshua config"); JoshuaConfiguration configuration = new JoshuaConfiguration(); configuration.readConfigFile(pathToJoshuaConfig); configuration.setConfigFilePath(new File(pathToJoshuaConfig).getCanonicalFile().getParent()); configuration.use_structured_output = true; decoder = new Decoder(configuration, pathToJoshuaConfig); log.debug("decoder initialized"); Set<String> nodeTypes = new HashSet<>(); nodeTypes.addAll(Arrays.asList(nts)); queryTermsProvider = new MTFulltextQueryTermsProvider(decoder, nodeTypes, minScore); } catch (Exception e) { log.error("could not initialize MTFulltextQueryTermProvider", e); if (decoder != null) { decoder.cleanUp(); } } }
@Test public void testToStringArray() { final String[] defaultValue = new String[]{"1"}; assertArrayEquals(null, PropertiesUtil.toStringArray(5)); assertArrayEquals(null, PropertiesUtil.toStringArray(null)); assertArrayEquals(defaultValue, PropertiesUtil.toStringArray(5, defaultValue)); assertArrayEquals(defaultValue, PropertiesUtil.toStringArray(null, defaultValue)); assertArrayEquals(new String[]{"hallo"}, PropertiesUtil.toStringArray("hallo", defaultValue)); assertArrayEquals(new String[]{"hallo"}, PropertiesUtil.toStringArray(new String[]{"hallo"}, defaultValue)); assertArrayEquals(new String[]{"hallo", "you"}, PropertiesUtil.toStringArray(new String[]{"hallo", "you"}, defaultValue)); assertArrayEquals(new String[]{"5", "1"}, PropertiesUtil.toStringArray(new Integer[]{5, 1}, defaultValue)); assertArrayEquals(new String[]{"5", "1"}, PropertiesUtil.toStringArray(new Integer[]{5, null, 1}, defaultValue)); final List<String> l = new ArrayList<String>(); assertArrayEquals(new String[]{}, PropertiesUtil.toStringArray(l, defaultValue)); l.add("1"); l.add("2"); assertArrayEquals(new String[]{"1", "2"}, PropertiesUtil.toStringArray(l, defaultValue)); l.add(null); assertArrayEquals(new String[]{"1", "2"}, PropertiesUtil.toStringArray(l, defaultValue)); final Map<String, Object> m = new HashMap<String, Object>(); m.put("1", 5); assertArrayEquals(defaultValue, PropertiesUtil.toStringArray(m, defaultValue)); }