private void HandleDeleteAsset(string module, string[] args) { if (args.Length < 3) { MainConsole.Instance.Output("Syntax: delete asset <ID>"); return; } AssetBase asset = m_AssetService.Get(args[2]); if (asset == null || asset.Data.Length == 0) { MainConsole.Instance.OutputFormat("Could not find asset with ID {0}", args[2]); return; } if (!m_AssetService.Delete(asset.ID)) { MainConsole.Instance.OutputFormat("ERROR: Could not delete asset {0} {1}", asset.ID, asset.Name); } else { MainConsole.Instance.OutputFormat("Deleted asset {0} {1}", asset.ID, asset.Name); } }
public bool Delete(string id) { if (m_Cache != null) { m_Cache.Expire(id); } bool result = false; if (IsHG(id)) { result = m_HGService.Delete(id); } else { result = m_GridService.Delete(id); } if (result && m_Cache != null) { m_Cache.Expire(id); } return(result); }
protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { bool result = false; string[] p = SplitParams(path); if (p.Length > 0) { if (m_allowedTypes != AllowedRemoteDeleteTypes.None) { string assetID = p[0]; AssetBase asset = m_AssetService.Get(assetID); if (asset != null) { if (m_allowedTypes == AllowedRemoteDeleteTypes.All || (int)(asset.Flags & AssetFlags.Maptile) != 0) { result = m_AssetService.Delete(assetID); } else { m_log.DebugFormat( "[ASSET SERVER DELETE HANDLER]: Request to delete asset {0}, but type is {1} and allowed remote delete types are {2}", assetID, (AssetFlags)asset.Flags, m_allowedTypes); } } } } XmlSerializer xs = new XmlSerializer(typeof(bool)); return(ServerUtils.SerializeResult(xs, result)); }
public async Task <IActionResult> Delete(int id) { _logger.LogInformation($"[${nameof(AssetController)}] Delete called {DateTimeOffset.UtcNow}"); var result = await _service.Delete(id); return(Ok(result)); }
public bool Delete(string id) { if (m_Cache != null) { m_Cache.Expire(id); } return(m_AssetService.Delete(id)); }
public bool Delete(string id) { if (IsHG(id)) { return(false); } return(m_localConnector.Delete(id)); }
public IActionResult Delete(Guid id) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _assetService.Delete(id); return(Ok()); }
public bool Delete(UUID id) { bool asset = m_localService.Delete(id); if (!asset) { asset = m_remoteService.Delete(id); } return(asset); }
public void CacheWearableData(UUID principalID, AvatarWearable wearable) { if (!m_enableCacheBakedTextures) { IAssetService service = m_registry.RequestModuleInterface <IAssetService>(); if (service != null) { //Remove the old baked textures then from the DB as we don't want to keep them around foreach (UUID texture in wearable.GetItems().Values) { service.Delete(texture.ToString()); } } return; } wearable.MaxItems = 0; //Unlimited items /*AvatarBaseData baseData = new AvatarBaseData(); * AvatarBaseData[] av = m_CacheDatabase.Get("PrincipalID", principalID.ToString()); * foreach (AvatarBaseData abd in av) * { * //If we have one already made, keep what is already there * if (abd.Data["Name"] == "CachedWearables") * { * baseData = abd; * OSDArray array = (OSDArray)OSDParser.DeserializeJson(abd.Data["Value"]); * AvatarWearable w = new AvatarWearable(); * w.MaxItems = 0; //Unlimited items * w.Unpack(array); * foreach (KeyValuePair<UUID, UUID> kvp in w.GetItems()) * { * wearable.Add(kvp.Key, kvp.Value); * } * } * } * //If we don't have one, set it up for saving a new one * if (baseData.Data == null) * { * baseData.PrincipalID = principalID; * baseData.Data = new Dictionary<string, string>(); * baseData.Data.Add("Name", "CachedWearables"); * } * baseData.Data["Value"] = OSDParser.SerializeJsonString(wearable.Pack()); * try * { * bool store = m_CacheDatabase.Store(baseData); * if (!store) * { * m_log.Warn("[AvatarService]: Issue saving the cached wearables to the database."); * } * } * catch * { * }*/ }
public async Task <IActionResult> Delete(string id) { try { return(new OkObjectResult(await _assettService.Delete(id))); } catch (Exception ex) { return(StatusCode(500, "Internal server error" + ex.Message)); } }
public bool DeleteAsset(string ids) { if (ids == "undefined") { return(false); } foreach (var id in ids.Split(',').ToList().ConvertAll(Guid.Parse)) { _assetService.Delete(id); //_auditTrailService.LogAction(AuditTrailAction.RemoveAssetGroup, id, new AuditTrailPayloadModel() { Data = JsonConvert.SerializeObject(id) }); } return(true); }
public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { bool result = false; string[] p = SplitParams(path); if (p.Length > 0) { result = m_AssetService.Delete(p[0]); } XmlSerializer xs = new XmlSerializer(typeof(bool)); return(ServerUtils.SerializeResult(xs, result)); }
public bool Delete(string id) { if (m_Cache != null) { m_Cache.Expire(id); } if (IsHG(id)) { return(m_HGService.Delete(id)); } else { return(m_LocalService.Delete(id)); } }
public async Task <IActionResult> Delete(string id) { try { Asset asset = _assetService.GetById(id); if (asset == null) { return(NotFound()); } _assetService.Delete(asset); return(NoContent()); } catch { return(StatusCode((int)HttpStatusCode.InternalServerError)); } }
//[Route("api/Asset/DeleteAsset/assetid")] public IHttpActionResult DeleteAsset(string id) { try { Guid assetid = Guid.Parse(id); var asset = _AssetService.GetById(assetid); if (asset == null) { return(NotFound()); } _AssetService.Delete(asset); return(Ok(asset)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
void HandleDeleteAsset(string module, string[] args) { if (args.Length < 3) { MainConsole.Instance.Output("Syntax: delete asset <ID>"); return; } AssetBase asset = m_AssetService.Get(args[2]); if (asset == null || asset.Data.Length == 0) { MainConsole.Instance.Output("Asset not found"); return; } m_AssetService.Delete(args[2]); //MainConsole.Instance.Output("Asset deleted"); // TODO: Implement this MainConsole.Instance.Output("Asset deletion not supported by database"); }
public void AssetService_Delete_CallDeleteAssetAndCallsSaveChanges() { #region Arrange var asset = new Asset { Id = 2 }; #endregion #region Act _assetService.Delete(asset); #endregion #region Assert _mockAssetRepository.Verify(x => x.Delete(It.IsAny <Asset>()), Times.Once()); _mockUnitOfWork.Verify(x => x.Save(), Times.Exactly(1)); #endregion }
public IActionResult Delete(int id) { var response = _service.Delete(id); return(Ok(response)); }
public bool Delete(UUID id) { return(m_localService.Delete(id)); }
// List<UUID> m_lastInventoryItemIDs = new List<UUID>(); public AvatarAppearance BakeAppearance(UUID agentID, int cof_version) { AvatarAppearance appearance = m_avatarService.GetAppearance(agentID); if (appearance == null) { MainConsole.Instance.Error("[ServerSide appearance]: Unable to retrieve avatar appearance for bake!"); return(new AvatarAppearance()); } List <BakeType> pendingBakes = new List <BakeType> (); InventoryFolderBase cof = m_inventoryService.GetFolderForType(agentID, InventoryType.Unknown, FolderType.CurrentOutfit); if (cof.Version < cof_version) { int i = 0; while (i < 10) { cof = m_inventoryService.GetFolderForType(agentID, InventoryType.Unknown, FolderType.CurrentOutfit); System.Threading.Thread.Sleep(100); if (cof.Version >= cof_version) { break; } i++; } } List <InventoryItemBase> items = m_inventoryService.GetFolderItems(agentID, cof.ID); foreach (InventoryItemBase itm in items) { MainConsole.Instance.Info("[ServerSide appearance]: Baking " + itm.Name); } for (int i = 0; i < Textures.Length; i++) { Textures [i] = new TextureData(); } WearableData alphaWearable = null; List <UUID> currentItemIDs = new List <UUID> (); foreach (InventoryItemBase itm in items) { if (itm.AssetType == (int)AssetType.Link) { UUID assetID = m_inventoryService.GetItemAssetID(agentID, itm.AssetID); if (appearance.Wearables.Any((w) => w.GetItem(assetID) != UUID.Zero)) { currentItemIDs.Add(assetID); //if (m_lastInventoryItemIDs.Contains(assetID)) // continue; WearableData wearable = new WearableData(); AssetBase asset = m_assetService.Get(assetID.ToString()); if (asset != null && asset.TypeAsset != AssetType.Object) { var assetData = new byte [asset.Data.Length]; asset.Data.CopyTo(assetData, 0); asset.Dispose(); wearable.Asset = new AssetClothing(assetID, assetData); if (wearable.Asset.Decode()) { wearable.AssetID = assetID; wearable.AssetType = wearable.Asset.AssetType; wearable.WearableType = wearable.Asset.WearableType; wearable.ItemID = itm.AssetID; if (wearable.WearableType == WearableType.Alpha) { alphaWearable = wearable; continue; } AppearanceManager.DecodeWearableParams(wearable, ref Textures); } } if (asset != null) // have asset but not an object { asset.Dispose(); } } } } /*foreach (UUID id in m_lastInventoryItemIDs) * { * if (!currentItemIDs.Contains(id)) * { * OpenMetaverse.AppearanceManager.WearableData wearable = new OpenMetaverse.AppearanceManager.WearableData(); * AssetBase asset = m_assetService.Get(id.ToString()); * if (asset != null && asset.TypeAsset != AssetType.Object) * { * wearable.Asset = new AssetClothing(id, asset.Data); * if (wearable.Asset.Decode()) * { * foreach (KeyValuePair<AvatarTextureIndex, UUID> entry in wearable.Asset.Textures) * { * int i = (int)entry.Key; * * Textures[i].Texture = null; * Textures[i].TextureID = UUID.Zero; * } * } * } * } * }*/ //m_lastInventoryItemIDs = currentItemIDs; for (int i = 0; i < Textures.Length; i++) { /*if (Textures[i].TextureID == UUID.Zero) * continue; * if (Textures[i].Texture != null) * continue;*/ AssetBase asset = m_assetService.Get(Textures [i].TextureID.ToString()); if (asset != null) { var assetData = new byte [asset.Data.Length]; asset.Data.CopyTo(assetData, 0); asset.Dispose(); Textures [i].Texture = new AssetTexture(Textures [i].TextureID, assetData); Textures [i].Texture.Decode(); } } for (int bakedIndex = 0; bakedIndex < AppearanceManager.BAKED_TEXTURE_COUNT; bakedIndex++) { AvatarTextureIndex textureIndex = AppearanceManager.BakeTypeToAgentTextureIndex((BakeType)bakedIndex); if (Textures [(int)textureIndex].TextureID == UUID.Zero) { // If this is the skirt layer and we're not wearing a skirt then skip it if (bakedIndex == (int)BakeType.Skirt && appearance.Wearables [(int)WearableType.Skirt].Count == 0) { continue; } pendingBakes.Add((BakeType)bakedIndex); } } int start = Environment.TickCount; List <UUID> newBakeIDs = new List <UUID> (); foreach (BakeType bakeType in pendingBakes) { UUID assetID = UUID.Zero; List <AvatarTextureIndex> textureIndices = AppearanceManager.BakeTypeToTextures(bakeType); Baker oven = new Baker(bakeType); for (int i = 0; i < textureIndices.Count; i++) { int textureIndex = (int)textureIndices [i]; TextureData texture = Textures [textureIndex]; texture.TextureIndex = (AvatarTextureIndex)textureIndex; if (alphaWearable != null) { if (alphaWearable.Asset.Textures.ContainsKey(texture.TextureIndex) && alphaWearable.Asset.Textures [texture.TextureIndex] != UUID.Parse("5748decc-f629-461c-9a36-a35a221fe21f")) { assetID = alphaWearable.Asset.Textures [texture.TextureIndex]; goto bake_complete; } } oven.AddTexture(texture); } oven.Bake(); byte [] assetData = oven.BakedTexture.AssetData; AssetBase newBakedAsset = new AssetBase(UUID.Random()); newBakedAsset.Data = assetData; newBakedAsset.TypeAsset = AssetType.Texture; newBakedAsset.Name = "ServerSideAppearance Texture"; newBakedAsset.Flags = AssetFlags.Deletable | AssetFlags.Collectable | AssetFlags.Rewritable | AssetFlags.Temporary; var faceTextureID = appearance.Texture.FaceTextures [(int)AppearanceManager.BakeTypeToAgentTextureIndex(bakeType)].TextureID; if (faceTextureID != UUID.Zero) { try { m_assetService.Delete(faceTextureID); } catch { MainConsole.Instance.ErrorFormat("[Serverside apperance]: Unable to delete asset {0} during bake", faceTextureID); } } assetID = m_assetService.Store(newBakedAsset); bake_complete: newBakeIDs.Add(assetID); MainConsole.Instance.WarnFormat("[ServerSide appearance]: Baked {0}", assetID); int place = (int)AppearanceManager.BakeTypeToAgentTextureIndex(bakeType); appearance.Texture.FaceTextures [place].TextureID = assetID; } MainConsole.Instance.ErrorFormat("[ServerSide appearance]: Baking took {0} ms", (Environment.TickCount - start)); appearance.Serial = cof_version + 1; cof = m_inventoryService.GetFolderForType(agentID, InventoryType.Unknown, FolderType.CurrentOutfit); if (cof.Version > cof_version) { //it changed during the baking... kill it with fire! return(null); } m_avatarService.SetAppearance(agentID, appearance); return(appearance); }
public void Asset([FromQuery] string id) { _assetService.Delete(id); }
public IActionResult Delete(string id) { _assetService.Delete(id); return(Ok()); }