当前位置: 首页>>代码示例>>Java>>正文


Java ResourcePersistenceType类代码示例

本文整理汇总了Java中de.digitalcollections.core.model.api.resource.enums.ResourcePersistenceType的典型用法代码示例。如果您正苦于以下问题:Java ResourcePersistenceType类的具体用法?Java ResourcePersistenceType怎么用?Java ResourcePersistenceType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ResourcePersistenceType类属于de.digitalcollections.core.model.api.resource.enums包,在下文中一共展示了ResourcePersistenceType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getResource

import de.digitalcollections.core.model.api.resource.enums.ResourcePersistenceType; //导入依赖的package包/类
private Resource getResource(String key, ResourcePersistenceType persistenceType, MimeType mimeType) {
  Resource resource = new ResourceImpl();
  if (mimeType != null) {
    if (mimeType.getExtensions() != null && !mimeType.getExtensions().isEmpty()) {
      resource.setFilenameExtension(mimeType.getExtensions().get(0));
    }
    resource.setMimeType(mimeType);
  }
  if (ResourcePersistenceType.REFERENCED.equals(persistenceType)) {
    resource.setReadonly(true);
  }
  if (ResourcePersistenceType.MANAGED.equals(persistenceType)) {
    resource.setUuid(UUID.fromString(key));
  }
  return resource;
}
 
开发者ID:dbmdz,项目名称:digitalcollections-core,代码行数:17,代码来源:ResourceRepositoryImpl.java

示例2: find

import de.digitalcollections.core.model.api.resource.enums.ResourcePersistenceType; //导入依赖的package包/类
@Override
public Resource find(String key, ResourcePersistenceType resourcePersistenceType, MimeType mimeType) throws ResourceIOException {
  Resource resource = getResource(key, resourcePersistenceType, mimeType);
  List<URI> candidates = getUris(key, resourcePersistenceType, mimeType);
  if (candidates.isEmpty()) {
    throw new ResourceIOException("Could not resolve key " + key + "with MIME type " + mimeType.getTypeName() + "to an URI");
  }
  URI uri = candidates.stream()
          .filter(u -> resourceLoader.getResource(u.toString()).isReadable())
          .findFirst()
          .orElseThrow(() -> new ResourceIOException(
          "Could not resolve key " + key + " with MIME type " + mimeType.getTypeName()
          + " to a readable Resource. Attempted URIs were " + candidates));
  resource.setUri(uri);
  org.springframework.core.io.Resource springResource = resourceLoader.getResource(uri.toString());

  long lastModified = getLastModified(springResource);
  resource.setLastModified(lastModified);

  long length = getSize(springResource);
  resource.setSize(length);

  return resource;
}
 
开发者ID:dbmdz,项目名称:digitalcollections-core,代码行数:25,代码来源:ResourceRepositoryImpl.java

示例3: testFind

import de.digitalcollections.core.model.api.resource.enums.ResourcePersistenceType; //导入依赖的package包/类
/**
 * Test of find method, of class ResourceRepositoryImpl.
 */
@Test
public void testFind() throws Exception {
  System.out.println("find");
  String key = "snafu";
  ResourcePersistenceType resourcePersistenceType = RESOLVED;
  Resource resource = resourceRepository.find(key, resourcePersistenceType, MimeType.MIME_APPLICATION_XML);

  URI expResult = URI.create("classpath:/snafu.xml");
  URI result = resource.getUri();
  Assert.assertEquals(expResult, result);

  long expSize = 65;
  long size = resource.getSize();
  Assert.assertEquals(expSize, size);

  long lastModified = resource.getLastModified();
  Assert.assertTrue(lastModified > 0);
}
 
开发者ID:dbmdz,项目名称:digitalcollections-core,代码行数:22,代码来源:ResourceRepositoryImplTest.java

示例4: getReader

import de.digitalcollections.core.model.api.resource.enums.ResourcePersistenceType; //导入依赖的package包/类
/** Try to obtain a {@link ImageReader} for a given identifier **/
private ImageReader getReader(String identifier) throws ResourceNotFoundException, UnsupportedFormatException, IOException {
  if (imageSecurityService != null && !imageSecurityService.isAccessAllowed(identifier)) {
    throw new ResourceNotFoundException();
  }
  Resource res = null;
  try {
    res = resourceService.get(identifier, ResourcePersistenceType.RESOLVED, MimeType.MIME_IMAGE);
  } catch (ResourceIOException e) {
    throw new ResourceNotFoundException();
  }
  ImageInputStream iis = ImageIO.createImageInputStream(resourceService.getInputStream(res));
  ImageReader reader = Streams.stream(ImageIO.getImageReaders(iis))
          .findFirst()
          .orElseThrow(() -> new UnsupportedFormatException());
  reader.setInput(iis);
  return reader;
}
 
