@Override public void copyFrom(Object that) { Map<String, Object> me = JSObjectAdapter.$properties(this); for (String key : me) me.$delete(key); Map<String, Object> you = JSObjectAdapter.$properties(that); // We do not upgrade encrypted objects, as it invalidates the // signatures. for (String key : you) { if (me.$get(key) == null) me.$put(key.replace("@", ""), you.$get(key)); } if (!isAny(getTypes())) throw new RuntimeException("Incompatible type: " + getFullType()); }
@Override public void $invoke(String p1) { if (JSObjectAdapter.$get(cache, originalUrl) != null) { JSObjectAdapter.$properties(fetching).$delete(originalUrl); success.$invoke((EcRemoteLinkedData) JSObjectAdapter.$get(cache, originalUrl)); return; } fd.append("signatureSheet", p1); EcRemote.postExpectingObject(finalUrl, null, fd, new Callback1<Object>() { @Override public void $invoke(Object p1) { getHandleData(p1, originalUrl, success, failure, finalUrl); } }, new Callback1<String>() { @Override public void $invoke(String p1) { EcRepository.find(originalUrl, p1, new Object(), 0, success, failure); } }); } }, failure);
EcRemoteLinkedData result = (EcRemoteLinkedData) JSObjectAdapter.$get(cache, originalUrl); if (!caching) { JSObjectAdapter.$properties(cache).$delete(originalUrl);
private static void find(final String url, final String error, final Object history, final int i, final Callback1<EcRemoteLinkedData> success, final Callback1<String> failure) { if (JSGlobal.isNaN(i) || (Object) i == JSGlobal.undefined || i > repos.$length() || repos.$get(i) == null) { JSObjectAdapter.$properties(fetching).$delete(url); if (failure != null) failure.$invoke(error);
JSObjectAdapter.$properties(d).$delete("signature");
/** * Encodes the object in a form where it is ready to be signed. * This method is under long term review, and may change from version to version. * * @return ASCII-sort order encoded space-free and tab-free JSON-LD. * @method toSignableJson */ public String toSignableJson() { EcLinkedData d = (EcLinkedData) JSGlobal.JSON.parse(toJson()); if (type.indexOf("http://schema.eduworks.com/") != -1 && type.indexOf("/0.1/") != -1) { JSObjectAdapter.$properties(d).$delete("@signature"); JSObjectAdapter.$properties(d).$delete("@owner"); JSObjectAdapter.$properties(d).$delete("@reader"); JSObjectAdapter.$properties(d).$delete("@id"); } else { // Whom else has signed the object does not change the contents of // the object. JSObjectAdapter.$properties(d).$delete("@signature"); // Where the object resides does not change the contents of the // object, and provides server administration capabilities. JSObjectAdapter.$properties(d).$delete("@id"); // Who owns the object, or who can read the object *does* matter // though, as administrators should not be able to change the // ownership properties of the object in a clandestine fashion. } EcLinkedData e = new EcLinkedData(d.context, d.type); e.copyFrom(d); return e.toJson(); }
private static EcRemoteLinkedData findBlocking(final String url, final String error, final Object history, final int i) { if (i > repos.$length() || repos.$get(i) == null) { JSObjectAdapter.$properties(fetching).$delete(url); return null; } final EcRepository repo = repos.$get(i); if (((Boolean) JSObjectAdapter.$get(history, repo.selectedServer)) == true) findBlocking(url, error, history, i + 1); JSObjectAdapter.$put(history, repo.selectedServer, true); Array<EcRemoteLinkedData> strings = repo.searchBlocking("@id:\"" + url + "\""); if (strings == null || strings.$length() == 0) return findBlocking(url, error, history, i + 1); else { for (int j = 0; j < strings.$length(); j++) { if (strings.$get(j).id == url) { JSObjectAdapter.$properties(fetching).$delete(url); if (caching) { JSObjectAdapter.$put(cache, url, strings.$get(j)); if (strings.$get(j).id != null) JSObjectAdapter.$put(cache, url, strings.$get(j).id); } return strings.$get(j); } } } return findBlocking(url, error, history, i + 1); }
@Override public void $invoke(Array<EcRemoteLinkedData> strings) { if (strings == null || strings.$length() == 0) find(url, error, history, i + 1, success, failure); else { boolean done = false; for (int i = 0; i < strings.$length(); i++) { if (strings.$get(i).id == url) { if (done) Logger.log("Searching for exact ID:" + url + ", found more than one@:" + repo.selectedServer); done = true; JSObjectAdapter.$properties(fetching).$delete(url); if (caching) { JSObjectAdapter.$put(cache, url, strings.$get(i)); if (strings.$get(i).id != null) JSObjectAdapter.$put(cache, url, strings.$get(i).id); } success.$invoke(strings.$get(i)); } } if (done) return; find(url, error, history, i + 1, success, failure); } } }, new Callback1<String>() {
private static void getHandleData(Object p1, String originalUrl, Callback1<EcRemoteLinkedData> success, Callback1<String> failure, String finalUrl) { JSObjectAdapter.$properties(fetching).$delete(originalUrl); EcRemoteLinkedData d = new EcRemoteLinkedData("", ""); d.copyFrom(p1); if (d.getFullType() == null) { EcRepository.find(originalUrl, Global.JSON.stringify(p1), new Object(), 0, success, failure); return; } if (caching) { JSObjectAdapter.$put(cache, finalUrl, d); if (d.id != null) JSObjectAdapter.$put(cache, d.id, d); //See eduworks/ec#1 - fray. //JSObjectAdapter.$put(cache, d.shortId(), d); } success.$invoke(d); }
@Override public void $invoke(String p1) { if (cacheKey != null) { JSObjectAdapter.$properties(fetching).$delete(cacheKey); } JSObjectAdapter.$put(cache, cacheKey, null); } });
@Override public void $invoke(Object p1) { JSObjectAdapter.$put(cache, cacheKey, p1); if (cacheKey != null) { JSObjectAdapter.$properties(fetching).$delete(cacheKey); } } }, new Callback1<String>() {
@Override public void $invoke(Object p1) { JSObjectAdapter.$put(cache, cacheKey, p1); if (cacheKey != null) { JSObjectAdapter.$properties(fetching).$delete(cacheKey); } } }, new Callback1<String>() {
@Override public void $invoke(String p1) { if (cacheKey != null) { JSObjectAdapter.$properties(fetching).$delete(cacheKey); } JSObjectAdapter.$put(cache, cacheKey, null); } });
@Override public void $invoke(String p1) { if (cacheKey != null) { JSObjectAdapter.$properties(fetching).$delete(cacheKey); } if (failure != null) { failure.$invoke(p1); } } });
@Override public void $invoke(Object p1) { if (cachingSearch) { JSObjectAdapter.$put(cache, cacheKey, p1); } if (cacheKey != null) { JSObjectAdapter.$properties(fetching).$delete(cacheKey); } me.handleSearchResults((Array<EcRemoteLinkedData>) p1, eachSuccess, success, failure); } }, new Callback1<String>() {