items.add(folder);
}
else
{
InventoryItem item = new InventoryItem(itemID);
item.Name = name;
item.ParentUUID = parentID;
item.AssetType = assetType;
items.add(item);
}
//endregion inv_object
}
else if (key.equals("inv_item"))
{
//region inv_item
// Any inventory item that links to an assetID, has permissions, etc
UUID itemID = UUID.Zero;
UUID assetID = UUID.Zero;
UUID parentID = UUID.Zero;
UUID creatorID = UUID.Zero;
UUID ownerID = UUID.Zero;
UUID lastOwnerID = UUID.Zero;
UUID groupID = UUID.Zero;
boolean groupOwned = false;
String name = "";
String desc = "";
AssetType assetType = AssetType.Unknown;
InventoryType inventoryType = InventoryType.Unknown;
Date creationDate = Utils.Epoch;
//uint
long flags = 0;
Permissions perms = Permissions.NoPermissions;
SaleType saleType = SaleType.Not;
int salePrice = 0;
while (lineNum < lines.length)
{
if (ParseLine(lines[lineNum++], key, value))
{
if (key[0].equals("{"))
{
continue;
}
else if (key[0].equals("}"))
{
break;
}
else if (key[0].equals("item_id"))
{
itemID = UUID.Parse(value[0]);
}
else if (key[0].equals("parent_id"))
{
parentID = UUID.Parse(value[0]);
}
else if (key[0].equals("permissions"))
{
//region permissions
while (lineNum < lines.length)
{
if (ParseLine(lines[lineNum++], key, value))
{
if (key[0].equals("{"))
{
continue;
}
else if (key[0].equals("}"))
{
break;
}
//TODO need to verify following
else if (key[0].equals("creator_mask"))
{
// Deprecated
long val;
if ((val = Utils.hexStringToUInt(value[0], false)) >=0)
perms.BaseMask = PermissionMask.get(val);
}
else if (key[0].equals("base_mask"))
{
long val;
if ((val = Utils.hexStringToUInt(value[0], false)) >=0)
perms.BaseMask = PermissionMask.get(val);
}
else if (key[0].equals("owner_mask"))
{
long val;
if ((val = Utils.hexStringToUInt(value[0], false)) >=0)
perms.OwnerMask = PermissionMask.get(val);
}
else if (key[0].equals("group_mask"))
{
long val;
if ((val = Utils.hexStringToUInt(value[0], false)) >=0)
perms.GroupMask = PermissionMask.get(val);
}
else if (key[0].equals("everyone_mask"))
{
long val;
if ((val = Utils.hexStringToUInt(value[0], false)) >=0)
perms.EveryoneMask = PermissionMask.get(val);
}
else if (key[0].equals("next_owner_mask"))
{
long val;
if ((val = Utils.hexStringToUInt(value[0], false)) >=0)
perms.NextOwnerMask = PermissionMask.get(val);
}
else if (key[0].equals("creator_id"))
{
creatorID = UUID.Parse(value[0]);
}
else if (key[0].equals("owner_id"))
{
ownerID = UUID.Parse(value[0]);
}
else if (key[0].equals("last_owner_id"))
{
lastOwnerID = UUID.Parse(value[0]);
}
else if (key[0].equals("group_id"))
{
groupID = UUID.Parse(value[0]);
}
else if (key[0].equals("group_owned"))
{
long val;
if ((val = Utils.hexStringToUInt(value[0], false)) >=0)
groupOwned = (val != 0);
}
}
}
//endregion permissions
}
else if (key[0].equals("sale_info"))
{
//region sale_info
while (lineNum < lines.length)
{
if (ParseLine(lines[lineNum++], key, value))
{
if (key[0].equals("{"))
{
continue;
}
else if (key[0].equals("}"))
{
break;
}
else if (key[0].equals("sale_type"))
{
saleType = Utils.StringToSaleType(value[0]);
}
else if (key[0].equals("sale_price"))
{
salePrice = (int)Utils.hexStringToUInt(value[0], false);
}
}
}
//endregion sale_info
}
else if (key[0].equals("shadow_id"))
{
UUID[] shadowID = new UUID[0];
if (Utils.tryParseUUID(value[0], shadowID))
assetID = DecryptShadowID(shadowID[0]);
}
else if (key[0].equals("asset_id"))
{
assetID = UUID.Parse(value[0]);
}
else if (key[0].equals("type"))
{
assetType = Utils.StringToAssetType(value[0]);
}
else if (key[0].equals("inv_type"))
{
inventoryType = Utils.StringToInventoryType(value[0]);
}
else if (key[0].equals("flags"))
{
long[] a = new long[1];
Utils.tryParseLong(value[0], a);
flags = a[1];
}
else if (key[0].equals("name"))
{
name = value[0].substring(0, value[0].indexOf('|'));
}
else if (key[0].equals("desc"))
{
desc = value[0].substring(0, value[0].indexOf('|'));
}
else if (key[0].equals("creation_date"))
{
long[] timestamp = new long[1];
if (Utils.tryParseLong(value[0], timestamp))
creationDate = Utils.unixTimeToDate(timestamp[0]);
else
JLogger.warn("Failed to parse creation_date " + value[0]);
}
}
}
InventoryItem item = CreateInventoryItem(inventoryType, itemID);
item.AssetUUID = assetID;
item.AssetType = assetType;
item.CreationDate = creationDate;
item.CreatorID = creatorID;
item.Description = desc;