开发者ID:dbmdz,项目名称:iiif-server-hymir,代码行数:19,代码来源:ImageServiceImpl.java

示例5: create

import de.digitalcollections.core.model.api.resource.enums.ResourcePersistenceType; //导入依赖的package包/类
@Override
public Resource create(String key, ResourcePersistenceType resourcePersistenceType, MimeType mimeType) throws ResourceIOException {
  Resource resource = getResource(key, resourcePersistenceType, mimeType);
  List<URI> uris = getUris(key, resourcePersistenceType, mimeType);
  resource.setUri(uris.get(0));
  return resource;
}
 
开发者ID:dbmdz,项目名称:digitalcollections-core,代码行数:8,代码来源:ResourceRepositoryImpl.java

示例6: getResourcePersistenceTypeHandler

import de.digitalcollections.core.model.api.resource.enums.ResourcePersistenceType; //导入依赖的package包/类
public ResourcePersistenceTypeHandler getResourcePersistenceTypeHandler(ResourcePersistenceType resourcePersistence)
        throws ResourceIOException {
  for (ResourcePersistenceTypeHandler resourcePersistenceTypeHandler : this.getResourcePersistenceTypeHandlers()) {
    if (resourcePersistence.equals(resourcePersistenceTypeHandler.getResourcePersistenceType())) {
      return resourcePersistenceTypeHandler;
    }
  }
  throw new ResourceIOException("No ResourcePersistenceHandler defined for " + resourcePersistence);
}
 
开发者ID:dbmdz,项目名称:digitalcollections-core,代码行数:10,代码来源:ResourceRepositoryImpl.java

示例7: testCreate

import de.digitalcollections.core.model.api.resource.enums.ResourcePersistenceType; //导入依赖的package包/类
/**
 * Test of create method, of class ResourceRepositoryImpl.
 */
@Test
public void testCreate() throws Exception {
  System.out.println("create");

  // test managed
  String key = "a30cf362-5992-4f5a-8de0-61938134e721";
  ResourcePersistenceType resourcePersistenceType = ResourcePersistenceType.MANAGED;
  Resource resource = resourceRepository.create(key, resourcePersistenceType, "xml");
  URI expResult = URI.create("/src/test/resources/repository/de.digitalcollections.core.data.stream/a30c/f362/5992/4f5a/8de0/6193/8134/e721/a30cf362-5992-4f5a-8de0-61938134e721.xml");
  URI result = resource.getUri();
  Assert.assertEquals(expResult, result);

  // test resolved
  key = "bsb00001000";
  resourcePersistenceType = RESOLVED;
  resource = resourceRepository.create(key, resourcePersistenceType, "xml");
  expResult = URI.create("http://rest.digitale-sammlungen.de/data/bsb00001000.xml");
  result = resource.getUri();
  Assert.assertEquals(expResult, result);
  Assert.assertFalse(resource.isReadonly());

  // test referenced
  key = "bsb00001000";
  resourcePersistenceType = ResourcePersistenceType.REFERENCED;
  resource = resourceRepository.create(key, resourcePersistenceType, "xml");
  expResult = URI.create("http://rest.digitale-sammlungen.de/data/bsb00001000.xml");
  result = resource.getUri();
  Assert.assertEquals(expResult, result);
  Assert.assertTrue(resource.isReadonly());
}
 
开发者ID:dbmdz,项目名称:digitalcollections-core,代码行数:34,代码来源:ResourceRepositoryImplTest.java

示例8: getCollection

import de.digitalcollections.core.model.api.resource.enums.ResourcePersistenceType; //导入依赖的package包/类
@Override
public Collection getCollection(String name) throws ResolvingException, InvalidDataException {
  // to get a regex resolable pattern we add a static prefix for collections
  String collectionName = COLLECTION_PREFIX + name;
  try {
    Resource resource = resourceService.get(collectionName, ResourcePersistenceType.REFERENCED, MimeType.MIME_APPLICATION_JSON);
    return objectMapper.readValue(getResourceJson(resource.getUri()), Collection.class);
  } catch (IOException ex) {
    LOGGER.info("Could not retrieve collection {}", collectionName, ex);
    throw new ResolvingException("No collection for name " + collectionName);
  }
}
 
开发者ID:dbmdz,项目名称:iiif-server-hymir,代码行数:13,代码来源:PresentationRepositoryImpl.java

示例9: getManifest

