incorporate several APLAWS patches for ccm-core:
r1708: Changed sync() to run() so unit tests now compile (LuceneTest.java, SearchTest.java). r1709: Created java equivalent of manipulate-input.js to convert titles to url form. r1720: Converted formatting of code examples to <pre> tags (PackageTestSuite.java). r1723: NodeGenerator now has more context (parent object and property parameters) (SimpleDomainObjectXMLFormatter.java , NodeGenerator.java ) r1740: Validates a value is a valid HTML hex code for a colour. git-svn-id: https://svn.libreccm.org/ccm/trunk@60 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
6754f1cf85
commit
3521640c08
|
|
@ -85,7 +85,7 @@ public class SimpleDomainObjectXMLFormatter
|
||||||
|
|
||||||
Object formatted = null;
|
Object formatted = null;
|
||||||
if (formatter == null) {
|
if (formatter == null) {
|
||||||
formatted = generator.format(value);
|
formatted = generator.format(obj, prop, value);
|
||||||
} else {
|
} else {
|
||||||
formatted = formatter.format(value);
|
formatted = formatter.format(value);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ permissions.button.search=Los!
|
||||||
permissions.denied.title=Keine Zugriffsberechtigung
|
permissions.denied.title=Keine Zugriffsberechtigung
|
||||||
permissions.directPermissions.explanation=Diesem Objekt hat folgende direkte Zugriffsberechtigungen
|
permissions.directPermissions.explanation=Diesem Objekt hat folgende direkte Zugriffsberechtigungen
|
||||||
permissions.directPermissions.heading=Zugriffsberechtigungen die Sie veraendern koennen
|
permissions.directPermissions.heading=Zugriffsberechtigungen die Sie veraendern koennen
|
||||||
permissions.index.adminObjects=Sie haben Administrator Berechtigung fuer folgende Objekte
|
permissions.index.adminObjects=Sie haben Administrator Berechtigung f\u00FCr folgende Objekte
|
||||||
permissions.index.noAdminObjects=keine
|
permissions.index.noAdminObjects=keine
|
||||||
permissions.index.title=Zugriffsberechtigungen
|
permissions.index.title=Zugriffsberechtigungen
|
||||||
permissions.index.panelTitle=Zugriffsberechtigungen Administration
|
permissions.index.panelTitle=Zugriffsberechtigungen Administration
|
||||||
|
|
@ -13,17 +13,17 @@ permissions.indirectPermissions.explanation=Diese Zugriffsberechtigungen sind ge
|
||||||
permissions.indirectPermissions.context=Das vererbende Objekt ist
|
permissions.indirectPermissions.context=Das vererbende Objekt ist
|
||||||
permissions.indirectPermissions.heading=Zugriffsberechtigungen die nicht geaendert werden koennen
|
permissions.indirectPermissions.heading=Zugriffsberechtigungen die nicht geaendert werden koennen
|
||||||
permissions.main.site=Haupt Seite
|
permissions.main.site=Haupt Seite
|
||||||
permissions.one.grant.explanation.left=Waehlen Sie die Benutzer/Gruppen
|
permissions.one.grant.explanation.left=W\u00E4hlen Sie die Benutzer/Gruppen
|
||||||
permissions.one.grant.explanation.right=Waehlen Sie die Zugriffsberechtigungen
|
permissions.one.grant.explanation.right=W\u00E4hlen Sie die Zugriffsberechtigungen
|
||||||
permissions.one.grant.title=Zuweisung von Zugriffsberechtigungen
|
permissions.one.grant.title=Zuweisung von Zugriffsberechtigungen
|
||||||
permissions.one.title=Zugriffsberechtigungen zu
|
permissions.one.title=Zugriffsberechtigungen zu
|
||||||
permissions.personal.site=Meine Seite
|
permissions.personal.site=Meine Seite
|
||||||
permissions.searchForm.label=Eingabe der Objekt ID
|
permissions.searchForm.label=Eingabe der Objekt ID
|
||||||
permissions.table.grantee=Wer
|
permissions.table.grantee=Wer
|
||||||
permissions.table.actions=Action
|
permissions.table.actions=Aktion
|
||||||
permissions.table.actions.removeAll=Wollen Sie wirklich alle Zugriffsberechtigungen fuer diesen User/Gruppe loeschen?
|
permissions.table.actions.removeAll=Wollen Sie wirklich alle Zugriffsberechtigungen fuer diesen User/Gruppe loeschen?
|
||||||
permissions.table.inherited=Geerbt von
|
permissions.table.inherited=Geerbt von
|
||||||
permissions.table.parent.context.null=Diese Objekt hat keinen Kontext.
|
permissions.table.parent.context.null=Dieses Objekt hat keinen Kontext.
|
||||||
permissions.userSearchForm.label=Suche Personen oder Gruppen fuer Zuweisung direkter Berechtigungen.
|
permissions.userSearchForm.label=Suche Personen oder Gruppen fuer Zuweisung direkter Berechtigungen.
|
||||||
|
|
||||||
permissions.userSearchForm.noResults=Keine Zielgruppe gefunden.
|
permissions.userSearchForm.noResults=Keine Zielgruppe gefunden.
|
||||||
|
|
|
||||||
|
|
@ -1300,6 +1300,37 @@ public class StringUtils {
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert a name into a URL form, the java equivalent of "<code>manipulate-input.js</code>"
|
||||||
|
*
|
||||||
|
* For example, "<code>Business promotions!</code>" will be converted to "<code>business-promotions</code>".
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
* the to be converted into a URL.
|
||||||
|
* @return the converted name, possibly unchanged and null if the input is null.
|
||||||
|
*/
|
||||||
|
public static String urlize(String name) {
|
||||||
|
if (name == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
StringBuffer urlizedName = new StringBuffer(name.length());
|
||||||
|
|
||||||
|
for (int i = 0; i < name.length(); i++) {
|
||||||
|
char ch = name.charAt(i);
|
||||||
|
|
||||||
|
if (Character.isLetter(ch)) {
|
||||||
|
urlizedName.append(Character.toLowerCase(ch));
|
||||||
|
}
|
||||||
|
else if (Character.isDigit(ch) || ch == '_' || ch == '-') {
|
||||||
|
urlizedName.append(ch);
|
||||||
|
}
|
||||||
|
else if (ch == ' ' || ch == '&' || ch == '/') {
|
||||||
|
urlizedName.append('-');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return urlizedName.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,9 @@
|
||||||
*/
|
*/
|
||||||
package com.arsdigita.xml;
|
package com.arsdigita.xml;
|
||||||
|
|
||||||
|
import com.arsdigita.domain.DomainObject;
|
||||||
|
import com.arsdigita.persistence.metadata.Property;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An interface providing an API for converting an object
|
* An interface providing an API for converting an object
|
||||||
* to a new Element. This is useful when rendering objects where
|
* to a new Element. This is useful when rendering objects where
|
||||||
|
|
@ -28,5 +31,5 @@ package com.arsdigita.xml;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface NodeGenerator {
|
public interface NodeGenerator {
|
||||||
Element format(Object value);
|
Element format(DomainObject parent, Property property, Object value);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ public class LuceneTest extends LuceneTestCase {
|
||||||
note.save();
|
note.save();
|
||||||
|
|
||||||
Indexer idx = new Indexer(Index.getLocation());
|
Indexer idx = new Indexer(Index.getLocation());
|
||||||
idx.sync();
|
idx.run();
|
||||||
|
|
||||||
// This is kindof a hack since it's possible there are other things in
|
// This is kindof a hack since it's possible there are other things in
|
||||||
// the index that will contain the same search term since the search
|
// the index that will contain the same search term since the search
|
||||||
|
|
|
||||||
|
|
@ -149,7 +149,7 @@ public class SearchTest extends LuceneTestCase {
|
||||||
|
|
||||||
private void sync() throws Exception {
|
private void sync() throws Exception {
|
||||||
Indexer idx = new Indexer(Index.getLocation());
|
Indexer idx = new Indexer(Index.getLocation());
|
||||||
idx.sync();
|
idx.run();
|
||||||
|
|
||||||
}
|
}
|
||||||
private void cleanIndex() throws Exception {
|
private void cleanIndex() throws Exception {
|
||||||
|
|
|
||||||
|
|
@ -32,18 +32,18 @@ import junit.framework.TestSuite;
|
||||||
* This class is the foundation for the test suite methodology. At each package level,
|
* This class is the foundation for the test suite methodology. At each package level,
|
||||||
* an PackageTestSuite derived class is defined. For Ant to handle TestSuites, the class
|
* an PackageTestSuite derived class is defined. For Ant to handle TestSuites, the class
|
||||||
* must define:
|
* must define:
|
||||||
* <code>
|
* <pre>
|
||||||
* public static Test suite();
|
* public static Test suite();</pre>
|
||||||
* </code>
|
|
||||||
*
|
*
|
||||||
* In the PackageTestSuite framework, this method works as in the following example:
|
* In the PackageTestSuite framework, this method works as in the following example:
|
||||||
*
|
*
|
||||||
|
* <pre>
|
||||||
* public static Test suite()
|
* public static Test suite()
|
||||||
* {
|
* {
|
||||||
* PersistenceSuite suite = new PersistenceSuite();
|
* PersistenceSuite suite = new PersistenceSuite();
|
||||||
* populateSuite(suite);
|
* populateSuite(suite);
|
||||||
* return suite;
|
* return suite;
|
||||||
* }
|
* }</pre>
|
||||||
*
|
*
|
||||||
* The PackageTestSuite.populateSuite method adds all the valid test cases in the same
|
* The PackageTestSuite.populateSuite method adds all the valid test cases in the same
|
||||||
* package as the derived Suite class. Optionally, if the property test.testpath is defined,
|
* package as the derived Suite class. Optionally, if the property test.testpath is defined,
|
||||||
|
|
@ -75,20 +75,23 @@ public class PackageTestSuite extends TestSuite {
|
||||||
* If the test class has a field named FAILS, the test will not be added to the suite.
|
* If the test class has a field named FAILS, the test will not be added to the suite.
|
||||||
* FAILS can be any public static type, such as:
|
* FAILS can be any public static type, such as:
|
||||||
*
|
*
|
||||||
* <code> public static final boolean FAILS = true; </code>
|
* <pre>
|
||||||
|
* public static final boolean FAILS = true;
|
||||||
|
* </pre>
|
||||||
*
|
*
|
||||||
* If the TestCase requires initialization of some external resources, the
|
* If the TestCase requires initialization of some external resources, the
|
||||||
* class should implement the following method:
|
* class should implement the following method:
|
||||||
*
|
*
|
||||||
* <code>
|
* <pre>
|
||||||
* public static Test suite()
|
* public static Test suite()
|
||||||
* </code>
|
* </pre>
|
||||||
*
|
*
|
||||||
* This factory method can then return the TestCase wrapped in some TestDecorator
|
* This factory method can then return the TestCase wrapped in some TestDecorator
|
||||||
* that performs initialization.
|
* that performs initialization.
|
||||||
*
|
*
|
||||||
* An example would be:
|
* An example would be:
|
||||||
* <code>
|
*
|
||||||
|
* <pre>
|
||||||
* public FooTest extends TestCase {
|
* public FooTest extends TestCase {
|
||||||
* public static Test suite() {
|
* public static Test suite() {
|
||||||
* TestSuite suite = new TestSuite(FooTest.class);
|
* TestSuite suite = new TestSuite(FooTest.class);
|
||||||
|
|
@ -110,19 +113,24 @@ public class PackageTestSuite extends TestSuite {
|
||||||
* SQLLoader.clearDatabase();
|
* SQLLoader.clearDatabase();
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* </code>
|
* </pre>
|
||||||
*
|
*
|
||||||
* There is an alternative methodology, which may be cleaner. Since this whole system,
|
* There is an alternative methodology, which may be cleaner. Since this whole system,
|
||||||
* like the original Ant test setup, relies on class names, there may be a
|
* like the original Ant test setup, relies on class names, there may be a
|
||||||
* better way. If the test for some class Foo requires a TestSetup wrapper,
|
* better way. If the test for some class Foo requires a TestSetup wrapper,
|
||||||
* the classes could be named as follows:
|
* the classes could be named as follows:
|
||||||
*
|
*
|
||||||
* FooTestImpl.java - The TestCase based class. Was FooTest in prior example
|
* <p>
|
||||||
* FooTest.java - The TestSetup derived class, which is created wrapping
|
* <ul>
|
||||||
* FooTestImpl.java. Was FooSetup in above example
|
* <li><p>FooTestImpl.java - The TestCase based class. Was FooTest in prior example</p></li>
|
||||||
|
* <li><p>FooTest.java - The TestSetup derived class, which is created wrapping
|
||||||
|
* FooTestImpl.java. Was FooSetup in above example</p></li>
|
||||||
|
* </ul>
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* An example would be:
|
* An example would be:
|
||||||
* <code>
|
*
|
||||||
|
* <pre>
|
||||||
* public class FooTest extends TestSetup {
|
* public class FooTest extends TestSetup {
|
||||||
* public FooTest(Test test)
|
* public FooTest(Test test)
|
||||||
* {
|
* {
|
||||||
|
|
@ -132,7 +140,8 @@ public class PackageTestSuite extends TestSuite {
|
||||||
* return new FooTest(new TestSuite(FooTestImpl.class));
|
* return new FooTest(new TestSuite(FooTestImpl.class));
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* </code>
|
* </pre>
|
||||||
|
*
|
||||||
* @param testClass The test class to add to the suite.
|
* @param testClass The test class to add to the suite.
|
||||||
*/
|
*/
|
||||||
public void addTestSuite(final Class testClass) {
|
public void addTestSuite(final Class testClass) {
|
||||||
|
|
|
||||||
|
|
@ -359,4 +359,16 @@ public class StringUtilsTest extends TestCase {
|
||||||
assertEquals(expected, actual);
|
assertEquals(expected, actual);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void testUrlize() {
|
||||||
|
assertEquals(null, StringUtils.urlize(null));
|
||||||
|
assertEquals("", StringUtils.urlize(""));
|
||||||
|
assertEquals("-", StringUtils.urlize(" "));
|
||||||
|
assertEquals("----", StringUtils.urlize(" "));
|
||||||
|
assertEquals("abc-def", StringUtils.urlize("ABC DEF"));
|
||||||
|
assertEquals("-abc-def-", StringUtils.urlize(" ABC DEF "));
|
||||||
|
assertEquals("0123456789abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz-_---", StringUtils.urlize("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_ &/"));
|
||||||
|
assertEquals("helpaplawsorg", StringUtils.urlize("help@aplaws.org"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue