Package org.apache.slide.projector.i18n

Examples of org.apache.slide.projector.i18n.ErrorMessage


          Element pathsElement = repositoryElement.getChild("paths");
          projectorDir = pathsElement.getChildText("projector");
          applicationsDir = pathsElement.getChildText("applications");
          workDir = pathsElement.getChildText("work");
        } catch (Exception e) {
          throw new ConfigurationException(new ErrorMessage("projector/configurationFailed"), e);
        }
  }
View Full Code Here


    public Result process(Map parameter, Context context) throws Exception {
        String fragment = ((StringValue)parameter.get(FRAGMENT)).toString();
        Template template = getRequiredFragment(fragment);
        parameter.remove(FRAGMENT);
        if ( template == null ) throw new ProcessException(new ErrorMessage("templateArrayRenderer/fragmentNotFound", new String[] { fragment }));
        StringBuffer buffer = new StringBuffer(template.getLength());
        for ( int i = 0; i < getMaxIndex(parameter); i++ ) {
            template.evaluate(buffer, parameter, i);
        }
        return new Result(OK, OUTPUT, new StringValue(buffer.toString(), template.getContentType(), false));
View Full Code Here

    public Result process(Map parameter, Context context) throws Exception {
        String statemenet = parameter.get(STATEMENT).toString();
        Value []values = ((ArrayValue)parameter.get(VALUES)).getArray();
        javax.naming.Context ctx = new InitialContext();

        if ( ctx == null ) throw new ProcessException(new ErrorMessage("noInitialContextAvailable"));

        DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/TestDB");
        Result result = new Result(StateDescriptor.OK);
        if (ds != null) {
            ResultSet resultSet = null;
            PreparedStatement preparedStatement = null;
            Connection conn = null;
            try {
                conn = ds.getConnection();
                if(conn != null)  {
                    preparedStatement = conn.prepareStatement(statemenet);
                    for ( int i = 0; i < values.length; i++ ) {
                        // FIXME: We need a mapping for every sql type that should be supported
                        if ( values[i] instanceof StringValue ) {
                            preparedStatement.setString(i+1, values[i].toString());
                        } else if ( values[i] instanceof NumberValue ) {
                            preparedStatement.setInt(i+1, ((NumberValue)values[i]).getNumber().intValue());
                        } else if ( values[i] instanceof StreamableValue ) {
                            preparedStatement.setBinaryStream(i+1, ((StreamableValue)values[i]).getInputStream(), ((StreamableValue)values[i]).getContentLength());
                        }
                    }
                    if ( preparedStatement.execute() ) {
                        resultSet = preparedStatement.getResultSet();
                        List resultSetResources = new ArrayList();
                        ResultSetMetaData metaData = resultSet.getMetaData();
                        while ( resultSet.next() ) {
                            Map rowMap = new HashMap();
                            int columnCount = metaData.getColumnCount();
                            for ( int i = 0; i < columnCount; i++ ) {
                                String key = metaData.getColumnLabel(i+1);
                                Object object = resultSet.getObject(i+1);
                                if ( object instanceof String ) {
                                    rowMap.put(key, new StringValue((String)object));
                                } else if ( object instanceof Integer ) {
                                    rowMap.put(key, new NumberValue((Integer)object));
                                }
                            }
                            resultSetResources.add(new MapValue(rowMap));
                        }
                        Value[] resultEntries = new Value[resultSetResources.size()];
                        result.addResultEntry(RESULT, new ArrayValue((Value[] )resultSetResources.toArray(resultEntries)));
                    } else {
                        result.addResultEntry(ROW_COUNT, new NumberValue(new BigDecimal(preparedStatement.getUpdateCount())));
                    }
                    conn.close();
                }
            } catch (SQLException e) {
                throw new ProcessException(new ErrorMessage("sqlException"), e);
            } finally {
                // Always make sure result sets and statements are closed,
                // and the connection is returned to the pool
                if (resultSet != null) {
                    try { resultSet.close(); } catch (SQLException e) { ; }
View Full Code Here

        String password = parameter.get(PASSWORD).toString();
        String state = OK;
        // Check spelling
        Value user = NullValue.NULL;
        if ( !password.equals(retypedPassword) ) {
            context.addInformation(new Information(Information.ERROR, new ErrorMessage("register/passwordsNotIdentical"), new String[] { PASSWORD, RETYPE_PASSWORD }));
            state = FAILED;
        } else {
            try {
              user = Projector.getRepository().createUser(username, password, context.getCredentials())
            } catch ( UserExistsException exception ) {
                context.addInformation(new Information(Information.ERROR, exception.getErrorMessage(), new String[] { USERNAME }));
                state = FAILED;
            }
        }
        if ( user == null ) {
            context.addInformation(new Information(Information.ERROR, new ErrorMessage("register/failed"), new String[0]));
            state = FAILED;
        }
        return new Result(state, USER, user);
    }
View Full Code Here

                            requiredFragmentDefined = true;
                            break;
                        }
                    }
                    if ( !requiredFragmentDefined ) {
                        throw new ConfigurationException(new ErrorMessage("templateRenderer/requiredFragmentMissing", new String[] { requiredFragments[i] }));
                    }
                }
            }
            parameterDescriptions.add(new ParameterDescriptor(FRAGMENT, new ParameterMessage("templateRenderer/fragment"), new StringValueDescriptor((String [])templates.keySet().toArray(new String[0])), new StringValue(DEFAULT_FRAGMENT)));
            if ( fragments ) {
View Full Code Here

        template.evaluate(buffer, parameter);
    }

    protected Template getRequiredFragment(String fragment) throws ProcessException {
        Template template = (Template)templates.get(fragment);
        if ( template == null ) throw new ProcessException(new ErrorMessage("templateArrayRenderer/fragmentNotFound", new String[] { fragment }));
        return template;
    }
