void setTerm(Term term) { if (this.term != null) throw new OntopiaRuntimeException("Cannot set parent term on variant more than once." + this + " " + this.term + " " + term); this.term = term; }
public static byte[][] getBytes(String[] s) { try { byte[][] b = new byte[s.length][]; for (int i=0; i < s.length; i++) { b[i] = s[i].getBytes("UTF-8"); } return b; } catch (UnsupportedEncodingException e) { throw new OntopiaRuntimeException(e); } }
public void close() { if (conn != null) { try { conn.close(); } catch (SQLException t) { throw new OntopiaRuntimeException(t); } conn = null; } }
public void close() { try { if (rs != null) rs.close(); if (stm != null) stm.close(); } catch (SQLException t) { throw new OntopiaRuntimeException(t); } }
public String[] readNext() { try { return reader.readNext(); } catch (java.io.IOException e) { throw new OntopiaRuntimeException(e); } }
public String getOrderValue() { try { return JDBCUtils.getHighPrecisionString(rs, ocix, ocoltype); } catch (Throwable t) { throw new OntopiaRuntimeException(t); } }
public static String resolveVirtualReference(String address, String tmid) { String topicMapIndex = RemoteTopicIndex.sourceTopicMapFromVirtualReference(address); if (!topicMapIndex.equals(tmid)) throw new OntopiaRuntimeException("Topic map IDs do not match, requested=" + topicMapIndex + ", current=" + tmid); return address.substring(address.indexOf('#') + 1); }
public ChangelogReaderIF getChangelogReader(Changelog changelog, String startOrder) { try { return new ChangelogReader(changelog, startOrder); } catch (SQLException e) { throw new OntopiaRuntimeException("Error creating ChangelogReader", e); } }
public LastModifiedAt() { try { psi = new URILocator(PSI_URI); } catch (java.net.MalformedURLException e) { throw new net.ontopia.utils.OntopiaRuntimeException(e); } formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm"); }
public String getLockUserIdLocalized() { if (namedLock == null) // throw new OntopiaRuntimeException("Attempted to get name of null NamedLock."); return bundle.getString("unknown"); if (namedLock.getUser() == null) throw new OntopiaRuntimeException("No user found on NamedLock"); String lockName = namedLock.getUser().getId(); if (lockName.equals("defaultUser")) lockName = bundle.getString("unknown"); return lockName; }
public void readContent(ClassifiableContentIF cc, TextHandlerIF handler) { try { WordExtractor extractor = new WordExtractor(new BufferedInputStream(new ByteArrayInputStream(cc.getContent()))); String s = extractor.getText(); char[] c = s.toCharArray(); handler.startRegion("document"); handler.text(c, 0, c.length); handler.endRegion(); } catch (Exception e) { throw new OntopiaRuntimeException(e); } }
public static void processWithVelocity(PageContext pageContext, String template_file, Writer writer, VelocityContext vc) { try { VelocityEngine vengine = getVelocityEngine(pageContext.getServletContext()); vengine.mergeTemplate(template_file, org.apache.velocity.runtime.RuntimeSingleton.getString(Velocity.INPUT_ENCODING, Velocity.ENCODING_DEFAULT), vc, writer); } catch (Exception e) { throw new OntopiaRuntimeException(e); } }
public InputStream getInputStream() throws ResourceStreamNotFoundException { try { return new Base64.InputStream(new ReaderInputStream(reader, "utf-8"), Base64.DECODE); } catch (UnsupportedEncodingException e) { throw new OntopiaRuntimeException(e); } }
protected static TopicIF getTopic(TopicMapIF topicmap, LocatorIF base_on, String ref) { LocatorIF loc = base_on.resolveAbsolute(ref); TopicIF topic = topicmap.getTopicBySubjectIdentifier(loc); if (topic == null) throw new OntopiaRuntimeException("Cannot find topic with id " + loc.getAddress()); else return topic; }
public synchronized void merge(TopicIF topic) { if (realTopic != null) throw new OntopiaRuntimeException("THIS SHOULD NEVER HAPPEN."); RemoteTopic rtopic = (RemoteTopic) topic; if (rtopic.isLoaded || this.isLoaded) { rtopic.setLoaded(true); setLoaded(true); } super.merge(topic); rtopic.setRealTopic(this); }
private TopicMapClassification classifyContent(ClassifiableContentIF cc, TopicMapIF topicmap) { try { TopicMapClassification tmc = new TopicMapClassification(topicmap); BlackList bl = getBlackList(); if (bl != null) tmc.setCustomTermAnalyzer(bl); tmc.classify(cc); return tmc; } catch (Exception e) { throw new OntopiaRuntimeException(e); } }
public void save() { TopicMapReferenceIF ref = getTopicMapIF().getStore().getReference(); if (ref instanceof XTMTopicMapReference) { try { ((XTMTopicMapReference) ref).save(); } catch (IOException e) { throw new OntopiaRuntimeException(e); } } }
protected static void removeTopic(TopicMapIF topicmap, LocatorIF base_on, String ref) { LocatorIF loc = base_on.resolveAbsolute(ref); TopicIF topic = topicmap.getTopicBySubjectIdentifier(loc); if (topic == null) throw new OntopiaRuntimeException("Cannot find topic with id " + loc.getAddress()); else topic.remove(); }
/** Attempts to load topic from remote topic map.*/ private synchronized void load() { RemoteTopicMapStore store = (RemoteTopicMapStore) getTopicMap().getStore(); RemoteTopicIndex tindex = store.getTopicIndex(); if (getSubjectIdentifiers().isEmpty() && getItemIdentifiers().isEmpty() && getSubjectLocators().isEmpty()) throw new OntopiaRuntimeException("Can't load topic without identity"); // isLoaded gets set from elsewhere, strangely tindex.getTopics(getSubjectIdentifiers(), getItemIdentifiers(), getSubjectLocators()); }
public static String convertNew(TopicMap oldTopicMap, String tmname, TopicMapSource tmsource) { TopicMapRepositoryIF repository = OntopolyContext.getOntopolyRepository().getTopicMapRepository(); try { String referenceId = OntopolyContext.getOntopolyRepository().createOntopolyTopicMap(tmsource.getId(), tmname); TopicMapIF topicMapIF = OntopolyContext.getOntopolyRepository().getTopicMapRepository() .getReferenceByKey(referenceId).createStore(false).getTopicMap(); TopicMap newTopicMap = new TopicMap(topicMapIF, referenceId); return inferAndCreateSchema(oldTopicMap, newTopicMap, tmname, repository); } catch (Exception e) { throw new OntopiaRuntimeException(e); } }