List of usage examples for java.util UUID equals
public boolean equals(Object obj)
From source file:org.apache.jackrabbit.oak.run.SegmentUtils.java
private static void filterNodeStates(Set<UUID> uuids, List<String> paths, SegmentNodeState state, String path) { Set<String> localPaths = newTreeSet(); for (PropertyState ps : state.getProperties()) { if (ps instanceof SegmentPropertyState) { SegmentPropertyState sps = (SegmentPropertyState) ps; RecordId recordId = sps.getRecordId(); UUID id = recordId.getSegmentId().asUUID(); if (uuids.contains(id)) { if (ps.getType().tag() == STRING) { String val = ""; if (ps.count() > 0) { // only shows the first value, do we need more? val = displayString(ps.getValue(Type.STRING, 0)); }//ww w .j a v a 2 s . co m localPaths.add(path + ps.getName() + " = " + val + " [SegmentPropertyState<" + ps.getType() + ">@" + recordId + "]"); } else { localPaths .add(path + ps + " [SegmentPropertyState<" + ps.getType() + ">@" + recordId + "]"); } } if (ps.getType().tag() == BINARY) { // look for extra segment references for (int i = 0; i < ps.count(); i++) { Blob b = ps.getValue(Type.BINARY, i); for (SegmentId sbid : SegmentBlob.getBulkSegmentIds(b)) { UUID bid = sbid.asUUID(); if (!bid.equals(id) && uuids.contains(bid)) { localPaths.add(path + ps + " [SegmentPropertyState<" + ps.getType() + ">@" + recordId + "]"); } } } } } } RecordId stateId = state.getRecordId(); if (uuids.contains(stateId.getSegmentId().asUUID())) { localPaths.add(path + " [SegmentNodeState@" + stateId + "]"); } RecordId templateId = getTemplateId(state); if (uuids.contains(templateId.getSegmentId().asUUID())) { localPaths.add(path + "[Template@" + templateId + "]"); } paths.addAll(localPaths); for (ChildNodeEntry ce : state.getChildNodeEntries()) { NodeState c = ce.getNodeState(); if (c instanceof SegmentNodeState) { filterNodeStates(uuids, paths, (SegmentNodeState) c, path + ce.getName() + "/"); } } }
From source file:com.skelril.skree.content.registry.item.zone.ZoneItemUtil.java
public static boolean playerAlreadyHasInvite(ItemStack stack, Player target) { UUID zoneID = getZoneID(stack).orElseThrow(() -> new IllegalArgumentException("Illegal zone ItemStack")); ItemStack[] inv = tf(target).inventory.mainInventory; for (ItemStack aStack : inv) { Optional<UUID> optZoneID = getZoneID(aStack); if (optZoneID.isPresent()) { if (zoneID.equals(optZoneID.get())) { return true; }//from w ww . ja v a2 s .c o m } } return false; }
From source file:org.apache.jackrabbit.oak.run.SegmentTarUtils.java
private static void filterNodeStates(Set<UUID> uuids, List<String> paths, SegmentNodeState state, String path) { Set<String> localPaths = newTreeSet(); for (PropertyState ps : state.getProperties()) { if (ps instanceof SegmentPropertyState) { SegmentPropertyState sps = (SegmentPropertyState) ps; RecordId recordId = sps.getRecordId(); UUID id = recordId.getSegmentId().asUUID(); if (uuids.contains(id)) { if (ps.getType().tag() == PropertyType.STRING) { String val = ""; if (ps.count() > 0) { // only shows the first value, do we need more? val = displayString(ps.getValue(Type.STRING, 0)); }/*from w w w . j ava 2s .c o m*/ localPaths.add(path + ps.getName() + " = " + val + " [SegmentPropertyState<" + ps.getType() + ">@" + recordId + "]"); } else { localPaths .add(path + ps + " [SegmentPropertyState<" + ps.getType() + ">@" + recordId + "]"); } } if (ps.getType().tag() == PropertyType.BINARY) { // look for extra segment references for (int i = 0; i < ps.count(); i++) { Blob b = ps.getValue(Type.BINARY, i); for (SegmentId sbid : SegmentBlob.getBulkSegmentIds(b)) { UUID bid = sbid.asUUID(); if (!bid.equals(id) && uuids.contains(bid)) { localPaths.add(path + ps + " [SegmentPropertyState<" + ps.getType() + ">@" + recordId + "]"); } } } } } } RecordId stateId = state.getRecordId(); if (uuids.contains(stateId.getSegmentId().asUUID())) { localPaths.add(path + " [SegmentNodeState@" + stateId + "]"); } RecordId templateId = getTemplateId(state); if (uuids.contains(templateId.getSegmentId().asUUID())) { localPaths.add(path + "[Template@" + templateId + "]"); } paths.addAll(localPaths); for (ChildNodeEntry ce : state.getChildNodeEntries()) { NodeState c = ce.getNodeState(); if (c instanceof SegmentNodeState) { filterNodeStates(uuids, paths, (SegmentNodeState) c, path + ce.getName() + "/"); } } }
From source file:me.ryanhamshire.griefprevention.migrator.RedProtectMigrator.java
public static void migrate(World world, Path redProtectFilePath, Path gpClaimDataPath) throws FileNotFoundException, ClassNotFoundException { if (!GriefPreventionPlugin.getGlobalConfig().getConfig().migrator.redProtectMigrator) { return;//from w ww . java 2 s .c o m } int count = 0; try { GriefPreventionPlugin.instance.getLogger().info("Starting RedProtect region data migration for world " + world.getProperties().getWorldName() + "..."); ConfigurationLoader<CommentedConfigurationNode> regionManager = HoconConfigurationLoader.builder() .setPath(redProtectFilePath).build(); CommentedConfigurationNode region = regionManager.load(); GriefPreventionPlugin.instance.getLogger() .info("Scanning RedProtect regions in world data file '" + redProtectFilePath + "'..."); for (Object key : region.getChildrenMap().keySet()) { String rname = key.toString(); if (!region.getNode(rname).hasMapChildren()) { continue; } int maxX = region.getNode(rname, "maxX").getInt(); int maxY = region.getNode(rname, "maxY").getInt(255); int maxZ = region.getNode(rname, "maxZ").getInt(); int minX = region.getNode(rname, "minX").getInt(); int minY = region.getNode(rname, "minY").getInt(0); int minZ = region.getNode(rname, "minZ").getInt(); List<String> owners = new ArrayList<String>(); owners.addAll(region.getNode(rname, "owners").getList(TypeToken.of(String.class))); List<String> members = new ArrayList<String>(); members.addAll(region.getNode(rname, "members").getList(TypeToken.of(String.class))); String creator = region.getNode(rname, "creator").getString(); String welcome = region.getNode(rname, "welcome").getString(); // create GP claim data file GriefPreventionPlugin.instance.getLogger() .info("Migrating RedProtect region data '" + rname + "'..."); UUID ownerUniqueId = null; if (validate(creator)) { try { // check cache first ownerUniqueId = PlayerUtils.getUUIDByName(creator); if (ownerUniqueId == null) { ownerUniqueId = UUID.fromString(getUUID(creator)); } } catch (Throwable e) { // assume admin claim } } UUID claimUniqueId = UUID.randomUUID(); Location<World> lesserBoundaryCorner = new Location<>(world, minX, minY, minZ); Location<World> greaterBoundaryCorner = new Location<>(world, maxX, maxY, maxZ); Path claimFilePath = gpClaimDataPath.resolve(claimUniqueId.toString()); if (!Files.exists(claimFilePath)) { Files.createFile(claimFilePath); } ClaimStorageData claimStorage = new ClaimStorageData(claimFilePath); ClaimDataConfig claimDataConfig = claimStorage.getConfig(); claimDataConfig.setName(Text.of(rname)); claimDataConfig.setWorldUniqueId(world.getUniqueId()); claimDataConfig.setOwnerUniqueId(ownerUniqueId); claimDataConfig.setLesserBoundaryCorner(BlockUtils.positionToString(lesserBoundaryCorner)); claimDataConfig.setGreaterBoundaryCorner(BlockUtils.positionToString(greaterBoundaryCorner)); claimDataConfig.setDateLastActive(Instant.now()); claimDataConfig.setType(ownerUniqueId == null ? ClaimType.ADMIN : ClaimType.BASIC); if (!welcome.equals("")) { claimDataConfig.setGreeting(Text.of(welcome)); } List<String> rpUsers = new ArrayList<>(owners); rpUsers.addAll(members); List<UUID> builders = claimDataConfig.getBuilders(); for (String builder : rpUsers) { if (!validate(builder)) { continue; } UUID builderUniqueId = null; try { builderUniqueId = PlayerUtils.getUUIDByName(builder); if (builderUniqueId == null) { builderUniqueId = UUID.fromString(getUUID(builder)); } } catch (Throwable e) { GriefPreventionPlugin.instance.getLogger().error("Could not locate a valid UUID for user '" + builder + "' in region '" + rname + "'. Skipping..."); continue; } if (!builders.contains(builderUniqueId) && ownerUniqueId != null && !builderUniqueId.equals(ownerUniqueId)) { builders.add(builderUniqueId); } } claimDataConfig.setRequiresSave(true); claimStorage.save(); GriefPreventionPlugin.instance.getLogger().info( "Successfully migrated RedProtect region data '" + rname + "' to '" + claimFilePath + "'"); count++; } GriefPreventionPlugin.instance.getLogger().info("Finished RedProtect region data migration for world '" + world.getProperties().getWorldName() + "'." + " Migrated a total of " + count + " regions."); } catch (IOException e) { e.printStackTrace(); } catch (ObjectMappingException e) { e.printStackTrace(); } }
From source file:org.usergrid.persistence.cassandra.GeoIndexManager.java
public static void addLocationIndexEntries(List<HColumn<ByteBuffer, ByteBuffer>> columns, Set<EntityLocationRef> locations) { if (columns != null) { EntityLocationRef prevEntry = null; for (HColumn<ByteBuffer, ByteBuffer> column : columns) { DynamicComposite composite = DynamicComposite.fromByteBuffer(column.getName()); UUID uuid = composite.get(0, UUIDSerializer.get()); String type = composite.get(1, StringSerializer.get()); UUID timestampUuid = composite.get(2, UUIDSerializer.get()); composite = DynamicComposite.fromByteBuffer(column.getValue()); Double latitude = composite.get(0, DoubleSerializer.get()); Double longitude = composite.get(1, DoubleSerializer.get()); if ((prevEntry != null) && uuid.equals(prevEntry.getUuid())) { prevEntry.setLatitude(latitude); prevEntry.setLongitude(longitude); } else { prevEntry = new EntityLocationRef(type, uuid, timestampUuid, latitude, longitude); locations.add(prevEntry); }/* w ww .j a v a 2 s. co m*/ } } }
From source file:org.efaps.admin.datamodel.Attribute.java
/** * @param _type Type the attributes are wanted for * @throws EFapsException on error/*from www . j av a 2s.c o m*/ */ protected static void add4Type(final Type _type) throws EFapsException { ConnectionResource con = null; try { con = Context.getThreadContext().getConnectionResource(); PreparedStatement stmt = null; final List<Object[]> values = new ArrayList<Object[]>(); try { stmt = con.getConnection().prepareStatement(Attribute.SQL_TYPE); stmt.setObject(1, _type.getId()); final ResultSet rs = stmt.executeQuery(); while (rs.next()) { values.add(new Object[] { rs.getLong(1), rs.getString(2).trim(), rs.getLong(3), rs.getLong(4), rs.getLong(5), rs.getLong(6), rs.getLong(7), rs.getString(8), rs.getString(9), rs.getString(10), rs.getString(11) }); } rs.close(); } finally { if (stmt != null) { stmt.close(); } } con.commit(); final Map<Long, AttributeSet> id2Set = new HashMap<Long, AttributeSet>(); final Map<Attribute, Long> attribute2setId = new HashMap<Attribute, Long>(); final List<Attribute> attributes = new ArrayList<Attribute>(); for (final Object[] row : values) { final long id = (Long) row[0]; final String name = (String) row[1]; final long typeAttrId = (Long) row[2]; final long tableId = (Long) row[3]; final long attrTypeId = (Long) row[4]; final long typeLinkId = (Long) row[5]; final long parentSetId = (Long) row[6]; final String sqlCol = (String) row[7]; final String defaultval = (String) row[8]; final String dimensionUUID = (String) row[9]; final String className = (String) row[10]; Attribute.LOG.debug("read attribute '{}/{}' (id = {})", _type.getName(), name, id); if (Type.check4Type(typeAttrId, CIAdminDataModel.AttributeSet.uuid)) { final AttributeSet set = new AttributeSet(id, _type, name, AttributeType.get(attrTypeId), sqlCol, tableId, typeLinkId, dimensionUUID); id2Set.put(id, set); } else { final Attribute attr = new Attribute(id, _type.getId(), name, sqlCol, SQLTable.get(tableId), AttributeType.get(attrTypeId), defaultval, dimensionUUID); final UUID uuid = attr.getAttributeType().getUUID(); if (uuid.equals(Attribute.AttributeTypeDef.ATTRTYPE_LINK.getUuid()) || uuid.equals(Attribute.AttributeTypeDef.ATTRTYPE_LINK_WITH_RANGES.getUuid()) || uuid.equals(Attribute.AttributeTypeDef.ATTRTYPE_STATUS.getUuid())) { attr.setLink(typeLinkId); // in case of a PersonLink, CreatorLink or ModifierLink a link to Admin_User_Person // must be set } else if (uuid.equals(Attribute.AttributeTypeDef.ATTRTYPE_CREATOR_LINK.getUuid()) || uuid.equals(Attribute.AttributeTypeDef.ATTRTYPE_MODIFIER_LINK.getUuid()) || uuid.equals(Attribute.AttributeTypeDef.ATTRTYPE_PERSON_LINK.getUuid())) { attr.setLink(Type.getId4UUID(CIAdminUser.Person.uuid)); // in case of a GroupLink, a link to Admin_User_Group must be set } else if (uuid.equals(Attribute.AttributeTypeDef.ATTRTYPE_GROUP_LINK.getUuid())) { attr.setLink(Type.getId4UUID(CIAdminUser.Group.uuid)); // in case of a Enum and BitEnum the className must be set } else if (uuid.equals(Attribute.AttributeTypeDef.ATTRTYPE_ENUM.getUuid()) || uuid.equals(Attribute.AttributeTypeDef.ATTRTYPE_BITENUM.getUuid()) || uuid.equals(Attribute.AttributeTypeDef.ATTRTYPE_JAXB.getUuid())) { if (className == null || className != null && className.isEmpty()) { Attribute.LOG.error( "An Attribute of Type Enum, BitEnum, Jaxb must have a className: {}", attr); } attr.setClassName(className.trim()); } attr.readFromDB4Properties(); if (Type.check4Type(typeAttrId, CIAdminDataModel.AttributeSetAttribute.uuid)) { attribute2setId.put(attr, parentSetId); } else { attributes.add(attr); Attribute.cacheAttribute(attr, _type); } } } // make connection between set and attributes for (final Entry<Attribute, Long> entry : attribute2setId.entrySet()) { final AttributeSet parentset = id2Set.get(entry.getValue()); final Attribute childAttr = entry.getKey(); parentset.addAttributes(false, childAttr); childAttr.setParentSet(parentset); // needed due to cluster serialization that does not update automatically Attribute.cacheAttribute(childAttr, parentset); } for (final AttributeSet set : id2Set.values()) { Type.cacheType(set); } _type.addAttributes(false, attributes.toArray(new Attribute[attributes.size()])); } catch (final SQLException e) { throw new CacheReloadException("Cannot read attributes.", e); } finally { if (con != null && con.isOpened()) { con.abort(); } } }
From source file:eu.griend.grpf.service.NodeService.java
public void deleteNode(UUID uuid) { boolean found = false; for (int n = 0; n < this.nodes.size(); n++) { if (uuid.equals(this.nodes.get(n).getUUID())) { this.nodes.remove(n); found = true;//from ww w .ja va 2 s . c o m break; } } if (!found) { throw new IllegalArgumentException(uuid.toString()); } this.logger.info("delete node: {}", uuid.toString()); }
From source file:eu.griend.grpf.service.NodeService.java
public void updateNode(UUID uuid, NodeEntity node) { boolean found = false; for (int n = 0; n < this.nodes.size(); n++) { if (uuid.equals(this.nodes.get(n).getUUID())) { this.nodes.set(n, node); found = true;/* w w w . j av a 2 s . c o m*/ break; } } if (!found) { throw new IllegalArgumentException(uuid.toString()); } this.logger.info("update node: {}", uuid.toString()); }
From source file:org.starnub.starnubserver.connections.player.session.PlayerSession.java
public static HashSet<PlayerSession> getRecentSessionsByIdentifier(String searchId, DateTime dateTime) { List<PlayerSession> allFromDateRangeToNow = PLAYER_SESSION_LOG_DB.getAllFromDateRangeToNow(END_TIME_COLUMN, dateTime);/*from w ww . j a v a 2 s . co m*/ HashSet<PlayerSession> newList = new HashSet<>(); if (Players.isStarNubId(searchId)) { int starnubId = Integer.parseInt(searchId.replaceAll("[sS]", "")); for (PlayerSession playerSession : allFromDateRangeToNow) { Account account = playerSession.getPlayerCharacter().getAccount(); if (account != null && starnubId == account.getStarnubId()) { newList.add(playerSession); } } } else if (StringUtils.countMatches(searchId, "-") >= 4) { UUID uuid = UUID.fromString(searchId); allFromDateRangeToNow.forEach(playerSession -> { UUID characterUuid = playerSession.getPlayerCharacter().getUuid(); if (uuid.equals(characterUuid)) { newList.add(playerSession); } }); } else if (StringUtils.countMatches(searchId, ".") == 3) { allFromDateRangeToNow.forEach(playerSession -> { String ipString = playerSession.getSessionIpString(); if (ipString.equals(searchId)) { newList.add(playerSession); } }); } else { for (PlayerSession playerSession : allFromDateRangeToNow) { PlayerCharacter character = playerSession.getPlayerCharacter(); String searchName = searchId.toLowerCase(); String cleanName = character.getCleanName().toLowerCase(); String characterName = character.getName().toLowerCase(); if (cleanName.contains(searchName) || characterName.contains(searchName)) { newList.add(playerSession); } } } return newList; }
From source file:eu.griend.grpf.service.NodeService.java
public NodeEntity readNode(UUID uuid) { NodeEntity node = null;/*from w w w . j a v a 2s. c o m*/ boolean found = false; for (int n = 0; n < this.nodes.size(); n++) { if (uuid.equals(this.nodes.get(n).getUUID())) { node = nodes.get(n); found = true; break; } } if (!found) { throw new IllegalArgumentException(uuid.toString()); } this.logger.debug("read node: {}", uuid.toString()); return node; }