本文整理汇总了Java中org.osgl.storage.ISObject类的典型用法代码示例。如果您正苦于以下问题:Java ISObject类的具体用法?Java ISObject怎么用?Java ISObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ISObject类属于org.osgl.storage包,在下文中一共展示了ISObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeBinary
import org.osgl.storage.ISObject; //导入依赖的package包/类
@Override
public UndertowResponse writeBinary(ISObject binary) {
beforeWritingContent();
File file = tryGetFileFrom(binary);
if (null == file) {
byte[] ba = binary.asByteArray();
ByteBuffer buffer = ByteBuffer.wrap(ba);
hse.getResponseSender().send(buffer);
} else {
try {
hse.getResponseSender().transferFrom(FileChannel.open(file.toPath()), IoCallback.END_EXCHANGE);
endAsync = true;
} catch (IOException e) {
endAsync = false;
throw E.ioException(e);
}
}
afterWritingContent();
return this;
}
示例2: _store
import org.osgl.storage.ISObject; //导入依赖的package包/类
private ISObject _store(FileItemStream fileItemStream) throws IOException {
String filename = fileItemStream.getName();
String key = newKey(filename);
File tmpFile = getFile(key);
InputStream input = fileItemStream.openStream();
ThresholdingByteArrayOutputStream output = new ThresholdingByteArrayOutputStream(inMemoryCacheThreshold, tmpFile);
IO.copy(input, output);
ISObject retVal;
if (output.exceedThreshold) {
retVal = getFull(key);
} else {
int size = output.written;
byte[] buf = output.buf();
retVal = SObject.of(key, buf, size);
}
if (S.notBlank(filename)) {
retVal.setFilename(filename);
}
String contentType = fileItemStream.getContentType();
if (null != contentType) {
retVal.setContentType(contentType);
}
return retVal;
}
示例3: zip
import org.osgl.storage.ISObject; //导入依赖的package包/类
public static ISObject zip(ISObject... objects) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ZipOutputStream zos = new ZipOutputStream(baos);
try {
for (ISObject obj: objects) {
ZipEntry entry = new ZipEntry(obj.getAttribute(SObject.ATTR_FILE_NAME));
InputStream is = obj.asInputStream();
zos.putNextEntry(entry);
copy(is, zos, false);
zos.closeEntry();
}
} catch (IOException e) {
throw E.ioException(e);
} finally {
close(zos);
}
return SObject.of(Codec.encodeUrl(S.random()), baos.toByteArray());
}
示例4: delete
import org.osgl.storage.ISObject; //导入依赖的package包/类
public void delete(ISObject sobj) {
String id = sobj.getAttribute(ISObject.ATTR_SS_ID);
IStorageService ss = storageService(id);
String contextPath = sobj.getAttribute(ISObject.ATTR_SS_CTX);
if (S.notBlank(contextPath)) {
ss = ss.subFolder(contextPath);
}
ss.remove(sobj.getKey());
}
示例5: testRemoteFetch
import org.osgl.storage.ISObject; //导入依赖的package包/类
@GetAction("/rmt")
public String testRemoteFetch(StorageServiceManager ssm) {
String url = "https://propertymanage.atlassian.net/secure/projectavatar?pid=10400&avatarId=11200";
ISObject sobj = new SObjectResolver().resolve(url);
//sobj.setAttribute(ISObject.ATTR_FILE_NAME, "remote_file.png");
IStorageService ss = ssm.storageService("store1");
sobj = ss.put(ss.getKey(), sobj);
return sobj.getUrl();
}
示例6: tryGetFileFrom
import org.osgl.storage.ISObject; //导入依赖的package包/类
private File tryGetFileFrom(ISObject sobj) {
String className = sobj.getClass().getSimpleName();
if (className.contains("FileSObject")) {
return sobj.asFile();
}
return null;
}
示例7: resolve
import org.osgl.storage.ISObject; //导入依赖的package包/类
@Override
public String resolve(String bean, String model, ParamValueProvider params) {
try {
ISObject sobj = SObjectBinder.INSTANCE.resolve(null, model, params);
return null == sobj ? fallBack(model, params) : IO.readContentAsString(sobj.asInputStream());
} catch (Exception e) {
return fallBack(model, params);
}
}
示例8: resolve
import org.osgl.storage.ISObject; //导入依赖的package包/类
@Override
public List<String> resolve(String value) {
try {
ISObject sobj = SObjectResolver.INSTANCE.resolve(value);
return null == sobj ? fallBack(value) : IO.readLines(sobj.asInputStream());
} catch (Exception e) {
return fallBack(value);
}
}
示例9: resolve
import org.osgl.storage.ISObject; //导入依赖的package包/类
@Override
public String resolve(String value) {
try {
ISObject sobj = SObjectResolver.INSTANCE.resolve(value);
return null == sobj ? fallBack(value) : IO.readContentAsString(sobj.asInputStream());
} catch (Exception e) {
return fallBack(value);
}
}
示例10: resolve
import org.osgl.storage.ISObject; //导入依赖的package包/类
@Override
public SObject resolve(String value) {
if (value.startsWith("http://") || value.startsWith("https://")) {
return resolveFromURL(value);
} else if (value.startsWith("data:")) {
int pos = value.indexOf("base64,");
if (pos < 0) {
return null;
}
String encoded = value.substring(pos + "base64,".length());
return resolveFromBase64(encoded);
} else {
File file;
CliContext cli = CliContext.current();
if (null != cli) {
file = cli.getFile(value);
if (file.exists() && file.canRead()) {
return SObject.of(file);
}
} else {
ActionContext act = ActionContext.current();
if (null != act) {
ISObject sobj = act.upload(value);
if (null != sobj) {
return (SObject)sobj;
}
}
}
// last try base64 decoder
try {
return resolveFromBase64(value);
} catch (Exception e) {
Act.LOGGER.warn(S.concat("Cannot resolve SObject from value: ", value));
return null;
}
}
}
示例11: resolve
import org.osgl.storage.ISObject; //导入依赖的package包/类
@Override
public List<String> resolve(List<String> bean, String model, ParamValueProvider params) {
try {
ISObject sobj = SObjectBinder.INSTANCE.resolve(null, model, params);
return null == sobj ? fallBack(model, params) : IO.readLines(sobj.asInputStream());
} catch (Exception e) {
return fallBack(model, params);
}
}
示例12: writeBinary
import org.osgl.storage.ISObject; //导入依赖的package包/类
@Override
public H.Response writeBinary(ISObject binary) {
realResponse.writeBinary(binary);
byte[] ba = binary.asByteArray();
ByteBuffer buffer = ByteBuffer.allocateDirect(ba.length);
buffer.put(ba);
buffer.flip();
this.buffer = buffer;
return this;
}
示例13: registerBuiltInResolvers
import org.osgl.storage.ISObject; //导入依赖的package包/类
private void registerBuiltInResolvers(AppConfig config) {
// We have the StringValueResolverFinder to handle built in resolver registration
// put(Date.class, new DateResolver(config));
// put(LocalDate.class, new JodaLocalDateCodec(config));
// put(LocalDateTime.class, new JodaLocalDateTimeCodec(config));
// put(LocalTime.class, new JodaLocalTimeCodec(config));
// put(DateTime.class, new JodaDateTimeCodec(config));
// rebind SObjectResolver to ISObject.class in addition to SObject.class
put(ISObject.class, SObjectResolver.INSTANCE);
}
示例14: upload
import org.osgl.storage.ISObject; //导入依赖的package包/类
public ISObject upload(String name) {
Integer index = attribute(ATTR_CURRENT_FILE_INDEX);
if (null == index) {
index = 0;
}
return upload(name, index);
}
示例15: addUpload
import org.osgl.storage.ISObject; //导入依赖的package包/类
public ActionContext addUpload(String name, ISObject sobj) {
ISObject[] a = uploads.get(name);
if (null == a) {
a = new ISObject[1];
a[0] = sobj;
} else {
ISObject[] newA = new ISObject[a.length + 1];
System.arraycopy(a, 0, newA, 0, a.length);
newA[a.length] = sobj;
a = newA;
}
uploads.put(name, a);
return this;
}