Search in sources :

Example 6 with NotFoundException

use of net.runelite.http.service.util.exception.NotFoundException in project runelite by runelite.

the class CacheController method getArchiveData.

@RequestMapping("{cacheId}/{indexId}/{archiveId}/data")
public byte[] getArchiveData(@PathVariable int cacheId, @PathVariable int indexId, @PathVariable int archiveId) {
    CacheEntry cache = cacheService.findCache(cacheId);
    if (cache == null) {
        throw new NotFoundException();
    }
    IndexEntry indexEntry = cacheService.findIndexForCache(cache, indexId);
    if (indexEntry == null) {
        throw new NotFoundException();
    }
    ArchiveEntry archiveEntry = cacheService.findArchiveForIndex(indexEntry, archiveId);
    if (archiveEntry == null) {
        throw new NotFoundException();
    }
    return cacheService.getArchive(archiveEntry);
}
Also used : NotFoundException(net.runelite.http.service.util.exception.NotFoundException) IndexEntry(net.runelite.http.service.cache.beans.IndexEntry) ArchiveEntry(net.runelite.http.service.cache.beans.ArchiveEntry) CacheEntry(net.runelite.http.service.cache.beans.CacheEntry) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 7 with NotFoundException

use of net.runelite.http.service.util.exception.NotFoundException in project runelite by runelite.

the class CacheController method listIndexes.

@RequestMapping("{cacheId}")
public List<CacheIndex> listIndexes(@PathVariable int cacheId) {
    CacheEntry cache = cacheService.findCache(cacheId);
    if (cache == null) {
        throw new NotFoundException();
    }
    List<IndexEntry> indexes = cacheService.findIndexesForCache(cache);
    return indexes.stream().map(entry -> new CacheIndex(entry.getIndexId(), entry.getRevision())).collect(Collectors.toList());
}
Also used : PathVariable(org.springframework.web.bind.annotation.PathVariable) RequestParam(org.springframework.web.bind.annotation.RequestParam) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ArchiveFiles(net.runelite.cache.fs.ArchiveFiles) TextureProvider(net.runelite.cache.definitions.providers.TextureProvider) Autowired(org.springframework.beans.factory.annotation.Autowired) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) Cache(net.runelite.http.api.cache.Cache) SpriteDefinition(net.runelite.cache.definitions.SpriteDefinition) SpriteLoader(net.runelite.cache.definitions.loaders.SpriteLoader) IndexEntry(net.runelite.http.service.cache.beans.IndexEntry) ImageIO(javax.imageio.ImageIO) CacheEntry(net.runelite.http.service.cache.beans.CacheEntry) ItemLoader(net.runelite.cache.definitions.loaders.ItemLoader) FSFile(net.runelite.cache.fs.FSFile) IndexType(net.runelite.cache.IndexType) ObjectDefinition(net.runelite.cache.definitions.ObjectDefinition) TextureDefinition(net.runelite.cache.definitions.TextureDefinition) TextureLoader(net.runelite.cache.definitions.loaders.TextureLoader) NpcLoader(net.runelite.cache.definitions.loaders.NpcLoader) BufferedImage(java.awt.image.BufferedImage) ArchiveEntry(net.runelite.http.service.cache.beans.ArchiveEntry) Container(net.runelite.cache.fs.Container) IOException(java.io.IOException) ObjectLoader(net.runelite.cache.definitions.loaders.ObjectLoader) Collectors(java.util.stream.Collectors) RestController(org.springframework.web.bind.annotation.RestController) SpriteProvider(net.runelite.cache.definitions.providers.SpriteProvider) CacheIndex(net.runelite.http.api.cache.CacheIndex) CacheArchive(net.runelite.http.api.cache.CacheArchive) ConfigType(net.runelite.cache.ConfigType) ItemProvider(net.runelite.cache.definitions.providers.ItemProvider) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) ItemDefinition(net.runelite.cache.definitions.ItemDefinition) ItemSpriteFactory(net.runelite.cache.item.ItemSpriteFactory) NotFoundException(net.runelite.http.service.util.exception.NotFoundException) NpcDefinition(net.runelite.cache.definitions.NpcDefinition) ResponseEntity(org.springframework.http.ResponseEntity) ModelLoader(net.runelite.cache.definitions.loaders.ModelLoader) ModelProvider(net.runelite.cache.definitions.providers.ModelProvider) ModelDefinition(net.runelite.cache.definitions.ModelDefinition) CacheIndex(net.runelite.http.api.cache.CacheIndex) NotFoundException(net.runelite.http.service.util.exception.NotFoundException) IndexEntry(net.runelite.http.service.cache.beans.IndexEntry) CacheEntry(net.runelite.http.service.cache.beans.CacheEntry) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 8 with NotFoundException

