Here are the examples of the java api org.apache.ofbiz.entity.GenericValue taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
907 Examples
19
Source : HtmlMenuRenderer.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* User login id has changed boolean.
* @return the boolean
*/
public boolean userLoginIdHasChanged() {
boolean hasChanged = false;
GenericValue userLogin = (GenericValue) request.getSession().getAttribute("userLogin");
userLoginIdAtPermGrant = getUserLoginIdAtPermGrant();
String userLoginId = null;
if (userLogin != null) {
userLoginId = userLogin.getString("userLoginId");
}
if ((userLoginId == null && userLoginIdAtPermGrant != null) || (userLoginId != null && userLoginIdAtPermGrant == null) || ((userLoginId != null && userLoginIdAtPermGrant != null) && !userLoginId.equals(userLoginIdAtPermGrant))) {
hasChanged = true;
} else {
if (userLoginIdAtPermGrant != null) {
hasChanged = true;
} else {
hasChanged = false;
}
userLoginIdAtPermGrant = null;
}
return hasChanged;
}
19
Source : PortalPageWorker.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Checks if the user is allowed to configure the PortalPage.
* PortalPage configuration is allowed if he is the PortalPage owner or he has got the PORTALPAGE_ADMIN permission
*/
public static Boolean userIsAllowedToConfigure(String portalPageId, Map<String, Object> context) {
Boolean userIsAllowed = false;
if (UtilValidate.isNotEmpty(portalPageId)) {
GenericValue userLogin = (GenericValue) context.get("userLogin");
if (userLogin != null) {
String userLoginId = (String) userLogin.get("userLoginId");
Security security = (Security) context.get("security");
Boolean hasPortalAdminPermission = security.hasPermission("PORTALPAGE_ADMIN", userLogin);
try {
Delegator delegator = WidgetWorker.getDelegator(context);
GenericValue portalPage = EnreplacedyQuery.use(delegator).from("PortalPage").where("portalPageId", portalPageId).queryOne();
if (portalPage != null) {
String ownerUserLoginId = (String) portalPage.get("ownerUserLoginId");
// Users with PORTALPAGE_ADMIN permission can configure every Portal Page
userIsAllowed = (ownerUserLoginId.equals(userLoginId) || hasPortalAdminPermission);
}
} catch (GenericEnreplacedyException e) {
return false;
}
}
}
return userIsAllowed;
}
19
Source : WebSiteWorker.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* returns a WebSite-GenericValue
* @param delegator
* @param webSiteId
* @param useCache
* @return GenericValue
*/
public static GenericValue findWebSite(Delegator delegator, String webSiteId, boolean useCache) {
GenericValue result = null;
try {
result = EnreplacedyQuery.use(delegator).from("WebSite").where("webSiteId", webSiteId).cache(useCache).queryOne();
} catch (GenericEnreplacedyException e) {
Debug.logError("Error looking up website with id " + webSiteId, MODULE);
}
return result;
}
19
Source : WebSiteProperties.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Returns a <code>WebSiteProperties</code> instance initialized to the settings found
* in the WebSite enreplacedy value.
* @param webSiteValue
*/
public static WebSiteProperties from(GenericValue webSiteValue) {
replacedert.notNull("webSiteValue", webSiteValue);
if (!"WebSite".equals(webSiteValue.getEnreplacedyName())) {
throw new IllegalArgumentException("webSiteValue is not a WebSite enreplacedy value");
}
WebSiteProperties defaults = new WebSiteProperties(webSiteValue.getDelegator());
String httpPort = (webSiteValue.get("httpPort") != null) ? webSiteValue.getString("httpPort") : defaults.getHttpPort();
String httpHost = (webSiteValue.get("httpHost") != null) ? webSiteValue.getString("httpHost") : defaults.getHttpHost();
String httpsPort = (webSiteValue.get("httpsPort") != null) ? webSiteValue.getString("httpsPort") : defaults.getHttpsPort();
String httpsHost = (webSiteValue.get("httpsHost") != null) ? webSiteValue.getString("httpsHost") : defaults.getHttpsHost();
String webappPath = (webSiteValue.get("webappPath") != null) ? webSiteValue.getString("webappPath") : null;
boolean enableHttps = (webSiteValue.get("enableHttps") != null) ? webSiteValue.getBoolean("enableHttps") : defaults.getEnableHttps();
if (Start.getInstance().getConfig().getPortOffset() != 0) {
Integer httpPortValue = Integer.valueOf(httpPort);
httpPortValue += Start.getInstance().getConfig().getPortOffset();
httpPort = httpPortValue.toString();
Integer httpsPortValue = Integer.valueOf(httpsPort);
httpsPortValue += Start.getInstance().getConfig().getPortOffset();
// Here unlike above we trust the user and don't rely on the request, no dontAddPortoffset.
httpsPort = httpsPortValue.toString();
}
return new WebSiteProperties(httpPort, httpHost, httpsPort, httpsHost, webappPath, enableHttps);
}
19
Source : ContentUrlTag.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
public static void appendContentPrefix(GenericValue webSite, boolean secure, Appendable urlBuffer) throws IOException {
if (secure) {
if (webSite != null && UtilValidate.isNotEmpty(webSite.getString("secureContentPrefix"))) {
urlBuffer.append(webSite.getString("secureContentPrefix").trim());
} else {
String prefix = UtilProperties.getPropertyValue("url", "content.url.prefix.secure");
if (prefix != null) {
urlBuffer.append(prefix.trim());
}
}
} else {
if (webSite != null && UtilValidate.isNotEmpty(webSite.getString("standardContentPrefix"))) {
urlBuffer.append(webSite.getString("standardContentPrefix").trim());
} else {
String prefix = UtilProperties.getPropertyValue("url", "content.url.prefix.standard");
if (prefix != null) {
urlBuffer.append(prefix.trim());
}
}
}
}
19
Source : OfbizUrlBuilder.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Returns an <code>OfbizUrlBuilder</code> instance. Use this method when you
* don't have a <code>HttpServletRequest</code> object - like in scheduled jobs.
* @param webAppInfo Optional - if <code>null</code>, the builder can only build the host part,
* and that will be based only on the settings in <code>url.properties</code> (the WebSite
* enreplacedy will be ignored).
* @param delegator
* @throws WebAppConfigurationException
* @throws IOException
* @throws SAXException
* @throws GenericEnreplacedyException
*/
public static OfbizUrlBuilder from(WebappInfo webAppInfo, Delegator delegator) throws WebAppConfigurationException, IOException, SAXException, GenericEnreplacedyException {
WebSiteProperties webSiteProps = null;
ControllerConfig config = null;
String servletPath = null;
if (webAppInfo != null) {
replacedert.notNull("delegator", delegator);
String webSiteId = WebAppUtil.getWebSiteId(webAppInfo);
if (webSiteId != null) {
GenericValue webSiteValue = EnreplacedyQuery.use(delegator).from("WebSite").where("webSiteId", webSiteId).cache().queryOne();
if (webSiteValue != null) {
webSiteProps = WebSiteProperties.from(webSiteValue);
}
}
config = ConfigXMLReader.getControllerConfig(webAppInfo);
servletPath = WebAppUtil.getControlServletPath(webAppInfo);
}
if (webSiteProps == null) {
webSiteProps = WebSiteProperties.defaults(delegator);
}
return new OfbizUrlBuilder(config, webSiteProps, servletPath);
}
19
Source : ServiceEntityAutoTests.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Test enreplacedy auto expire enreplacedy.
* @throws Exception the exception
*/
public void testEnreplacedyAutoExpireEnreplacedy() throws Exception {
Delegator delegator = getDelegator();
Timestamp now = UtilDateTime.nowTimestamp();
delegator.create("Testing", "testingId", "TESTING_6");
delegator.create("TestingNode", "testingNodeId", "TESTNODE_6");
Map<String, Object> testingNodeMemberPkMap = UtilMisc.toMap("testingId", "TESTING_6", "testingNodeId", "TESTNODE_6", "fromDate", now);
delegator.create("TestingNodeMember", testingNodeMemberPkMap);
// test expire the thruDate
Map<String, Object> results = getDispatcher().runSync("testEnreplacedyAutoExpireTestingNodeMember", testingNodeMemberPkMap);
replacedertTrue(ServiceUtil.isSuccess(results));
GenericValue testingNodeMember = EnreplacedyQuery.use(delegator).from("TestingNodeMember").where(testingNodeMemberPkMap).queryOne();
Timestamp expireDate = testingNodeMember.getTimestamp("thruDate");
replacedertNotNull("Expire thruDate set ", expireDate);
// test expire to ensure the thruDate isn't update but extendThruDate is
results = getDispatcher().runSync("testEnreplacedyAutoExpireTestingNodeMember", testingNodeMemberPkMap);
replacedertTrue(ServiceUtil.isSuccess(results));
testingNodeMember = EnreplacedyQuery.use(delegator).from("TestingNodeMember").where(testingNodeMemberPkMap).queryOne();
replacedertTrue(expireDate.compareTo(testingNodeMember.getTimestamp("thruDate")) == 0);
replacedertNotNull("Expire extendThruDate set ", testingNodeMember.getTimestamp("extendThruDate"));
// test expire a specific field
delegator.create("TestFieldType", "testFieldTypeId", "TESTING_6");
Map<String, Object> testingExpireMap = UtilMisc.toMap("testFieldTypeId", "TESTING_6");
results = getDispatcher().runSync("testEnreplacedyAutoExpireTestFieldType", testingExpireMap);
replacedertTrue(ServiceUtil.isSuccess(results));
GenericValue testFieldType = EnreplacedyQuery.use(delegator).from("TestFieldType").where("testFieldTypeId", "TESTING_6").queryOne();
replacedertNotNull("Expire dateTimeField set", testFieldType.getTimestamp("dateTimeField"));
// test expire a specific field with in value
delegator.create("TestFieldType", "testFieldTypeId", "TESTING_6bis");
testingExpireMap = UtilMisc.toMap("testFieldTypeId", "TESTING_6bis", "dateTimeField", now);
results = getDispatcher().runSync("testEnreplacedyAutoExpireTestFieldType", testingExpireMap);
replacedertTrue(ServiceUtil.isSuccess(results));
testFieldType = EnreplacedyQuery.use(delegator).from("TestFieldType").where("testFieldTypeId", "TESTING_6bis").queryOne();
replacedertTrue(now.compareTo(testFieldType.getTimestamp("dateTimeField")) == 0);
}
19
Source : ServiceEntityAutoTests.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Test enreplacedy auto enreplacedy status concept.
* @throws Exception the exception
*/
public void testEnreplacedyAutoEnreplacedyStatusConcept() throws Exception {
Delegator delegator = getDelegator();
delegator.create("Testing", "testingId", "TESTING_7");
delegator.create("StatusType", "statusTypeId", "TESTINGSTATUS");
delegator.create("StatusItem", "statusId", "TESTING_CREATE", "statusTypeId", "TESTINGSTATUS");
delegator.create("StatusItem", "statusId", "TESTING_UPDATE", "statusTypeId", "TESTINGSTATUS");
GenericValue userLogin = getUserLogin("system");
// test create testingStatus with userlogin
Map<String, Object> testingStatusCreateMap = UtilMisc.toMap("testingId", "TESTING_7", "statusId", "TESTING_CREATE", "userLogin", userLogin);
Map<String, Object> results = getDispatcher().runSync("testEnreplacedyAutoCreateTestingStatus", testingStatusCreateMap);
replacedertTrue(ServiceUtil.isSuccess(results));
GenericValue testing = EnreplacedyQuery.use(delegator).from("TestingStatus").where("testingId", "TESTING_7").queryFirst();
replacedertNotNull(testing.getTimestamp("statusDate"));
replacedertEquals("system", testing.getString("changeByUserLoginId"));
// test create testingStatus without userLogin
try {
testingStatusCreateMap = UtilMisc.toMap("testingId", "TESTING_7", "statusId", "TESTING_CREATE");
results = getDispatcher().runSync("testEnreplacedyAutoCreateTestingStatus", testingStatusCreateMap, 10, true);
replacedertTrue(ServiceUtil.isError(results));
} catch (GenericServiceException e) {
replacedertEquals(e.toString(), "You call a creation on enreplacedy that require the userLogin to track the activity, " + "please control that your service definition has auth='true'");
}
// test update testingStatus
try {
Map<String, Object> testingStatusUpdateMap = UtilMisc.toMap("testingStatusId", testing.get("testingStatusId"), "statusId", "TESTING_UPDATE", "userLogin", userLogin);
results = getDispatcher().runSync("testEnreplacedyAutoUpdateTestingStatus", testingStatusUpdateMap, 10, true);
replacedertTrue(ServiceUtil.isError(results));
} catch (GenericServiceException e) {
replacedertEquals(e.toString(), "You call a updating operation on enreplacedy that track the activity, sorry I can't do that," + "please amazing developer check your service definition;)");
}
// test delete testingStatus
try {
Map<String, Object> testingStatusDeleteMap = UtilMisc.toMap("testingStatusId", testing.get("testingStatusId"), "userLogin", userLogin);
results = getDispatcher().runSync("testEnreplacedyAutoDeleteTestingStatus", testingStatusDeleteMap, 10, true);
replacedertTrue(ServiceUtil.isError(results));
} catch (GenericServiceException e) {
replacedertEquals(e.toString(), "You call a deleting operation on enreplacedy that track the activity, sorry I can't do that, " + "please amazing developer check your service definition;)");
}
}
19
Source : ServiceEntityAutoTests.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Test enreplacedy auto create singl pk enreplacedy.
* @throws Exception the exception
*/
public void testEnreplacedyAutoCreateSinglPkEnreplacedy() throws Exception {
Delegator delegator = getDelegator();
// test create with given pk
Map<String, Object> testingPkPresentMap = new HashMap<>();
testingPkPresentMap.put("testingId", "TESTING_1");
testingPkPresentMap.put("testingName", "enreplacedy auto testing");
Map<String, Object> results = getDispatcher().runSync("testEnreplacedyAutoCreateTestingPkPresent", testingPkPresentMap);
replacedertTrue(ServiceUtil.isSuccess(results));
GenericValue testing = EnreplacedyQuery.use(delegator).from("Testing").where("testingId", "TESTING_1").queryOne();
replacedertNotNull(testing);
// test create with auto sequence
Map<String, Object> testingPkMissingMap = new HashMap<>();
testingPkPresentMap.put("testingName", "enreplacedy auto testing without pk part in");
results = getDispatcher().runSync("testEnreplacedyAutoCreateTestingPkMissing", testingPkMissingMap);
replacedertTrue(ServiceUtil.isSuccess(results));
testing = EnreplacedyQuery.use(delegator).from("Testing").where("testingId", results.get("testingId")).queryOne();
replacedertNotNull(testing);
// test collision
results = getDispatcher().runSync("testEnreplacedyAutoCreateTestingPkPresent", testingPkPresentMap, 10, true);
replacedertTrue(ServiceUtil.isError(results));
}
19
Source : ServiceEntityAutoTests.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Test enreplacedy auto create double pk enreplacedy.
* @throws Exception the exception
*/
public void testEnreplacedyAutoCreateDoublePkEnreplacedy() throws Exception {
Delegator delegator = getDelegator();
delegator.create("Testing", "testingId", "TESTING_2");
// test create with given pk
Map<String, Object> testingItemPkPresentMap = UtilMisc.toMap("testingId", "TESTING_2", "testingSeqId", "00001");
Map<String, Object> results = getDispatcher().runSync("testEnreplacedyAutoCreateTestingItemPkPresent", testingItemPkPresentMap);
replacedertTrue(ServiceUtil.isSuccess(results));
GenericValue testingItem = EnreplacedyQuery.use(delegator).from("TestingItem").where("testingId", "TESTING_2", "testingSeqId", "00001").queryOne();
replacedertNotNull(testingItem);
// test create with auto sub-sequence
Map<String, Object> testingItemPkMissingMap = UtilMisc.toMap("testingId", "TESTING_2");
results = getDispatcher().runSync("testEnreplacedyAutoCreateTestingItemPkMissing", testingItemPkMissingMap);
replacedertTrue(ServiceUtil.isSuccess(results));
testingItem = EnreplacedyQuery.use(delegator).from("TestingItem").where("testingId", "TESTING_2", "testingSeqId", results.get("testingSeqId")).queryOne();
replacedertNotNull(testingItem);
replacedertEquals("00002", testingItem.get("testingSeqId"));
// test collision
results = getDispatcher().runSync("testEnreplacedyAutoCreateTestingItemPkPresent", testingItemPkPresentMap, 10, true);
replacedertTrue(ServiceUtil.isError(results));
// replacedertEquals("", ServiceUtil.getErrorMessage(results));
}
19
Source : ServiceUtil.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* A small routine used all over to improve code efficiency, get the partyId and does a security check
* <b>security check</b>: userLogin partyId must equal partyId, or must have [secEnreplacedy][secOperation] permission
*/
public static String getPartyIdCheckSecurity(GenericValue userLogin, Security security, Map<String, ? extends Object> context, Map<String, Object> result, String secEnreplacedy, String secOperation) {
return getPartyIdCheckSecurity(userLogin, security, context, result, secEnreplacedy, secOperation, null, null);
}
19
Source : ServiceSemaphore.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* ServiceSemapreplaced
*/
public final clreplaced ServiceSemapreplaced {
// TODO: add something to make sure semapreplaceds are cleaned up on failures
// and when the thread somehow goes away without cleaning it up
// TODO: write service engine test cases to make sure semapreplaced both blocking
// and timing out (use config to set sleep and wait to low values so it times out quickly)
private static final String MODULE = ServiceSemapreplaced.clreplaced.getName();
private static final int SEMAPreplaced_MODE_FAIL = 0;
private static final int SEMAPreplaced_MODE_WAIT = 1;
private static final int SEMAPreplaced_MODE_NONE = 2;
private Delegator delegator;
private GenericValue lock;
private ModelService model;
private int wait = 0;
private int mode;
private Timestamp lockTime = null;
public ServiceSemapreplaced(Delegator delegator, ModelService model) {
this.delegator = delegator;
this.mode = "wait".equals(model.getSemapreplaced()) ? SEMAPreplaced_MODE_WAIT : ("fail".equals(model.getSemapreplaced()) ? SEMAPreplaced_MODE_FAIL : SEMAPreplaced_MODE_NONE);
this.model = model;
this.lock = null;
}
/**
* Try to acquire semapreplaced lock
* @throws SemapreplacedWaitException @link SemapreplacedWaitException
* @throws SemapreplacedFailException @link SemapreplacedFailException
*/
public void acquire() throws SemapreplacedWaitException, SemapreplacedFailException {
if (mode == SEMAPreplaced_MODE_NONE) {
return;
}
lockTime = UtilDateTime.nowTimestamp();
if (this.checkLockNeedToWait()) {
waitOrFail();
}
}
/**
* Release semapreplaced locks
* @return {@code true} if release is success
*/
public synchronized boolean release() {
// remove the lock file
if (mode != SEMAPreplaced_MODE_NONE && lock != null) {
return dbWrite(lock, true);
}
return true;
}
/**
* Try to get lock ownership corresponding to semapreplaced type
* Throw exception when failure.
* @throws SemapreplacedWaitException @link SemapreplacedWaitException
* @throws SemapreplacedFailException @link SemapreplacedFailException
*/
private void waitOrFail() throws SemapreplacedWaitException, SemapreplacedFailException {
if (SEMAPreplaced_MODE_FAIL == mode) {
// fail
throw new SemapreplacedFailException("Service [" + model.getName() + "] is locked");
} else if (SEMAPreplaced_MODE_WAIT == mode) {
// get the wait and sleep values
long maxWaitCount = ((model.getSemapreplacedWait() * 1000) / model.getSemapreplacedSleep());
long sleep = model.getSemapreplacedSleep();
boolean timedOut = true;
while (wait < maxWaitCount) {
wait++;
try {
Thread.sleep(sleep);
} catch (InterruptedException e) {
Debug.logInfo(e, "Sleep interrupted: ServiceSemapreplaced.waitOrFail()", MODULE);
}
// try again
if (!checkLockNeedToWait()) {
timedOut = false;
break;
}
}
if (timedOut) {
double waitTimeSec = ((System.currentTimeMillis() - lockTime.getTime()) / 1000.0);
String errMsg = "Service [" + model.getName() + "] with wait semapreplaced exceeded wait timeout, waited [" + waitTimeSec + "], wait started at " + lockTime;
throw new SemapreplacedWaitException(errMsg);
}
} else if (SEMAPreplaced_MODE_NONE == mode) {
Debug.logWarning("Semapreplaced mode [none] attempted to aquire a lock; but should not have!", MODULE);
} else {
throw new SemapreplacedFailException("Found invalid Semapreplaced mode [" + mode + "]");
}
}
/**
* Check the absence of the lock, if true, try to insert the lock in the synchronized way.
* Return {@code true} if lock already in place or failed during insertion.
* @return boolean indicating if more wait is needed
* @throws SemapreplacedFailException @link SemapreplacedFailException
*/
private boolean checkLockNeedToWait() throws SemapreplacedFailException {
String threadName = Thread.currentThread().getName();
GenericValue semapreplaced;
try {
if (EnreplacedyQuery.use(delegator).from("ServiceSemapreplaced").where("serviceName", model.getName()).queryCount() == 0) {
semapreplaced = delegator.makeValue("ServiceSemapreplaced", "serviceName", model.getName(), "lockedByInstanceId", JobManager.INSTANCE_ID, "lockThread", threadName, "lockTime", lockTime);
// use the special method below so we can reuse the unique tx functions
// if semapreplaced successfully owned no need to wait anymore.
return !dbWrite(semapreplaced, false);
}
// found a semapreplaced, need to wait
return true;
} catch (GenericEnreplacedyException e) {
throw new SemapreplacedFailException(e);
}
}
/**
* Operates synchronized jdbc access (create/remove) method to ensure unique semapreplaced token management
* The same method is used for creating or removing the lock.
* @param value the value that will be operated
* @param delete specify the action
* {@code true} for removal
* {@code false} for insertion
* @return boolean if operation is success
*/
private synchronized boolean dbWrite(GenericValue value, boolean delete) {
Transaction parent = null;
boolean beganTx;
boolean isError = false;
try {
// prepare the suspended transaction
if (TransactionUtil.isTransactionInPlace()) {
parent = TransactionUtil.suspend();
}
beganTx = TransactionUtil.begin();
if (!beganTx) {
Debug.logError("Cannot obtain unique transaction for semapreplaced logging", MODULE);
return false;
}
// store the value
try {
if (delete) {
value.refresh();
value.remove();
lock = null;
} else {
// Last check before inserting data in this transaction to avoid error log
isError = EnreplacedyQuery.use(delegator).from("ServiceSemapreplaced").where("serviceName", model.getName()).queryCount() != 0;
if (!isError) {
lock = value.create();
}
}
} catch (GenericEnreplacedyException e) {
Debug.logError("Cannot obtain unique transaction for semapreplaced logging", MODULE);
isError = true;
} finally {
try {
if (isError) {
TransactionUtil.rollback();
} else {
TransactionUtil.commit();
}
} catch (GenericTransactionException e) {
Debug.logError(e, MODULE);
}
}
} catch (GenericTransactionException e) {
Debug.logError(e, MODULE);
} finally {
if (parent != null) {
try {
TransactionUtil.resume(parent);
} catch (GenericTransactionException e) {
Debug.logError(e, MODULE);
}
}
}
return !isError;
}
}
19
Source : ServiceSemaphore.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Check the absence of the lock, if true, try to insert the lock in the synchronized way.
* Return {@code true} if lock already in place or failed during insertion.
* @return boolean indicating if more wait is needed
* @throws SemapreplacedFailException @link SemapreplacedFailException
*/
private boolean checkLockNeedToWait() throws SemapreplacedFailException {
String threadName = Thread.currentThread().getName();
GenericValue semapreplaced;
try {
if (EnreplacedyQuery.use(delegator).from("ServiceSemapreplaced").where("serviceName", model.getName()).queryCount() == 0) {
semapreplaced = delegator.makeValue("ServiceSemapreplaced", "serviceName", model.getName(), "lockedByInstanceId", JobManager.INSTANCE_ID, "lockThread", threadName, "lockTime", lockTime);
// use the special method below so we can reuse the unique tx functions
// if semapreplaced successfully owned no need to wait anymore.
return !dbWrite(semapreplaced, false);
}
// found a semapreplaced, need to wait
return true;
} catch (GenericEnreplacedyException e) {
throw new SemapreplacedFailException(e);
}
}
19
Source : ServiceMcaUtil.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
public static void evalRules(LocalDispatcher dispatcher, MimeMessageWrapper wrapper, GenericValue userLogin) throws GenericServiceException {
Set<String> actionsRun = new TreeSet<>();
for (ServiceMcaRule rule : getServiceMcaRules()) {
rule.eval(dispatcher, wrapper, actionsRun, userLogin);
}
}
19
Source : PurgeJob.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Purge job - removes a JobSandbox enreplacedy value and its related values.
*/
@SuppressWarnings("serial")
public clreplaced PurgeJob extends AbstractJob implements Serializable {
private static final String MODULE = PurgeJob.clreplaced.getName();
private final GenericValue jobValue;
public PurgeJob(GenericValue jobValue) {
super(jobValue.getString("jobId"), "Purge " + jobValue.getString("jobName"));
this.jobValue = jobValue;
}
@Override
public void exec() throws InvalidJobException {
if (getCurrentState() != State.QUEUED) {
throw new InvalidJobException("Illegal state change");
}
setCurrentState(State.RUNNING);
JobUtil.removeJob(jobValue);
}
@Override
public boolean isValid() {
return getCurrentState() == State.CREATED;
}
@Override
public void deQueue() throws InvalidJobException {
if (getCurrentState() != State.QUEUED) {
throw new InvalidJobException("Illegal state change");
}
}
/*
* Returns JobPriority.LOW
*/
@Override
public long getPriority() {
return JobPriority.LOW;
}
}
19
Source : PersistedServiceJob.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* A {@link Job} that is backed by the enreplacedy engine. Job data is stored
* in the JobSandbox enreplacedy.
* <p>When the job is queued, this object "owns" the enreplacedy value. Any external changes
* are ignored except the cancelDateTime field - jobs can be canceled after they are queued.</p>
*/
@SuppressWarnings("serial")
public clreplaced PersistedServiceJob extends GenericServiceJob {
private static final String MODULE = PersistedServiceJob.clreplaced.getName();
private final transient Delegator delegator;
private long nextRecurrence = -1;
private final long maxRetry;
private final long currentRetryCount;
private final GenericValue jobValue;
private final long startTime;
/**
* Creates a new PersistedServiceJob
* @param dctx
* @param jobValue
* @param req
*/
public PersistedServiceJob(DispatchContext dctx, GenericValue jobValue, GenericRequester req) {
super(dctx, jobValue.getString("jobId"), jobValue.getString("jobName"), null, null, req);
this.delegator = dctx.getDelegator();
this.jobValue = jobValue;
Timestamp storedDate = jobValue.getTimestamp("runTime");
this.startTime = storedDate.getTime();
this.maxRetry = jobValue.get("maxRetry") != null ? jobValue.getLong("maxRetry") : 0;
Long retryCount = jobValue.getLong("currentRetryCount");
if (retryCount != null) {
this.currentRetryCount = retryCount;
} else {
// backward compatibility
this.currentRetryCount = getRetries(this.delegator);
}
}
@Override
public void queue() throws InvalidJobException {
super.queue();
try {
jobValue.refresh();
} catch (GenericEnreplacedyException e) {
throw new InvalidJobException("Unable to refresh JobSandbox value", e);
}
if (!JobManager.INSTANCE_ID.equals(jobValue.getString("runByInstanceId"))) {
throw new InvalidJobException("Job has been accepted by a different instance");
}
Timestamp cancelTime = jobValue.getTimestamp("cancelDateTime");
Timestamp startTime = jobValue.getTimestamp("startDateTime");
if (cancelTime != null || startTime != null) {
// job not available
throw new InvalidJobException("Job [" + getJobId() + "] is not available");
}
jobValue.set("statusId", "SERVICE_QUEUED");
try {
jobValue.store();
} catch (GenericEnreplacedyException e) {
throw new InvalidJobException("Unable to set the startDateTime and statusId on the current job [" + getJobId() + "]; not running!", e);
}
if (Debug.verboseOn()) {
Debug.logVerbose("Placing job [" + getJobId() + "] in queue", MODULE);
}
}
@Override
protected void init() throws InvalidJobException {
super.init();
try {
jobValue.refresh();
} catch (GenericEnreplacedyException e) {
throw new InvalidJobException("Unable to refresh JobSandbox value", e);
}
if (!JobManager.INSTANCE_ID.equals(jobValue.getString("runByInstanceId"))) {
throw new InvalidJobException("Job has been accepted by a different instance");
}
if (jobValue.getTimestamp("cancelDateTime") != null) {
// Job cancelled
throw new InvalidJobException("Job [" + getJobId() + "] was cancelled");
}
jobValue.set("startDateTime", UtilDateTime.nowTimestamp());
jobValue.set("statusId", "SERVICE_RUNNING");
try {
jobValue.store();
} catch (GenericEnreplacedyException e) {
throw new InvalidJobException("Unable to set the startDateTime and statusId on the current job [" + getJobId() + "]; not running!", e);
}
if (Debug.verboseOn()) {
Debug.logVerbose("Job [" + getJobId() + "] running", MODULE);
}
// configure any additional recurrences
long maxRecurrenceCount = -1;
long currentRecurrenceCount = 0;
TemporalExpression expr = null;
RecurrenceInfo recurrence = getRecurrenceInfo();
if (recurrence != null) {
Debug.logWarning("Persisted Job [" + getJobId() + "] references a RecurrenceInfo, recommend using TemporalExpression instead", MODULE);
currentRecurrenceCount = recurrence.getCurrentCount();
expr = RecurrenceInfo.toTemporalExpression(recurrence);
}
if (expr == null && UtilValidate.isNotEmpty(jobValue.getString("tempExprId"))) {
try {
expr = TemporalExpressionWorker.getTemporalExpression(this.delegator, jobValue.getString("tempExprId"));
} catch (GenericEnreplacedyException e) {
throw new RuntimeException(e.getMessage());
}
}
if (jobValue.get("maxRecurrenceCount") != null) {
maxRecurrenceCount = jobValue.getLong("maxRecurrenceCount");
}
if (jobValue.get("currentRecurrenceCount") != null) {
currentRecurrenceCount = jobValue.getLong("currentRecurrenceCount");
}
if (maxRecurrenceCount != -1) {
currentRecurrenceCount++;
jobValue.set("currentRecurrenceCount", currentRecurrenceCount);
}
try {
if (expr != null && (maxRecurrenceCount == -1 || currentRecurrenceCount <= maxRecurrenceCount)) {
if (recurrence != null) {
recurrence.incrementCurrentCount();
}
TimeZone timeZone = jobValue.get("recurrenceTimeZone") != null ? TimeZone.getTimeZone(jobValue.getString("recurrenceTimeZone")) : TimeZone.getDefault();
Calendar next = expr.next(Calendar.getInstance(timeZone));
if (next != null) {
createRecurrence(next.getTimeInMillis(), false);
}
}
} catch (GenericEnreplacedyException e) {
throw new InvalidJobException(e);
}
if (Debug.infoOn()) {
Debug.logInfo("Job [" + getJobName() + "] Id [" + getJobId() + "] -- Next runtime: " + new Date(nextRecurrence), MODULE);
}
}
private void createRecurrence(long next, boolean isRetryOnFailure) throws GenericEnreplacedyException {
if (Debug.verboseOn()) {
Debug.logVerbose("Next runtime returned: " + next, MODULE);
}
if (next > startTime) {
String pJobId = jobValue.getString("parentJobId");
if (pJobId == null) {
pJobId = jobValue.getString("jobId");
}
GenericValue newJob = GenericValue.create(jobValue);
newJob.remove("jobId");
newJob.set("previousJobId", jobValue.getString("jobId"));
newJob.set("parentJobId", pJobId);
newJob.set("statusId", "SERVICE_PENDING");
newJob.set("startDateTime", null);
newJob.set("runByInstanceId", null);
newJob.set("runTime", new java.sql.Timestamp(next));
if (isRetryOnFailure) {
newJob.set("currentRetryCount", currentRetryCount + 1);
} else {
newJob.set("currentRetryCount", 0L);
}
nextRecurrence = next;
// Set priority if missing
if (newJob.getLong("priority") == null) {
newJob.set("priority", JobPriority.NORMAL);
}
delegator.createSetNextSeqId(newJob);
if (Debug.verboseOn()) {
Debug.logVerbose("Created next job entry: " + newJob, MODULE);
}
}
}
@Override
protected void finish(Map<String, Object> result) throws InvalidJobException {
super.finish(result);
// set the finish date
jobValue.set("statusId", "SERVICE_FINISHED");
jobValue.set("finishDateTime", UtilDateTime.nowTimestamp());
String jobResult = null;
if (ServiceUtil.isError(result)) {
jobResult = StringUtils.substring(ServiceUtil.getErrorMessage(result), 0, 255);
} else {
jobResult = StringUtils.substring(ServiceUtil.makeSuccessMessage(result, "", "", "", ""), 0, 255);
}
if (UtilValidate.isNotEmpty(jobResult)) {
jobValue.set("jobResult", jobResult);
}
try {
jobValue.store();
} catch (GenericEnreplacedyException e) {
Debug.logError(e, "Cannot update the job [" + getJobId() + "] sandbox", MODULE);
}
}
@Override
protected void failed(Throwable t) throws InvalidJobException {
super.failed(t);
// if the job has not been re-scheduled; we need to re-schedule and run again
if (nextRecurrence == -1) {
if (this.canRetry()) {
// create a recurrence
Calendar cal = Calendar.getInstance();
try {
cal.add(Calendar.MINUTE, ServiceConfigUtil.getServiceEngine().getThreadPool().getFailedRetryMin());
} catch (GenericConfigException e) {
Debug.logWarning(e, "Unable to get retry minutes for job [" + getJobId() + "], defaulting to now: ", MODULE);
}
long next = cal.getTimeInMillis();
try {
createRecurrence(next, true);
} catch (GenericEnreplacedyException e) {
Debug.logError(e, "Unable to re-schedule job [" + getJobId() + "]: ", MODULE);
}
Debug.logInfo("Persisted Job [" + getJobId() + "] Failed. Re-Scheduling : " + next, MODULE);
} else {
Debug.logWarning("Persisted Job [" + getJobId() + "] Failed. Max Retry Hit, not re-scheduling", MODULE);
}
}
// set the failed status
jobValue.set("statusId", "SERVICE_FAILED");
jobValue.set("finishDateTime", UtilDateTime.nowTimestamp());
jobValue.set("jobResult", StringUtils.substring(t.getMessage(), 0, 255));
try {
jobValue.store();
} catch (GenericEnreplacedyException e) {
Debug.logError(e, "Cannot update the JobSandbox enreplacedy", MODULE);
}
}
@Override
protected String getServiceName() {
if (jobValue == null || jobValue.get("serviceName") == null) {
return null;
}
return jobValue.getString("serviceName");
}
@Override
protected Map<String, Object> getContext() throws InvalidJobException {
Map<String, Object> context = null;
try {
if (UtilValidate.isNotEmpty(jobValue.getString("runtimeDataId"))) {
GenericValue contextObj = jobValue.getRelatedOne("RuntimeData", false);
if (contextObj != null) {
context = UtilGenerics.checkMap(XmlSerializer.deserialize(contextObj.getString("runtimeInfo"), delegator), String.clreplaced, Object.clreplaced);
}
}
if (context == null) {
context = new HashMap<>();
}
// check the runAsUser
if (UtilValidate.isNotEmpty(jobValue.getString("runAsUser"))) {
context.put("userLogin", ServiceUtil.getUserLogin(getDctx(), context, jobValue.getString("runAsUser")));
}
} catch (GenericEnreplacedyException e) {
Debug.logError(e, "PersistedServiceJob.getContext(): Enreplacedy Exception", MODULE);
} catch (SerializeException e) {
Debug.logError(e, "PersistedServiceJob.getContext(): Serialize Exception", MODULE);
} catch (ParserConfigurationException e) {
Debug.logError(e, "PersistedServiceJob.getContext(): Parse Exception", MODULE);
} catch (SAXException e) {
Debug.logError(e, "PersistedServiceJob.getContext(): SAXException", MODULE);
} catch (IOException e) {
Debug.logError(e, "PersistedServiceJob.getContext(): IOException", MODULE);
}
if (context == null) {
Debug.logError("Job context is null", MODULE);
}
return context;
}
// returns the number of current retries
private long getRetries(Delegator delegator) {
String pJobId = jobValue.getString("parentJobId");
if (pJobId == null) {
return 0;
}
long count = 0;
try {
count = EnreplacedyQuery.use(delegator).from("JobSandbox").where("parentJobId", pJobId, "statusId", "SERVICE_FAILED").queryCount();
} catch (GenericEnreplacedyException e) {
Debug.logError(e, "Exception thrown while counting retries: ", MODULE);
}
// add one for the parent
return count + 1;
}
private boolean canRetry() {
if (maxRetry == -1) {
return true;
}
return currentRetryCount < maxRetry;
}
private RecurrenceInfo getRecurrenceInfo() {
try {
if (UtilValidate.isNotEmpty(jobValue.getString("recurrenceInfoId"))) {
GenericValue ri = jobValue.getRelatedOne("RecurrenceInfo", false);
if (ri != null) {
return new RecurrenceInfo(ri);
}
}
} catch (GenericEnreplacedyException e) {
Debug.logError(e, "Problem getting RecurrenceInfo enreplacedy from JobSandbox", MODULE);
} catch (RecurrenceInfoException re) {
Debug.logError(re, "Problem creating RecurrenceInfo instance: " + re.getMessage(), MODULE);
}
return null;
}
@Override
public void deQueue() throws InvalidJobException {
if (getCurrentState() != State.QUEUED) {
throw new InvalidJobException("Illegal state change");
}
setCurrentState(State.CREATED);
try {
jobValue.refresh();
jobValue.set("startDateTime", null);
jobValue.set("runByInstanceId", null);
jobValue.set("statusId", "SERVICE_PENDING");
jobValue.store();
} catch (GenericEnreplacedyException e) {
throw new InvalidJobException("Unable to dequeue job [" + getJobId() + "]", e);
}
if (Debug.verboseOn()) {
Debug.logVerbose("Job [" + getJobId() + "] not queued, rescheduling", MODULE);
}
}
@Override
public Date getStartTime() {
return new Date(startTime);
}
/*
* Returns the priority stored in the JobSandbox.priority field, if no value is present
* then it defaults to AbstractJob.getPriority()
*/
@Override
public long getPriority() {
Long priority = jobValue.getLong("priority");
if (priority == null) {
return super.getPriority();
}
return priority;
}
}
19
Source : JobManager.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Schedule a job to start at a specific time with specific recurrence info
* @param jobName The name of the job
* @param poolName The name of the pool to run the service from
* @param serviceName The name of the service to invoke
* @param context The context for the service
* @param startTime The time in milliseconds the service should run
* @param frequency The frequency of the recurrence (HOURLY, DAILY, MONTHLY etc)
* @param interval The interval of the frequency recurrence
* @param count The number of times to repeat
* @param endTime The time in milliseconds the service should expire
* @param maxRetry The max number of retries on failure (-1 for no max)
* @throws JobManagerException the job manager exception
*/
public void schedule(String jobName, String poolName, String serviceName, Map<String, ? extends Object> context, long startTime, int frequency, int interval, int count, long endTime, int maxRetry) throws JobManagerException {
// persist the context
String dataId = null;
try {
GenericValue runtimeData = delegator.makeValue("RuntimeData");
runtimeData.set("runtimeInfo", XmlSerializer.serialize(context));
runtimeData = delegator.createSetNextSeqId(runtimeData);
dataId = runtimeData.getString("runtimeDataId");
} catch (GenericEnreplacedyException | SerializeException | IOException e) {
throw new JobManagerException(e.getMessage(), e);
}
// schedule the job
schedule(jobName, poolName, serviceName, dataId, startTime, frequency, interval, count, endTime, maxRetry);
}
19
Source : TemporalExpressionWorker.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Create a <code>TemporalExpression</code> instance from a TemporalExpression
* GenericValue.<p>This method makes recursive calls, so care must be taken to
* avoid endless loops.</p>
* @param delegator
* @param exprValue
* @return A <code>TemporalExpression</code> instance based on <code>exprValue</code>
* @throws GenericEnreplacedyException
*/
public static TemporalExpression makeTemporalExpression(Delegator delegator, GenericValue exprValue) throws GenericEnreplacedyException {
String tempExprId = exprValue.getString("tempExprId");
String tempExprTypeId = exprValue.getString("tempExprTypeId");
if (DATE_RANGE.equals(tempExprTypeId)) {
return setExpressionId(exprValue, new TemporalExpressions.DateRange(exprValue.getTimestamp("date1"), exprValue.getTimestamp("date2")));
} else if (DAY_IN_MONTH.equals(tempExprTypeId)) {
return setExpressionId(exprValue, new TemporalExpressions.DayInMonth(exprValue.getLong("integer1").intValue(), exprValue.getLong("integer2").intValue()));
} else if (DAY_OF_MONTH_RANGE.equals(tempExprTypeId)) {
return setExpressionId(exprValue, new TemporalExpressions.DayOfMonthRange(exprValue.getLong("integer1").intValue(), exprValue.getLong("integer2").intValue()));
} else if (DAY_OF_WEEK_RANGE.equals(tempExprTypeId)) {
return setExpressionId(exprValue, new TemporalExpressions.DayOfWeekRange(exprValue.getLong("integer1").intValue(), exprValue.getLong("integer2").intValue()));
} else if (DIFFERENCE.equals(tempExprTypeId)) {
List<GenericValue> childExpressions = EnreplacedyQuery.use(delegator).from("TemporalExpressionreplacedoc").where("fromTempExprId", tempExprId).cache(true).queryList();
GenericValue inclreplacedoc = null;
GenericValue exclreplacedoc = null;
for (GenericValue childExpression : childExpressions) {
if (INCLUDE.equals(childExpression.get("exprreplacedocType"))) {
inclreplacedoc = childExpression;
} else if (EXCLUDE.equals(childExpression.get("exprreplacedocType"))) {
exclreplacedoc = childExpression;
}
}
if (inclreplacedoc != null && exclreplacedoc != null) {
return setExpressionId(exprValue, new TemporalExpressions.Difference(getTemporalExpression(delegator, inclreplacedoc.getString("toTempExprId")), getTemporalExpression(delegator, exclreplacedoc.getString("toTempExprId"))));
}
} else if (FREQUENCY.equals(tempExprTypeId)) {
return setExpressionId(exprValue, new TemporalExpressions.Frequency(exprValue.getTimestamp("date1"), exprValue.getLong("integer1").intValue(), exprValue.getLong("integer2").intValue()));
} else if (HOUR_RANGE.equals(tempExprTypeId)) {
return setExpressionId(exprValue, new TemporalExpressions.HourRange(exprValue.getLong("integer1").intValue(), exprValue.getLong("integer2").intValue()));
} else if (INTERSECTION.equals(tempExprTypeId)) {
return setExpressionId(exprValue, new TemporalExpressions.Intersection(getChildExpressions(delegator, tempExprId)));
} else if (MINUTE_RANGE.equals(tempExprTypeId)) {
return setExpressionId(exprValue, new TemporalExpressions.MinuteRange(exprValue.getLong("integer1").intValue(), exprValue.getLong("integer2").intValue()));
} else if (MONTH_RANGE.equals(tempExprTypeId)) {
return setExpressionId(exprValue, new TemporalExpressions.MonthRange(exprValue.getLong("integer1").intValue(), exprValue.getLong("integer2").intValue()));
} else if (SUBSreplacedUTION.equals(tempExprTypeId)) {
List<GenericValue> childExpressions = EnreplacedyQuery.use(delegator).from("TemporalExpressionreplacedoc").where("fromTempExprId", tempExprId).cache(true).queryList();
GenericValue inclreplacedoc = null;
GenericValue exclreplacedoc = null;
GenericValue substreplacedoc = null;
for (GenericValue childExpression : childExpressions) {
if (INCLUDE.equals(childExpression.get("exprreplacedocType"))) {
inclreplacedoc = childExpression;
} else if (EXCLUDE.equals(childExpression.get("exprreplacedocType"))) {
exclreplacedoc = childExpression;
} else if (SUBSreplacedUTE.equals(childExpression.get("exprreplacedocType"))) {
substreplacedoc = childExpression;
}
}
if (inclreplacedoc != null && exclreplacedoc != null && substreplacedoc != null) {
return setExpressionId(exprValue, new TemporalExpressions.Subsreplacedution(getTemporalExpression(delegator, inclreplacedoc.getString("toTempExprId")), getTemporalExpression(delegator, exclreplacedoc.getString("toTempExprId")), getTemporalExpression(delegator, substreplacedoc.getString("toTempExprId"))));
}
} else if (UNION.equals(tempExprTypeId)) {
return setExpressionId(exprValue, new TemporalExpressions.Union(getChildExpressions(delegator, tempExprId)));
}
return TemporalExpressions.NULL_EXPRESSION;
}
19
Source : TemporalExpressionWorker.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
private static TemporalExpression setExpressionId(GenericValue value, TemporalExpression expression) {
expression.setId(value.getString("tempExprId"));
return expression;
}
19
Source : RecurrenceInfo.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Initializes the rules for this RecurrenceInfo object.
*/
public void init() throws RecurrenceInfoException {
if (info.get("startDateTime") == null) {
throw new RecurrenceInfoException("Recurrence startDateTime cannot be null.");
}
// Get start date
long startTime = info.getTimestamp("startDateTime").getTime();
if (startTime > 0) {
int nanos = info.getTimestamp("startDateTime").getNanos();
startTime += (nanos / 1000000);
} else {
throw new RecurrenceInfoException("Recurrence startDateTime must have a value.");
}
startDate = new Date(startTime);
// Get the recurrence rules objects
try {
rRulesList = new ArrayList<>();
for (GenericValue value : info.getRelated("RecurrenceRule", null, null, false)) {
rRulesList.add(new RecurrenceRule(value));
}
} catch (GenericEnreplacedyException gee) {
rRulesList = null;
} catch (RecurrenceRuleException rre) {
throw new RecurrenceInfoException("Illegal rule format.", rre);
}
// Get the exception rules objects
try {
eRulesList = new ArrayList<>();
for (GenericValue value : info.getRelated("ExceptionRecurrenceRule", null, null, false)) {
eRulesList.add(new RecurrenceRule(value));
}
} catch (GenericEnreplacedyException gee) {
eRulesList = null;
} catch (RecurrenceRuleException rre) {
throw new RecurrenceInfoException("Illegal rule format", rre);
}
// Get the recurrence date list
rDateList = RecurrenceUtil.parseDateList(StringUtil.split(info.getString("recurrenceDateTimes"), ","));
// Get the exception date list
eDateList = RecurrenceUtil.parseDateList(StringUtil.split(info.getString("exceptionDateTimes"), ","));
// Sort the lists.
rDateList.sort(null);
eDateList.sort(null);
}
19
Source : SecurityUtil.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Return a JWToken for authenticate a userLogin with salt the token by userLoginId and currentPreplacedword
*/
public static String generateJwtToAuthenticateUserLogin(Delegator delegator, String userLoginId) throws GenericEnreplacedyException {
GenericValue userLogin = EnreplacedyQuery.use(delegator).from("UserLogin").where("userLoginId", userLoginId).queryOne();
Map<String, String> claims = UtilMisc.toMap("userLoginId", userLogin.getString("userLoginId"));
return JWTManager.createJwt(delegator, claims, userLogin.getString("userLoginId") + userLogin.getString("currentPreplacedword"), -1);
}
19
Source : MethodContext.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
public void setUserLogin(GenericValue userLogin, String userLoginEnvName) {
this.userLogin = userLogin;
this.putEnv(userLoginEnvName, userLogin);
}
19
Source : SetPkFields.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
@Override
public boolean exec(MethodContext methodContext) throws MiniLangException {
GenericValue value = valueFma.get(methodContext.getEnvMap());
if (value == null) {
throw new MiniLangRuntimeException("Enreplacedy value not found with name: " + valueFma, this);
}
Map<String, ? extends Object> theMap = mapFma.get(methodContext.getEnvMap());
if (theMap == null) {
throw new MiniLangRuntimeException("Map not found with name: " + mapFma, this);
}
boolean setIfNull = !"false".equals(setIfNullFse.expand(methodContext.getEnvMap()));
value.setPKFields(theMap, setIfNull);
return true;
}
19
Source : CloneValue.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
@Override
public boolean exec(MethodContext methodContext) throws MiniLangException {
GenericValue value = valueFma.get(methodContext.getEnvMap());
if (value != null) {
newValueFma.put(methodContext.getEnvMap(), GenericValue.create(value));
}
return true;
}
19
Source : EntityCacheServices.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Gets auth user login.
* @return the auth user login
*/
public GenericValue getAuthUserLogin() {
GenericValue userLogin = null;
try {
userLogin = EnreplacedyQuery.use(delegator).from("UserLogin").where("userLoginId", userLoginId).cache().queryOne();
} catch (GenericEnreplacedyException e) {
Debug.logError(e, "Error finding the userLogin for distributed cache clear", MODULE);
}
return userLogin;
}
19
Source : EntityTypeUtil.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* A generic method to be used on Type enities, e.g. ProductType. Recurse to the root level in the type hierarchy
* and checks if the specified type childType has parentType as its parent somewhere in the hierarchy.
* @param delegator The Delegator object.
* @param enreplacedyName Name of the Type enreplacedy on which check is performed.
* @param primaryKey Primary Key field of the Type enreplacedy.
* @param childType Type value for which the check is performed.
* @param parentTypeField Field in Type enreplacedy which stores the parent type.
* @param parentType Value of the parent type against which check is performed.
* @return boolean value based on the check results.
*/
public static boolean hasParentType(Delegator delegator, String enreplacedyName, String primaryKey, String childType, String parentTypeField, String parentType) {
GenericValue childTypeValue = null;
try {
childTypeValue = EnreplacedyQuery.use(delegator).from(enreplacedyName).where(primaryKey, childType).cache(true).queryOne();
} catch (GenericEnreplacedyException e) {
Debug.logError("Error finding " + enreplacedyName + " record for type " + childType, MODULE);
}
if (childTypeValue != null) {
if (parentType.equals(childTypeValue.getString(primaryKey)))
return true;
if (childTypeValue.getString(parentTypeField) != null) {
if (parentType.equals(childTypeValue.getString(parentTypeField))) {
return true;
} else {
return hasParentType(delegator, enreplacedyName, primaryKey, childTypeValue.getString(parentTypeField), parentTypeField, parentType);
}
}
}
return false;
}
19
Source : EntityTypeUtil.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
public static boolean isType(GenericValue thisType, GenericValue targetType) {
if (thisType == null) {
return false;
} else if (targetType.equals(thisType)) {
return true;
} else {
return isType(getParentType(thisType), targetType);
}
}
19
Source : EntityTypeUtil.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
public static boolean isType(Collection<GenericValue> thisCollection, String typeRelation, GenericValue targetType) {
for (GenericValue value : thisCollection) {
try {
GenericValue related = value.getRelatedOne(typeRelation, false);
if (isType(related, targetType)) {
return true;
}
// else keep looking
} catch (GenericEnreplacedyException e) {
continue;
}
}
return false;
}
19
Source : EntityQuery.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Executes the EnreplacedyQuery and returns the first result
* @return GenericValue representing the first result record from the query
*/
public GenericValue queryFirst() throws GenericEnreplacedyException {
EnreplacedyFindOptions efo = makeEnreplacedyFindOptions();
// Only limit results when the query isn't filtering by date in memory against a cached result
if (!this.useCache && !this.filterByDate) {
efo.setMaxRows(1);
}
GenericValue result = EnreplacedyUtil.getFirst(query(efo));
return result;
}
19
Source : EntityQuery.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Executes the EnreplacedyQuery and a single result record
* @return GenericValue representing the only result record from the query
*/
public GenericValue queryOne() throws GenericEnreplacedyException {
this.searchPkOnly = true;
GenericValue result = EnreplacedyUtil.getOnly(queryList());
return result;
}
19
Source : EntityDataAssert.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
public static void checkSingleValue(GenericValue checkValue, Delegator delegator, List<Object> errorMessages) throws GenericEnreplacedyException {
if (checkValue == null) {
errorMessages.add("Got a value to check was null");
return;
}
// to check get the PK, find by that, compare all fields
GenericPK checkPK = null;
try {
checkPK = checkValue.getPrimaryKey();
GenericValue currentValue = EnreplacedyQuery.use(delegator).from(checkPK.getEnreplacedyName()).where(checkPK).queryOne();
if (currentValue == null) {
errorMessages.add("Enreplacedy [" + checkPK.getEnreplacedyName() + "] record not found for pk: " + checkPK);
return;
}
ModelEnreplacedy modelEnreplacedy = checkValue.getModelEnreplacedy();
for (String nonpkFieldName : modelEnreplacedy.getNoPkFieldNames()) {
// skip the fields the enreplacedy engine maintains
if (ModelEnreplacedy.CREATE_STAMP_FIELD.equals(nonpkFieldName) || ModelEnreplacedy.CREATE_STAMP_TX_FIELD.equals(nonpkFieldName) || ModelEnreplacedy.STAMP_FIELD.equals(nonpkFieldName) || ModelEnreplacedy.STAMP_TX_FIELD.equals(nonpkFieldName)) {
continue;
}
Object checkField = checkValue.get(nonpkFieldName);
Object currentField = currentValue.get(nonpkFieldName);
if (checkField != null && !checkField.equals(currentField)) {
errorMessages.add("Field [" + modelEnreplacedy.getEnreplacedyName() + "." + nonpkFieldName + "] did not match; file value [" + checkField + "], db value [" + currentField + "] pk [" + checkPK + "]");
}
}
} catch (GenericEnreplacedyException e) {
throw e;
} catch (Throwable t) {
String errMsg;
if (checkPK == null) {
errMsg = "Error checking value [" + checkValue + "]: " + t.toString();
} else {
errMsg = "Error checking enreplacedy [" + checkPK.getEnreplacedyName() + "] with pk [" + checkPK.getAllFields() + "]: " + t.toString();
}
errorMessages.add(errMsg);
Debug.logError(t, errMsg, MODULE);
}
}
19
Source : EntityDataAssert.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
public static void checkValueList(List<GenericValue> valueList, Delegator delegator, List<Object> errorMessages) throws GenericEnreplacedyException {
if (valueList == null)
return;
for (GenericValue checkValue : valueList) {
checkSingleValue(checkValue, delegator, errorMessages);
}
}
19
Source : EntityCryptoTestSuite.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Test crypto.
* @throws Exception the exception
*/
public void testCrypto() throws Exception {
String nanoTime = "" + System.nanoTime();
getDelegator().removeByAnd("TestingCrypto", UtilMisc.toMap("testingCryptoTypeId", "BASIC"));
getDelegator().create("TestingCrypto", UtilMisc.toMap("testingCryptoId", "1", "testingCryptoTypeId", "BASIC"));
GenericValue enreplacedy = EnreplacedyQuery.use(getDelegator()).from("TestingCrypto").where("testingCryptoId", "1").queryOne();
replacedertNull(enreplacedy.getString("unencryptedValue"));
replacedertNull(enreplacedy.getString("encryptedValue"));
enreplacedy.setString("unencryptedValue", nanoTime);
enreplacedy.setString("encryptedValue", nanoTime);
enreplacedy.setString("saltedEncryptedValue", nanoTime);
replacedertEquals(nanoTime, enreplacedy.getString("unencryptedValue"));
replacedertEquals(nanoTime, enreplacedy.getString("encryptedValue"));
replacedertEquals(nanoTime, enreplacedy.getString("saltedEncryptedValue"));
enreplacedy.store();
enreplacedy.refresh();
replacedertEquals(nanoTime, enreplacedy.getString("unencryptedValue"));
replacedertEquals(nanoTime, enreplacedy.getString("encryptedValue"));
replacedertEquals(nanoTime, enreplacedy.getString("saltedEncryptedValue"));
}
19
Source : EntityCryptoTestSuite.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Test crypto encryption.
* @throws Exception the exception
*/
public void testCryptoEncryption() throws Exception {
Delegator delegator = getDelegator();
// clear out all values
delegator.removeByAnd("TestingCrypto", UtilMisc.toMap("testingCryptoTypeId", "BASIC"));
String nanoTime = "" + System.nanoTime();
// Ensure that null values are preplaceded thru unencrypted.
delegator.create("TestingCrypto", UtilMisc.toMap("testingCryptoId", "1", "testingCryptoTypeId", "BASIC"));
GenericValue enreplacedy = EnreplacedyQuery.use(delegator).from("TestingCrypto").where("testingCryptoId", "1").queryOne();
replacedertNull(enreplacedy.getString("unencryptedValue"));
replacedertNull(enreplacedy.getString("encryptedValue"));
replacedertNull(enreplacedy.getString("saltedEncryptedValue"));
GenericValue view = EnreplacedyQuery.use(delegator).from("TestingCryptoRawView").where("testingCryptoId", "1").queryOne();
replacedertNull(view.getString("unencryptedValue"));
replacedertNull(view.getString("encryptedValue"));
replacedertNull(view.getString("saltedEncryptedValue"));
replacedertNull(view.getString("rawEncryptedValue"));
replacedertNull(view.getString("rawSaltedEncryptedValue"));
// Verify that encryption is taking place
enreplacedy.setString("unencryptedValue", nanoTime);
enreplacedy.setString("encryptedValue", nanoTime);
enreplacedy.setString("saltedEncryptedValue", nanoTime);
enreplacedy.store();
view.refresh();
replacedertEquals(nanoTime, view.getString("unencryptedValue"));
replacedertEquals(nanoTime, view.getString("encryptedValue"));
replacedertEquals(nanoTime, view.getString("saltedEncryptedValue"));
String initialValue = view.getString("rawEncryptedValue");
String initialSaltedValue = view.getString("rawSaltedEncryptedValue");
replacedertFalse(nanoTime.equals(initialValue));
replacedertFalse(nanoTime.equals(initialSaltedValue));
replacedertFalse(initialValue.equals(initialSaltedValue));
// Verify that the same value stored repeatedly gives different raw encrypted values.
enreplacedy.setString("encryptedValue", nanoTime);
enreplacedy.setString("saltedEncryptedValue", nanoTime);
enreplacedy.store();
// enreplacedy.refresh(); // this is a bug; store() ends up setting the encrypted value *into* the enreplacedy
replacedertEquals(nanoTime, enreplacedy.getString("unencryptedValue"));
replacedertEquals(nanoTime, enreplacedy.getString("encryptedValue"));
view.refresh();
replacedertEquals(nanoTime, view.getString("unencryptedValue"));
replacedertEquals(nanoTime, view.getString("encryptedValue"));
replacedertEquals(nanoTime, view.getString("saltedEncryptedValue"));
String updatedValue = view.getString("rawEncryptedValue");
String updatedSaltedValue = view.getString("rawSaltedEncryptedValue");
replacedertFalse(nanoTime.equals(updatedValue));
replacedertFalse(nanoTime.equals(updatedSaltedValue));
replacedertFalse(updatedValue.equals(updatedSaltedValue));
replacedertEquals(initialValue, updatedValue);
replacedertFalse(initialSaltedValue.equals(updatedSaltedValue));
}
19
Source : ReadOnlyHelperDAO.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Find a Generic Enreplacedy by its Primary Key and only returns the values requested by the preplaceded keys (names)
* @param primaryKey The primary key to find by.
* @param keys The keys, or names, of the values to retrieve; only these values will be retrieved
* @return The GenericValue corresponding to the primaryKey
*/
@Override
public GenericValue findByPrimaryKeyPartial(GenericPK primaryKey, Set<String> keys) throws GenericEnreplacedyException {
if (primaryKey == null) {
return null;
}
GenericValue genericValue = GenericValue.create(primaryKey);
genericDAO.partialSelect(genericValue, keys);
return genericValue;
}
19
Source : ReadOnlyHelperDAO.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Read only, no store realize on the database
* @return 0
*/
@Override
public int store(GenericValue value) throws GenericEnreplacedyException {
return 0;
}
19
Source : ReadOnlyHelperDAO.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
@Override
public List<GenericValue> findByMultiRelation(GenericValue value, ModelRelation modelRelationOne, ModelEnreplacedy modelEnreplacedyOne, ModelRelation modelRelationTwo, ModelEnreplacedy modelEnreplacedyTwo, List<String> orderBy) throws GenericEnreplacedyException {
return genericDAO.selectByMultiRelation(value, modelRelationOne, modelEnreplacedyOne, modelRelationTwo, modelEnreplacedyTwo, orderBy);
}
19
Source : ReadOnlyHelperDAO.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Find a Generic Enreplacedy by its Primary Key
* @param primaryKey The primary key to find by.
* @return The GenericValue corresponding to the primaryKey
*/
@Override
public GenericValue findByPrimaryKey(GenericPK primaryKey) throws GenericEnreplacedyException {
if (primaryKey == null) {
return null;
}
GenericValue genericValue = GenericValue.create(primaryKey);
genericDAO.select(genericValue);
return genericValue;
}
19
Source : ReadOnlyHelperDAO.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Read only, no creation realize on the database
* @return null
*/
@Override
public GenericValue create(GenericValue value) throws GenericEnreplacedyException {
return null;
}
19
Source : GenericHelperDAO.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Store the Enreplacedy from the GenericValue to the persistent store
* @param value GenericValue instance containing the enreplacedy
* @return int representing number of rows effected by this operation
*/
@Override
public int store(GenericValue value) throws GenericEnreplacedyException {
if (value == null) {
return 0;
}
return genericDAO.update(value);
}
19
Source : GenericHelperDAO.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Creates a Enreplacedy in the form of a GenericValue and write it to the database
* @return GenericValue instance containing the new instance
*/
@Override
public GenericValue create(GenericValue value) throws GenericEnreplacedyException {
if (value == null) {
return null;
}
int retVal = genericDAO.insert(value);
if (Debug.verboseOn()) {
Debug.logVerbose("Insert Return Value : " + retVal, MODULE);
}
return value;
}
19
Source : Cache.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Put generic value.
* @param pk the pk
* @param enreplacedy the enreplacedy
* @return the generic value
*/
public GenericValue put(GenericPK pk, GenericValue enreplacedy) {
GenericValue oldEnreplacedy = enreplacedyCache.put(pk, enreplacedy);
if (pk.getModelEnreplacedy().getAutoClearCache()) {
enreplacedyListCache.storeHook(pk, enreplacedy);
enreplacedyObjectCache.storeHook(pk, enreplacedy);
}
return oldEnreplacedy;
}
19
Source : Cache.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Remove generic value.
* @param pk the pk
* @return the generic value
*/
public GenericValue remove(GenericPK pk) {
if (Debug.verboseOn()) {
Debug.logVerbose("Cache remove GenericPK: " + pk, MODULE);
}
GenericValue oldEnreplacedy = enreplacedyCache.remove(pk);
// Workaround because AbstractEnreplacedyConditionCache.storeHook doesn't work.
enreplacedyListCache.remove(pk);
enreplacedyObjectCache.remove(pk);
// enreplacedyListCache.storeHook(pk, null);
// enreplacedyObjectCache.storeHook(pk, null);
return oldEnreplacedy;
}
19
Source : PerformFindTests.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
private void performFindFilterByDateWithDedicateDateField() throws Exception {
GenericValue userLogin = getUserLogin("system");
prepareData();
LocalDispatcher dispatcher = getDispatcher();
// first test without filterDate condition
Map<String, Object> inputFields = UtilMisc.toMap("testingNodeId", "NODE_1");
Map<String, Object> performFindMap = UtilMisc.toMap("userLogin", userLogin, "enreplacedyName", "TestingNodeMember", "inputFields", inputFields, "filterByDate", "N", "filterByDateValue", UtilDateTime.nowTimestamp(), "fromDateName", "extendFromDate", "thruDateName", "extendThruDate");
Map<String, Object> result = dispatcher.runSync("performFind", performFindMap);
replacedertTrue(ServiceUtil.isSuccess(result));
List<GenericValue> foundElements = getCompleteList(result);
replacedertEquals("performFind search with filterDate N and specific date field name", 5, foundElements.size());
// second test with filterDate condition
performFindMap = UtilMisc.toMap("userLogin", userLogin, "enreplacedyName", "TestingNodeMember", "inputFields", inputFields, "filterByDate", "Y", "filterByDateValue", UtilDateTime.nowTimestamp(), "fromDateName", "extendFromDate", "thruDateName", "extendThruDate");
result = dispatcher.runSync("performFind", performFindMap);
replacedertTrue(ServiceUtil.isSuccess(result));
foundElements = getCompleteList(result);
replacedertEquals("performFind search with filterDate Y and specific date field name", 4, foundElements.size());
}
19
Source : PerformFindTests.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
private void performFindConditionFieldLike() throws Exception {
GenericValue userLogin = getUserLogin("system");
prepareData();
LocalDispatcher dispatcher = getDispatcher();
// first test like condition
Map<String, Object> inputFields = UtilMisc.toMap("testingName", "nice", "testingName_op", "like");
Map<String, Object> performFindMap = UtilMisc.toMap("userLogin", userLogin, "enreplacedyName", "Testing", "inputFields", inputFields);
Map<String, Object> result = dispatcher.runSync("performFind", performFindMap);
replacedertTrue(ServiceUtil.isSuccess(result));
List<GenericValue> foundElements = getCompleteList(result);
replacedertEquals("performFind search with like nice% condition", 3, foundElements.size());
// second test contains condition
inputFields = UtilMisc.toMap("testingName", "name", "testingName_op", "contains");
performFindMap = UtilMisc.toMap("userLogin", userLogin, "enreplacedyName", "Testing", "inputFields", inputFields);
result = dispatcher.runSync("performFind", performFindMap);
replacedertTrue(ServiceUtil.isSuccess(result));
foundElements = getCompleteList(result);
replacedertEquals("performFind search with like %name% condition", 4, foundElements.size());
// third test not-like condition
inputFields = UtilMisc.toMap("testingName", "bad", "testingName_op", "not-like");
performFindMap = UtilMisc.toMap("userLogin", userLogin, "enreplacedyName", "Testing", "inputFields", inputFields);
result = dispatcher.runSync("performFind", performFindMap);
replacedertTrue(ServiceUtil.isSuccess(result));
foundElements = getCompleteList(result);
replacedertEquals("performFind search with not like bad% condition", 4, foundElements.size());
// fourth test not-contains condition
inputFields = UtilMisc.toMap("testingName", "name", "testingName_op", "not-contains");
performFindMap = UtilMisc.toMap("userLogin", userLogin, "enreplacedyName", "Testing", "inputFields", inputFields);
result = dispatcher.runSync("performFind", performFindMap);
replacedertTrue(ServiceUtil.isSuccess(result));
foundElements = getCompleteList(result);
replacedertEquals("performFind search with not like %name% condition", 1, foundElements.size());
}
19
Source : PerformFindTests.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
private void performFindFilterByDate() throws Exception {
GenericValue userLogin = getUserLogin("system");
prepareData();
LocalDispatcher dispatcher = getDispatcher();
// first test without filterDate condition
Map<String, Object> inputFields = UtilMisc.toMap("testingNodeId", "NODE_1");
Map<String, Object> performFindMap = UtilMisc.toMap("userLogin", userLogin, "enreplacedyName", "TestingNodeMember", "inputFields", inputFields, "filterByDate", "N", "filterByDateValue", UtilDateTime.nowTimestamp());
Map<String, Object> result = dispatcher.runSync("performFind", performFindMap);
replacedertTrue(ServiceUtil.isSuccess(result));
List<GenericValue> foundElements = getCompleteList(result);
replacedertEquals("performFind search with filterDate N", 5, foundElements.size());
// second test with filterDate condition
performFindMap = UtilMisc.toMap("userLogin", userLogin, "enreplacedyName", "TestingNodeMember", "inputFields", inputFields, "filterByDate", "Y", "filterByDateValue", UtilDateTime.nowTimestamp());
result = dispatcher.runSync("performFind", performFindMap);
replacedertTrue(ServiceUtil.isSuccess(result));
foundElements = getCompleteList(result);
replacedertEquals("performFind search with filterDate Y", 3, foundElements.size());
}
19
Source : PerformFindTests.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
private void performFindConditionDistinct() throws Exception {
GenericValue userLogin = getUserLogin("system");
prepareData();
LocalDispatcher dispatcher = getDispatcher();
// first test without distinct condition
Map<String, Object> inputFields = UtilMisc.toMap("testingTypeId", "PERFOMFINDTEST");
List<String> fieldList = UtilMisc.toList("testingName", "testingTypeId");
Map<String, Object> performFindMap = UtilMisc.toMap("userLogin", userLogin, "enreplacedyName", "Testing", "inputFields", inputFields, "fieldList", fieldList, "distinct", "N");
Map<String, Object> result = dispatcher.runSync("performFind", performFindMap);
replacedertTrue(ServiceUtil.isSuccess(result));
List<GenericValue> foundElements = getCompleteList(result);
replacedertEquals("performFind search with distinct N", 9, foundElements.size());
// second test with distinct condition
performFindMap = UtilMisc.toMap("userLogin", userLogin, "enreplacedyName", "Testing", "inputFields", inputFields, "fieldList", fieldList, "distinct", "Y");
result = dispatcher.runSync("performFind", performFindMap);
replacedertTrue(ServiceUtil.isSuccess(result));
foundElements = getCompleteList(result);
replacedertEquals("performFind search with distinct Y", 5, foundElements.size());
}
19
Source : ContextHelper.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
public void setUserLogin(GenericValue userLogin, String userLoginEnvName) {
putEnv(userLoginEnvName, userLogin);
}
19
Source : PreferenceWorker.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Convert a List of UserPreference GenericValues to a userPrefMap.
* @param recList List of GenericValues to convert
* @throws GeneralException
* @return user preference map
*/
public static Map<String, Object> createUserPrefMap(List<GenericValue> recList) throws GeneralException {
Map<String, Object> userPrefMap = new LinkedHashMap<>();
if (recList != null) {
for (GenericValue value : recList) {
addPrefToMap(value, userPrefMap);
}
}
return userPrefMap;
}
19
Source : PreferenceWorker.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Convert a UserPreference GenericValue to a userPrefMap.
* @param rec GenericValue to convert
* @throws GeneralException
* @return user preference map
*/
public static Map<String, Object> createUserPrefMap(GenericValue rec) throws GeneralException {
return addPrefToMap(rec, new LinkedHashMap<>());
}
See More Examples