Package org.modeshape.common.i18n

Examples of org.modeshape.common.i18n.I18n


            String parentPathStr = readable(parentPath);
            int numExistingSns = node.getChildReferences(cache).getChildCount(newNodeName);
            int sns = numExistingSns + 1;
            String segment = readable(session.pathFactory().createSegment(newNodeName, sns));
            String opv = OnParentVersionAction.nameFromValue(childDefn.getOnParentVersion());
            I18n msg = JcrI18n.cannotCreateChildOnCheckedInNodeSinceOpvOfChildDefinitionIsNotIgnore;
            throw new VersionException(msg.text(segment, readable(parentPathStr), childDefn.getName(), opv));
        }

        // We can create the shared node ...
        NodeKey childKey = shareableNode.key();
        node.linkChild(cache, childKey, newNodeName);
View Full Code Here


            NodeDefinition defn = getDefinition();
            int opv = defn.getOnParentVersion();
            if (opv != OnParentVersionAction.IGNORE) {
                // The OPV is not 'ignore', so we can't create the new node ...
                String opvStr = OnParentVersionAction.nameFromValue(opv);
                I18n msg = JcrI18n.cannotRemoveChildOnCheckedInNodeSinceOpvOfChildDefinitionIsNotIgnore;
                throw new VersionException(msg.text(path(), defn.getName(), opvStr));
            }
            // Otherwise, child node definition is 'ignore', so okay to remove ...
        }

        // Even if this is shareable, we remove the shareable nodes the same way
View Full Code Here

            if (problems.hasErrors()) {
                String msg = JcrI18n.errorsParsingNodeTypeDefinitions.text(file.getAbsolutePath(), summary);
                throw new RepositoryException(msg);
            }
            // Otherwise, there are warnings, so log them ...
            I18n msg = JcrI18n.warningsParsingNodeTypeDefinitions;
            Logger.getLogger(getClass()).warn(msg, file.getAbsolutePath(), summary);
        }

        // Register the node types ...
        return registerNodeTypes(importer.getNodeTypeDefinitions(), allowUpdate);
View Full Code Here

            if (problems.hasErrors()) {
                String msg = JcrI18n.errorsParsingStreamOfNodeTypeDefinitions.text(summary);
                throw new RepositoryException(msg);
            }
            // Otherwise, there are warnings, so log them ...
            I18n msg = JcrI18n.warningsParsingStreamOfNodeTypeDefinitions;
            Logger.getLogger(getClass()).warn(msg, summary);
        }

        // Register the node types ...
        return registerNodeTypes(importer.getNodeTypeDefinitions(), allowUpdate);
View Full Code Here

            if (problems.hasErrors()) {
                String msg = JcrI18n.errorsParsingNodeTypeDefinitions.text(url.toExternalForm(), summary);
                throw new RepositoryException(msg);
            }
            // Otherwise, there are warnings, so log them ...
            I18n msg = JcrI18n.warningsParsingNodeTypeDefinitions;
            Logger.getLogger(getClass()).warn(msg, url.toExternalForm(), summary);
        }

        // Register the node types ...
        return registerNodeTypes(importer.getNodeTypeDefinitions(), allowUpdate);
