Search in sources :

Example 6 with ArchiveEntry

use of net.runelite.http.service.cache.beans.ArchiveEntry in project runelite by runelite.

the class CacheController method getCacheArchive.

@RequestMapping("{cacheId}/{indexId}/{archiveId}")
public CacheArchive getCacheArchive(@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 new CacheArchive(archiveEntry.getArchiveId(), archiveEntry.getNameHash(), archiveEntry.getRevision());
}
Also used : CacheArchive(net.runelite.http.api.cache.CacheArchive) 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 ArchiveEntry

use of net.runelite.http.service.cache.beans.ArchiveEntry 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 8 with ArchiveEntry

use of net.runelite.http.service.cache.beans.ArchiveEntry 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 ArchiveEntry

use of net.runelite.http.service.cache.beans.ArchiveEntry 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)

Example 10 with ArchiveEntry

use of net.runelite.http.service.cache.beans.ArchiveEntry in project runelite by runelite.

the class CacheService method findArchivesForIndex.

public List<ArchiveEntry> findArchivesForIndex(IndexEntry indexEntry) {
    try (Connection con = sql2o.open()) {
        CacheDAO cacheDao = new CacheDAO();
        ResultSetIterable<ArchiveEntry> archiveEntries = cacheDao.findArchivesForIndex(con, indexEntry);
        List<ArchiveEntry> archives = new ArrayList<>();
        Iterables.addAll(archives, archiveEntries);
        return archives;
    }
}
Also used : Connection(org.sql2o.Connection) ArrayList(java.util.ArrayList) ArchiveEntry(net.runelite.http.service.cache.beans.ArchiveEntry)

Aggregations

ArchiveEntry (net.runelite.http.service.cache.beans.ArchiveEntry)11 NotFoundException (net.runelite.http.service.util.exception.NotFoundException)8 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)7 ArchiveFiles (net.runelite.cache.fs.ArchiveFiles)6 FSFile (net.runelite.cache.fs.FSFile)6 CacheEntry (net.runelite.http.service.cache.beans.CacheEntry)6 IndexEntry (net.runelite.http.service.cache.beans.IndexEntry)6 IOException (java.io.IOException)3 SpriteDefinition (net.runelite.cache.definitions.SpriteDefinition)3 SpriteLoader (net.runelite.cache.definitions.loaders.SpriteLoader)3 BufferedImage (java.awt.image.BufferedImage)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 ItemDefinition (net.runelite.cache.definitions.ItemDefinition)2 NpcDefinition (net.runelite.cache.definitions.NpcDefinition)2 ObjectDefinition (net.runelite.cache.definitions.ObjectDefinition)2 TextureDefinition (net.runelite.cache.definitions.TextureDefinition)2 ItemLoader (net.runelite.cache.definitions.loaders.ItemLoader)2 ModelLoader (net.runelite.cache.definitions.loaders.ModelLoader)2 NpcLoader (net.runelite.cache.definitions.loaders.NpcLoader)2 ObjectLoader (net.runelite.cache.definitions.loaders.ObjectLoader)2