Package org.apache.openjpa.util

Examples of org.apache.openjpa.util.UserException


    public Slice getSlice(String name, boolean mustExist) {
        for (Slice slice : _slices)
            if (slice.getName().equals(name))
                return slice;
        if (mustExist) {
            throw new UserException(_loc.get("slice-not-found", name,
                    getActiveSliceNames()));
        }
        return null;
    }
View Full Code Here


            } catch (Throwable ex) {
                handleBadConnection(isLenient(), slice, ex);
            }
        }
        if (dataSources.isEmpty())
            throw new UserException(_loc.get("no-slice"));
        DistributedDataSource result = new DistributedDataSource(dataSources);
        return result;
    }
View Full Code Here

                log.warn(_loc.get("slice-connect-known-warn", slice, url, ex.getCause()));
            } else {
                log.warn(_loc.get("slice-connect-warn", slice, url));
            }
        } else if (ex != null) {
            throw new UserException(_loc.get("slice-connect-known-error", slice, url, ex), ex.getCause());
        } else {
            throw new UserException(_loc.get("slice-connect-error", slice, url));
        }
    }
View Full Code Here

    Slice addSlice(String name, Map newProps) {
        String prefix = PREFIX_SLICE + DOT + name + DOT;
        for (Object key : newProps.keySet()) {
            if (!String.class.isInstance(key)
             && key.toString().startsWith(prefix))
                throw new UserException(_loc.get("slice-add-wrong-key", key));
        }
        Slice slice = getSlice(name);
        if (slice != null)
            throw new UserException(_loc.get("slice-exists", name));
        Map<String,String> original = super.toProperties(true);
        original.putAll(newProps);
         slice = newSlice(name, original);
        _slices.add(slice);
        try {
View Full Code Here

            setDate(stmnt, idx, ((Calendar) val).getTime(), col);
        else if (val instanceof Reader)
            setCharacterStream(stmnt, idx, (Reader) val,
                (sized == null) ? 0 : sized.size, col);
        else
            throw new UserException(_loc.get("bad-param", val.getClass()));
    }
View Full Code Here

     * If the given name is indeed longer then raises a UserException with the
     * given message key otherwise returns the same name.
     */
    final String checkNameLength(String name, int length, String msgKey) {
        if (name.length() > length) {
            throw new UserException(_loc.get(msgKey, name, name.length(), length));
        }
        return name;
    }
View Full Code Here

        // always return the input name,
        String name = toDBName(identifier);
        String compareName = qualified ? name : toDBName(identifier.getUnqualifiedName());
       
        if (compareName.length() > length) {
            throw new UserException(_loc.get(msgKey, name, name.length(), length));
        }
        return name;
    }
View Full Code Here

     * @param unique the unique constraint. null means no-op.
     */
    public void addUnique(DBIdentifier table, Unique unique) {
      if (!DBIdentifier.equal(_tableName, table) &&
         (_seconds == null || !_seconds.containsKey(table))) {
            throw new UserException(_loc.get("unique-no-table",
                    new Object[]{table, _className, _tableName,
                    ((_seconds == null) ? "" : _seconds.keySet())}));
      }
      if (unique == null)
        return;
View Full Code Here

                Column[] uniqueColumns = new Column[templateColumns.length];
                Table table = getTable((ClassMapping)cm, tableName, adapt);
            for (int i=0; i<uniqueColumns.length; i++) {
                    DBIdentifier columnName = templateColumns[i].getIdentifier();
              if (!table.containsColumn(columnName)) {
                        throw new UserException(_loc.get(
                                "unique-missing-column",
                                new Object[]{cm, columnName, tableName,
                                Arrays.toString(table.getColumnNames())}));
              }
                    Column uniqueColumn = table.getColumn(columnName);
View Full Code Here

                            return rtrn;
                        }
                    }
                }
            default:
                throw new UserException(_loc.get("invalid-oid", new Object[] { expected, oid.getClass() }));
            }
        } catch (RuntimeException re) {
            if (expected == null)
                throw new UserException(_loc.get("invalid-oid", new Object[] { Number.class, oid.getClass() }));
            throw new UserException(_loc.get("invalid-oid", new Object[] { expected, oid.getClass() }));
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.openjpa.util.UserException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.