use of net.runelite.http.service.util.exception.NotFoundException in project runelite by runelite.

the class CacheController method getNpc.

@RequestMapping("npc/{npcId}")
public NpcDefinition getNpc(@PathVariable int npcId) throws IOException {
    ArchiveEntry archiveEntry = findConfig(ConfigType.NPC);
    ArchiveFiles archiveFiles = cacheService.getArchiveFiles(archiveEntry);
    if (archiveFiles == null) {
        throw new NotFoundException();
    }
    FSFile file = archiveFiles.findFile(npcId);
    if (file == null) {
        throw new NotFoundException();
    }
    NpcDefinition npcdef = new NpcLoader().load(npcId, file.getContents());
    return npcdef;
}
Also used : ArchiveFiles(net.runelite.cache.fs.ArchiveFiles) NpcDefinition(net.runelite.cache.definitions.NpcDefinition) NpcLoader(net.runelite.cache.definitions.loaders.NpcLoader) NotFoundException(net.runelite.http.service.util.exception.NotFoundException) ArchiveEntry(net.runelite.http.service.cache.beans.ArchiveEntry) FSFile(net.runelite.cache.fs.FSFile) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 9 with NotFoundException

use of net.runelite.http.service.util.exception.NotFoundException in project runelite by runelite.

the class CacheController method getItem.

@RequestMapping("item/{itemId}")
public ItemDefinition getItem(@PathVariable int itemId) throws IOException {
    ArchiveEntry archiveEntry = findConfig(ConfigType.ITEM);
    ArchiveFiles archiveFiles = cacheService.getArchiveFiles(archiveEntry);
    if (archiveFiles == null) {
        throw new NotFoundException();
    }
    FSFile file = archiveFiles.findFile(itemId);
    if (file == null) {
        throw new NotFoundException();
    }
    ItemDefinition itemdef = new ItemLoader().load(itemId, file.getContents());
    return itemdef;
}
Also used : ArchiveFiles(net.runelite.cache.fs.ArchiveFiles) ItemDefinition(net.runelite.cache.definitions.ItemDefinition) NotFoundException(net.runelite.http.service.util.exception.NotFoundException) ArchiveEntry(net.runelite.http.service.cache.beans.ArchiveEntry) ItemLoader(net.runelite.cache.definitions.loaders.ItemLoader) FSFile(net.runelite.cache.fs.FSFile) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

NotFoundException (net.runelite.http.service.util.exception.NotFoundException)9 ArchiveEntry (net.runelite.http.service.cache.beans.ArchiveEntry)8 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)7 ArchiveFiles (net.runelite.cache.fs.ArchiveFiles)5 FSFile (net.runelite.cache.fs.FSFile)5 CacheEntry (net.runelite.http.service.cache.beans.CacheEntry)5 IndexEntry (net.runelite.http.service.cache.beans.IndexEntry)5 ItemDefinition (net.runelite.cache.definitions.ItemDefinition)3 NpcDefinition (net.runelite.cache.definitions.NpcDefinition)3 ObjectDefinition (net.runelite.cache.definitions.ObjectDefinition)3 ItemLoader (net.runelite.cache.definitions.loaders.ItemLoader)3 NpcLoader (net.runelite.cache.definitions.loaders.NpcLoader)3 ObjectLoader (net.runelite.cache.definitions.loaders.ObjectLoader)3 CacheArchive (net.runelite.http.api.cache.CacheArchive)3 BufferedImage (java.awt.image.BufferedImage)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 IOException (java.io.IOException)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 ImageIO (javax.imageio.ImageIO)2