/** * */ 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; }
/** * Check if rid has local part and if it is null. */ protected void checkLocalRid(IResourceIdentifier rid) { if(rid!=null && rid.getLocalIdentifier()!=null && rid.getLocalIdentifier().getUri()==null) { System.out.println("local null rid found: "+rid); // throw new RuntimeException("local rid is null"); } }
/** * Get the string representation. */ public String toString() { return rid.getGlobalIdentifier().toString(); }
/** * Test if a rid is local to this platform. */ protected boolean isLocal(IResourceIdentifier rid) { return rid.getLocalIdentifier()!=null && rid.getLocalIdentifier().getComponentIdentifier().equals(component.getComponentIdentifier().getRoot()); } }
/** * Test if the global id is non-null and a hash id. */ public static boolean isHashGid(IResourceIdentifier rid) { return rid!=null && rid.getGlobalIdentifier()!=null && rid.getGlobalIdentifier().getResourceId()!=null && rid.getGlobalIdentifier().getResourceId().startsWith("::"); }
/** * 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; }
public void customResultAvailable(List<IResourceIdentifier> result) { final List<URL> res = new ArrayList<URL>(); for(int i=0; i<result.size(); i++) { res.add(result.get(i).getLocalIdentifier().getUrl()); } res.addAll(getInternalNonManagedURLs()); ret.setResult(res); } });
protected String getLabel(ITreeNode node) { String ret = null; if(getModel().getRoot().equals(node.getParent()) && node instanceof IFileNode) { // URL url = SUtil.toURL(((IFileNode)node).getFilePath()); // IResourceIdentifier rid = rootentries.get(url); IResourceIdentifier rid = getRootEntry(((IFileNode)node).getFilePath()); ret = rid!=null && rid.getGlobalIdentifier()!=null ? rid.getGlobalIdentifier().toString() : null; if(ret!=null && ret.indexOf(':')!=-1) ret = ret.substring(ret.indexOf(':')+1); } return ret!=null ? ret : node.toString(); } });
/** * 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; }
/** * Create a new classloader. */ public DelegationURLClassLoader(IResourceIdentifier rid, ClassLoader basecl, DelegationURLClassLoader[] delegates) { super(rid!=null && rid.getLocalIdentifier()!=null? new URL[]{rid.getLocalIdentifier().getUrl()}: new URL[0], // No parent class loader to avoid multiple lookups of unavailable classes (not supported on android) SReflect.isAndroid() ? basecl : null); this.rid = rid; this.basecl = basecl; this.delegates = delegates.clone(); // System.out.println("d1 : "+rid+" "+SUtil.arrayToString(delegates)); }
/** * 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; }
if(rid.getGlobalIdentifier()!=null && rid.getGlobalIdentifier().getResourceId()!=null && !isHashGid(rid)) project = rid.getGlobalIdentifier().getResourceId(); else if(rid.getLocalIdentifier()!=null && rid.getLocalIdentifier().getUri()!=null) File file = SUtil.getFile(SUtil.toURL(rid.getLocalIdentifier().getUri())); if(file.getName().endsWith(".jar"))
/** * Test if a rid is local to this platform. */ protected boolean isLocal(IResourceIdentifier rid) { // return rid.getLocalIdentifier()!=null && rid.getLocalIdentifier().getComponentIdentifier().equals(component.getComponentIdentifier().getRoot()); return rid.getLocalIdentifier()!=null && rid.getLocalIdentifier().getHostIdentifier().equals( SUtil.getMacAddress()!=null ? SUtil.getMacAddress() : rootrid.getLocalIdentifier().getComponentIdentifier().getName()); }
/** * 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; }
IGlobalResourceIdentifier grid = ((IResourceIdentifier)o).getGlobalIdentifier(); if(grid!=null) ILocalResourceIdentifier lrid = ((IResourceIdentifier)o).getLocalIdentifier(); ret = lrid.getUrl().toString();
/** * Create a new classloader. */ public DelegationURLClassLoader(IResourceIdentifier rid, ClassLoader basecl, DelegationURLClassLoader[] delegates) { super(rid!=null && rid.getLocalIdentifier()!=null? new URL[]{rid.getLocalIdentifier().getUrl()}: new URL[0], // No parent class loader to avoid multiple lookups of unavailable classes (not supported on android) SReflect.isAndroid() ? basecl : null); this.rid = rid; this.basecl = basecl; this.delegates = delegates==null? new ArrayList(): SUtil.arrayToList(delegates); this.parents = new ArrayList<DelegationURLClassLoader>(); // addParentClassLoader(parent); // System.out.println("d1 : "+rid+" "+SUtil.arrayToString(delegates)); }
public Icon getSwingOverlay(ISwingTreeNode node) { Icon overlay = null; if(getModel().getRoot().equals(node.getParent()) && node instanceof IFileNode) { // URL url = SUtil.toURL(((IFileNode)node).getFilePath()); // IResourceIdentifier rid = rootentries.get(url); IResourceIdentifier rid = getRootEntry(((IFileNode)node).getFilePath()); if(rid!=null && rid.getGlobalIdentifier()!=null) { overlay = ModelTreePanel.icons.getIcon("gid"); } } return overlay; } };
/** * Create properties from rid. * @param The resource identifier. * @return rid The resource identifier properties. */ public Properties ridToProperties(IResourceIdentifier rid) { Properties ret = new Properties(); if(rid!=null && rid.getGlobalIdentifier()!=null) { ret.addProperty(new Property("gid_ri", rid.getGlobalIdentifier().getResourceId())); ret.addProperty(new Property("gid_vi", rid.getGlobalIdentifier().getVersionInfo())); // ret.addProperty(new Property("url", rid.getGlobalIdentifier().getRepositoryInfo())); } if(rid!=null && rid.getLocalIdentifier()!=null) { ret.addProperty(new Property("lid_url", SUtil.convertPathToRelative(rid.getLocalIdentifier().getUrl().toString()))); // todo: check if own platform cid? // ret.addProperty(new Property("lid_cid", rid.getLocalIdentifier().getComponentIdentifier())); } return ret; }
/** * Test if a rid is local to this platform. * Test is performed by MAC address. * Root cid is only used as fallback. */ public static boolean isLocal(IResourceIdentifier rid, IComponentIdentifier root) { return rid!=null && rid.getLocalIdentifier()!=null && (SUtil.equals(rid.getLocalIdentifier().getHostIdentifier(), SUtil.getMacAddress()) || SUtil.equals(rid.getLocalIdentifier().getHostIdentifier(), root.getName())); }
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; 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); } });