import de.digitalcollections.core.model.api.resource.enums.ResourcePersistenceType; //导入依赖的package包/类
@Override
public Manifest getManifest(String identifier) throws ResolvingException, InvalidDataException {
  try {
    Resource resource = resourceService.get(identifier, ResourcePersistenceType.REFERENCED, MimeType.MIME_APPLICATION_JSON);
    return objectMapper.readValue(getResourceJson(resource.getUri()), Manifest.class);
  } catch (IOException ex) {
    LOGGER.info("Error getting manifest for identifier " + identifier, ex);
    throw new ResolvingException("No manifest for identifier " + identifier);
  }
}
 
开发者ID:dbmdz,项目名称:iiif-server-hymir,代码行数:11,代码来源:PresentationRepositoryImpl.java

示例10: getResourceModificationDate

import de.digitalcollections.core.model.api.resource.enums.ResourcePersistenceType; //导入依赖的package包/类
private Instant getResourceModificationDate(String identifier) throws ResolvingException {
  try {
    Resource resource = resourceService.get(identifier, ResourcePersistenceType.REFERENCED, MimeType.MIME_APPLICATION_JSON);
    return Instant.ofEpochMilli(resource.getLastModified());
  } catch (ResourceIOException ex) {
    throw new ResolvingException("No manifest for identifier " + identifier);
  }
}
 
开发者ID:dbmdz,项目名称:iiif-server-hymir,代码行数:9,代码来源:PresentationRepositoryImpl.java

示例11: getImageModificationDate

import de.digitalcollections.core.model.api.resource.enums.ResourcePersistenceType; //导入依赖的package包/类
@Override
public Instant getImageModificationDate(String identifier) throws ResourceNotFoundException {
  if (imageSecurityService != null && !imageSecurityService.isAccessAllowed(identifier)) {
    throw new ResourceNotFoundException();
  }
  try {
    Resource res = resourceService.get(identifier, ResourcePersistenceType.RESOLVED, MimeType.MIME_IMAGE);
    return Instant.ofEpochMilli(res.getLastModified());
  } catch (ResourceIOException e) {
    throw new ResourceNotFoundException();
  }
}
 
开发者ID:dbmdz,项目名称:iiif-server-hymir,代码行数:13,代码来源:ImageServiceImpl.java

示例12: getCollection

import de.digitalcollections.core.model.api.resource.enums.ResourcePersistenceType; //导入依赖的package包/类
@Override
public Collection getCollection(String name) throws NotFoundException, InvalidDataException {
  // to get a regex resolable pattern we add a static prefix for collections
  String collectionName = COLLECTION_PREFIX + name;

  Resource resource;
  try {
    resource = resourceService.get(collectionName, ResourcePersistenceType.REFERENCED, MimeType.MIME_APPLICATION_JSON);
  } catch (ResourceIOException ex) {
    LOGGER.warn("Error getting collection for name " + collectionName, ex);
    throw new NotFoundException("No collection for name " + collectionName);
  }
  URI uri = resource.getUri();
  return getCollection(uri);
}
 
开发者ID:dbmdz,项目名称:iiif-presentation-api,代码行数:16,代码来源:PresentationRepositoryImpl.java

示例13: getManifest

import de.digitalcollections.core.model.api.resource.enums.ResourcePersistenceType; //导入依赖的package包/类
@Override
public Manifest getManifest(String identifier) throws NotFoundException, InvalidDataException {
  Resource resource;
  try {
    resource = resourceService.get(identifier, ResourcePersistenceType.REFERENCED, MimeType.MIME_APPLICATION_JSON);
  } catch (ResourceIOException ex) {
    LOGGER.warn("Error getting manifest for identifier " + identifier, ex);
    throw new NotFoundException("No manifest for identifier " + identifier);
  }
  URI uri = resource.getUri();
  return getManifest(uri);
}
 
开发者ID:dbmdz,项目名称:iiif-presentation-api,代码行数:13,代码来源:PresentationRepositoryImpl.java

示例14: create

import de.digitalcollections.core.model.api.resource.enums.ResourcePersistenceType; //导入依赖的package包/类
default Resource create(String key, ResourcePersistenceType resourcePersistenceType, String filenameExtension) throws ResourceIOException {
  return create(key, resourcePersistenceType, MimeType.fromExtension(filenameExtension));
}
 
开发者ID:dbmdz,项目名称:digitalcollections-core,代码行数:4,代码来源:ResourceRepository.java

示例15: find

import de.digitalcollections.core.model.api.resource.enums.ResourcePersistenceType; //导入依赖的package包/类
default Resource find(String key, ResourcePersistenceType resourcePersistenceType, String filenameExtension) throws ResourceIOException {
  return find(key, resourcePersistenceType, MimeType.fromExtension(filenameExtension));
}
 
开发者ID:dbmdz,项目名称:digitalcollections-core,代码行数:4,代码来源:ResourceRepository.java


注:本文中的de.digitalcollections.core.model.api.resource.enums.ResourcePersistenceType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。