@Test public void testActionableDynamicQuery() throws Exception { final IntegerWrapper count = new IntegerWrapper(); ActionableDynamicQuery actionableDynamicQuery = ReleaseLocalServiceUtil.getActionableDynamicQuery(); actionableDynamicQuery.setPerformActionMethod( new ActionableDynamicQuery.PerformActionMethod() { @Override public void performAction(Object object) { Release release = (Release) object; Assert.assertNotNull(release); count.increment(); } }); actionableDynamicQuery.performActions(); Assert.assertEquals(count.getValue(), _persistence.countAll()); }
public static void upgrade() throws Exception { // Disable database caching before upgrade if (_log.isDebugEnabled()) { _log.debug("Disable cache registry"); } CacheRegistryUtil.setActive(false); // Check release int buildNumber = ReleaseLocalServiceUtil.getBuildNumberOrCreate(); if (buildNumber > ReleaseInfo.getParentBuildNumber()) { StringBundler sb = new StringBundler(6); sb.append("Attempting to deploy an older Liferay Portal version. "); sb.append("Current build version is "); sb.append(buildNumber); sb.append(" and attempting to deploy version "); sb.append(ReleaseInfo.getParentBuildNumber()); sb.append("."); throw new IllegalStateException(sb.toString()); } else if (buildNumber < ReleaseInfo.RELEASE_5_2_3_BUILD_NUMBER) { String msg = "You must first upgrade to Liferay Portal 5.2.3"; System.out.println(msg); throw new RuntimeException(msg); } // Reload SQL CustomSQLUtil.reloadCustomSQL(); SQLTransformer.reloadSQLTransformer(); // Upgrade if (_log.isDebugEnabled()) { _log.debug("Update build " + buildNumber); } _checkPermissionAlgorithm(); _checkReleaseState(); if (PropsValues.UPGRADE_DATABASE_TRANSACTIONS_DISABLED) { _disableTransactions(); } try { StartupHelperUtil.upgradeProcess(buildNumber); } catch (Exception e) { _updateReleaseState(ReleaseConstants.STATE_UPGRADE_FAILURE); throw e; } finally { if (PropsValues.UPGRADE_DATABASE_TRANSACTIONS_DISABLED) { _enableTransactions(); } } // Update company key if (StartupHelperUtil.isUpgraded()) { if (_log.isDebugEnabled()) { _log.debug("Update company key"); } _updateCompanyKey(); } // Check class names if (_log.isDebugEnabled()) { _log.debug("Check class names"); } ClassNameLocalServiceUtil.checkClassNames(); // Check resource actions if (_log.isDebugEnabled()) { _log.debug("Check resource actions"); } ResourceActionLocalServiceUtil.checkResourceActions(); // Delete temporary images if (_log.isDebugEnabled()) { _log.debug("Delete temporary images"); } _deleteTempImages(); // Clear the caches only if the upgrade process was run if (_log.isDebugEnabled()) { _log.debug("Clear cache if upgrade process was run"); } if (StartupHelperUtil.isUpgraded()) { MultiVMPoolUtil.clear(); } }
public static void verify() throws Exception { // Check release Release release = null; try { release = ReleaseLocalServiceUtil.getRelease( ReleaseConstants.DEFAULT_SERVLET_CONTEXT_NAME, ReleaseInfo.getParentBuildNumber()); } catch (PortalException pe) { release = ReleaseLocalServiceUtil.addRelease( ReleaseConstants.DEFAULT_SERVLET_CONTEXT_NAME, ReleaseInfo.getParentBuildNumber()); } _checkReleaseState(); // Update indexes if (PropsValues.DATABASE_INDEXES_UPDATE_ON_STARTUP) { StartupHelperUtil.setDropIndexes(true); StartupHelperUtil.updateIndexes(); } else if (StartupHelperUtil.isUpgraded()) { StartupHelperUtil.updateIndexes(); } // Verify if (PropsValues.VERIFY_DATABASE_TRANSACTIONS_DISABLED) { _disableTransactions(); } try { StartupHelperUtil.verifyProcess(release.isVerified()); } catch (Exception e) { _updateReleaseState(ReleaseConstants.STATE_VERIFY_FAILURE); throw e; } finally { if (PropsValues.VERIFY_DATABASE_TRANSACTIONS_DISABLED) { _enableTransactions(); } } // Update indexes if (PropsValues.DATABASE_INDEXES_UPDATE_ON_STARTUP || StartupHelperUtil.isUpgraded()) { StartupHelperUtil.updateIndexes(false); } // Update release boolean verified = StartupHelperUtil.isVerified(); if (release.isVerified()) { verified = true; } ReleaseLocalServiceUtil.updateRelease( release.getReleaseId(), ReleaseInfo.getParentBuildNumber(), ReleaseInfo.getBuildDate(), verified); // Enable database caching after verify CacheRegistryUtil.setActive(true); }