JBoss Portal SVN: r12486 - branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms.
by portal-commits@lists.jboss.org
Author: vrockai
Date: 2009-01-13 08:57:31 -0500 (Tue, 13 Jan 2009)
New Revision: 12486
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSSecureTestCase.java
Log:
cms security tweak
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSSecureTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSSecureTestCase.java 2009-01-13 13:31:02 UTC (rev 12485)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSSecureTestCase.java 2009-01-13 13:57:31 UTC (rev 12486)
@@ -165,8 +165,10 @@
login("admin", "admin");
Assert.assertFalse(selenium.isTextPresent("Access to this resource is denied "), "Non secured resource is not visible.#1");
- //Assert.assertFalse(selenium.isTextPresent("You are not allowed to access the following resource - /default/index.html"),
- // "Non secured resource is not visible.#2");
+ // Assert.assertFalse(selenium.isTextPresent(
+ // "You are not allowed to access the following resource - /default/index.html"
+ // ),
+ // "Non secured resource is not visible.#2");
selenium.click(LNK_ADMIN);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -193,7 +195,7 @@
}
- @Test(enabled = true, dependsOnMethods={"testSetRoleReadPer2"}, description = "Set admin/secRole read permissions, login as user w secRole.")
+ @Test(enabled = true, dependsOnMethods = { "testSetRoleReadPer2" }, description = "Set admin/secRole read permissions, login as user w secRole.")
public void testSetRoleReadPer1() {
login("admin", "admin");
@@ -290,7 +292,7 @@
logout();
}
- @Test(enabled = true, dependsOnMethods={"testSetRoleReadPer1"},description = "Subpage permission test")
+ @Test(enabled = true, dependsOnMethods = { "testSetRoleReadPer1" }, description = "Subpage permission test")
public void testSubpageSecurity() {
selenium.open("/portal/portal/default");
@@ -339,11 +341,12 @@
Assert.assertTrue(selenium.isTextPresent(roleDisplay), "Role display name: " + roleDisplay + " not found on the page.");
final String CHECK_ROLE = MessageFormat.format(IdentityAdminTestCase.ID_CHECK_ROLE, role);
- selenium.click(CHECK_ROLE);
+ if (!selenium.isChecked(CHECK_ROLE)) {
+ selenium.click(CHECK_ROLE);
- selenium.click(IdentityAdminTestCase.ID_SUBMIT_ASSIGN_ROLE);
- selenium.waitForPageToLoad(PAGE_LOAD);
-
+ selenium.click(IdentityAdminTestCase.ID_SUBMIT_ASSIGN_ROLE);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ }
searchUser(user, email);
selenium.click(butUsrRol_id(user));
@@ -362,10 +365,12 @@
// check the tempRole check box
final String CHECK_ROLE = MessageFormat.format(IdentityAdminTestCase.ID_CHECK_ROLE, role);
- selenium.click(CHECK_ROLE);
+ if (selenium.isChecked(CHECK_ROLE)) {
+ selenium.click(CHECK_ROLE);
- selenium.click(IdentityAdminTestCase.ID_SUBMIT_ASSIGN_ROLE);
- selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click(IdentityAdminTestCase.ID_SUBMIT_ASSIGN_ROLE);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ }
searchUser(user, email);
selenium.click(butUsrRol_id(user));
17 years, 3 months
JBoss Portal SVN: r12483 - in branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium: cms and 1 other directories.
by portal-commits@lists.jboss.org
Author: vrockai
Date: 2009-01-13 08:25:21 -0500 (Tue, 13 Jan 2009)
New Revision: 12483
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/DashboardTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossPortalSeleniumTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossSeleniumTestListener.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSSecureTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/AdminPortalTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/PortletInstancesTestCase.java
Log:
portlet instances
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/DashboardTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/DashboardTestCase.java 2009-01-13 13:24:44 UTC (rev 12482)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/DashboardTestCase.java 2009-01-13 13:25:21 UTC (rev 12483)
@@ -42,10 +42,18 @@
@Test(enabled = true)
public void testCreatePage() {
//selenium.setSpeed("0");
+ selenium.setSpeed("6000");
selenium.click(LNK_DASHBOARD);
- selenium.waitForPageToLoad(PAGE_LOAD);
+
+ //selenium.waitForPageToLoad(PAGE_LOAD);
+
+
+
selenium.click(LNK_CONFIGURE_DASHBOARD);
- selenium.waitForPageToLoad(PAGE_LOAD);
+
+ selenium.setSpeed("0");
+ //selenium.waitForPageToLoad(PAGE_LOAD);
+
selenium.type(INP_PAGENAME, "DashTestPage");
clickAndWait(SUB_CREATEPAGE);
@@ -64,7 +72,13 @@
selenium.click(LNK_DASHBOARD);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(LNK_CONFIGURE_DASHBOARD);
- selenium.waitForPageToLoad(PAGE_LOAD);
+ //selenium.waitForPageToLoad(PAGE_LOAD);
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
selectIfNotSelected(SEL_PAGE,"DashTestPage");
@@ -89,7 +103,13 @@
selenium.click(LNK_DASHBOARD);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(LNK_CONFIGURE_DASHBOARD);
- selenium.waitForPageToLoad(PAGE_LOAD);
+ //selenium.waitForPageToLoad(PAGE_LOAD);
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
selenium.windowMaximize();
selectIfNotSelected(SEL_PAGE,"DashTestPage");
@@ -116,7 +136,13 @@
selenium.click(LNK_CONFIGURE_DASHBOARD);
- selenium.waitForPageToLoad(PAGE_LOAD);
+ //selenium.waitForPageToLoad(PAGE_LOAD);
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
selectIfNotSelected(SEL_PAGE,"DashTestPage");
selenium.click("link=Who's online portlet");
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -143,7 +169,13 @@
selenium.click(LNK_DASHBOARD);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(LNK_CONFIGURE_DASHBOARD);
- selenium.waitForPageToLoad(PAGE_LOAD);
+ //selenium.waitForPageToLoad(PAGE_LOAD);
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
selenium.type(INP_PAGENAME, pageName);
selenium.click(SUB_CREATEPAGE);
@@ -183,7 +215,13 @@
selenium.click(LNK_DASHBOARD);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(LNK_CONFIGURE_DASHBOARD);
- selenium.waitForPageToLoad(PAGE_LOAD);
+ //selenium.waitForPageToLoad(PAGE_LOAD);
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
selectIfNotSelected(SEL_PAGE,pageName);
selenium.addSelection(SEL_CENTER_REGION, "label=ExceptionPortletWindow");
@@ -205,7 +243,13 @@
selenium.click(LNK_DASHBOARD);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(LNK_CONFIGURE_DASHBOARD);
- selenium.waitForPageToLoad(PAGE_LOAD);
+ //selenium.waitForPageToLoad(PAGE_LOAD);
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
selectIfNotSelected(SEL_PAGE,"DashTestPage");
@@ -228,7 +272,13 @@
selenium.click(LNK_DASHBOARD);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(LNK_CONFIGURE_DASHBOARD);
- selenium.waitForPageToLoad(PAGE_LOAD);
+ //selenium.waitForPageToLoad(PAGE_LOAD);
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
selectIfNotSelected(SEL_PAGE,"DashTestPage");
selenium.select(SEL_CONTENT_TYPE, "label=widget/google");
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -257,7 +307,13 @@
selenium.click(LNK_DASHBOARD);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(LNK_CONFIGURE_DASHBOARD);
- selenium.waitForPageToLoad(PAGE_LOAD);
+ //selenium.waitForPageToLoad(PAGE_LOAD);
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
selenium.type(INP_PAGENAME, pageName);
selenium.click(SUB_CREATEPAGE);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -305,7 +361,13 @@
selenium.click(LNK_DASHBOARD);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(LNK_CONFIGURE_DASHBOARD);
- selenium.waitForPageToLoad(PAGE_LOAD);
+ //selenium.waitForPageToLoad(PAGE_LOAD);
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
selectIfNotSelected(SEL_PAGE,pageName);
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossPortalSeleniumTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossPortalSeleniumTestCase.java 2009-01-13 13:24:44 UTC (rev 12482)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossPortalSeleniumTestCase.java 2009-01-13 13:25:21 UTC (rev 12483)
@@ -26,7 +26,7 @@
protected Selenium selenium;
// Generic timeout in miliseconds
- protected static final String PAGE_LOAD = "12000000";
+ protected static final String PAGE_LOAD = "1200000";
// Element timeout in seconds
protected static final int ELEM_TIMEOUT = 220;
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossSeleniumTestListener.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossSeleniumTestListener.java 2009-01-13 13:24:44 UTC (rev 12482)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossSeleniumTestListener.java 2009-01-13 13:25:21 UTC (rev 12483)
@@ -22,32 +22,42 @@
protected static Selenium selenium;
protected static int count;
protected static boolean screenshot = false;
+ protected static boolean htmlSource = false;
static {
String ss = System.getProperty("screenshot");
- if("true".equals(ss)){
+ if ("true".equals(ss)) {
screenshot = true;
}
+
+ String sh = System.getProperty("html-src");
+ if ("true".equals(ss)) {
+ htmlSource = true;
+ }
}
-
+
@Override
public void onTestFailure(ITestResult tr) {
+
String name = "F_" + tr.getName() + "-" + count;
- try {
- PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(name + ".html")));
- out.println(selenium.getHtmlSource());
- out.close();
- } catch (IOException e1) {
- e1.printStackTrace();
+
+ if (htmlSource) {
+ try {
+ PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(name + ".html")));
+ out.println(selenium.getHtmlSource());
+ out.close();
+ } catch (IOException e1) {
+ e1.printStackTrace();
+ }
}
- if (screenshot)
+ if (screenshot){
try {
selenium.windowMaximize();
selenium.captureScreenshot(name + ".jpg");
} catch (SeleniumException e2) {
e2.printStackTrace();
}
-
+ }
count++;
}
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSSecureTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSSecureTestCase.java 2009-01-13 13:24:44 UTC (rev 12482)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSSecureTestCase.java 2009-01-13 13:25:21 UTC (rev 12483)
@@ -193,7 +193,7 @@
}
- @Test(enabled = true, description = "Set admin/secRole read permissions, login as user w secRole.")
+ @Test(enabled = true, dependsOnMethods={"testSetRoleReadPer2"}, description = "Set admin/secRole read permissions, login as user w secRole.")
public void testSetRoleReadPer1() {
login("admin", "admin");
@@ -290,7 +290,7 @@
logout();
}
- @Test(enabled = true, description = "Subpage permission test")
+ @Test(enabled = true, dependsOnMethods={"testSetRoleReadPer1"},description = "Subpage permission test")
public void testSubpageSecurity() {
selenium.open("/portal/portal/default");
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/AdminPortalTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/AdminPortalTestCase.java 2009-01-13 13:24:44 UTC (rev 12482)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/AdminPortalTestCase.java 2009-01-13 13:25:21 UTC (rev 12483)
@@ -65,7 +65,6 @@
selenium.click("link=Admin");
selenium.waitForPageToLoad(PAGE_LOAD);
-
clickIfVisible(TAB_PORTALOBJ_ID);
clickIfVisible(LINK_PORTALS_ID);
@@ -228,16 +227,22 @@
// click on the page layout
selenium.click(MessageFormat.format(PAG_TL_LAYOUT, r));
- selenium.waitForPageToLoad(PAGE_LOAD);
+ //selenium.waitForPageToLoad(PAGE_LOAD);
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
selenium.click("link=Who's online portlet");
- selenium.waitForPageToLoad("30000");
+ selenium.waitForPageToLoad(PAGE_LOAD);
selenium.type(INP_WINDOW_NAME, windowName);
selenium.click(SUB_LAYOUT_ADD_CENTER);
- selenium.waitForPageToLoad("30000");
+ selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isTextPresent(windowName));
selenium.open("/portal/auth/portal/mimikry");
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/PortletInstancesTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/PortletInstancesTestCase.java 2009-01-13 13:24:44 UTC (rev 12482)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/PortletInstancesTestCase.java 2009-01-13 13:25:21 UTC (rev 12483)
@@ -13,7 +13,7 @@
private static final String SUBMIT_SECURITY_UPDATE = "//input[contains(@id,'common-edit-security-form:update')]";
private static final String SUBMIT_SECURITY_CANCEL = "//input[contains(@id,'common-edit-security-form:cancel')]";
- private static final String LINK_20_PAGE = "Link=20";
+ private static final String LINK_20_PAGE = "link=20";
private static final String LINK_PREF_WELCOMEPORT = "//a[contains(@id,'security-JSPPortletInstance')]";
private static final String TABLE_PREF_KEY = "//form[contains(@id,'common-edit-pref-form')]/table";
@@ -27,12 +27,12 @@
private static final String INPUT_PREF_APPEND = "//input[contains(@id,'common-edit-exisiting-form:pref-input-0')]";
private static final String SUBMIT_PREF_CANCEL = "//input[contains(@id,':cancel')]";
private static final String LINK_CURUSER_PREFERENCES = "//a[contains(@id,'instances-form:preference-CurrentUsersPortletInstance')]";
- private static final String LINK_DEL_EXCEPTPORT = "//a[contains(@id,'instances-form:delete-ExceptionPortletInstance')]";
+ private static final String LINK_DEL_EXCEPTPORT = "//a[contains(@id,'instances-form:delete-GoogleMapPortletInstance')]";
private static final String SUBMIT_PI_DELETE_CONF = "//input[contains(@id,'confirm-delete-form1:delete')]";
private static final String SUBMIT_PI_DELETE_CANC = "//input[contains(@id,'confirm-delete-form1:cancel')]";
private static final String T_LINK_DELETENAME = "//a[contains(@id,''instance-display-form:locale-datatable:{0}:delete-link'')]";
private static final String T_LINK_MODIFYNAME = "//a[contains(@id,''instance-display-form:locale-datatable:{0}:edit-link'')]";
- private static final String LINK_COUNTPORT = "//a[contains(@id,'instances-form:CounterPortletInstance')]";
+ private static final String LINK_COUNTPORT = "//a[contains(@id,'instances-form:CurrentUsersPortletInstance')]";
private static final String SUBMIT_MODIFY_NAME = "//input[contains(@id,'add-display-name-form:addDisplay')]";
private static final String INPUT_NAME = "//input[contains(@id,'add-display-name-form:newName')]";
private static final String SELECT_LANGUAGE = "//select[contains(@id,'add-display-name-form:locales')]";
@@ -124,8 +124,8 @@
String instance_name = "JSPPortletInstance";
String table = "instancesTable2";
- selenium.click(LINK_20_PAGE);
- selenium.waitForPageToLoad(PAGE_LOAD);
+ //selenium.click(LINK_20_PAGE);
+ //selenium.waitForPageToLoad(PAGE_LOAD);
int r = findTableRow(table, instance_name, 0);
@@ -147,9 +147,9 @@
// then cancel
goToPI();
- selenium.click(LINK_20_PAGE);
+// selenium.click(LINK_20_PAGE);
+// selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.waitForPageToLoad(PAGE_LOAD);
r = findTableRow(table, instance_name, 0);
selenium.click(MessageFormat.format(LNK_SEC_BUTTON, r));
selenium.waitForPageToLoad("30000");
@@ -167,8 +167,8 @@
// then really stop the greetings portlet
goToPI();
//selenium.setSpeed("5000");
- selenium.click(LINK_20_PAGE);
- selenium.waitForPageToLoad(PAGE_LOAD);
+// selenium.click(LINK_20_PAGE);
+ // selenium.waitForPageToLoad(PAGE_LOAD);
r = findTableRow(table, instance_name, 0);
selenium.click(MessageFormat.format(LNK_SEC_BUTTON, r));
selenium.waitForPageToLoad("30000");
17 years, 3 months
JBoss Portal SVN: r12479 - in modules/cms/trunk/cms-jackrabbit/src: main/java/org/jboss/portal/cms/hibernate/state and 5 other directories.
by portal-commits@lists.jboss.org
Author: sohil.shah(a)jboss.com
Date: 2009-01-13 04:14:42 -0500 (Tue, 13 Jan 2009)
New Revision: 12479
Added:
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/MaterializedBlobType.java
Modified:
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/HibernateStore.java
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/state/JBossCachePersistenceManager.java
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/impl/jcr/JCRCMS.java
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/impl/jcr/jackrabbit/JackrabbitJCRService.java
modules/cms/trunk/cms-jackrabbit/src/test/java/org/jboss/portal/cms/test/TestJackrabbit.java
modules/cms/trunk/cms-jackrabbit/src/test/java/org/jboss/portal/cms/test/commands/AbstractCommandTestCase.java
modules/cms/trunk/cms-jackrabbit/src/test/resources/domain.hbm.xml
modules/cms/trunk/cms-jackrabbit/src/test/resources/jboss-unit.xml
Log:
code backup (a bit more stable, passes the testsuite locally)...more code cleanup to follow
Modified: modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/HibernateStore.java
===================================================================
--- modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/HibernateStore.java 2009-01-13 06:57:04 UTC (rev 12478)
+++ modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/HibernateStore.java 2009-01-13 09:14:42 UTC (rev 12479)
@@ -37,7 +37,6 @@
import org.jboss.portal.common.io.IOTools;
import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -869,13 +868,9 @@
List rs = query.list();
//
Iterator iter = rs.iterator();
- java.sql.Blob blob = (java.sql.Blob)iter.next();
- /*
- InputStream is = blob.getBinaryStream();
- Tools.safeClose(is);
- */
- BlobInputStream blobIs = new BlobInputStream(blob);
- return blobIs;
+ byte[] blob = (byte[])iter.next();
+
+ return new ByteArrayInputStream(blob);
}
catch (Exception e)
{
@@ -991,7 +986,6 @@
session.save(repoEntry);
}
- //session.flush();
}
catch (Exception e)
{
@@ -1027,7 +1021,6 @@
RepositoryEntry repoEntry = new RepositoryEntry(parentDir, name, IOTools.getBytes(in), System.currentTimeMillis(), length);
session.save(repoEntry);
}
- //session.flush();
}
catch (Exception e)
{
@@ -1196,7 +1189,6 @@
session.save(repoEntry);
}
- //session.flush();
}
catch (Exception e)
{
@@ -1232,7 +1224,6 @@
RepositoryEntry repoEntry = new RepositoryEntry(parentDir, name, IOTools.getBytes(in), System.currentTimeMillis(), length);
session.save(repoEntry);
}
- //session.flush();
}
catch (Exception e)
{
@@ -1491,7 +1482,6 @@
RepositoryEntry repoEntry = new RepositoryEntry(parentDir, name, null, System.currentTimeMillis(), 0);
session.save(repoEntry);
}
- //session.flush();
}
catch (Exception e)
{
@@ -1550,7 +1540,7 @@
}
finally
{
-// resetStatement(stmt);
+ resetStatement(stmt);
}
}
*/
@@ -1604,95 +1594,11 @@
}
finally
{
-// resetStatement(stmt);
+ resetStatement(stmt);
}
}
*/
}
-
-// Hibernate additions
-/*
- private class Blah
- {
- Session session;
- Transaction tx;
- public Blah()
- {
- }
- public void open()
- {
- session = hibernateSessionFactory.openSession();
- tx = session.beginTransaction();
- }
- public void close()
- {
- try
- {
- tx.commit();
- }
- finally
- {
- session.close();
- }
- }
- }
-*/
- /*
- public static class BlobInputStream extends ByteArrayInputStream
- {
-
- public BlobInputStream(Blob blob) throws Exception
- {
- super(getBytes(blob));
- }
-
- private static byte[] getBytes(Blob blob) throws Exception
- {
- InputStream in = null;
- try
- {
- in = blob.getBinaryStream();
- ByteArrayOutputStream out = new ByteArrayOutputStream(in.available());
- Tools.copy(in, out);
- return out.toByteArray();
- }
- finally
- {
- Tools.safeClose(in);
- }
- }
-
- }
-*/
-
-
- public static class BlobInputStream extends ByteArrayInputStream
- {
-
- public BlobInputStream(Blob blob) throws Exception
- {
- super(getBytes(blob));
- }
-
- private static byte[] getBytes(Blob blob) throws Exception
- {
- InputStream in = null;
- try
- {
- in = blob.getBinaryStream();
- ByteArrayOutputStream out = new ByteArrayOutputStream(in.available());
- IOTools.copy(in, out);
- return out.toByteArray();
- }
- finally
- {
- IOTools.safeClose(in);
- }
- }
-
-
- }
-
}
/*
* Copyright 2004-2005 The Apache Software Foundation or its licensors,
Added: modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/MaterializedBlobType.java
===================================================================
--- modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/MaterializedBlobType.java (rev 0)
+++ modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/MaterializedBlobType.java 2009-01-13 09:14:42 UTC (rev 12479)
@@ -0,0 +1,33 @@
+package org.jboss.portal.cms.hibernate;
+
+import java.sql.Types;
+
+import org.hibernate.type.AbstractBynaryType;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class MaterializedBlobType extends AbstractBynaryType {
+
+ public int sqlType() {
+ return Types.BLOB;
+ }
+
+ public String getName() {
+ return "materialized-blob";
+ }
+
+ public Class getReturnedClass() {
+ return byte[].class;
+ }
+
+ protected Object toExternalFormat(byte[] bytes) {
+ return bytes;
+ }
+
+ protected byte[] toInternalFormat(Object bytes) {
+ return ( byte[] ) bytes;
+ }
+}
Modified: modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/state/JBossCachePersistenceManager.java
===================================================================
--- modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/state/JBossCachePersistenceManager.java 2009-01-13 06:57:04 UTC (rev 12478)
+++ modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/hibernate/state/JBossCachePersistenceManager.java 2009-01-13 09:14:42 UTC (rev 12479)
@@ -1548,11 +1548,7 @@
String msg = "failed to write node state: " + blobId;
log.error(msg, e);
throw new ItemStateException(msg, e);
- }
- finally
- {
- //session.flush();
- }
+ }
}
else
// insert
@@ -1583,11 +1579,7 @@
String msg = "failed to write node state: " + blobId;
log.error(msg, e);
throw new ItemStateException(msg, e);
- }
- finally
- {
- //session.flush();
- }
+ }
}
}
@@ -1619,11 +1611,7 @@
String msg = "failed to delete binval: " + blobId;
log.error(msg, e);
throw new ItemStateException(msg, e);
- }
- finally
- {
- //session.flush();
- }
+ }
}
}
}
Modified: modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/impl/jcr/JCRCMS.java
===================================================================
--- modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/impl/jcr/JCRCMS.java 2009-01-13 06:57:04 UTC (rev 12478)
+++ modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/impl/jcr/JCRCMS.java 2009-01-13 09:14:42 UTC (rev 12479)
@@ -39,6 +39,7 @@
import org.jboss.portal.cms.model.File;
import org.jboss.portal.cms.model.Folder;
import org.jboss.portal.cms.util.RepositoryUtil;
+import org.jboss.portal.cms.util.HibernateUtil;
import org.jboss.portal.cms.workflow.ApprovePublish;
import org.jboss.portal.cms.security.AuthorizationManager;
import org.jboss.portal.common.invocation.InterceptorStackFactory;
@@ -57,6 +58,8 @@
import org.w3c.dom.Document;
import org.w3c.dom.Element;
+import org.hibernate.Transaction;
+
import javax.jcr.Repository;
import javax.jcr.Session;
import javax.transaction.xa.XAResource;
@@ -69,6 +72,7 @@
import java.util.LinkedList;
import java.util.Locale;
import java.util.Set;
+
import javax.transaction.TransactionManager;
import javax.transaction.Status;
import javax.naming.InitialContext;
@@ -106,6 +110,8 @@
private String jndiName;
private JNDI.Binding jndiBinding;
+
+ private String cmsSessionFactory;
private InvocationHandler handler = new InvocationHandler()
{
@@ -134,10 +140,7 @@
{
turnOffWorkflow.set(null);
}
-
- /**
- *
- */
+
protected static ThreadLocal applyUISecurityFilter = new ThreadLocal();
public static void enableUISecurityFilter()
{
@@ -286,45 +289,295 @@
{
this.jndiName = jndiName;
}
+
+ public CommandFactory getCommandFactory()
+ {
+ return commandFactory;
+ }
- /** CMS Start */
+ public Repository getRepository()
+ {
+ return jcr.getRepository();
+ }
+
+ /** @return */
+ public boolean isWorkflowActivated()
+ {
+ return (this.approvePublishWorkflow != null);
+ }
+
+ public void setStackFactory(InterceptorStackFactory stackFactory)
+ {
+ this.stackFactory = stackFactory;
+ }
+
+ public InterceptorStackFactory getStackFactory()
+ {
+ return stackFactory;
+ }
+
+ public String getCmsSessionFactory()
+ {
+ return this.cmsSessionFactory;
+ }
+
+ public void setCmsSessionFactory(String cmsSessionFactory)
+ {
+ this.cmsSessionFactory = cmsSessionFactory;
+ }
+ //-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
public void startService() throws Exception
{
- if (this.jndiName != null)
+ org.hibernate.Session session = HibernateUtil.getSessionFactory(this.cmsSessionFactory).openSession();
+ Transaction tx = session.beginTransaction();
+ try
+ {
+
+ if (this.jndiName != null)
+ {
+ jndiBinding = new JNDI.Binding(jndiName, this);
+ jndiBinding.bind();
+ }
+
+ //check the version of jbosscache being run
+ String cacheVersion = Version.getVersionString(Version.getVersionShort());
+ log.info("JBossCache Version=" + cacheVersion);
+
+ // See how long it takes us to start up
+ StopWatch watch = new StopWatch(true);
+ log.info("Starting JCR CMS");
+ //addInterceptors();
+ startJCR();
+ watch.stop();
+ log.info("Started JCR CMS in: " + watch);
+
+ tx.commit();
+ }
+ catch(Exception e)
+ {
+ log.error(this, e);
+ if(tx != null)
+ {
+ tx.rollback();
+ }
+ }
+ finally
+ {
+ if(session !=null && session.isOpen())
+ {
+ session.close();
+ }
+ }
+ }
+
+ public void stopService()
+ {
+ org.hibernate.Session session = HibernateUtil.getSessionFactory(this.cmsSessionFactory).openSession();
+ Transaction tx = session.beginTransaction();
+ try
+ {
+ if (jndiBinding != null)
+ {
+ jndiBinding.unbind();
+ jndiBinding = null;
+ }
+ log.info("Stopping JCR CMS");
+ stopJCR();
+
+ tx.commit();
+ }
+ catch(Exception e)
+ {
+ if(tx != null)
+ {
+ try
+ {
+ tx.rollback();
+ }
+ catch(Exception tme)
+ {
+ log.error(this, tme);
+ }
+ }
+ }
+ finally
+ {
+ if(session !=null && session.isOpen())
+ {
+ session.close();
+ }
+ }
+ }
+
+ public Object execute(Command cmd) throws CMSException
+ {
+ org.apache.jackrabbit.core.XASession session = null;
+ try
{
- jndiBinding = new JNDI.Binding(jndiName, this);
- jndiBinding.bind();
+ session = (org.apache.jackrabbit.core.XASession)jcr.login("anonid", "");
}
+ catch (Exception e)
+ {
+ throw new RuntimeException(e); // Fixme
+ }
+ // get XAResource
+ XAResource xares = session.getXAResource();
- //check the version of jbosscache being run
- String cacheVersion = Version.getVersionString(Version.getVersionShort());
- log.info("JBossCache Version=" + cacheVersion);
+ // create dummy Xid
+ Xid xid = new Xid()
+ {
+ public byte[] getBranchQualifier()
+ {
+ return new byte[0];
+ }
- // See how long it takes us to start up
- StopWatch watch = new StopWatch(true);
- log.info("Starting JCR CMS");
- //addInterceptors();
- startJCR();
- watch.stop();
- log.info("Started JCR CMS in: " + watch);
- }
+ public int getFormatId()
+ {
+ return 0;
+ }
+ public byte[] getGlobalTransactionId()
+ {
+ return new byte[0];
+ }
+ };
- /** Shuts down the repo and unregisters it */
- public void stopService()
- {
- if (jndiBinding != null)
+ Object obj = null;
+ boolean isClusterDelegatedRequest = false; //used to indicate this request is from another cluster node instead of the master node
+ boolean clusterWorkflowStatus = false;
+ org.hibernate.Session hibernateSession = HibernateUtil.getSessionFactory(this.cmsSessionFactory).openSession();
+ Transaction tx = hibernateSession.beginTransaction();
+ try
+ {
+ xares.start(xid, XAResource.TMNOFLAGS);
+
+ //Check and make sure in the case of a clustered call, the Identity propagated
+ //as part of the invocation is handled correctly
+ JCRCommandContext propagatedContext = (JCRCommandContext)((JCRCommand)cmd).getContext();
+ if (propagatedContext != null)
+ {
+ CMSUser propagatedUser = (CMSUser)propagatedContext.getClusterContextInfo("user");
+ if (propagatedUser != null)
+ {
+ JCRCMS.getUserInfo().set(propagatedUser);
+ isClusterDelegatedRequest = true;
+ }
+ Boolean workflowStatus = (Boolean)propagatedContext.getClusterContextInfo("workflowStatus");
+ if (workflowStatus != null)
+ {
+ JCRCMS.turnOffWorkflow();
+ clusterWorkflowStatus = true;
+ }
+ Boolean enableUISecurityFilter = (Boolean)propagatedContext.getClusterContextInfo("enableUISecurityFilter");
+ if(enableUISecurityFilter != null)
+ {
+ JCRCMS.enableUISecurityFilter();
+ }
+ Set<String> roles = (Set<String>)propagatedContext.getClusterContextInfo("roles");
+ if(roles != null)
+ {
+ JCRCMS.setRoles(roles);
+ }
+ }
+
+ // .... add new nodes & properties and save them
+ JCRCommand jcrCmd = (JCRCommand)cmd;
+ JCRCommandContext ctx = new JCRCommandContext(session, commandFactory, defaultLocale);
+ jcrCmd.setContext(ctx);
+
+ ctx.setAttribute(JCRCommandContext.scope, "user", JCRCMS.getUserInfo().get());
+ Object isWorkflowOff = JCRCMS.turnOffWorkflow.get();
+ if (this.approvePublishWorkflow != null //this checks and makes sure workflow is activated for the CMS
+ &&
+ isWorkflowOff == null //this checks and makes sure workflow is not turned off only for this particular request
+ )
+ {
+ ctx.setAttribute(JCRCommandContext.scope, "approvePublishWorkflow", this.approvePublishWorkflow);
+ }
+
+
+ if ((stackFactory != null) && (stackFactory.getInterceptorStack().getLength() != 0))
+ {
+ jcrCmd.setHandler(handler);
+ obj = jcrCmd.invoke(stackFactory.getInterceptorStack());
+ jcrCmd.setHandler(null);
+ }
+ else
+ {
+ obj = jcrCmd.execute();
+ }
+
+ //committ the transaction
+ xares.end(xid, XAResource.TMSUCCESS);
+ xares.prepare(xid);
+ session.save();
+ xares.commit(xid, false);
+
+ tx.commit();
+ }
+ catch (Exception e)
{
- jndiBinding.unbind();
- jndiBinding = null;
+ log.error(this, e);
+ try
+ {
+ xares.rollback(xid);
+ }
+ catch (Exception ex)
+ {
+ //we tried to roll it back...not sure what more we can do here
+ throw new CMSException(ex);
+ }
+
+ if(tx != null)
+ {
+ try
+ {
+ tx.rollback();
+ }
+ catch(Exception rbe)
+ {
+ log.error(this, rbe);
+ }
+ }
+
+ if (e instanceof CMSException)
+ {
+ throw (CMSException)e;
+ }
+ else if (e instanceof RuntimeException)
+ {
+ throw (RuntimeException)e;
+ }
+ else
+ {
+ throw new CMSException(e);
+ }
}
- log.info("Stopping JCR CMS");
- stopJCR();
-// removeInterceptors();
+ finally
+ {
+ if (session != null)
+ {
+ //must do this otherwise, the whole cms will hang
+ session.logout();
+ }
+ if (isClusterDelegatedRequest)
+ {
+ JCRCMS.getUserInfo().set(null);
+ }
+ if (clusterWorkflowStatus)
+ {
+ JCRCMS.turnOnWorkflow();
+ }
+ if(hibernateSession !=null && hibernateSession.isOpen())
+ {
+ hibernateSession.close();
+ }
+ }
+ return obj;
}
-
- public void startJCR() throws Exception
+ //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ private void startJCR() throws Exception
{
// Serialize the embedded configuration
DOMImplementation impl = config.getOwnerDocument().getImplementation();
@@ -357,7 +610,7 @@
}
}
- public void stopJCR()
+ private void stopJCR()
{
jcr.stop();
jcr = null;
@@ -383,9 +636,12 @@
}
}
- // /**
- /** Loads content from sar and adds it to the repo. */
- public void createContent() throws Exception
+ /**
+ * Initilizes the repository with initial/boot content
+ *
+ * @throws Exception
+ */
+ private void createContent() throws Exception
{
log.info("Creating default CMS content.");
@@ -523,199 +779,5 @@
//
URLNavigator.visit(root, visitor);
log.info("Default content created.");
- }
-
-
- public CommandFactory getCommandFactory()
- {
- return commandFactory;
- }
-
-
- public Repository getRepository()
- {
- return jcr.getRepository();
- }
-
- public Object execute(Command cmd) throws CMSException
- {
- org.apache.jackrabbit.core.XASession session = null;
- try
- {
- session = (org.apache.jackrabbit.core.XASession)jcr.login("anonid", "");
- }
- catch (Exception e)
- {
- throw new RuntimeException(e); // Fixme
- }
- // get XAResource
- XAResource xares = session.getXAResource();
-
- // create dummy Xid
- Xid xid = new Xid()
- {
- public byte[] getBranchQualifier()
- {
- return new byte[0];
- }
-
- public int getFormatId()
- {
- return 0;
- }
-
- public byte[] getGlobalTransactionId()
- {
- return new byte[0];
- }
- };
-
- Object obj = null;
- boolean isClusterDelegatedRequest = false; //used to indicate this request is from another cluster node instead of the master node
- boolean clusterWorkflowStatus = false;
- TransactionManager tm = null;
- boolean isStartedHere = false;
- try
- {
- tm = (TransactionManager)new InitialContext().lookup("java:/TransactionManager");
- if(tm.getStatus() == Status.STATUS_NO_TRANSACTION)
- {
- tm.begin();
- isStartedHere = true;
- }
-
- xares.start(xid, XAResource.TMNOFLAGS);
-
- //Check and make sure in the case of a clustered call, the Identity propagated
- //as part of the invocation is handled correctly
- JCRCommandContext propagatedContext = (JCRCommandContext)((JCRCommand)cmd).getContext();
- if (propagatedContext != null)
- {
- CMSUser propagatedUser = (CMSUser)propagatedContext.getClusterContextInfo("user");
- if (propagatedUser != null)
- {
- JCRCMS.getUserInfo().set(propagatedUser);
- isClusterDelegatedRequest = true;
- }
- Boolean workflowStatus = (Boolean)propagatedContext.getClusterContextInfo("workflowStatus");
- if (workflowStatus != null)
- {
- JCRCMS.turnOffWorkflow();
- clusterWorkflowStatus = true;
- }
- Boolean enableUISecurityFilter = (Boolean)propagatedContext.getClusterContextInfo("enableUISecurityFilter");
- if(enableUISecurityFilter != null)
- {
- JCRCMS.enableUISecurityFilter();
- }
- Set<String> roles = (Set<String>)propagatedContext.getClusterContextInfo("roles");
- if(roles != null)
- {
- JCRCMS.setRoles(roles);
- }
- }
-
- // .... add new nodes & properties and save them
- JCRCommand jcrCmd = (JCRCommand)cmd;
- JCRCommandContext ctx = new JCRCommandContext(session, commandFactory, defaultLocale);
- jcrCmd.setContext(ctx);
-
- ctx.setAttribute(JCRCommandContext.scope, "user", JCRCMS.getUserInfo().get());
- Object isWorkflowOff = JCRCMS.turnOffWorkflow.get();
- if (this.approvePublishWorkflow != null //this checks and makes sure workflow is activated for the CMS
- &&
- isWorkflowOff == null //this checks and makes sure workflow is not turned off only for this particular request
- )
- {
- ctx.setAttribute(JCRCommandContext.scope, "approvePublishWorkflow", this.approvePublishWorkflow);
- }
-
-
- if ((stackFactory != null) && (stackFactory.getInterceptorStack().getLength() != 0))
- {
- jcrCmd.setHandler(handler);
- obj = jcrCmd.invoke(stackFactory.getInterceptorStack());
- jcrCmd.setHandler(null);
- }
- else
- {
- obj = jcrCmd.execute();
- }
-
- //committ the transaction
- xares.end(xid, XAResource.TMSUCCESS);
- xares.prepare(xid);
- session.save();
- xares.commit(xid, false);
-
- if(isStartedHere)
- {
- tm.getTransaction().commit();
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- try
- {
- xares.rollback(xid);
- }
- catch (Exception ex)
- {
- //we tried to roll it back...not sure what more we can do here
- throw new CMSException(ex);
- }
-
- if(tm != null)
- {
- try{tm.getTransaction().rollback();}catch(Exception tme){}
- }
-
- if (e instanceof CMSException)
- {
- throw (CMSException)e;
- }
- else if (e instanceof RuntimeException)
- {
- throw (RuntimeException)e;
- }
- else
- {
- throw new CMSException(e);
- }
- }
- finally
- {
- if (session != null)
- {
- //must do this otherwise, the whole cms will hang
- session.logout();
- }
- if (isClusterDelegatedRequest)
- {
- JCRCMS.getUserInfo().set(null);
- }
- if (clusterWorkflowStatus)
- {
- JCRCMS.turnOnWorkflow();
- }
- }
- return obj;
- }
-
- /** @return */
- public boolean isWorkflowActivated()
- {
- return (this.approvePublishWorkflow != null);
- }
-
- public void setStackFactory(InterceptorStackFactory stackFactory)
- {
- this.stackFactory = stackFactory;
- }
-
- public InterceptorStackFactory getStackFactory()
- {
- return stackFactory;
- }
+ }
}
Modified: modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/impl/jcr/jackrabbit/JackrabbitJCRService.java
===================================================================
--- modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/impl/jcr/jackrabbit/JackrabbitJCRService.java 2009-01-13 06:57:04 UTC (rev 12478)
+++ modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/impl/jcr/jackrabbit/JackrabbitJCRService.java 2009-01-13 09:14:42 UTC (rev 12479)
@@ -50,11 +50,7 @@
import javax.jcr.version.OnParentVersionAction;
import java.io.StringReader;
-import javax.transaction.TransactionManager;
-import javax.transaction.Status;
-import javax.naming.InitialContext;
-
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 6469 $
@@ -104,82 +100,38 @@
public void start() throws Exception
{
- TransactionManager tm = null;
- boolean isStartedHere = false;
- try
- {
- tm = (TransactionManager)new InitialContext().lookup("java:/TransactionManager");
- if(tm.getStatus() == Status.STATUS_NO_TRANSACTION)
- {
- tm.begin();
- isStartedHere = true;
- }
-
- log.debug("JackRabbit configuration: " + config);
- // Create repository
- StringReader reader = new StringReader(config);
- InputSource src = new InputSource(reader);
- RepositoryConfig cfg = RepositoryConfig.create(src, homeDir);
- repository = RepositoryImpl.create(cfg);
- log.info("Repository '" + repositoryName + "' created");
-
- // Check portalcms-namespace nodetypes exist
- if (!nodeTypesExist())
- {
- log.info("The repository does not know about CMS node types");
- registerCustomNodeTypes(repository);
- }
- else
- {
- log.info("The repository has already the CMS node types registered");
- }
-
- if(isStartedHere)
- {
- tm.getTransaction().commit();
- }
- }
- catch(Exception e)
- {
- if(tm != null)
- {
- tm.getTransaction().rollback();
- }
- throw e;
- }
+ log.debug("JackRabbit configuration: " + config);
+ // Create repository
+ StringReader reader = new StringReader(config);
+ InputSource src = new InputSource(reader);
+ RepositoryConfig cfg = RepositoryConfig.create(src, homeDir);
+ repository = RepositoryImpl.create(cfg);
+ log.info("Repository '" + repositoryName + "' created");
+
+ // Check portalcms-namespace nodetypes exist
+ if (!nodeTypesExist())
+ {
+ log.info("The repository does not know about CMS node types");
+ registerCustomNodeTypes(repository);
+ }
+ else
+ {
+ log.info("The repository has already the CMS node types registered");
+ }
}
public void stop()
- {
- TransactionManager tm = null;
- boolean isStartedHere = false;
- try
- {
- tm = (TransactionManager)new InitialContext().lookup("java:/TransactionManager");
- if(tm.getStatus() == Status.STATUS_NO_TRANSACTION)
- {
- tm.begin();
- isStartedHere = true;
- }
-
+ {
+ try
+ {
log.info("Shutting down repository");
repository.shutdown();
- log.info("Repository shut down successfully");
-
- if(isStartedHere)
- {
- tm.getTransaction().commit();
- }
+ log.info("Repository shut down successfully");
}
catch (Exception e)
- {
- if(tm != null)
- {
- try{tm.getTransaction().rollback();}catch(Exception ex){}
- }
- e.printStackTrace();
+ {
log.error("Failed to unregister repository. Some locks may persist!", e);
- }
+ }
}
/** Check for existence of namespace nodetypes. */
Modified: modules/cms/trunk/cms-jackrabbit/src/test/java/org/jboss/portal/cms/test/TestJackrabbit.java
===================================================================
--- modules/cms/trunk/cms-jackrabbit/src/test/java/org/jboss/portal/cms/test/TestJackrabbit.java 2009-01-13 06:57:04 UTC (rev 12478)
+++ modules/cms/trunk/cms-jackrabbit/src/test/java/org/jboss/portal/cms/test/TestJackrabbit.java 2009-01-13 09:14:42 UTC (rev 12479)
@@ -67,21 +67,24 @@
LoaderResource res = new CLResourceLoader().getResource("jcr/repository.xml");
String config = res.asString();
+ TransactionManager tm = (TransactionManager)new InitialContext().lookup("java:/TransactionManager");
+ tm.begin();
jcr = new JackrabbitJCRService();
jcr.setRepositoryName("repo");
jcr.setConfig(config);
jcr.setHomeDir("repotest-" + getDataSourceName());
jcr.start();
+ tm.commit();
}
@Destroy
public void tearDown() throws Exception
- {
+ {
TransactionManager tm = (TransactionManager)new InitialContext().lookup("java:/TransactionManager");
- tm.commit();
-
+ tm.begin();
jcr.stop();
jcr = null;
+ tm.commit();
}
@Test
@@ -92,11 +95,10 @@
//
Session session = null;
- TransactionManager tm = null;
+ TransactionManager tm = (TransactionManager)new InitialContext().lookup("java:/TransactionManager");
try
{
- tm = (TransactionManager)new InitialContext().lookup("java:/TransactionManager");
- tm.begin();
+ tm.begin();
session = jcr.login("anonid", "");
Workspace wosp = session.getWorkspace();
@@ -123,8 +125,7 @@
//
try
- {
- tm = (TransactionManager)new InitialContext().lookup("java:/TransactionManager");
+ {
tm.begin();
session = jcr.login("anonid", "");
@@ -150,8 +151,7 @@
//
try
- {
- tm = (TransactionManager)new InitialContext().lookup("java:/TransactionManager");
+ {
tm.begin();
session = jcr.login("anonid", "");
Modified: modules/cms/trunk/cms-jackrabbit/src/test/java/org/jboss/portal/cms/test/commands/AbstractCommandTestCase.java
===================================================================
--- modules/cms/trunk/cms-jackrabbit/src/test/java/org/jboss/portal/cms/test/commands/AbstractCommandTestCase.java 2009-01-13 06:57:04 UTC (rev 12478)
+++ modules/cms/trunk/cms-jackrabbit/src/test/java/org/jboss/portal/cms/test/commands/AbstractCommandTestCase.java 2009-01-13 09:14:42 UTC (rev 12479)
@@ -71,6 +71,7 @@
service.setRepositoryName("repo");
service.setHomeDir("repotest-" + getDataSourceName());
service.setJNDIName("java:portal/CMS");
+ service.setCmsSessionFactory("java:/SessionFactory");
service.startService();
}
Modified: modules/cms/trunk/cms-jackrabbit/src/test/resources/domain.hbm.xml
===================================================================
--- modules/cms/trunk/cms-jackrabbit/src/test/resources/domain.hbm.xml 2009-01-13 06:57:04 UTC (rev 12478)
+++ modules/cms/trunk/cms-jackrabbit/src/test/resources/domain.hbm.xml 2009-01-13 09:14:42 UTC (rev 12479)
@@ -41,7 +41,7 @@
<property
name="data"
column="BINVAL_DATA"
- type="binary"
+ type="org.jboss.portal.cms.hibernate.MaterializedBlobType"
length="100000000"
not-null="true"/>
</class>
@@ -117,7 +117,7 @@
<property
name="data"
column="BINVAL_DATA"
- type="binary"
+ type="org.jboss.portal.cms.hibernate.MaterializedBlobType"
length="100000000"
not-null="true"/>
</class>
@@ -198,7 +198,7 @@
length="245"/>
<property name="data"
column="FSENTRY_DATA"
- type="binary"
+ type="org.jboss.portal.cms.hibernate.MaterializedBlobType"
length="100000000"
not-null="false"/>
<property name="lastmod"
@@ -230,7 +230,7 @@
length="245"/>
<property name="data"
column="FSENTRY_DATA"
- type="binary"
+ type="org.jboss.portal.cms.hibernate.MaterializedBlobType"
length="100000000"
not-null="false"/>
<property name="lastmod"
@@ -262,7 +262,7 @@
length="245"/>
<property name="data"
column="FSENTRY_DATA"
- type="binary"
+ type="org.jboss.portal.cms.hibernate.MaterializedBlobType"
length="100000000"
not-null="false"/>
<property name="lastmod"
Modified: modules/cms/trunk/cms-jackrabbit/src/test/resources/jboss-unit.xml
===================================================================
--- modules/cms/trunk/cms-jackrabbit/src/test/resources/jboss-unit.xml 2009-01-13 06:57:04 UTC (rev 12478)
+++ modules/cms/trunk/cms-jackrabbit/src/test/resources/jboss-unit.xml 2009-01-13 09:14:42 UTC (rev 12479)
@@ -6,13 +6,14 @@
<pojo>
<parameter name="datasources" value="datasources.xml"/>
<parameter name="dataSourceName">
- <value>hsqldb</value>
+ <value>hsqldb</value>
+ <!--
<value>oracle10g</value>
<value>mysql5</value>
- <value>postgresql8</value>
+ <value>postgresql8</value>
+ -->
</parameter>
<parameter name="hibernateConfig" value="hibernates.xml"/>
- <!--
<test >
<class name="org.jboss.portal.cms.test.commands.TestFileArchiveUpload"/>
</test>
@@ -61,11 +62,9 @@
<test >
<class name="org.jboss.portal.cms.test.commands.TestSearch"/>
</test>
- -->
<test >
<class name="org.jboss.portal.cms.test.TestJackrabbit"/>
</test>
- <!--
<test >
<class name="org.jboss.portal.cms.test.TestRegEx"/>
</test>
@@ -75,21 +74,21 @@
<test >
<class name="org.jboss.portal.cms.test.commands.TestRepositoryBootStrap"/>
</test>
- -->
</pojo>
<pojo>
<parameter name="datasources" value="datasources.xml"/>
<parameter name="dataSourceName">
- <value>hsqldb</value>
+ <value>hsqldb</value>
+ <!--
<value>oracle10g</value>
<value>mysql5</value>
- <value>postgresql8</value>
+ <value>postgresql8</value>
+ -->
</parameter>
<parameter name="hibernateConfig" value="hibernates.xml"/>
<parameter name="standardIdentityConfig" value="standardidentity-config.xml"/>
<parameter name="identityConfig" value="db-config.xml"/>
- <!--
<test >
<class name="org.jboss.portal.cms.test.security.TestManageAccess"/>
</test>
@@ -102,21 +101,21 @@
<test >
<class name="org.jboss.portal.cms.test.security.TestNewReadCommand"/>
</test>
- -->
</pojo>
<pojo>
<parameter name="datasources" value="datasources.xml"/>
<parameter name="dataSourceName">
<value>hsqldb</value>
+ <!--
<value>oracle10g</value>
<value>mysql5</value>
- <value>postgresql8</value>
+ <value>postgresql8</value>
+ -->
</parameter>
<parameter name="hibernateConfig" value="hibernates.xml"/>
<parameter name="standardIdentityConfig" value="standardidentity-config.xml"/>
<parameter name="identityConfig" value="db-config.xml"/>
- <!--
<test >
<class name="org.jboss.portal.cms.test.workflow.TestApprovedPublish"/>
</test>
@@ -126,21 +125,5 @@
<test >
<class name="org.jboss.portal.cms.test.workflow.TestWorkflowEnvironment"/>
</test>
- -->
- </pojo>
-
- <!--
- <pojo>
- <parameter name="datasources" value="datasources.xml"/>
- <parameter name="dataSourceName">
- <value>hsqldb</value>
- <value>oracle10g</value>
- <value>mysql5</value>
- </parameter>
- <parameter name="hibernateConfig" value="hibernates.xml"/>
- <test >
- <class name="org.jboss.portal.cms.test.commands.TestFileArchiveUpload"/>
- </test>
- </pojo>
- -->
+ </pojo>
</jboss-unit>
17 years, 3 months