View Full Code Here

        evenTemplate = getOptionalFragment(EVEN_FRAGMENT);
        emptyTemplate = getOptionalFragment(EMPTY_FRAGMENT);
        try {
            defaultTemplate = getRequiredFragment(DEFAULT_FRAGMENT);
        } catch ( ProcessException exception ) {
            throw new ConfigurationException(new ErrorMessage("tableRenderer/fragmentsMissing"), exception);
        }
    }
View Full Code Here

        } catch ( RoleExistsException exception ) {
          context.addInformation(new Information(Information.ERROR, exception.getErrorMessage(), new String[] { ROLENAME }));
          state = FAILED;
        }
        if ( role == null ) {
            context.addInformation(new Information(Information.ERROR, new ErrorMessage("createRole/failed"), new String[0]));
            state = FAILED;
        }
        return new Result(state, ROLE, role);
    }
View Full Code Here

    public Result process(Map parameter, Context context) throws Exception {
        String username = parameter.get(USERNAME).toString();
        String password = parameter.get(PASSWORD).toString();
        Credentials credentials = Projector.getRepository().login(username, password);
        if ( credentials == null ) {
            context.addInformation(new Information(Information.ERROR, new ErrorMessage("login/invalidLogin"), new String[] { USERNAME, PASSWORD }));
            return new Result(LOGIN_FAILED);
        }
        context.setCredentials(credentials);
        return new Result(LOGIN_OK);
    }
View Full Code Here

    public Result process(Map parameter, Context context) throws Exception {
        String name = ((StringValue)parameter.get(STORE)).toString();
        String key = ((StringValue)parameter.get(KEY)).toString();
        Store store = context.getStore(StoreHelper.getStoreByName(name));
        if ( store == null ) {
            throw new ProcessException(new ErrorMessage("storeNotAvailable", new String[] {name}));
        }
        store.dispose(key);
        return new Result( StateDescriptor.OK );
    }
View Full Code Here

TOP

Related Classes of org.apache.slide.projector.i18n.ErrorMessage

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.