View Full Code Here

        List<String> lines = null;
        try {
            String content = IoUtil.read(stream);
            lines = StringUtil.splitLines(content);
        } catch (IOException e) {
            I18n msg = CommonI18n.unableToAccessResourceFileFromClassLoader;
            LOGGER.warn(e, msg, MIME_TYPE_EXTENSIONS_RESOURCE_PATH);
        }
        Map<String, String> mimeTypesByExtension = new HashMap<String, String>();
        if (lines != null) {
            for (String line : lines) {
View Full Code Here

                                             String id ) {
        if (i18nClass != null && !Object.class.equals(i18nClass) && id != null) {
            try {
                // Look up the I18n field ...
                Field i18nMsg = i18nClass.getDeclaredField(id);
                I18n msg = (I18n)i18nMsg.get(null);
                if (msg != null) {
                    return msg.text();
                }
            } catch (SecurityException err) {
                // ignore
            } catch (NoSuchFieldException err) {
                // ignore
View Full Code Here

    @Test
    public void shouldGetAllPropertiesOnJavaBean() throws Exception {
        Status status = Status.INFO;
        int code = 121;
        I18n msg = CommonI18n.argumentMayNotBeEmpty;
        Object[] params = new Object[] {"argName"};
        String resource = "The source";
        String location = "The place to be";
        Throwable throwable = null;
        Problem problem = new Problem(status, code, msg, params, resource, location, throwable);
        Reflection reflection = new Reflection(Problem.class);
        List<Property> props = reflection.getAllPropertiesOn(problem);
        Map<String, Property> propsByName = reflection.getAllPropertiesByNameOn(problem);

        assertThat(props.size(), is(8));
        assertThat(propsByName.size(), is(8));
        assertThat(props.containsAll(propsByName.values()), is(true));

        Property property = propsByName.remove("status");
        assertThat(property.getName(), is("status"));
        assertThat(property.getLabel(), is("Status"));
        assertThat(property.getType().equals(Status.class), is(true));
        assertThat(property.isReadOnly(), is(true));
        assertThat(property, is(findProperty(property.getName(), props)));
        assertValue(reflection, problem, property, status);

        property = propsByName.remove("code");
        assertThat(property.getName(), is("code"));
        assertThat(property.getLabel(), is("Code"));
        assertThat(property.getType().equals(Integer.TYPE), is(true));
        assertThat(property.isReadOnly(), is(true));
        assertValue(reflection, problem, property, code);

        property = propsByName.remove("message");
        assertThat(property.getName(), is("message"));
        assertThat(property.getLabel(), is("Message"));
        assertThat(property.getType().equals(I18n.class), is(true));
        assertThat(property.isReadOnly(), is(true));
        assertValue(reflection, problem, property, msg);

        property = propsByName.remove("messageString");
        assertThat(property.getName(), is("messageString"));
        assertThat(property.getLabel(), is("Message String"));
        assertThat(property.getType().equals(String.class), is(true));
        assertThat(property.isReadOnly(), is(true));
        assertValue(reflection, problem, property, msg.text(params));

        property = propsByName.remove("parameters");
        assertThat(property.getName(), is("parameters"));
        assertThat(property.getLabel(), is("Parameters"));
        assertThat(property.getType().equals(Object[].class), is(true));
View Full Code Here

    public void shouldNotHaveProblems() throws Exception {
        for (Field fld : i18nClass.getDeclaredFields()) {
            if (fld.getType() == I18n.class && (fld.getModifiers() & Modifier.PUBLIC) == Modifier.PUBLIC
                && (fld.getModifiers() & Modifier.STATIC) == Modifier.STATIC
                && (fld.getModifiers() & Modifier.FINAL) != Modifier.FINAL) {
                I18n i18n = (I18n)fld.get(null);
                if (i18n.hasProblem()) {
                    fail(i18n.problem());
                }
            }
        }
        // Check for global problems after checking field problems since global problems are detected lazily upon field usage
        Set<Locale> locales = I18n.getLocalizationProblemLocales(i18nClass);
View Full Code Here

            assertThat(fld, is(notNullValue()));
            // Now check the I18n field ...
            if (fld.getType() == I18n.class && (fld.getModifiers() & Modifier.PUBLIC) == Modifier.PUBLIC
                && (fld.getModifiers() & Modifier.STATIC) == Modifier.STATIC
                && (fld.getModifiers() & Modifier.FINAL) != Modifier.FINAL) {
                I18n i18n = (I18n)fld.get(null);
                if (i18n.hasProblem()) {
                    fail(i18n.problem());
                }
            }
        } catch (NoSuchFieldException e) {
            fail("Missing I18n field on " + i18nClass.getName() + " for " + annotation + " on " + annotatedObject);
        }
View Full Code Here

TOP

Related Classes of org.modeshape.common.i18n.I18n

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.