org.osgl.storage.ISObject Java Examples
The following examples show how to use
org.osgl.storage.ISObject.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ResourceLoader.java From actframework with Apache License 2.0 | 6 votes |
public static boolean isBinary(BeanSpec spec) { Class<?> type = spec.rawType(); if (byte[].class == type) { return true; } if (URL.class == type) { return true; } if (InputStream.class == type) { return true; } if (ISObject.class.isAssignableFrom(type)) { return true; } return false; }
Example #2
Source File: Gh1128.java From actframework with Apache License 2.0 | 5 votes |
@PostAction public void upload(ISObject file, StorageServiceManager ssMgr) { IStorageService ss = ssMgr.storageService("1128_upload"); String key = ss.getKey(); file.getAttribute(ISObject.ATTR_FILE_NAME); file = ss.put(key, file); }
Example #3
Source File: SObject.java From java-tool with Apache License 2.0 | 5 votes |
private ISObject force() { if (null == sobj_) { synchronized (this) { if (null == sobj_) sobj_ = ss_.get(getKey()); } } return sobj_; }
Example #4
Source File: UploadFileStorageService.java From actframework with Apache License 2.0 | 5 votes |
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; if (0 == size) { return null; } 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; }
Example #5
Source File: UploadFileStorageService.java From actframework with Apache License 2.0 | 5 votes |
public static ISObject store(FileItemStream fileItemStream, App app) { UploadFileStorageService ss = app.uploadFileStorageService(); try { return ss._store(fileItemStream); } catch (IOException e) { throw E.ioException(e); } }
Example #6
Source File: FastJsonSObjectSerializer.java From actframework with Apache License 2.0 | 5 votes |
@Override public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException { SerializeWriter out = serializer.out; if (object instanceof ISObject) { ISObject sobj = (ISObject) object; out.write(S.fmt("ISObject[%s]", sobj.getKey())); return; } throw new UnsupportedOperationException("Object type not supported: " + object.getClass()); }
Example #7
Source File: ActionContext.java From actframework with Apache License 2.0 | 5 votes |
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; }
Example #8
Source File: ActionContext.java From actframework with Apache License 2.0 | 5 votes |
public ISObject upload(String name) { Integer index = attribute(ATTR_CURRENT_FILE_INDEX); if (null == index) { index = 0; } return upload(name, index); }
Example #9
Source File: StringValueResolverManager.java From actframework with Apache License 2.0 | 5 votes |
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); }
Example #10
Source File: ResponseCache.java From actframework with Apache License 2.0 | 5 votes |
@Override public H.Response writeBinary(ISObject binary) { byte[] ba = binary.asByteArray(); ByteBuffer buffer = ByteBuffer.allocateDirect(ba.length); buffer.put(ba); buffer.flip(); this.buffer = buffer; realResponse.writeContent(buffer); this.wroteDirectly = true; return this; }
Example #11
Source File: ContentLinesBinder.java From actframework with Apache License 2.0 | 5 votes |
@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); } }
Example #12
Source File: UndertowResponse.java From actframework with Apache License 2.0 | 5 votes |
@Override public UndertowResponse writeBinary(ISObject binary) { beforeWritingContent(); File file = tryGetFileFrom(binary); if (null != file) { return send(file); } byte[] ba = binary.asByteArray(); ByteBuffer buffer = ByteBuffer.wrap(ba); sender().send(buffer); endAsync = !blocking(); afterWritingContent(); return this; }
Example #13
Source File: ContentStringResolver.java From actframework with Apache License 2.0 | 5 votes |
@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); } }
Example #14
Source File: UndertowResponse.java From actframework with Apache License 2.0 | 5 votes |
private File tryGetFileFrom(ISObject sobj) { String className = sobj.getClass().getSimpleName(); if (className.contains("FileSObject")) { return sobj.asFile(); } return null; }
Example #15
Source File: ContentLinesResolver.java From actframework with Apache License 2.0 | 5 votes |
@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); } }
Example #16
Source File: ContentStringBinder.java From actframework with Apache License 2.0 | 5 votes |
@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); } }
Example #17
Source File: FileBinder.java From actframework with Apache License 2.0 | 5 votes |
@Override public File resolve(File file, String s, ParamValueProvider paramValueProvider) { ActionContext ctx = $.cast(paramValueProvider); if (ctx.req().url().startsWith("/~/cmd/run")) { String fileName = ctx.paramVal(s); if (S.isBlank(fileName)) { return null; } return new File(fileName); } ISObject sobj = ctx.upload(s); return null == sobj ? null : sobj.asFile(); }
Example #18
Source File: IO.java From java-tool with Apache License 2.0 | 4 votes |
public ISObject toSObject() { return SObject.of(toInputStream()); }
Example #19
Source File: Gh1083.java From actframework with Apache License 2.0 | 4 votes |
@PostAction public boolean handleUpload(ISObject file, String fileName) { return null == file; }
Example #20
Source File: IO.java From java-tool with Apache License 2.0 | 4 votes |
private <T> T _to(Type type) { Object o; InputStreamHandlerDispatcher inputStreamHandler = null; MimeType mimeType = this.mimeType; if (null == mimeType) { String sourceName = sourceName(); if (null != sourceName) { String suffix = S.fileExtension(sourceName); mimeType = MimeType.findByFileExtension(suffix); } } if (null != mimeType) { inputStreamHandler = inputStreamHandlerLookup.get(mimeType); } if (String.class == type) { o = toString(); } else if (TypeReference.LIST_STRING == type) { if (null != inputStreamHandler && inputStreamHandler.support(type)) { return inputStreamHandler.read(toInputStream(), type, mimeType, hint); } o = toLines(); } else if (InputStream.class == type) { o = toInputStream(); } else if (Reader.class == type) { o = toReader(); } else if (ISObject.class == type || SObject.class == type) { o = toSObject(); } else if (Properties.class == type) { if (null != inputStreamHandler && inputStreamHandler.support(type)) { return inputStreamHandler.read(toInputStream(), type, mimeType, hint); } o = toProperties(); } else if (byte[].class == type) { o = toByteArray(); } else { if (null != inputStreamHandler) { return inputStreamHandler.read(toInputStream(), type, mimeType, hint); } o = toUnknownType(type); } return $.cast(o); }
Example #21
Source File: IO.java From java-tool with Apache License 2.0 | 4 votes |
@Override public ISObject toSObject() { return SObject.of(source.toString()); }
Example #22
Source File: IO.java From java-tool with Apache License 2.0 | 4 votes |
public SObjectReadStage(ISObject isObject) { super(isObject); sourceName = isObject.getFilename(); }
Example #23
Source File: IO.java From java-tool with Apache License 2.0 | 4 votes |
public static SObjectWriteStage write(ISObject sobj) { return new SObjectWriteStage(sobj); }
Example #24
Source File: IO.java From java-tool with Apache License 2.0 | 4 votes |
public static SObjectReadStage read(ISObject sobj) { return new SObjectReadStage(sobj); }
Example #25
Source File: SObject.java From java-tool with Apache License 2.0 | 4 votes |
@Override public ISObject setAttribute(String key, String val) { assertValid(); attrs.put(key, val); return this; }
Example #26
Source File: SObject.java From java-tool with Apache License 2.0 | 4 votes |
@Override public ISObject setAttributes(Map<String, String> attrs) { assertValid(); setAttrs(attrs); return this; }
Example #27
Source File: SObject.java From java-tool with Apache License 2.0 | 4 votes |
public static SObject valueOf(String key, ISObject copy) { SObject sobj = of(key, copy.asByteArray()); sobj.setAttrs(copy.getAttributes()); return sobj; }
Example #28
Source File: IO.java From java-tool with Apache License 2.0 | 4 votes |
protected SObjectWriteStage(ISObject isObject) { super(isObject); }
Example #29
Source File: EndpointTester.java From actframework with Apache License 2.0 | 4 votes |
public ReqBuilder post(ISObject content) { this.post(); this.postAttachment = content; return this; }
Example #30
Source File: SObjectBinder.java From actframework with Apache License 2.0 | 4 votes |
@Override public ISObject resolve(ISObject sobj, String s, ParamValueProvider paramValueProvider) { E.illegalArgumentIf(!(paramValueProvider instanceof ActionContext)); return SObjectResolver.INSTANCE.resolve(s); }