/** * override this method, if you work on entity beans with generic ids. you should assign the parent object. * * @param selectedSourceItems items to move to the destination list. */ public void moveToDest(Collection<T> selectedSourceItems) { assert sourceItems.containsAll(selectedSourceItems); if (!(sourceItems.removeAll(selectedSourceItems))) { throw new ManagedException("tsl2nano.unexpectederror", null); } destItems.addAll(selectedSourceItems); }
/** * override this method, if you work on entity beans with generic ids. you should remove the ids. * * @param destItem items to move to the source list. */ public void moveToSource(Collection<T> selectedDestItems) { assert destItems.containsAll(selectedDestItems); if (!(destItems.removeAll(selectedDestItems))) { throw new ManagedException("tsl2nano.unexpectederror", null); } sourceItems.addAll(selectedDestItems); }
/** * if servicefactory is not initialized, an exception will be thrown */ public static void checkConnection() { if (!ServiceFactory.isInitialized()) { LOG.error("Server-Connection Lost! May be caused by Server-Restart or Instruction-Error (no previously call of ServiceFactory.createInstance(..))"); throw new ManagedException("tsl2nano.login.noconnection"); } }
/** * checkDelegate * @param interfaze * @param delegate */ static <T> void checkDelegate(Class<T> interfaze, T delegate) { if (delegate == null || !interfaze.isAssignableFrom(delegate.getClass())) { throw new ManagedException("the delegate instance must implement the service interface!\ninterface: " + interfaze + "\ndelegate: " + Messages.stripParameterBrackets(String.valueOf(delegate)) + "\n\nmostly the reason are missing appserver-client-libraries to your client."); } }
/** * checks the given interface package path to start with defined feature interface path. * * @param <T> * @param interfaze interface package to check */ protected <T> void checkInterfacePath(Class<T> interfaze) { String featurePathConstraint = properties.getProperty(KEY_INTERF_PACKAGE_PREFIX); if (featurePathConstraint != null) { if (!interfaze.getPackage().getName().startsWith(featurePathConstraint)) { throw new ManagedException("tsl2nano.implementationerror", new Object[] { "Feature-Interface: " + interfaze.getName(), "Please use only feature interfaces in packages starting with '" + featurePathConstraint + "'!" }); } } else { //not defined? ==> default mechansim featurePathConstraint = "feature"; if (!interfaze.getPackage().getName().contains(featurePathConstraint)) { throw new ManagedException("tsl2nano.implementationerror", new Object[] { "Feature-Interface: " + interfaze.getName(), "Please use only feature interfaces in packages containing the substring '" + featurePathConstraint + "'!" }); } } }
/** * {@inheritDoc} */ @Override public <T> T findByExample(T exampleBean, Class... lazyRelations) { Collection<T> collection = findByExample(exampleBean, false); if (collection.size() > 1) { throw new ManagedException("tsl2nano.multiple.items", new Object[] { exampleBean }); } collection = fillTree(collection, lazyRelations); return collection.size() > 0 ? collection.iterator().next() : null; }
/** * {@inheritDoc} */ @Override public Object findItemByQuery(String queryString, boolean nativeQuery, Object[] args, Class... lazyRelations) { Collection<?> collection = findByQuery(queryString, nativeQuery, args, lazyRelations); if (collection.size() > 1) { throw new ManagedException("tsl2nano.multiple.items", new Object[] { StringUtil.fixString(queryString, 25, ' ', true) }); } collection = fillTree(collection, lazyRelations); return collection.size() > 0 ? collection.iterator().next() : null; }
NoMoreTimeoutsException { if (callbacks == null || callbacks.size() == 0) { throw new ManagedException("list of callbacks is null or empty - cannot start the runJobs service");
/** {@inheritDoc} */ protected <T> T instantiateLazyRelationship(Class<T> clazz, Object beanId, String[] attributes, List<Class> fillTypes) { LOG.info("instantiating lazy relation on " + clazz + " with id:" + beanId + "--> (special-attributeNames)" + attributes); final T bean = findById(clazz, beanId); if (bean == null) { throw new ManagedException("couldn''t find bean of type " + clazz + " with id: " + beanId + ".\nPossible causes are: null values on not-nullable attributes of that bean - or a relation!"); } return instantiateLazyRelationship(bean, attributes, fillTypes); }
public void checkJDBCConnection() { Connection con = null; try { con = getConnection(); ResultSet tables = getTableNames(con); if (!tables.next()) { LOG.info("Available tables are:\n" + getTablesAsString(con.getMetaData().getTables(null, null, null, null))); throw new ManagedException("The desired jdbc connection provides no tables to work on!"); } } catch (Exception e) { ManagedException.forward(e); } finally { close(con); } }
public static SIShell create(String file) { File ffile = new File(file); //do a pre-check on the toolbox configuration file which needs ant to be available if (file.contains(DEFAULT_NAME) && ffile.getAbsoluteFile().exists() && !NetUtil.isOnline() && !new CompatibilityLayer().isAvailable("org.apache.tools.ant.Task")) throw new ManagedException("error.ant.missing", file); SIShell t = ffile.exists() ? XmlUtil.loadXml(file, SIShell.class) : new SIShell(new Container(file, null)); t.name = file; return t; }
return toAppendTo.append(matcher.group()); } else { throw new ManagedException("tsl2nano.regexpfailure", new Object[] { o, pattern });
for (final BeanValue mhValue : mustHaveValues) { if (mhValue.getValue() == null) { throw new ManagedException("tsl2nano.musthavefailure", new Object[] { beanValue.getName(), mhValue.getName() }); for (final BeanValue mnhValue : mustNotHaveValues) { if (mnhValue.getValue() != null) { throw new ManagedException("tsl2nano.mustnothavefailure", new Object[] { beanValue.getName(), mnhValue.getName() });
/** * setBasicDef * * @param length {@link #length()} * @param nullable {@link #nullable()} * @param format {@link #getPattern()} * @param defaultValue {@link #getDefault()} * @param description {@link #getDescription()} */ @Override public <C extends IConstraint<T>> C setBasicDef(int length, boolean nullable, Format format, T defaultValue) { this.length = length; this.nullable = nullable; this.format = format; this.defaultValue = defaultValue; if (defaultValue != null) { IStatus s = checkStatus(getType() != null ? getType().getSimpleName() : "arg", defaultValue); if (!s.ok()) { throw new ManagedException(s.message()); } } return (C) this; }
if (runningJob != null) { LOG.error("job-start canceled. no concurrent running jobs are allowed.\nPlease use argument 'stopOnConcurrent=false' if you want to allow concurrent running jobs!"); RuntimeException ex = new ManagedException("tsl2nano.concurrentfailure", new Object[] { job, runningJob }); job.setLastException(ex);
/** * wraps the attribute value into a bean. the attribute has to be an entity. * * @param name attribute name * @return new bean holding the attributes value. */ public BeanDefinition<?> getValueAsBean(String name, boolean cacheInstance) { IValueDefinition<?> attribute = getAttribute(name); if (BeanUtil .isStandardType(attribute.getType()) /*!BeanContainer.instance().isPersistable(attribute.getType())*/) { throw new ManagedException("The attribute '" + name + "' is not a persistable bean"); } Serializable value = (Serializable) attribute.getValue(); if (value == null) { return null; } Bean<?> bean = value instanceof Bean ? (Bean) value : getBean(value, cacheInstance); return bean; }
if (isMultiSelection) { if (!Collection.class.isAssignableFrom(attribute.getType())) { throw new ManagedException( "tsl2nano.implementationerror", new Object[] {
/** * getParsedValue. throws a runtime exception on parsing error. * * @param source text to parse * @return parsed value */ public T getParsedValue(String source) { T value = null; if (getFormat() != null) { try { if (Util.isEmpty(source) && nullable()) return null; //the parser will decide, how to handle empty/null values value = (T) getFormat().parseObject(source); } catch (ParseException e) { ManagedException.forward(e); } } else if (String.class.isAssignableFrom(getType())) { value = (T) source; } else { throw new ManagedException("no format/parser available for field " + getName()); } return value; }
fillContext(newBean, getParameter()); if (newBean == null) { throw new ManagedException("tsl2nano.no_type_available");
throw new ManagedException("tsl2nano.impossible_create", new Object[] { /*Configuration.current()