use of org.apache.ofbiz.base.container.ContainerException in project ofbiz-framework by apache.
the class CatalinaContainer method prepareChannelSender.
private ReplicationTransmitter prepareChannelSender(Property clusterProp) throws ContainerException {
ReplicationTransmitter trans = new ReplicationTransmitter();
try {
MultiPointSender mps = (MultiPointSender) Class.forName(ContainerConfig.getPropertyValue(clusterProp, "replication-mode", "org.apache.catalina.tribes.transport.bio.PooledMultiSender")).newInstance();
trans.setTransport(mps);
} catch (Exception exc) {
throw new ContainerException("Cluster configuration requires a valid replication-mode property: " + exc.getMessage());
}
return trans;
}
use of org.apache.ofbiz.base.container.ContainerException in project ofbiz-framework by apache.
the class CatalinaContainer method isContextDistributable.
private boolean isContextDistributable(ContainerConfig.Configuration configuration, String location) throws ContainerException {
String webXmlFilePath = new StringBuilder().append("file:///").append(location).append("/WEB-INF/web.xml").toString();
boolean appIsDistributable = ContainerConfig.getPropertyValue(configuration, "apps-distributable", true);
try {
URL webXmlUrl = FlexibleLocation.resolveLocation(webXmlFilePath);
File webXmlFile = new File(webXmlUrl.getFile());
if (webXmlFile.exists()) {
Document webXmlDoc = UtilXml.readXmlDocument(webXmlUrl);
return appIsDistributable && webXmlDoc.getElementsByTagName("distributable").getLength() > 0;
}
Debug.logInfo(webXmlFilePath + " not found.", module);
return appIsDistributable;
} catch (SAXException | ParserConfigurationException | IOException e) {
throw new ContainerException(e);
}
}
use of org.apache.ofbiz.base.container.ContainerException in project ofbiz-framework by apache.
the class CatalinaContainer method prepareTomcatEngineValves.
private List<Valve> prepareTomcatEngineValves(Property engineConfig) throws ContainerException {
List<Valve> engineValves = new ArrayList<>();
// configure the CrossSubdomainSessionValve
if (ContainerConfig.getPropertyValue(engineConfig, "enable-cross-subdomain-sessions", false)) {
engineValves.add(new CrossSubdomainSessionValve());
}
// configure the SslAcceleratorValve
String sslAcceleratorPortStr = ContainerConfig.getPropertyValue(engineConfig, "ssl-accelerator-port", null);
if (UtilValidate.isNotEmpty(sslAcceleratorPortStr)) {
Integer sslAcceleratorPort = Integer.valueOf(sslAcceleratorPortStr);
SslAcceleratorValve sslAcceleratorValve = new SslAcceleratorValve();
sslAcceleratorValve.setSslAcceleratorPort(sslAcceleratorPort);
engineValves.add(sslAcceleratorValve);
}
// configure the AccessLogValve
String logDir = ContainerConfig.getPropertyValue(engineConfig, "access-log-dir", null);
if (logDir != null) {
AccessLogValve accessLogValve = new AccessLogValve();
logDir = logDir.startsWith("/") ? System.getProperty("ofbiz.home") + "/" + logDir : logDir;
File logFile = new File(logDir);
if (!logFile.isDirectory()) {
throw new ContainerException("Log directory [" + logDir + "] is not available; make sure the directory is created");
}
accessLogValve.setDirectory(logFile.getAbsolutePath());
String accessLogPattern = ContainerConfig.getPropertyValue(engineConfig, "access-log-pattern", null);
if (UtilValidate.isNotEmpty(accessLogPattern)) {
accessLogValve.setPattern(accessLogPattern);
}
String accessLogPrefix = ContainerConfig.getPropertyValue(engineConfig, "access-log-prefix", null);
if (UtilValidate.isNotEmpty(accessLogPrefix)) {
accessLogValve.setPrefix(accessLogPrefix);
}
accessLogValve.setRotatable(ContainerConfig.getPropertyValue(engineConfig, "access-log-rotate", false));
engineValves.add(accessLogValve);
}
return engineValves;
}
use of org.apache.ofbiz.base.container.ContainerException in project ofbiz-framework by apache.
the class EntityDataLoadContainer method loadData.
private void loadData(Delegator delegator, Delegator baseDelegator, Collection<ComponentConfig> allComponents, GenericHelperInfo helperInfo, Map<String, String> loadDataProps) throws ContainerException {
// prepare command line properties passed by user
int txTimeout = getTransactionTimeout(loadDataProps.get(TIMEOUT));
boolean useDummyFks = isPropertySet(loadDataProps, CREATE_F_KEYS);
boolean maintainTxs = isPropertySet(loadDataProps, MAINTAIN_TXS);
boolean tryInserts = isPropertySet(loadDataProps, TRY_INSERTS);
boolean continueOnFail = isPropertySet(loadDataProps, CONTINUE_ON_FAIL);
List<URL> urlList = prepareDataUrls(delegator, baseDelegator, allComponents, helperInfo, loadDataProps);
List<String> infoMessages = new ArrayList<String>();
List<Object> errorMessages = new ArrayList<Object>();
int totalRowsChanged = 0;
logDataLoadingPlan(urlList, delegator.getDelegatorName());
for (URL dataUrl : urlList) {
try {
int rowsChanged = EntityDataLoader.loadData(dataUrl, helperInfo.getHelperBaseName(), delegator, errorMessages, txTimeout, useDummyFks, maintainTxs, tryInserts, continueOnFail);
totalRowsChanged += rowsChanged;
infoMessages.add(createDataLoadMessage(dataUrl, rowsChanged, totalRowsChanged));
} catch (GenericEntityException e) {
if (continueOnFail) {
Debug.logError(e, "Error loading data file: " + dataUrl.toExternalForm(), module);
} else {
throw new ContainerException(e);
}
}
}
logDataLoadingResults(infoMessages, errorMessages, totalRowsChanged);
}
use of org.apache.ofbiz.base.container.ContainerException in project ofbiz-framework by apache.
the class EntityDataLoadContainer method init.
@Override
public void init(List<StartupCommand> ofbizCommands, String name, String configFile) throws ContainerException {
this.name = name;
// get the data-load properties passed by the user in the command line
Map<String, String> loadDataProps = ofbizCommands.stream().filter(command -> command.getName().equals(StartupCommandUtil.StartupOption.LOAD_DATA.getName())).map(command -> command.getProperties()).findFirst().get();
/* disable job scheduler, JMS listener and startup services
* FIXME: This is not thread-safe. */
ServiceDispatcher.enableJM(false);
ServiceDispatcher.enableJMS(false);
ServiceDispatcher.enableSvcs(false);
Configuration configuration = ContainerConfig.getConfiguration(name, configFile);
Property delegatorNameProp = configuration.getProperty("delegator-name");
String overrideDelegator = loadDataProps.get(DELEGATOR_NAME);
if ("all-tenants".equals(overrideDelegator)) {
// load data for all tenants
for (GenericValue tenant : getTenantList(delegatorNameProp)) {
String tenantDelegator = delegatorNameProp.value + "#" + tenant.getString("tenantId");
loadDataForDelegator(loadDataProps, configuration, delegatorNameProp, tenantDelegator);
}
} else {
// load data for a single delegator
loadDataForDelegator(loadDataProps, configuration, delegatorNameProp, overrideDelegator);
}
}
Aggregations