Package com.ngt.jopenmetaverse.shared.types

Examples of com.ngt.jopenmetaverse.shared.types.UUID


            File[] files = FileUtils.getFileList(textureCacheFolder, "*.texture", true);
            Map<UUID, String> idToFiles = new HashMap<UUID, String>(files.length);
            for (int i = 0; i < files.length; i++)
            {
                String filename = files[i].getName();
                UUID id;

                if ((id = UUID.Parse(FileUtils.getFileNameWithoutExtension(filename)))!=null)
                    idToFiles.put(id, filename);
            }

            for (int i = 0; i < textures.size(); i++)
            {
                UUID texture = textures.get(i);

                if (idToFiles.containsKey(texture))
                {
                    try
                    {
                        FileUtils.copyFile(idToFiles.get(texture), FileUtils.combineFilePath(assetsPath, texture.toString() + "_texture.jp2"), false);
                        ++count;
                    }
                    catch (Exception ex)
                    {
                        JLogger.error("Failed to save texture " + texture.toString() + ": " + Utils.getExceptionStackTraceAsString(ex));
                    }
                }
                else
                {
                    JLogger.warn("Skipping missing texture " + texture.toString());
                }
            }

            JLogger.info("Copied " + count + " textures to the asset archive folder");
        }
View Full Code Here


                                    stri++;
                                    line = lines[stri].trim();
                                    fields = line.split(" ");

                                    AvatarTextureIndex id = AvatarTextureIndex.get(Integer.parseInt(fields[0]));
                                    UUID texture = new UUID(fields[1]);

                                    Textures.put(id,  texture);
                                }
                            }
                            else if (fields[0].equals("type"))
                            {
                                WearableType = WearableType.get((byte)Integer.parseInt(fields[1]));
                            }

                        }
                        else if (fields.length == 2)
                        {
                          if(fields[0].equals("creator_mask"))
                          {
                            // Deprecated, apply this as the base mask
                            Permissions.BaseMask = PermissionMask.get(Utils.hexStringToUInt(fields[1], false));
                          }
                          else if(fields[0].equals("base_mask"))
                          {
                            Permissions.BaseMask = PermissionMask.get(Utils.hexStringToUInt(fields[1], false));
                          }
                          else if(fields[0].equals("owner_mask"))
                          {
                            Permissions.OwnerMask = PermissionMask.get(Utils.hexStringToUInt(fields[1], false));
                          }
                          else if(fields[0].equals("group_mask"))
                          {
                            Permissions.GroupMask = PermissionMask.get(Utils.hexStringToUInt(fields[1], false));
                          }
                          else if(fields[0].equals("everyone_mask")) {
                            Permissions.EveryoneMask = PermissionMask.get(Utils.hexStringToUInt(fields[1], false));
                          }
                          else if(fields[0].equals("next_owner_mask")) {
                            Permissions.NextOwnerMask = PermissionMask.get(Utils.hexStringToUInt(fields[1], false));
                          }
                          else if(fields[0].equals("creator_id")) {
                            Creator = new UUID(fields[1]);
                          }
                          else if(fields[0].equals("owner_id")) {
                            Owner = new UUID(fields[1]);
                          }
                          else if(fields[0].equals("last_owner_id")) {
                            LastOwner = new UUID(fields[1]);
                          }
                          else if(fields[0].equals("group_id")) {
                            Group = new UUID(fields[1]);
                          }
                          else if(fields[0].equals("group_owned")) {
                            GroupOwned = (Integer.parseInt(fields[1]) != 0);
                          }
                          else if(fields[0].equals("sale_type")) {
View Full Code Here

//                   
//                    if (!(m = Regex.Match(lines[i++], @"inv_item\s+0")).Success)
//                        throw new Exception("missing inv item");

                    // Item itself
                    UUID uuid = UUID.Zero;
                    UUID creatorID = UUID.Zero;
                    UUID ownerID = UUID.Zero;
                    UUID lastOwnerID = UUID.Zero;
                    UUID groupID = UUID.Zero;
                    Permissions permissions = Permissions.NoPermissions;
                    int salePrice = 0;
                    SaleType saleType = SaleType.Not;
                    UUID parentUUID = UUID.Zero;
                    UUID assetUUID = UUID.Zero;
                    AssetType assetType = AssetType.Unknown;
                    InventoryType inventoryType = InventoryType.Unknown;
                    //uint
                    long flags = 0;
                    String name = "";
                    String description = "";
                    Date creationDate = Utils.Epoch;

                    while (true)
                    {
                        if(!(m = Pattern.compile("([^\\s]+)(\\s+)?(.*)?").matcher(lines[i++])).find())
                            throw new Exception("wrong format");

//                        if (!(m = Regex.Match(lines[i++], @"([^\s]+)(\s+)?(.*)?")).Success)
//                            throw new Exception("wrong format");
                       
                        String key = m.group(1);
                        StringBuilder val = new StringBuilder(m.group(3));
                        if (key.equals("{"))
                            continue;
                        if (key.equals("}"))
                            break;
                        else if (key.equals("permissions"))
                        {
                          //uint
                            long baseMask = 0;
                            long ownerMask = 0;
                            long groupMask = 0;
                            long everyoneMask = 0;
                            long nextOwnerMask = 0;

                            while (true)
                            {
                                if(!(m = Pattern.compile("([^\\s]+)(\\s+)?([^\\s]+)?").matcher(lines[i++])).find())
                                    throw new Exception("wrong format");
                             
//                                if (!(m = Regex.Match(lines[i++], @"([^\s]+)(\s+)?([^\s]+)?")).Success)
//                                    throw new Exception("wrong format");
                                String pkey = m.group(1);
                                String pval = m.group(3);

                                if (pkey.equals("{"))
                                    continue;
                                if (pkey.equals("}"))
                                    break;
                                else if (pkey.equals("creator_id"))
                                {
                                    creatorID = new UUID(pval);
                                }
                                else if (pkey.equals("owner_id"))
                                {
                                    ownerID = new UUID(pval);
                                }
                                else if (pkey.equals("last_owner_id"))
                                {
                                    lastOwnerID = new UUID(pval);
                                }
                                else if (pkey.equals("group_id"))
                                {
                                    groupID = new UUID(pval);
                                }
                                else if (pkey.equals("base_mask"))
                                {
                                  baseMask = Utils.hexStringToUInt(pval, false);
//                                    baseMask = Utils.hexStringToUInt(pval, false);
                                }
                                else if (pkey.equals("owner_mask"))
                                {
                                    ownerMask = Utils.hexStringToUInt(pval, false);
                                }
                                else if (pkey.equals("group_mask"))
                                {
                                    groupMask = Utils.hexStringToUInt(pval, false);
                                }
                                else if (pkey.equals("everyone_mask"))
                                {
                                    everyoneMask = Utils.hexStringToUInt(pval, false);
                                }
                                else if (pkey.equals("next_owner_mask"))
                                {
                                    nextOwnerMask = Utils.hexStringToUInt(pval, false);
                                }
                            }
                            permissions = new Permissions(baseMask, everyoneMask, groupMask, nextOwnerMask, ownerMask);
                        }
                        else if (key.equals("sale_info"))
                        {
                            while (true)
                            {
                                if(!(m = Pattern.compile("([^\\s]+)(\\s+)?([^\\s]+)?").matcher(lines[i++])).find())
                                    throw new Exception("wrong format");

//                                if (!(m = Regex.Match(lines[i++], @"([^\s]+)(\s+)?([^\s]+)?")).Success)
//                                    throw new Exception("wrong format");
                               
                                String pkey = m.group(1);
                                String pval = m.group(3);

                                if (pkey == "{")
                                    continue;
                                if (pkey == "}")
                                    break;
                                else if (pkey.equals("sale_price"))
                                {
                                    salePrice = Integer.parseInt(pval);
                                }
                                else if (pkey.equals("sale_type"))
                                {
                                    saleType = Utils.StringToSaleType(pval);
                                }
                            }
                        }
                        else if (key.equals("item_id"))
                        {
                            uuid = new UUID(val.toString());
                        }
                        else if (key.equals("parent_id"))
                        {
                            parentUUID = new UUID(val.toString());
                        }
                        else if (key.equals("asset_id"))
                        {
                            assetUUID = new UUID(val.toString());
                        }
                        else if (key.equals("type"))
                        {
                            assetType = Utils.StringToAssetType(val.toString());
                        }
View Full Code Here

        public boolean Decode() throws UnsupportedEncodingException
        {
            String text = Utils.bytesWithTrailingNullByteToString(AssetData);
            if (text.toLowerCase().contains("landmark version 2"))
            {
                RegionID = new UUID(text.substring(text.indexOf("region_id") + 10, 36));
                String vecDelim = " ";
                String[] vecStrings = text.substring(text.indexOf("local_pos") + 10).split(vecDelim);
                if (vecStrings.length == 3)
                {
                    Position = new Vector3(Float.parseFloat(vecStrings[0]), Float.parseFloat(vecStrings[1]),Float.parseFloat(vecStrings[2]));
View Full Code Here

    tempSD = map.get("region_id");
    Assert.assertNotNull(tempSD);
    Assert.assertTrue(tempSD instanceof OSDUUID);
    Assert.assertTrue(tempSD.getType() == OSDType.UUID);
    tempUUID = (OSDUUID)tempSD;
    Assert.assertEquals(new UUID("67153d5b-3659-afb4-8510-adda2c034649"), tempUUID.asUUID());

    tempSD = map.get("scale");
    Assert.assertNotNull(tempSD);
    Assert.assertTrue(tempSD instanceof OSDString);
    Assert.assertTrue(tempSD.getType() == OSDType.String);
View Full Code Here

    Assert.assertTrue(theSD instanceof OSDArray);
    array = (OSDArray)theSD;

    Assert.assertEquals(OSDType.UUID, array.get(0).getType());
    tempUUID = (OSDUUID)array.get(0);
    Assert.assertEquals(new UUID("d7f4aeca-88f1-42a1-b385-b9db18abb255"), tempUUID.asUUID());

    Assert.assertEquals(OSDType.UUID, array.get(1).getType());
    tempUUID = (OSDUUID)array.get(1);
    Assert.assertEquals(UUID.Zero, tempUUID.asUUID());
  }
View Full Code Here

    }

    @Test
    public void SerializeUUID() throws Exception
    {
        OSD llsdAUUID = OSD.FromUUID(new UUID("97f4aeca-88a1-42a1-b385-b97b18abb255"));
        byte[] binaryAUUIDSerialized = BinaryLLSDOSDParser.SerializeLLSDBinary(llsdAUUID);
        Assert.assertArrayEquals(binaryAUUID, binaryAUUIDSerialized);

        binaryAUUIDSerialized = BinaryLLSDOSDParser.SerializeLLSDBinary(llsdAUUID);
        Assert.assertArrayEquals(binaryAUUID, binaryAUUIDSerialized);

        OSD llsdZeroUUID = OSD.FromUUID(new UUID("00000000-0000-0000-0000-000000000000"));
        byte[] binaryZeroUUIDSerialized = BinaryLLSDOSDParser.SerializeLLSDBinary(llsdZeroUUID);
        Assert.assertArrayEquals(binaryZeroUUID, binaryZeroUUIDSerialized);

        binaryZeroUUIDSerialized = BinaryLLSDOSDParser.SerializeLLSDBinary(llsdZeroUUID);
        Assert.assertArrayEquals(binaryZeroUUID, binaryZeroUUIDSerialized);
View Full Code Here

public class GroupRoleUpdatePacketTest {
 
  @Test
  public void ToBytesMultiple() throws MalformedDataException
  {
    UUID testID = UUID.Random();

    GroupRoleUpdatePacket bigPacket = new GroupRoleUpdatePacket();
    bigPacket.header.Zerocoded = false;
    bigPacket.header.Sequence = 42;
    bigPacket.header.AppendedAcks = true;
    //Unsigned int
    bigPacket.header.AckList = new long[50];
    for (int i = 0; i < bigPacket.header.AckList.length; i++) { bigPacket.header.AckList[i] = (long)i; }
    bigPacket.AgentData.AgentID = testID;
    bigPacket.AgentData.SessionID = testID;
//    bigPacket.TransactionBlock.TransactionID = testID;
   
    bigPacket.RoleData = new RoleDataBlock[200];
    for(int i = 0; i < bigPacket.RoleData.length; i++)
    {
      GroupRoleUpdatePacket.RoleDataBlock fdb = new GroupRoleUpdatePacket.RoleDataBlock();
      fdb.RoleID = testID;
      fdb.Name = Utils.stringToBytes("Test Name: " + i);
//      //System.out.println("Name Length" + fdb.Name.length);
      fdb.Description = Utils.stringToBytes("Test Description: " + i);
      fdb.Title = Utils.stringToBytes("Test Title: " + i);
      fdb.Powers = new BigInteger("4294967295");
      fdb.UpdateType = (byte)i;
      bigPacket.RoleData[i] = fdb;
    }
   
//    //System.out.println(Utils.bytesToHexString(bigPacket.ToBytes(), "GroupRoleUpdatePacketTest ToBytes"));
   
    byte[][] splitPackets = bigPacket.ToBytesMultiple();

    int roleDataCount = 0;
    int k = 0;
    for (int i = 0; i < splitPackets.length; i++)
    {
      byte[] packetData = splitPackets[i];
     
      int[] len = new int[]{packetData.length - 1};
      GroupRoleUpdatePacket packet = (GroupRoleUpdatePacket)Packet.BuildPacket(packetData, len, packetData);

      Assert.assertTrue(packet.AgentData.AgentID.equals(bigPacket.AgentData.AgentID));
      Assert.assertTrue(packet.AgentData.SessionID.equals(bigPacket.AgentData.SessionID));

      for (int j = 0; j < packet.RoleData.length; j++)
      {
        Assert.assertTrue("Expected FolderId of " + testID.toString() + " but got " + packet.RoleData[j].RoleID.toString(),
            packet.RoleData[j].RoleID.equals(testID));
        Assert.assertArrayEquals(packet.RoleData[j].Name, Utils.stringToBytes("Test Name: " + k));
        Assert.assertArrayEquals(packet.RoleData[j].Description, Utils.stringToBytes("Test Description: " + k));
        Assert.assertArrayEquals(packet.RoleData[j].Title, Utils.stringToBytes("Test Title: " + k));
       
View Full Code Here

  @Test
  public void ToBytesTest() throws MalformedDataException
  {
    UseCircuitCodePacket use1 = new UseCircuitCodePacket();
    use1.CircuitCode.Code = 1064081002;
    use1.CircuitCode.ID = new UUID("dca4f918-6e92-4c65-a42a-00c9887c2669");
    use1.CircuitCode.SessionID = new UUID("7818e42d-d2c4-462b-88c8-13015c93540f0000");
   
    byte[] data1 = use1.ToBytes();
    UseCircuitCodePacket tuse1 = (UseCircuitCodePacket)UseCircuitCodePacket.BuildPacket(data1, new int[]{data1.length-1}, null);
   
   
View Full Code Here

          }

          @Test
          public void SerializeUUID() throws IOException, OSDException
          {
              OSD llsdOne = OSD.FromUUID(new UUID("97f4aeca-88a1-42a1-b385-b97b18abb255"));
              String sOne = NotationalLLSDOSDParser.SerializeLLSDNotation(llsdOne);
              OSD llsdOneDS = NotationalLLSDOSDParser.DeserializeLLSDNotation(sOne);
              Assert.assertEquals(OSDType.UUID, llsdOneDS.getType());
              Assert.assertEquals("97f4aeca-88a1-42a1-b385-b97b18abb255", llsdOneDS.asString());

              OSD llsdTwo = OSD.FromUUID(new UUID("00000000-0000-0000-0000-000000000000"));
              String sTwo = NotationalLLSDOSDParser.SerializeLLSDNotation(llsdTwo);
              OSD llsdTwoDS = NotationalLLSDOSDParser.DeserializeLLSDNotation(sTwo);
              Assert.assertEquals(OSDType.UUID, llsdTwoDS.getType());
              Assert.assertEquals("00000000-0000-0000-0000-000000000000", llsdTwoDS.asString());
          }
View Full Code Here

TOP

Related Classes of com.ngt.jopenmetaverse.shared.types.UUID

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.