List of usage examples for java.util ArrayList isEmpty
public boolean isEmpty()
From source file:net.opentsdb.meta.Annotation.java
/** * Scans through the global annotation storage rows and returns a list of * parsed annotation objects. If no annotations were found for the given * timespan, the resulting list will be empty. * @param tsdb The TSDB to use for storage access * @param start_time Start time to scan from. May be 0 * @param end_time End time to scan to. Must be greater than 0 * @return A list with detected annotations. May be empty. * @throws IllegalArgumentException if the end timestamp has not been set or * the end time is less than the start time *///from w ww. j av a 2 s . c o m public static Deferred<List<Annotation>> getGlobalAnnotations(final TSDB tsdb, final long start_time, final long end_time) { if (end_time < 1) { throw new IllegalArgumentException("The end timestamp has not been set"); } if (end_time < start_time) { throw new IllegalArgumentException("The end timestamp cannot be less than the start timestamp"); } /** * Scanner that loops through the [0, 0, 0, timestamp] rows looking for * global annotations. Returns a list of parsed annotation objects. * The list may be empty. */ final class ScannerCB implements Callback<Deferred<List<Annotation>>, ArrayList<ArrayList<KeyValue>>> { final Scanner scanner; final ArrayList<Annotation> annotations = new ArrayList<Annotation>(); /** * Initializes the scanner */ public ScannerCB() { final byte[] start = new byte[TSDB.metrics_width() + Const.TIMESTAMP_BYTES]; final byte[] end = new byte[TSDB.metrics_width() + Const.TIMESTAMP_BYTES]; final long normalized_start = (start_time - (start_time % Const.MAX_TIMESPAN)); final long normalized_end = (end_time - (end_time % Const.MAX_TIMESPAN) + Const.MAX_TIMESPAN); Bytes.setInt(start, (int) normalized_start, TSDB.metrics_width()); Bytes.setInt(end, (int) normalized_end, TSDB.metrics_width()); scanner = tsdb.getClient().newScanner(tsdb.dataTable()); scanner.setStartKey(start); scanner.setStopKey(end); scanner.setFamily(FAMILY); } public Deferred<List<Annotation>> scan() { return scanner.nextRows().addCallbackDeferring(this); } @Override public Deferred<List<Annotation>> call(final ArrayList<ArrayList<KeyValue>> rows) throws Exception { if (rows == null || rows.isEmpty()) { return Deferred.fromResult((List<Annotation>) annotations); } for (final ArrayList<KeyValue> row : rows) { for (KeyValue column : row) { if ((column.qualifier().length == 3 || column.qualifier().length == 5) && column.qualifier()[0] == PREFIX()) { Annotation note = JSON.parseToObject(column.value(), Annotation.class); if (note.start_time < start_time || note.end_time > end_time) { continue; } annotations.add(note); } } } return scan(); } } return new ScannerCB().scan(); }
From source file:de.alpharogroup.collections.ListExtensions.java
/** * Splits the Set to Parts to the specified times. * * @param <T>/*from w w w . j ava2s .c o m*/ * the generic type * @param set * The Set to Split * @param times * How to split. * @return An ArrayList with the Splitted Parts */ public static <T> List<List<T>> splitSetToParts(final Set<T> set, final int times) { final List<List<T>> returnList = new ArrayList<>(); ArrayList<T> tmp = new ArrayList<>(); final Iterator<T> it = set.iterator(); int count = 0; while (it.hasNext()) { if (count == times) { returnList.add(tmp); tmp = new ArrayList<>(); tmp.add(it.next()); count = 1; } else { tmp.add(it.next()); count++; } } if (!tmp.isEmpty()) { returnList.add(tmp); } return returnList; }
From source file:AntColonyPDP.Environment.java
private static void registerCentralizedSimulator(final long endTime, final Simulator simulator, final RandomGenerator rng, final RoadModel roadModel) { //Adding and register the colonies in the environment for (int i = 0; i < NUM_COLONIES; i++) { Colony colony = new Colony(roadModel.getRandomPosition(rng), 0); simulator.register(colony);/*from w w w .java 2 s. c om*/ register(colony); } //Adding and register the ants in the environment for (int i = 0; i < NUM_ANTS; i++) { CentralizedAnt nca = new CentralizedAnt(roadModel.getRandomPosition(rng), ANT_CAPACITY); simulator.register(nca); register(nca); } //Adding and register the food sources in the environment for (int i = 0; i < NUM_FOOD_SOURCE; i++) { generateFoodSource(simulator, rng, roadModel); } simulator.addTickListener(new TickListener() { @Override public void tick(TimeLapse time) { if (time.getStartTime() > endTime) { simulator.stop(); } else { // 1: Generate new food sources if (rng.nextDouble() < NEW_FOOD_SOURCE_PROB * (MAX_SOURCES - SOURCES.size()) / MAX_SOURCES) { //&& SOURCES.size() < MAX_SOURCES) { generateFoodSource(simulator, rng, roadModel); } // 2: check expiration and empty food sources for (FoodSource source : new ArrayList<FoodSource>(SOURCES)) { if (source.isExpired()) { SOURCES.remove(source); } } assignments = new HashMap<CentralizedAnt, FoodSource>(); // 3: get the positions HashMap<FoodSource, Point> fsPositions = new HashMap<FoodSource, Point>(); for (FoodSource fs : SOURCES) fsPositions.put(fs, fs.getPickupLocation()); HashMap<CentralizedAnt, Point> caPositions = new HashMap<CentralizedAnt, Point>(); for (CentralizedAnt ca : CENTRALIZED_ANTS) caPositions.put(ca, ca.getPosition().get()); // 4: extract closest pair and find next ArrayList<CentralizedAnt> remainingAnts = new ArrayList<CentralizedAnt>(CENTRALIZED_ANTS); for (CentralizedAnt ant : CENTRALIZED_ANTS) { if (ant.isTaken()) remainingAnts.remove(ant); } // 5: Assign food elements with ants when it is possible ArrayList<FoodSource> remainingSources = new ArrayList<FoodSource>(SOURCES); Map<Pair, Double> shortestFound = new HashMap<Pair, Double>(); while (!remainingSources.isEmpty() && !remainingAnts.isEmpty()) { for (FoodSource fs : remainingSources) { Point pos = fsPositions.get(fs); Map<Pair, Double> distances = new HashMap<Pair, Double>(); for (CentralizedAnt ca : remainingAnts) { Point antPos = caPositions.get(ca); distances.put(new Pair(ca, fs), Point.distance(antPos, pos)); } distances = MapUtil.sortByValue(distances); Pair first = null; double firstDist = 10; for (Map.Entry<Pair, Double> entry : distances.entrySet()) { //this for loop is just a complicated way to extract the first element if (first == null) { first = entry.getKey(); firstDist = entry.getValue(); } } //found the shortest for current ant shortestFound.put(first, firstDist); } // found the shortest for each customer //now sort again shortestFound = MapUtil.sortByValue(shortestFound); Pair absoluteShortest = null; for (Map.Entry<Pair, Double> entry : shortestFound.entrySet()) { if (absoluteShortest == null) { absoluteShortest = entry.getKey(); } } //we found and now use the absolute minimal distance pair found //if the ant can reach it if (canDeliver(absoluteShortest.v, absoluteShortest.c)) { assignments.put(absoluteShortest.v, absoluteShortest.c); remainingSources.remove(absoluteShortest.c); } else absoluteShortest.v.groundAnt(); remainingAnts.remove(absoluteShortest.v); shortestFound = new HashMap<Pair, Double>(); } //printAssignments(assignments); // debug method } } @Override public void afterTick(TimeLapse timeLapse) { performanceAssessment(simulator, roadModel); } }); }
From source file:net.opentsdb.meta.Annotation.java
/** * Deletes global or TSUID associated annotiations for the given time range. * @param tsdb The TSDB object to use for storage access * @param tsuid An optional TSUID. If set to null, then global annotations for * the given range will be deleted//from w w w . j a v a2 s . co m * @param start_time A start timestamp in milliseconds * @param end_time An end timestamp in millseconds * @return The number of annotations deleted * @throws IllegalArgumentException if the timestamps are invalid * @since 2.1 */ public static Deferred<Integer> deleteRange(final TSDB tsdb, final byte[] tsuid, final long start_time, final long end_time) { if (end_time < 1) { throw new IllegalArgumentException("The end timestamp has not been set"); } if (end_time < start_time) { throw new IllegalArgumentException("The end timestamp cannot be less than the start timestamp"); } final List<Deferred<Object>> delete_requests = new ArrayList<Deferred<Object>>(); int width = tsuid != null ? tsuid.length + Const.TIMESTAMP_BYTES : TSDB.metrics_width() + Const.TIMESTAMP_BYTES; final byte[] start_row = new byte[width]; final byte[] end_row = new byte[width]; // downsample to seconds for the row keys final long start = start_time / 1000; final long end = end_time / 1000; final long normalized_start = (start - (start % Const.MAX_TIMESPAN)); final long normalized_end = (end - (end % Const.MAX_TIMESPAN) + Const.MAX_TIMESPAN); Bytes.setInt(start_row, (int) normalized_start, TSDB.metrics_width()); Bytes.setInt(end_row, (int) normalized_end, TSDB.metrics_width()); if (tsuid != null) { // first copy the metric UID then the tags System.arraycopy(tsuid, 0, start_row, 0, TSDB.metrics_width()); System.arraycopy(tsuid, 0, end_row, 0, TSDB.metrics_width()); width = TSDB.metrics_width() + Const.TIMESTAMP_BYTES; final int remainder = tsuid.length - TSDB.metrics_width(); System.arraycopy(tsuid, TSDB.metrics_width(), start_row, width, remainder); System.arraycopy(tsuid, TSDB.metrics_width(), end_row, width, remainder); } /** * Iterates through the scanner results in an asynchronous manner, returning * once the scanner returns a null result set. */ final class ScannerCB implements Callback<Deferred<List<Deferred<Object>>>, ArrayList<ArrayList<KeyValue>>> { final Scanner scanner; public ScannerCB() { scanner = tsdb.getClient().newScanner(tsdb.dataTable()); scanner.setStartKey(start_row); scanner.setStopKey(end_row); scanner.setFamily(FAMILY); if (tsuid != null) { final List<String> tsuids = new ArrayList<String>(1); tsuids.add(UniqueId.uidToString(tsuid)); Internal.createAndSetTSUIDFilter(scanner, tsuids); } } public Deferred<List<Deferred<Object>>> scan() { return scanner.nextRows().addCallbackDeferring(this); } @Override public Deferred<List<Deferred<Object>>> call(final ArrayList<ArrayList<KeyValue>> rows) throws Exception { if (rows == null || rows.isEmpty()) { return Deferred.fromResult(delete_requests); } for (final ArrayList<KeyValue> row : rows) { final long base_time = Internal.baseTime(tsdb, row.get(0).key()); for (KeyValue column : row) { if ((column.qualifier().length == 3 || column.qualifier().length == 5) && column.qualifier()[0] == PREFIX()) { final long timestamp = timeFromQualifier(column.qualifier(), base_time); if (timestamp < start_time || timestamp > end_time) { continue; } final DeleteRequest delete = new DeleteRequest(tsdb.dataTable(), column.key(), FAMILY, column.qualifier()); delete_requests.add(tsdb.getClient().delete(delete)); } } } return scan(); } } /** Called when the scanner is done. Delete requests may still be pending */ final class ScannerDoneCB implements Callback<Deferred<ArrayList<Object>>, List<Deferred<Object>>> { @Override public Deferred<ArrayList<Object>> call(final List<Deferred<Object>> deletes) throws Exception { return Deferred.group(delete_requests); } } /** Waits on the group of deferreds to complete before returning the count */ final class GroupCB implements Callback<Deferred<Integer>, ArrayList<Object>> { @Override public Deferred<Integer> call(final ArrayList<Object> deletes) throws Exception { return Deferred.fromResult(deletes.size()); } } Deferred<ArrayList<Object>> scanner_done = new ScannerCB().scan().addCallbackDeferring(new ScannerDoneCB()); return scanner_done.addCallbackDeferring(new GroupCB()); }
From source file:com.google.android.apps.santatracker.data.DestinationDbHelper.java
private static Destination.Photo[] processPhoto(String s) { if (s == null || s.isEmpty()) { return null; }/*from w w w . ja va2s. c o m*/ ArrayList<Destination.Photo> list = new ArrayList<>(5); try { JSONArray array = new JSONArray(s); for (int i = 0; i < array.length(); i++) { JSONObject json = array.getJSONObject(i); Destination.Photo photo = new Destination.Photo(); photo.url = json.getString(APIProcessor.FIELD_PHOTO_URL); photo.attributionHTML = json.getString(APIProcessor.FIELD_PHOTO_ATTRIBUTIONHTML); list.add(photo); } } catch (JSONException e) { // ignore invalid values } return list.isEmpty() ? null : list.toArray(new Destination.Photo[list.size()]); }
From source file:blusunrize.immersiveengineering.api.shader.ShaderRegistry.java
public static void compileWeight() { totalWeight.clear();//from w ww . jav a 2 s. co m chestLootShaders.clear(); for (ShaderRegistryEntry entry : shaderRegistry.values()) { if (entry.getIsBagLoot()) { int entryRarityWeight = rarityWeightMap.get(entry.getRarity()); for (Map.Entry<EnumRarity, Integer> weightedRarity : rarityWeightMap.entrySet()) if (entry.getIsInLowerBags() ? (weightedRarity.getValue() >= entryRarityWeight) : (weightedRarity.getValue() == entryRarityWeight)) { int i = totalWeight.containsKey(weightedRarity.getKey()) ? totalWeight.get(weightedRarity.getKey()) : 0; totalWeight.put(weightedRarity.getKey(), i + entry.getWeight()); } } if (entry.getIsCrateLoot()) for (int i = 0; i < entry.getWeight(); i++) chestLootShaders.add(entry.getName()); } sortedRarityMap.clear(); sortedRarityMap.addAll(ShaderRegistry.rarityWeightMap.keySet()); Collections.sort(sortedRarityMap, new Comparator<EnumRarity>() { @Override public int compare(EnumRarity enum0, EnumRarity enum1) { return Integer.compare(ShaderRegistry.rarityWeightMap.get(enum0), ShaderRegistry.rarityWeightMap.get(enum1)); } }); if (manualEntry != null) { ArrayList<PositionedItemStack[]> recipes = new ArrayList(); NonNullList<ItemStack> shaderBags = NonNullList.withSize(ShaderRegistry.sortedRarityMap.size(), ItemStack.EMPTY); recipes = new ArrayList(); for (int i = 0; i < ShaderRegistry.sortedRarityMap.size(); i++) { EnumRarity outputRarity = ShaderRegistry.sortedRarityMap.get(i); shaderBags.set(i, new ItemStack(itemShaderBag)); shaderBags.get(i).setTagCompound(new NBTTagCompound()); shaderBags.get(i).getTagCompound().setString("rarity", outputRarity.toString()); ArrayList<EnumRarity> upperRarities = ShaderRegistry.getHigherRarities(outputRarity); if (!upperRarities.isEmpty()) { ArrayList<ItemStack> inputList = new ArrayList(); for (EnumRarity r : upperRarities) { ItemStack bag = new ItemStack(itemShaderBag); bag.setTagCompound(new NBTTagCompound()); bag.getTagCompound().setString("rarity", r.toString()); inputList.add(bag); } ItemStack s0 = new ItemStack(itemShaderBag, 2); s0.setTagCompound(new NBTTagCompound()); s0.getTagCompound().setString("rarity", outputRarity.toString()); if (!inputList.isEmpty()) recipes.add(new PositionedItemStack[] { new PositionedItemStack(inputList, 33, 0), new PositionedItemStack(s0, 69, 0) }); // inputList = new ArrayList(); // for(ShaderRegistryEntry entry : ShaderRegistry.shaderRegistry.values()) // if(upperRarities.contains(entry.getRarity())) // { // ItemStack shader = new ItemStack(itemShader); // shader.setTagCompound(new NBTTagCompound()); // shader.getTagCompound().setString("shader_name", entry.getName()); // inputList.add(shader); // } // ItemStack s1 = new ItemStack(itemShaderBag); // s1.setTagCompound(new NBTTagCompound()); // s1.getTagCompound().setString("rarity", outputRarity.toString()); // if(!inputList.isEmpty()) // recipes.add(new PositionedItemStack[]{ new PositionedItemStack(inputList, 33, 0), new PositionedItemStack(s1, 69, 0)}); } } manualEntry.getPages()[2] = new ManualPages.ItemDisplay(ManualHelper.getManual(), "shader2", shaderBags); manualEntry.getPages()[3] = new ManualPages.CraftingMulti(ManualHelper.getManual(), "shader3", (Object[]) recipes.toArray(new PositionedItemStack[recipes.size()][3])); } }
From source file:com.genentech.application.calcProps.SDFCalcProps.java
/** * Sort commands by dependencies ex. Solubility_Index requires cLogD7.4 * Need to calculate cLogD7.4 before calculating solubility_index * cLogD7.4 command line need to appear before solubility_index command line *//*from www . j a v a2s .c o m*/ private static List<Calculator> sortByDependencies(ArrayList<Calculator> calculators, int noCalculatorSizeChangeCount) { int oldCalculatorsSize = calculators.size(); List<Calculator> sorted = new ArrayList<Calculator>(); if (!calculators.isEmpty()) { Calculator calc = calculators.remove(0); //get first element in list Set<String> reqCalculators = calc.getRequiredCalculators(); if (reqCalculators.size() == 0) { // no dependencies, add to beginning sorted.add(0, calc); } else { //there are dependencies // are any dependencies left in the list of calculators to be sorted if (anyDependenciesInList(reqCalculators, calculators)) { calculators.add(calc); //add calc back to the end of the list to be sorted later } else { //they must be in the sorted list, add calc to the end of sorted list sorted.add(calc); //append to end of sorted calculators } } } if (calculators.size() == oldCalculatorsSize) noCalculatorSizeChangeCount = noCalculatorSizeChangeCount + 1; else noCalculatorSizeChangeCount = 0; /*If the number of calculators in the list has not going down within calculators.size() times*/ if (noCalculatorSizeChangeCount == calculators.size() && calculators.size() > 0) { StringBuffer calculatorText = new StringBuffer(); for (Calculator calc : calculators) calculatorText = calculatorText.append(calc.getName()).append(" "); throw new Error("There is a circular dependencies amongst following calculators: " + calculatorText.substring(0, calculatorText.length())); } //recursively sort remaining calculators if (calculators.size() > 0) { //append rest to sorted sorted.addAll(sortByDependencies(calculators, noCalculatorSizeChangeCount)); } return sorted; }
From source file:Main.java
/** * Gets all facets of sourceElement. If facet has a few children the method * will return first one./* ww w . j av a 2 s .c om*/ * * @param sourceElement the source element * @param facetName * * param returnTextNode return child text node if facet doesn't have * any child elements; * @param returnTextNode the return text node * * @return the facets */ public static ArrayList<Node> getFacets(Element sourceElement, boolean returnTextNode) { ArrayList<Node> facets = new ArrayList<Node>(); NodeList children = sourceElement.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node node = children.item(i); if (node instanceof Element && "f:facet".equals(node.getNodeName())) { //$NON-NLS-1$ Element element = (Element) node; NodeList childNodes = element.getChildNodes(); Text textNode = null; for (int j = 0; j < childNodes.getLength(); j++) { Node child = childNodes.item(j); if (child instanceof Element) { facets.add(child); break; } else if (child instanceof Text) { textNode = (Text) child; } } if (returnTextNode && facets.isEmpty()) { facets.add(textNode); } } } return facets; }
From source file:com.vmware.identity.idm.server.LocalOsIdentityProviderTest.java
@BeforeClass public static void testSetup() { ISecurityAccountsLibrary lib = getSamLib(); if (lib != null) { GroupInfo g1 = new GroupInfo(group1Name, group1Description); GroupInfo g2 = new GroupInfo(group2Name, group2Description); _groups = new HashMap<String, GroupInfo>(); _groups.put(g1.getName(), g1);/* w w w .j a v a 2 s.c om*/ _groups.put(g2.getName(), g2); _found_os_groups = new HashMap<String, GroupInfo>(); _found_os_groups.put(g1.getName(), g1); if (SystemUtils.IS_OS_WINDOWS) {// Windows samlib makes g2 a search hit _found_os_groups.put(g2.getName(), g2); } UserInfo u1 = new UserInfo(user1Name, user1FirstName, user1LastName, userPassword, user1Description, false, false); UserInfo u2 = new UserInfo(user2Name, user2FirstName, user2LastName, userPassword, user2Description, false, false); UserInfo u3 = new UserInfo(user3Name, user3FirstName, user3LastName, userPassword, user3Description, true, false); UserInfo u4 = new UserInfo(user4Name, user4FirstName, user4LastName, userPassword, user4Description, false, true); UserInfo u5 = new UserInfo(user5Name, user5FirstName, user5LastName, userPassword, user5Description, true, true); UserInfo u6 = new UserInfo(user6Name, user6FirstName, user6LastName, userPassword, user6Description, false, false); _users = new HashMap<String, UserInfo>(); _users.put(u1.getName(), u1); _users.put(u2.getName(), u2); _users.put(u3.getName(), u3); _users.put(u4.getName(), u4); _users.put(u5.getName(), u5); _users.put(u6.getName(), u6); _found_os_users = new HashMap<String, UserInfo>(); _found_os_users.put(u1.getName(), u1); _found_os_users.put(u3.getName(), u3); _found_os_users.put(u5.getName(), u5); _found_os_users.put(u6.getName(), u6); if (SystemUtils.IS_OS_WINDOWS) {//For Windows, we are getting two additional users due to samlib impl. _found_os_users.put(u2.getName(), u2); _found_os_users.put(u4.getName(), u4); } _groupsToUsers = new HashMap<String, Set<UserInfo>>(); _groupsToUsers.put(g1.getName(), new HashSet<UserInfo>()); _groupsToUsers.put(g2.getName(), new HashSet<UserInfo>()); _groupsToUsers.get(g1.getName()).add(u1); _groupsToUsers.get(g1.getName()).add(u2); _groupsToUsers.get(g1.getName()).add(u3); _groupsToUsers.get(g1.getName()).add(u4); _groupsToUsers.get(g1.getName()).add(u5); _groupsToUsers.get(g2.getName()).add(u1); _groupsToUsers.get(g2.getName()).add(u3); _usersToGroups = new HashMap<String, Set<GroupInfo>>(); _usersToGroups.put(u1.getName(), new HashSet<GroupInfo>()); _usersToGroups.put(u2.getName(), new HashSet<GroupInfo>()); _usersToGroups.put(u3.getName(), new HashSet<GroupInfo>()); _usersToGroups.put(u4.getName(), new HashSet<GroupInfo>()); _usersToGroups.put(u5.getName(), new HashSet<GroupInfo>()); _usersToGroups.put(u6.getName(), new HashSet<GroupInfo>()); _usersToGroups.get(u1.getName()).add(g1); _usersToGroups.get(u1.getName()).add(g2); _usersToGroups.get(u2.getName()).add(g1); _usersToGroups.get(u3.getName()).add(g1); _usersToGroups.get(u3.getName()).add(g2); _usersToGroups.get(u4.getName()).add(g1); _usersToGroups.get(u5.getName()).add(g1); for (UserInfo userInfo : _users.values()) { lib.AddUser(userInfo.getName(), userInfo.getPassword(), userInfo.getFirstName() + " " + userInfo.getLastName(), userInfo.getDescription(), userInfo.isDisabled(), userInfo.isLocked()); } for (GroupInfo groupInfo : _groups.values()) { lib.AddGroup(groupInfo.getName(), groupInfo.getDescription()); } for (Map.Entry<String, Set<UserInfo>> entry : _groupsToUsers.entrySet()) { ArrayList<String> usersList = new ArrayList<String>(); for (UserInfo info : entry.getValue()) { usersList.add(info.getName()); } if (usersList.isEmpty() == false) { lib.AddUsersToGroup(entry.getKey(), usersList); } } // create the localOs provider ProviderFactory factory = new ProviderFactory(); ServerIdentityStoreData storeData = new ServerIdentityStoreData(DomainType.LOCAL_OS_DOMAIN, domainName); storeData.setAuthenticationType(AuthenticationType.PASSWORD); storeData.setProviderType(IdentityStoreType.IDENTITY_STORE_TYPE_LOCAL_OS); storeData.setAlias(domainAlias); Map<String, String> map = new HashMap<String, String>(); map.put("http://rsa.com/schemas/attr-names/2009/01/GroupIdentity", LocalOsIdentityProvider.GROUPS_ATTRIBUTE); map.put("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname", LocalOsIdentityProvider.FIRST_NAME_ATTRIBUTE); map.put("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname", LocalOsIdentityProvider.LAST_NAME_ATTRIBUTE); map.put("http://vmware.com/schemas/attr-names/2011/07/isSolution", LocalOsIdentityProvider.SUBJECT_TYPE_ATTRIBUTE); map.put("http://schemas.xmlsoap.org/claims/UPN", LocalOsIdentityProvider.USER_PRINCIPAL_NAME_ATTRIBUTE); storeData.setAttributeMap(map); try { localOsProvider = factory.buildProvider("vsphere.local", storeData, null); } catch (Exception e) { Assert.fail("Building local provider failed"); } } }
From source file:com.vmware.identity.idm.server.ServerUtils.java
public static LdapValue[] getLdapValue(ArrayList<? extends Certificate> certs) { LdapValue[] value = null;/*from w ww .ja va 2 s .c om*/ if ((certs != null) && (certs.isEmpty() == false)) { value = new LdapValue[certs.size()]; int i = 0; for (Certificate cert : certs) { byte[] bytes = getCertBytes(cert); if ((bytes != null) && (bytes.length > 0)) { value[i] = new LdapValue(bytes); } i++; } } return value; }