use of org.eclipse.scout.rt.platform.resource.BinaryResource in project scout.rt by eclipse.
the class HttpResourceCacheTest method testPutCachable.
@Test
public void testPutCachable() throws Exception {
BinaryResource res = BinaryResources.create().withFilename("a.html").withContent("<html></html>".getBytes("UTF-8")).withCachingAllowed(true).build();
HttpCacheObject obj = new HttpCacheObject(new HttpCacheKey("/"), res);
boolean b = rc.put(obj);
Assert.assertTrue(b);
}
use of org.eclipse.scout.rt.platform.resource.BinaryResource in project scout.rt by eclipse.
the class HttpResourceCacheTest method testPutGet.
@Test
public void testPutGet() throws Exception {
BinaryResource res = BinaryResources.create().withFilename("a.html").withContent("<html></html>".getBytes("UTF-8")).withCachingAllowed(true).build();
HttpCacheObject obj = new HttpCacheObject(new HttpCacheKey("/"), res);
boolean b = rc.put(obj);
Assert.assertTrue(b);
HttpCacheObject obj2 = rc.get(new HttpCacheKey("/"));
Assert.assertEquals(obj.getCacheKey(), obj2.getCacheKey());
}
use of org.eclipse.scout.rt.platform.resource.BinaryResource in project scout.rt by eclipse.
the class AbstractHtmlField method setAttachments.
@Override
public void setAttachments(Collection<? extends BinaryResource> attachments) {
if (attachments == null) {
m_attachments = new HashMap<>(0);
} else {
HashMap<String, BinaryResource> newMap = new HashMap<>(attachments.size());
for (BinaryResource attachment : attachments) {
if (attachment != null) {
newMap.put(attachment.getFilename(), attachment);
}
}
m_attachments = newMap;
}
}
use of org.eclipse.scout.rt.platform.resource.BinaryResource in project scout.rt by eclipse.
the class BinaryResourceUrlUtilityTest method testGetFilenameWithFingerprint_WithoutContent.
@Test
public void testGetFilenameWithFingerprint_WithoutContent() {
BinaryResource binaryResource = new BinaryResource("foo.txt", null);
assertEquals("foo.txt", BinaryResourceUrlUtility.getFilenameWithFingerprint(binaryResource));
}
use of org.eclipse.scout.rt.platform.resource.BinaryResource in project scout.rt by eclipse.
the class DefaultWizardStatusHtmlProvider method loadIcon.
/**
* To load an icon into the given attachments live list
*/
protected void loadIcon(List<BinaryResource> attachments, String iconName) {
if (attachments == null || iconName == null) {
return;
}
String tempIconName = iconName;
try {
int index;
// determine file format
index = tempIconName.lastIndexOf('.');
if (index > 0) {
tempIconName = tempIconName.substring(0, index);
}
// determine icon base name
String baseIconName = tempIconName;
index = tempIconName.lastIndexOf('_');
if (index > 0) {
baseIconName = tempIconName.substring(0, index);
}
// load icon
IconSpec iconSpec = IconLocator.instance().getIconSpec(tempIconName);
if (iconSpec == null && !tempIconName.equals(baseIconName)) {
iconSpec = IconLocator.instance().getIconSpec(baseIconName);
}
if (iconSpec != null) {
attachments.add(new BinaryResource(iconSpec.getName(), iconSpec.getContent()));
}
} catch (Exception t) {
LOG.warn("Failed to load icon '{}'", tempIconName, t);
}
}
Aggregations