use of org.structr.common.error.UnlicensedException in project structr by structr.
the class LocalizationTest method testLocalizationWithoutDomain.
@Test
public void testLocalizationWithoutDomain() {
final PropertyKey<String> localizedName = StructrApp.key(Localization.class, "localizedName");
final PropertyKey<String> domain = StructrApp.key(Localization.class, "domain");
final PropertyKey<String> locale = StructrApp.key(Localization.class, "locale");
// create
try (final Tx tx = app.tx()) {
app.create(Localization.class, new NodeAttribute<>(Localization.name, "test1"), new NodeAttribute<>(locale, "de"), new NodeAttribute<>(localizedName, "test1-de-no_domain"));
app.create(Localization.class, new NodeAttribute<>(Localization.name, "test2"), new NodeAttribute<>(locale, "de"), new NodeAttribute<>(domain, "ExistingDomain"), new NodeAttribute<>(localizedName, "test2-de-ExistingDomain"));
app.create(Localization.class, new NodeAttribute<>(Localization.name, "test3"), new NodeAttribute<>(locale, "de_DE"), new NodeAttribute<>(localizedName, "test3-de_DE-no_domain"));
app.create(Localization.class, new NodeAttribute<>(Localization.name, "test4"), new NodeAttribute<>(locale, "de_DE"), new NodeAttribute<>(domain, "ExistingDomain"), new NodeAttribute<>(localizedName, "test4-de_DE-ExistingDomain"));
tx.success();
} catch (FrameworkException fex) {
fail("Unexpected exception.");
}
try (final Tx tx = app.tx()) {
final ActionContext ctx = new ActionContext(securityContext);
ctx.setLocale(new Locale("de"));
assertEquals("Invalid localization result", "test1-de-no_domain", Scripting.evaluate(ctx, null, "${localize('test1', 'ExistingDomain')}", "test"));
assertEquals("Invalid localization result", "test1-de-no_domain", Scripting.evaluate(ctx, null, "${localize('test1', 'NonexistingDomain')}", "test"));
assertEquals("Invalid localization result", "test1-de-no_domain", Scripting.evaluate(ctx, null, "${localize('test1')}", "test"));
assertEquals("Invalid localization result", "test2-de-ExistingDomain", Scripting.evaluate(ctx, null, "${localize('test2', 'ExistingDomain')}", "test"));
assertEquals("Invalid localization result", "test2", Scripting.evaluate(ctx, null, "${localize('test2', 'NonexistingDomain')}", "test"));
assertEquals("Invalid localization result", "test2", Scripting.evaluate(ctx, null, "${localize('test2')}", "test"));
assertEquals("Invalid localization result", "test3", Scripting.evaluate(ctx, null, "${localize('test3', 'ExistingDomain')}", "test"));
assertEquals("Invalid localization result", "test3", Scripting.evaluate(ctx, null, "${localize('test3', 'NonexistingDomain')}", "test"));
assertEquals("Invalid localization result", "test3", Scripting.evaluate(ctx, null, "${localize('test3')}", "test"));
assertEquals("Invalid localization result", "test4", Scripting.evaluate(ctx, null, "${localize('test4', 'ExistingDomain')}", "test"));
assertEquals("Invalid localization result", "test4", Scripting.evaluate(ctx, null, "${localize('test4', 'NonexistingDomain')}", "test"));
assertEquals("Invalid localization result", "test4", Scripting.evaluate(ctx, null, "${localize('test4')}", "test"));
tx.success();
} catch (UnlicensedException | FrameworkException fex) {
fail("Unexpected exception.");
}
try (final Tx tx = app.tx()) {
final ActionContext ctx = new ActionContext(securityContext);
ctx.setLocale(new Locale("de", "DE"));
assertEquals("Invalid localization result", "test1-de-no_domain", Scripting.evaluate(ctx, null, "${localize('test1', 'ExistingDomain')}", "test"));
assertEquals("Invalid localization result", "test1-de-no_domain", Scripting.evaluate(ctx, null, "${localize('test1', 'NonexistingDomain')}", "test"));
assertEquals("Invalid localization result", "test1-de-no_domain", Scripting.evaluate(ctx, null, "${localize('test1')}", "test"));
assertEquals("Invalid localization result", "test2-de-ExistingDomain", Scripting.evaluate(ctx, null, "${localize('test2', 'ExistingDomain')}", "test"));
assertEquals("Invalid localization result", "test2", Scripting.evaluate(ctx, null, "${localize('test2', 'NonexistingDomain')}", "test"));
assertEquals("Invalid localization result", "test2", Scripting.evaluate(ctx, null, "${localize('test2')}", "test"));
assertEquals("Invalid localization result", "test3-de_DE-no_domain", Scripting.evaluate(ctx, null, "${localize('test3', 'ExistingDomain')}", "test"));
assertEquals("Invalid localization result", "test3-de_DE-no_domain", Scripting.evaluate(ctx, null, "${localize('test3', 'NonexistingDomain')}", "test"));
assertEquals("Invalid localization result", "test3-de_DE-no_domain", Scripting.evaluate(ctx, null, "${localize('test3')}", "test"));
assertEquals("Invalid localization result", "test4-de_DE-ExistingDomain", Scripting.evaluate(ctx, null, "${localize('test4', 'ExistingDomain')}", "test"));
assertEquals("Invalid localization result", "test4", Scripting.evaluate(ctx, null, "${localize('test4', 'NonexistingDomain')}", "test"));
assertEquals("Invalid localization result", "test4", Scripting.evaluate(ctx, null, "${localize('test4')}", "test"));
tx.success();
} catch (UnlicensedException | FrameworkException fex) {
fail("Unexpected exception.");
}
}
use of org.structr.common.error.UnlicensedException in project structr by structr.
the class AuthHelper method doLogin.
public static void doLogin(final HttpServletRequest request, final Principal user) throws FrameworkException {
HttpSession session = request.getSession(false);
if (session == null) {
session = SessionHelper.newSession(request);
}
SessionHelper.clearInvalidSessions(user);
// We need a session to login a user
if (session != null) {
SessionHelper.clearSession(session.getId());
user.addSessionId(session.getId());
try {
Actions.call(Actions.NOTIFICATION_LOGIN, user);
} catch (UnlicensedException ex) {
ex.log(logger);
}
}
}
use of org.structr.common.error.UnlicensedException in project structr by structr.
the class ScriptingTest method testEnumPropertyGet.
@Test
public void testEnumPropertyGet() {
// setup phase
try (final Tx tx = app.tx()) {
final ActionContext actionContext = new ActionContext(securityContext);
final TestOne context = app.create(TestOne.class);
Scripting.evaluate(actionContext, context, "${{ var e = Structr.get('this'); e.anEnum = 'One'; }}", "test");
assertEquals("Invalid enum get result", "One", Scripting.evaluate(actionContext, context, "${{ var e = Structr.get('this'); return e.anEnum; }}", "test"));
assertEquals("Invaliid Javascript enum comparison result", true, Scripting.evaluate(actionContext, context, "${{ var e = Structr.get('this'); return e.anEnum == 'One'; }}", "test"));
tx.success();
} catch (UnlicensedException | FrameworkException fex) {
logger.warn("", fex);
fail("Unexpected exception.");
}
}
use of org.structr.common.error.UnlicensedException in project structr by structr.
the class ScriptingTest method testWrappingUnwrapping.
@Test
public void testWrappingUnwrapping() {
// setup phase
try (final Tx tx = app.tx()) {
final ActionContext actionContext = new ActionContext(securityContext);
final TestOne context = app.create(TestOne.class);
Scripting.evaluate(actionContext, context, "${{ Structr.create('Group', { name: 'Group1' } ); }}", "test");
Scripting.evaluate(actionContext, context, "${{ Structr.create('Group', 'name', 'Group2'); }}", "test");
assertEquals("Invalid unwrapping result", 2, app.nodeQuery(Group.class).getAsList().size());
tx.success();
} catch (UnlicensedException | FrameworkException fex) {
logger.warn("", fex);
fail("Unexpected exception.");
}
}
use of org.structr.common.error.UnlicensedException in project structr by structr.
the class ScriptingTest method testQuotes.
@Test
public void testQuotes() {
try (final Tx tx = app.tx()) {
final ActionContext actionContext = new ActionContext(securityContext);
Scripting.evaluate(actionContext, app.create(TestOne.class), "${{\n // \"test\n}}", "test");
tx.success();
} catch (UnlicensedException | FrameworkException fex) {
logger.warn("", fex);
fail("Unexpected exception.");
}
}
Aggregations