IResourceIdentifier rid = new ResourceIdentifier(null, gid);
/** * Get the file for a hash rid. */ protected File getHashRidFile(IResourceIdentifier rid) { assert ResourceIdentifier.isHashGid(rid); // http://tools.ietf.org/html/rfc3548#section-4 for local storage of hashed resources String name = rid.getGlobalIdentifier().getResourceId().substring(2).replace('+', '-').replace('/', '_') + ".jar"; IContextService localService = SServiceProvider.getLocalService(component, IContextService.class); // use contextService to get private data dir on android IFuture<File> future = localService.getFile(SUtil.JADEXDIR + "resources/"+name); File file = future.get(); return file; }
/** * Test, if a resource is available locally. */ protected boolean isAvailable(IResourceIdentifier rid) { // Do not check existence of manually added (local) resources return ResourceIdentifier.isLocal(rid, component.getComponentIdentifier().getRoot()) || getHashRidFile(rid).exists(); }
/** * Test if equals. * They are equal when * a) global ids are equal * b) or global ids are null and local ids are equal. */ public boolean equals(Object obj) { boolean ret = false; if(obj instanceof IResourceIdentifier) { IResourceIdentifier other = (IResourceIdentifier)obj; ret = (getGlobalIdentifier()!=null && getGlobalIdentifier().equals(other.getGlobalIdentifier())) || (getGlobalIdentifier()==null && other.getGlobalIdentifier()==null && SUtil.equals(getLocalIdentifier(), other.getLocalIdentifier())); } return ret; }
ILocalResourceIdentifier lid = rid.getLocalIdentifier(); rid.setLocalIdentifier(new LocalResourceIdentifier(cid, lid.getUrl()));
/** * Test if equals. * They are equal when * a) global ids are equal * b) or global ids are null and local ids are equal. */ public boolean equals(Object obj) { boolean ret = false; if(obj instanceof IResourceIdentifier) { IResourceIdentifier other = (IResourceIdentifier)obj; ret = (getGlobalIdentifier()!=null && getGlobalIdentifier().equals(other.getGlobalIdentifier())) || (getGlobalIdentifier()==null && other.getGlobalIdentifier()==null && SUtil.equals(getLocalIdentifier(), other.getLocalIdentifier())); } return ret; }
ILocalResourceIdentifier lid = rid.getLocalIdentifier(); rid.setLocalIdentifier(new LocalResourceIdentifier(cid, lid.getUri()));
/** * Get the resource identifier for an url. * @param url The url. * @return The resource identifier. */ public IFuture<IResourceIdentifier> getResourceIdentifier(URL url) { // Does not use global identifiers. ILocalResourceIdentifier lid = new LocalResourceIdentifier(cid, url); ResourceIdentifier rid = new ResourceIdentifier(lid, null); return new Future<IResourceIdentifier>(rid); } }
if(pacl==null && ResourceIdentifier.isLocal(parid, component.getComponentIdentifier().getRoot()) && getInternalNonManagedURLs().contains(parid.getLocalIdentifier().getUri()))
/** * Get the tooltip. */ public String getTooltipText() { String ret = null; Object o = getUserObject(); if(o instanceof IResourceIdentifier) { if(ResourceIdentifier.isHashGid((IResourceIdentifier)o)) { ret = ((IResourceIdentifier)o).getGlobalIdentifier().getResourceId(); } } return ret; }
/** * Get the resource identifier for an url. * @param url The url. * @return The resource identifier. */ public IFuture<IResourceIdentifier> getResourceIdentifier(URL url) { // Does not use global identifiers. ILocalResourceIdentifier lid = new LocalResourceIdentifier(cid, url); ResourceIdentifier rid = new ResourceIdentifier(lid, null); return new Future<IResourceIdentifier>(rid); } }
if(ResourceIdentifier.isLocal(rid, component.getComponentIdentifier().getRoot()))
if(rid.getGlobalIdentifier()!=null && rid.getGlobalIdentifier().getResourceId()!=null && !isHashGid(rid))
/** * Get the resource identifier for an url. * @param url The url. * @return The resource identifier. */ public IFuture<IResourceIdentifier> getResourceIdentifier(URL url) { // Does not use global identifiers. ILocalResourceIdentifier lid = new LocalResourceIdentifier(cid, url); ResourceIdentifier rid = new ResourceIdentifier(lid, null); return new Future<IResourceIdentifier>(rid); } }
if(pacl==null && ResourceIdentifier.isLocal(parid, component.getComponentIdentifier().getRoot()) && getInternalNonManagedURLs().contains(parid.getLocalIdentifier().getUri()))
public void customResultAvailable(Collection<Tuple2<String, String>> result) { Properties props = new Properties(); Iterator<Tuple2<String, String>> it = result.iterator(); for(int i=0; i<tests.size(); i++) { Tuple2<String, String> local = it.next(); Properties entry = new Properties(); entry.addProperty(new Property("model", local.getFirstEntity())); entry.addProperty(new Property("ridurl", local.getSecondEntity())); // todo: save also repo info of gid IResourceIdentifier rid = tests.get(i).getSecondEntity(); String id = rid!=null && rid.getGlobalIdentifier()!=null && rid.getGlobalIdentifier().getResourceId()!=null && !ResourceIdentifier.isHashGid(rid) ? rid.getGlobalIdentifier().getResourceId(): null; entry.addProperty(new Property("globalrid", id)); props.addSubproperties("entry", entry); } props.addProperty(new Property("timeout", tfto.getText())); props.addProperty(new Property("concurrency", ""+concurrency)); props.addProperty(new Property("allowduplicates", ""+allowduplicates.isSelected())); ret.setResult(props); } });
/** * */ public static IResourceIdentifier getLocalResourceIdentifier(IResourceIdentifier rid) { IResourceIdentifier ret = null; if(rid!=null && rid.getGlobalIdentifier()!=null && rid.getLocalIdentifier()!=null) { ret = new ResourceIdentifier(rid.getLocalIdentifier(), null); } return ret; }