@Override public ProcessLoader getProcessLoader(String name) throws NotFoundException { synchronized (availableProcesses) { ProcessInfo info = availableProcesses.get(name); if (info == null) throw new NotFoundException("process unknown",name); return info.loader; } }
public static <T> T getService(Class<T> ifc) throws NotFoundException { BundleContext context = FrameworkUtil.getBundle(ifc).getBundleContext(); if (context == null) context = FrameworkUtil.getBundle(MOsgi.class).getBundleContext(); if (context == null) throw new NotFoundException("service context not found", ifc); ServiceReference<T> ref = context.getServiceReference(ifc); if (ref == null) throw new NotFoundException("service reference not found", ifc); T obj = context.getService(ref); if (obj == null) throw new NotFoundException("service not found", ifc); return obj; }
public Class<?> getManagedType(String name) throws NotFoundException { name = name.trim().toLowerCase(); for (Class<? extends Persistable> type : managedTypes) if (type.getCanonicalName().toLowerCase().endsWith(name)) return type; throw new NotFoundException("Type not found",name); }
public static <T> T getService(Class<T> ifc, String filter) throws NotFoundException { List<T> list = getServices(ifc, filter); if (list.size() == 0) throw new NotFoundException("service not found", ifc, filter); return list.get(0); }
@Override public <T> XdbType<T> getType(Class<T> type) throws NotFoundException { String tableName; try { tableName = AdbUtil.getTableName(this,type); } catch (IOException e) { throw new NotFoundException("Table not found",type,e); } Table table = this.getTable(tableName); if (table == null) throw new NotFoundException("Table not found",type); return new Type<T>(this,table); }
@Override public <T> XdbType<T> getType(String name) throws NotFoundException { String tableName; try { tableName = AdbUtil.getTableName(this,name); } catch (IOException e) { throw new NotFoundException("Table not found",name,e); } Table table = this.getTable(tableName); if (table == null) throw new NotFoundException("Table not found",name); return new Type<T>(this,table); }
throw new NotFoundException("LibreOffice not found");
public static IConfig createFromResource(Class<?> owner, String fileName) throws MException { try { URL url = MSystem.locateResource(owner, fileName); if (fileName.endsWith(".xml")) return new XmlConfigFile(url.openStream()); if (fileName.endsWith(".properties")) return new PropertiesConfigFile(url.openStream()); if (fileName.endsWith(".json")) return new JsonConfigFile(url.openStream()); } catch (Throwable t) { throw new MException(fileName,t); } throw new NotFoundException(fileName); }
public synchronized PojoModel getModelFor(Class<?> clazz) throws NotFoundException { // find managed object Class<? extends Persistable> type = null; for (Class<? extends Persistable> t : managedTypes) { if (clazz.isAssignableFrom(t)) { type = t; break; } } if (type == null) throw new NotFoundException("Managed type not found",clazz); PojoModel model = modelCache.get(type.getName()); if (model == null) { model = new PojoParser().parse(type, new AttributesStrategy()).filter(new MongoFilter()).getModel(); modelCache.put(type.getName(), model); } return model; }
Field f = fIndex.get(aname); if (f == null) throw new NotFoundException("field not found", name, aname); throw new NotFoundException("no valid fields found");
if (method == null) throw new NotFoundException("Method not found",methodName,p);
@Override public PCase loadCase(UUID id) throws IOException, NotFoundException { PCase caze = null; try { DbConnection con = pool.getConnection(); MProperties prop = new MProperties(); prop.put("id", id); DbStatement sta = con.createStatement("SELECT content_ FROM " + prefix + "_case_ WHERE id_=$id$"); DbResult res = sta.executeQuery(prop); if (res.next()) { InputStream in = res.getBinaryStream("content_"); caze = new PCase(); caze.readExternal(new ObjectInputStream(in)); } res.close(); con.close(); } catch (Exception e) { throw new IOException(e); } if (caze == null) throw new NotFoundException("case",id); return caze; }
@Override public PEngine loadEngine() throws IOException, NotFoundException { PEngine engine = null; try { DbConnection con = pool.getConnection(); MProperties prop = new MProperties(); prop.put("id", "engine"); DbStatement sta = con.createStatement("SELECT content_ FROM " + prefix + "_engine_ WHERE id_=$id$"); DbResult res = sta.executeQuery(prop); if (res.next()) { InputStream in = res.getBinaryStream("content_"); engine = new PEngine(); engine.readExternal(new ObjectInputStream(in)); } res.close(); con.close(); } catch (Exception e) { throw new IOException(e); } if (engine == null) throw new NotFoundException("engine"); return engine; }
@Override public OperationResult doExecuteInternal(CaoConfiguration configuration, Monitor monitor) throws CaoException { if (!canExecute(configuration)) return new NotSuccessful(getName(), "can't execute", -1); try { FsNode parent = (FsNode)configuration.getList().get(0); String rendition = configuration.getProperties().getString(UploadRenditionConfiguration.RENDITION); String path = configuration.getProperties().getString(UploadRenditionConfiguration.FILE); File file = new File(path); if (!file.exists() || !file.isFile()) throw new NotFoundException(path); File renditionFile = ((FsCore)parent.getConnection()).getContentFileFor(parent.getFile(), rendition); if (renditionFile == null) throw new MException("can't create rendition to internal file", rendition); MFile.copyFile(file, renditionFile); MProperties p = new MProperties(configuration.getProperties()); p.remove(UploadRenditionConfiguration.RENDITION); p.remove(UploadRenditionConfiguration.FILE); p.save( new File(renditionFile.getParentFile(), renditionFile.getName() + ".meta" ) ); return new Successful(getName()); } catch (Throwable t) { log().d(t); return new NotSuccessful(getName(),t.toString(),-1); } } }
@Override public OperationResult doExecuteInternal(CaoConfiguration configuration, Monitor monitor) throws CaoException { if (!canExecute(configuration)) return new NotSuccessful(getName(), "can't execute", -1); try { FdbNode parent = (FdbNode)configuration.getList().get(0); String rendition = configuration.getProperties().getString(UploadRenditionConfiguration.RENDITION); String path = configuration.getProperties().getString(UploadRenditionConfiguration.FILE); File file = new File(path); if (!file.exists() || !file.isFile()) throw new NotFoundException(path); MProperties p = new MProperties(configuration.getProperties()); p.remove(UploadRenditionConfiguration.RENDITION); p.remove(UploadRenditionConfiguration.FILE); // TODO upload rendition Changes changes = parent.adaptTo(Changes.class); if (changes != null) changes.uploadedRendition(rendition); return new Successful(getName()); } catch (Throwable t) { log().d(t); return new NotSuccessful(getName(),t.toString(),-1); } }
String path = configuration.getProperties().getString(UploadRenditionConfiguration.FILE); File file = new File(path); if (!file.exists() || !file.isFile()) throw new NotFoundException(path);
@Override public PNode loadFlowNode(UUID id) throws IOException, NotFoundException { PNode node = null; try { DbConnection con = pool.getConnection(); MProperties prop = new MProperties(); prop.put("id", id); DbStatement sta = con.createStatement("SELECT content_ FROM " + prefix + "_node_ WHERE id_=$id$"); DbResult res = sta.executeQuery(prop); if (res.next()) { InputStream in = res.getBinaryStream("content_"); node = new PNode(); try { node.readExternal(new ObjectInputStream(in)); } catch (java.io.EOFException eofe) { log().w(node,eofe); // most because of extended parameters } } res.close(); con.close(); } catch (Exception e) { throw new IOException(e); } if (node == null) throw new NotFoundException("node",id); return node; }