Author: doogie
Date: Sat Mar 21 23:23:34 2009 New Revision: 757070 URL: http://svn.apache.org/viewvc?rev=757070&view=rev Log: Fix purely empty whitespace lines, and remove trailing whitespace. Modified: ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/EntityGroupUtil.java ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/EntityServiceFactory.java ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/EntityWatchServices.java ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/cache/EntityCacheServices.java ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataLoadContainer.java ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataServices.java ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/DelegatorEcaHandler.java ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaAction.java ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaCondition.java ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaException.java ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaRule.java ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaSetField.java ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaUtil.java ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/permission/EntityPermissionChecker.java ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/synchronization/EntitySyncContext.java ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/synchronization/EntitySyncServices.java Modified: ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/EntityGroupUtil.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/EntityGroupUtil.java?rev=757070&r1=757069&r2=757070&view=diff ============================================================================== --- ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/EntityGroupUtil.java (original) +++ ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/EntityGroupUtil.java Sat Mar 21 23:23:34 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -41,14 +41,14 @@ public static Set<String> getEntityNamesByGroup(String entityGroupId, GenericDelegator delegator, boolean requireStampFields) throws GenericEntityException { Set<String> entityNames = FastSet.newInstance(); - + List<GenericValue> entitySyncGroupIncludes = delegator.findByAnd("EntityGroupEntry", UtilMisc.toMap("entityGroupId", entityGroupId)); - + List<ModelEntity> modelEntities = getModelEntitiesFromRecords(entitySyncGroupIncludes, delegator, requireStampFields); for (ModelEntity modelEntity: modelEntities) { entityNames.add(modelEntity.getEntityName()); } - + return entityNames; } @@ -57,17 +57,17 @@ for (String entityName: delegator.getModelReader().getEntityNames()) { ModelEntity modelEntity = delegator.getModelEntity(entityName); - + // if view-entity, throw it out if (modelEntity instanceof ModelViewEntity) { continue; } - + // if it doesn't have either or both of the two update stamp fields, throw it out if (requireStampFields && (!modelEntity.isField(ModelEntity.STAMP_FIELD) || !modelEntity.isField(ModelEntity.STAMP_TX_FIELD))) { continue; } - + // if there are no includes records, always include; otherwise check each one to make sure at least one matches if (entityGroupEntryValues.size() == 0) { entityModelToUseList.add(modelEntity); @@ -88,7 +88,7 @@ } else if (modelEntity.getPackageName().startsWith(entityOrPackage)) { matches = true; } - + if (matches) { if ("ESIA_INCLUDE".equals(entitySyncInclude.getString("applEnumId"))) { matchesInclude = true; @@ -100,7 +100,7 @@ } } } - + if (matchesAlways || (matchesInclude && !matchesExclude)) { // make sure this log message is not checked in uncommented: //Debug.log("In runEntitySync adding [" + modelEntity.getEntityName() + "] to list of Entities to sync", module); @@ -108,7 +108,7 @@ } } } - + return entityModelToUseList; } } Modified: ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/EntityServiceFactory.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/EntityServiceFactory.java?rev=757070&r1=757069&r2=757070&view=diff ============================================================================== --- ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/EntityServiceFactory.java (original) +++ ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/EntityServiceFactory.java Sat Mar 21 23:23:34 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -34,7 +34,7 @@ LocalDispatcher dispatcher = GenericDispatcher.getLocalDispatcher("entity-" + delegator.getDelegatorName(), delegator); return dispatcher; } - + public static DispatchContext getDispatchContext(GenericDelegator delegator) { LocalDispatcher dispatcher = getLocalDispatcher(delegator); if (dispatcher == null) return null; Modified: ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/EntityWatchServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/EntityWatchServices.java?rev=757070&r1=757069&r2=757070&view=diff ============================================================================== --- ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/EntityWatchServices.java (original) +++ ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/EntityWatchServices.java Sat Mar 21 23:23:34 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -47,7 +47,7 @@ /** * This service is meant to be called through an Entity ECA (EECA) to watch an entity - * + * * @param dctx * @param context * @return @@ -55,11 +55,11 @@ public static Map watchEntity(DispatchContext dctx, Map context) { GenericValue newValue = (GenericValue) context.get("newValue"); String fieldName = (String) context.get("fieldName"); - + if (newValue == null) { return ServiceUtil.returnSuccess(); } - + GenericValue currentValue = null; try { currentValue = dctx.getDelegator().findOne(newValue.getEntityName(), newValue.getPrimaryKey(), false); @@ -67,7 +67,7 @@ String errMsg = "Error finding currentValue for primary key [" + newValue.getPrimaryKey() + "]: " + e.toString(); Debug.logError(e, errMsg, module); } - + if (currentValue != null) { if (UtilValidate.isNotEmpty(fieldName)) { // just watch the field @@ -83,7 +83,7 @@ changed = true; } } - + if (changed) { String errMsg = "Watching entity [" + currentValue.getEntityName() + "] field [" + fieldName + "] value changed from [" + currentFieldValue + "] to [" + newFieldValue + "] for pk [" + newValue.getPrimaryKey() + "]"; Debug.log(new Exception(errMsg), errMsg, module); @@ -107,7 +107,7 @@ Debug.log(new Exception(errMsg), errMsg, module); } } - + return ServiceUtil.returnSuccess(); } } Modified: ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/cache/EntityCacheServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/cache/EntityCacheServices.java?rev=757070&r1=757069&r2=757070&view=diff ============================================================================== --- ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/cache/EntityCacheServices.java (original) +++ ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/cache/EntityCacheServices.java Sat Mar 21 23:23:34 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -39,7 +39,7 @@ * Entity Engine Cache Services */ public class EntityCacheServices implements DistributedCacheClear { - + public static final String module = EntityCacheServices.class.getName(); protected GenericDelegator delegator = null; @@ -53,7 +53,7 @@ this.dispatcher = EntityServiceFactory.getLocalDispatcher(delegator); this.userLoginId = userLoginId; } - + public GenericValue getAuthUserLogin() { GenericValue userLogin = null; try { @@ -76,7 +76,7 @@ Debug.logWarning("The userLogin for distributed cache clear was not found with userLoginId [" + userLoginId + "], not clearing remote caches.", module); return; } - + try { this.dispatcher.runAsync("distributedClearCacheLineByValue", UtilMisc.toMap("value", value, "userLogin", userLogin), false); } catch (GenericServiceException e) { @@ -96,7 +96,7 @@ Debug.logWarning("The userLogin for distributed cache clear was not found with userLoginId [" + userLoginId + "], not clearing remote caches.", module); return; } - + try { this.dispatcher.runAsync("distributedClearCacheLineByDummyPK", UtilMisc.toMap("dummyPK", dummyPK, "userLogin", userLogin), false); } catch (GenericServiceException e) { @@ -116,14 +116,14 @@ Debug.logWarning("The userLogin for distributed cache clear was not found with userLoginId [" + userLoginId + "], not clearing remote caches.", module); return; } - + try { this.dispatcher.runAsync("distributedClearCacheLineByCondition", UtilMisc.toMap("entityName", entityName, "condition", condition, "userLogin", userLogin), false); } catch (GenericServiceException e) { Debug.logError(e, "Error running the distributedClearCacheLineByCondition service", module); } } - + public void distributedClearCacheLine(GenericPK primaryKey) { // Debug.logInfo("running distributedClearCacheLine for primaryKey: " + primaryKey, module); if (this.dispatcher == null) { @@ -136,7 +136,7 @@ Debug.logWarning("The userLogin for distributed cache clear was not found with userLoginId [" + userLoginId + "], not clearing remote caches.", module); return; } - + try { this.dispatcher.runAsync("distributedClearCacheLineByPrimaryKey", UtilMisc.toMap("primaryKey", primaryKey, "userLogin", userLogin), false); } catch (GenericServiceException e) { @@ -155,14 +155,14 @@ Debug.logWarning("The userLogin for distributed cache clear was not found with userLoginId [" + userLoginId + "], not clearing remote caches.", module); return; } - + try { this.dispatcher.runAsync("distributedClearAllEntityCaches", UtilMisc.toMap("userLogin", userLogin), false); } catch (GenericServiceException e) { Debug.logError(e, "Error running the distributedClearAllCaches service", module); } } - + /** * Clear All Entity Caches Service *@param ctx The DispatchContext that this service is operating in @@ -174,12 +174,12 @@ Boolean distributeBool = (Boolean) context.get("distribute"); boolean distribute = false; if (distributeBool != null) distribute = distributeBool.booleanValue(); - + delegator.clearAllCaches(distribute); - + return ServiceUtil.returnSuccess(); } - + /** * Clear Cache Line Service: one of the following context parameters is required: value, dummyPK or primaryKey *@param ctx The DispatchContext that this service is operating in Modified: ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataLoadContainer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataLoadContainer.java?rev=757070&r1=757069&r2=757070&view=diff ============================================================================== --- ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataLoadContainer.java (original) +++ ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataLoadContainer.java Sat Mar 21 23:23:34 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -95,7 +95,7 @@ } argument = argument.substring(subIdx); } - + // parse the arguments String argumentName; String argumentVal; @@ -144,8 +144,8 @@ Debug.log("-inserts ............. use mostly inserts option", module); Debug.log("-help ................ display this information", module); System.exit(1); - } - + } + // special case if (this.readers == null && (!this.files.isEmpty() || this.directory != null)) { this.readers = "none"; @@ -244,7 +244,7 @@ NumberFormat changedFormat = NumberFormat.getIntegerInstance(); changedFormat.setMinimumIntegerDigits(5); changedFormat.setGroupingUsed(false); - + List<Object> errorMessages = FastList.newInstance(); List<String> infoMessages = FastList.newInstance(); int totalRowsChanged = 0; @@ -275,7 +275,7 @@ Debug.logImportant(message, module); } } - + if (errorMessages.size() > 0) { Debug.logImportant("The following errors occured in the data load:", module); for (Object message: errorMessages) { @@ -284,7 +284,7 @@ } Debug.logImportant("=-=-=-=-=-=-= Finished the data load with " + totalRowsChanged + " rows changed.", module); - + return true; } Modified: ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataServices.java?rev=757070&r1=757069&r2=757070&view=diff ============================================================================== --- ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataServices.java (original) +++ ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataServices.java Sat Mar 21 23:23:34 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -415,17 +415,17 @@ // step 8 - checkdb Debug.logImportant("Running DB check with add missing enabled", module); dbUtil.checkDb(modelEntities, messages, true); - + Map<String, Object> result = ServiceUtil.returnSuccess(); result.put("messages", messages); return result; } - + public static Map<String, Object> unwrapByteWrappers(DispatchContext dctx, Map<String, Object> context) { GenericDelegator delegator = dctx.getDelegator(); String entityName = (String) context.get("entityName"); String fieldName = (String) context.get("fieldName"); - + EntityListIterator eli = null; try { eli = delegator.find(entityName, null, null, null, null, null); @@ -451,7 +451,7 @@ } } } - + return ServiceUtil.returnSuccess(); } } Modified: ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/DelegatorEcaHandler.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/DelegatorEcaHandler.java?rev=757070&r1=757069&r2=757070&view=diff ============================================================================== --- ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/DelegatorEcaHandler.java (original) +++ ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/DelegatorEcaHandler.java Sat Mar 21 23:23:34 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -51,7 +51,7 @@ this.delegatorName = delegator.getDelegatorName(); this.entityEcaReaderName = EntityEcaUtil.getEntityEcaReaderName(this.delegatorName); this.dctx = EntityServiceFactory.getDispatchContext(delegator); - + //preload the cache EntityEcaUtil.getEntityEcaCache(this.entityEcaReaderName); } @@ -72,11 +72,11 @@ List<EntityEcaRule> rules = eventMap.get(event); //Debug.logInfo("Handler.evalRules for entity " + value.getEntityName() + ", event " + event + ", num rules=" + (rules == null ? 0 : rules.size()), module); - + if (rules == null || rules.size() == 0) { return; } - + if (!rules.isEmpty() && Debug.verboseOn()) Debug.logVerbose("Running ECA (" + event + ").", module); Set<String> actionsRun = new TreeSet<String>(); for (EntityEcaRule eca: rules) { Modified: ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaAction.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaAction.java?rev=757070&r1=757069&r2=757070&view=diff ============================================================================== --- ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaAction.java (original) +++ ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaAction.java Sat Mar 21 23:23:34 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -66,7 +66,7 @@ public void runAction(DispatchContext dctx, Map<String, ? extends Object> context, GenericEntity newValue) throws GenericEntityException { Map<String, Object> actionResult = null; - + try { // pull out context parameters needed for this service. Map<String, Object> actionContext = dctx.getModelService(serviceName).makeValid(context, ModelService.IN_PARAM); @@ -74,7 +74,7 @@ if (valueAttr != null && valueAttr.length() > 0) { actionContext.put(valueAttr, newValue); } - + //Debug.logInfo("Running Entity ECA action service " + this.serviceName + " triggered by entity: " + value.getEntityName(), module); //Debug.logInfo("Running Entity ECA action service " + this.serviceName + "; value=" + value + "; actionContext=" + actionContext, module); Modified: ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaCondition.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaCondition.java?rev=757070&r1=757069&r2=757070&view=diff ============================================================================== --- ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaCondition.java (original) +++ ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaCondition.java Sat Mar 21 23:23:34 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -34,7 +34,7 @@ * EntityEcaCondition */ public class EntityEcaCondition implements java.io.Serializable { - + public static final String module = EntityEcaCondition.class.getName(); protected String lhsValueName, rhsValueName; Modified: ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaException.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaException.java?rev=757070&r1=757069&r2=757070&view=diff ============================================================================== --- ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaException.java (original) +++ ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaException.java Sat Mar 21 23:23:34 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY Modified: ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaRule.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaRule.java?rev=757070&r1=757069&r2=757070&view=diff ============================================================================== --- ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaRule.java (original) +++ ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaRule.java Sat Mar 21 23:23:34 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -95,7 +95,7 @@ if (!"any".equals(this.operationName) && this.operationName.indexOf(currentOperation) == -1) { return; } - + Map<String, Object> context = FastMap.newInstance(); context.putAll(value); Modified: ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaSetField.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaSetField.java?rev=757070&r1=757069&r2=757070&view=diff ============================================================================== --- ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaSetField.java (original) +++ ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaSetField.java Sat Mar 21 23:23:34 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -62,7 +62,7 @@ // process the context changes if (UtilValidate.isNotEmpty(value)) { - context.put(fieldName, this.format(value, context)); + context.put(fieldName, this.format(value, context)); } else if (UtilValidate.isNotEmpty(envName) && context.get(envName) != null) { context.put(fieldName, this.format((String) context.get(envName), context)); } @@ -70,7 +70,7 @@ } protected Object format(String s, Map<String, ? extends Object> c) { - if (UtilValidate.isEmpty(s) || UtilValidate.isEmpty(format)) { + if (UtilValidate.isEmpty(s) || UtilValidate.isEmpty(format)) { return s; } @@ -81,7 +81,7 @@ newStr.append(c.get(envName)); } newStr.append(s); - return newStr.toString(); + return newStr.toString(); } if ("to-upper".equalsIgnoreCase(format)) { return s.toUpperCase(); Modified: ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaUtil.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaUtil.java?rev=757070&r1=757069&r2=757070&view=diff ============================================================================== --- ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaUtil.java (original) +++ ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaUtil.java Sat Mar 21 23:23:34 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY Modified: ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/permission/EntityPermissionChecker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/permission/EntityPermissionChecker.java?rev=757070&r1=757069&r2=757070&view=diff ============================================================================== --- ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/permission/EntityPermissionChecker.java (original) +++ ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/permission/EntityPermissionChecker.java Sat Mar 21 23:23:34 2009 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -70,28 +70,28 @@ protected PermissionConditionGetter permissionConditionGetter; protected RelatedRoleGetter relatedRoleGetter; protected AuxiliaryValueGetter auxiliaryValueGetter; - + public EntityPermissionChecker(Element element) { this.entityNameExdr = FlexibleStringExpander.getInstance(element.getAttribute("entity-name")); this.entityIdExdr = FlexibleStringExpander.getInstance(element.getAttribute("entity-id")); this.displayFailCond = "true".equals(element.getAttribute("display-fail-cond")); Element permissionConditionElement = UtilXml.firstChildElement(element, "permission-condition-getter"); if (permissionConditionElement == null) { - permissionConditionGetter = new StdPermissionConditionGetter(); + permissionConditionGetter = new StdPermissionConditionGetter(); } else { - permissionConditionGetter = new StdPermissionConditionGetter(permissionConditionElement); + permissionConditionGetter = new StdPermissionConditionGetter(permissionConditionElement); } Element auxiliaryValueElement = UtilXml.firstChildElement(element, "auxiliary-value-getter"); if (auxiliaryValueElement == null) { - auxiliaryValueGetter = new StdAuxiliaryValueGetter(); + auxiliaryValueGetter = new StdAuxiliaryValueGetter(); } else { - auxiliaryValueGetter = new StdAuxiliaryValueGetter(auxiliaryValueElement); + auxiliaryValueGetter = new StdAuxiliaryValueGetter(auxiliaryValueElement); } Element relatedRoleElement = UtilXml.firstChildElement(element, "related-role-getter"); if (relatedRoleElement == null) { - relatedRoleGetter = new StdRelatedRoleGetter(); + relatedRoleGetter = new StdRelatedRoleGetter(); } else { - relatedRoleGetter = new StdRelatedRoleGetter(relatedRoleElement); + relatedRoleGetter = new StdRelatedRoleGetter(relatedRoleElement); } String targetOperationString = element.getAttribute("target-operation"); if (UtilValidate.isNotEmpty(targetOperationString)) { @@ -106,7 +106,7 @@ } public boolean runPermissionCheck(Map<String, ?> context) { - + boolean passed = false; String idString = entityIdExdr.expandString(context); List<String> entityIdList = null; @@ -118,7 +118,7 @@ String entityName = entityNameExdr.expandString(context); HttpServletRequest request = (HttpServletRequest)context.get("request"); GenericValue userLogin = null; - String partyId = null; + String partyId = null; GenericDelegator delegator = null; if (request != null) { HttpSession session = request.getSession(); @@ -128,7 +128,7 @@ } delegator = (GenericDelegator)request.getAttribute("delegator"); } - + if (auxiliaryValueGetter != null) auxiliaryValueGetter.clearList(); if (relatedRoleGetter != null) relatedRoleGetter.clearList(); try { @@ -183,7 +183,7 @@ List<Object> entityIds = FastList.newInstance(); if (content != null) entityIds.add(content); if (UtilValidate.isNotEmpty(quickCheckContentId)) { - List<String> quickList = StringUtil.split(quickCheckContentId, "|"); + List<String> quickList = StringUtil.split(quickCheckContentId, "|"); if (UtilValidate.isNotEmpty(quickList)) entityIds.addAll(quickList); } Map<String, Object> results = FastMap.newInstance(); @@ -192,7 +192,7 @@ passed = security.hasEntityPermission("CONTENTMGR", entityAction, userLogin); } if (passed) { - results.put("permissionStatus", "granted"); + results.put("permissionStatus", "granted"); return results; } try { @@ -203,15 +203,15 @@ results.put("permissionStatus", "rejected"); } } catch (GenericEntityException e) { - ServiceUtil.returnError(e.getMessage()); + ServiceUtil.returnError(e.getMessage()); } return results; } - - + + public static boolean checkPermissionMethod(GenericDelegator delegator, GenericValue userLogin, List<String> targetOperationList, String entityName, List<? extends Object> entityIdList, List<String> purposeList, List<String> roleList, String privilegeEnumId) throws GenericEntityException { boolean passed = false; - + String lcEntityName = entityName.toLowerCase(); String userLoginId = null; String partyId = null; @@ -230,22 +230,22 @@ boolean hasStatusField = false; if (modelEntity.getField("statusId") != null) hasStatusField = true; - + boolean hasPrivilegeField = false; if (modelEntity.getField("privilegeEnumId") != null) hasPrivilegeField = true; - + List<GenericValue> operationEntities = null; ModelEntity modelOperationEntity = delegator.getModelEntity(entityName + "PurposeOperation"); if (modelOperationEntity == null) { - modelOperationEntity = delegator.getModelEntity(entityName + "Operation"); + modelOperationEntity = delegator.getModelEntity(entityName + "Operation"); } - + if (modelOperationEntity == null) { Debug.logError("No operation entity found for " + entityName, module); throw new RuntimeException("No operation entity found for " + entityName); } - + boolean hasPurposeOp = false; if (modelOperationEntity.getField(lcEntityName + "PurposeTypeId") != null) hasPurposeOp = true; @@ -255,8 +255,8 @@ boolean hasPrivilegeOp = false; if (modelOperationEntity.getField("privilegeEnumId") != null) hasPrivilegeOp = true; - - // Get all the condition operations that could apply, rather than having to go thru + + // Get all the condition operations that could apply, rather than having to go thru // entire table each time. //List condList = FastList.newInstance(); //Iterator iterType = targetOperationList.iterator(); @@ -265,49 +265,49 @@ // condList.add(EntityCondition.makeCondition(lcEntityName + "OperationId", op)); //} //EntityCondition opCond = EntityCondition.makeCondition(condList, EntityOperator.OR); - + EntityCondition opCond = EntityCondition.makeCondition(lcEntityName + "OperationId", EntityOperator.IN, targetOperationList); - + List<GenericValue> targetOperationEntityList = delegator.findList(modelOperationEntity.getEntityName(), opCond, null, null, null, true); Map<String, GenericValue> entities = FastMap.newInstance(); String pkFieldName = modelEntity.getFirstPkFieldName(); - + //TODO: privilegeEnumId test /* if (hasPrivilegeOp && hasPrivilegeField) { int privilegeEnumSeq = -1; - + if ( UtilValidate.isNotEmpty(privilegeEnumId)) { GenericValue privEnum = delegator.findByPrimaryKeyCache("Enumeration", UtilMisc.toMap("enumId", privilegeEnumId)); if (privEnum != null) { - String sequenceId = privEnum.getString("sequenceId"); + String sequenceId = privEnum.getString("sequenceId"); try { privilegeEnumSeq = Integer.parseInt(sequenceId); } catch (NumberFormatException e) { - // just leave it at -1 + // just leave it at -1 } } } - boolean thisPassed = true; + boolean thisPassed = true; Iterator iter = entityIdList.iterator(); while (iter.hasNext()) { GenericValue entity = getNextEntity(delegator, entityName, pkFieldName, iter.next(), entities); if (entity == null) continue; - + String entityId = entity.getString(pkFieldName); String targetPrivilegeEnumId = entity.getString("privilegeEnumId"); if (UtilValidate.isNotEmpty(targetPrivilegeEnumId)) { int targetPrivilegeEnumSeq = -1; GenericValue privEnum = delegator.findByPrimaryKeyCache("Enumeration", UtilMisc.toMap("enumId", privilegeEnumId)); if (privEnum != null) { - String sequenceId = privEnum.getString("sequenceId"); + String sequenceId = privEnum.getString("sequenceId"); try { targetPrivilegeEnumSeq = Integer.parseInt(sequenceId); } catch (NumberFormatException e) { - // just leave it at -1 + // just leave it at -1 } if (targetPrivilegeEnumSeq > privilegeEnumSeq) { - return false; + return false; } } } @@ -315,7 +315,7 @@ } } */ - + // check permission for each id in passed list until success. // Note that "quickCheck" id come first in the list // Check with no roles or purposes on the chance that the permission fields contain _NA_ s. @@ -327,41 +327,41 @@ for (Object id: entityIdList) { GenericValue entity = getNextEntity(delegator, entityName, pkFieldName, id, entities); if (entity == null) continue; - + String statusId = null; if (hasStatusOp && hasStatusField) { statusId = entity.getString("statusId"); } - + int privilegeEnumSeq = -1; if (hasPrivilegeOp && hasPrivilegeField) { privilegeEnumId = entity.getString("privilegeEnumId"); privilegeEnumSeq = getPrivilegeEnumSeq(delegator, privilegeEnumId); } - + passed = hasMatch(entityName, targetOperationEntityList, roleList, hasPurposeOp, purposeList, hasStatusOp, statusId); if (passed) { break; } } - + if (passed) { return true; } - + if (hasPurposeOp) { // Check with just purposes next. for (Object id: entityIdList) { GenericValue entity = getNextEntity(delegator, entityName, pkFieldName, id, entities); if (entity == null) continue; - + String entityId = entity.getString(pkFieldName); purposeList = getRelatedPurposes(entity, null); String statusId = null; if (hasStatusOp && hasStatusField) { statusId = entity.getString("statusId"); } - + if (purposeList.size() > 0) { passed = hasMatch(entityName, targetOperationEntityList, roleList, hasPurposeOp, purposeList, hasStatusOp, statusId); } @@ -371,11 +371,11 @@ purposes.put(entityId, purposeList); } } - + if (passed) return true; - + if (userLogin == null) return false; - + // Check with roles. for (Object id: entityIdList) { GenericValue entity = getNextEntity(delegator, entityName, pkFieldName, id, entities); @@ -386,70 +386,70 @@ if (tmpPurposeList != null) { purposeList.addAll(tmpPurposeList); } - } else { + } else { purposeList = tmpPurposeList; } - + List<String> tmpRoleList = getUserRoles(entity, userLogin, delegator); if (roleList != null ) { if (tmpRoleList != null) { roleList.addAll(tmpRoleList); } - } else { + } else { roleList = tmpRoleList; } - + String statusId = null; if (hasStatusOp && hasStatusField) { statusId = entity.getString("statusId"); } - + passed = hasMatch(entityName, targetOperationEntityList, roleList, hasPurposeOp, purposeList, hasStatusOp, statusId); if (passed) { break; } roles.put(entityId, roleList); } - + if (passed) return true; - + // Follow ownedEntityIds if (modelEntity.getField("owner" + entityName + "Id") != null) { for (Object id: entityIdList) { GenericValue entity = getNextEntity(delegator, entityName, pkFieldName, id, entities); if (entity == null) continue; - + String entityId = entity.getString(pkFieldName); List<String> ownedContentIdList = FastList.newInstance(); getEntityOwners(delegator, entity, ownedContentIdList, "Content", "ownerContentId"); - + List<String> ownedContentRoleIds = getUserRolesFromList(delegator, ownedContentIdList, partyId, "contentId", "partyId", "roleTypeId", "ContentRole"); String statusId = null; if (hasStatusOp && hasStatusField) { statusId = entity.getString("statusId"); } - + purposeList = purposes.get(entityId); passed = hasMatch(entityName, targetOperationEntityList, ownedContentRoleIds, hasPurposeOp, purposeList, hasStatusOp, statusId); if (passed) break; - - /* + + /* String ownedEntityId = entity.getString("owner" + entityName + "Id"); GenericValue ownedEntity = delegator.findByPrimaryKeyCache(entityName,UtilMisc.toMap(pkFieldName, ownedEntityId)); while (ownedEntity != null) { if (!alreadyCheckedIds.contains(ownedEntityId)) { // Decided to let the original purposes only be used in permission checking - // + // //purposeList = (List)purposes.get(entityId); //purposeList = getRelatedPurposes(ownedEntity, purposeList); roleList = getUserRoles(ownedEntity, userLogin, delegator); - + String statusId = null; if (hasStatusOp && hasStatusField) { statusId = entity.getString("statusId"); } - + passed = hasMatch(entityName, targetOperationEntityList, roleList, hasPurposeOp, purposeList, hasStatusOp, statusId); if (passed) break; @@ -467,8 +467,8 @@ */ } } - - + + /* seems like repeat // Check parents iter = entityIdList.iterator(); @@ -477,7 +477,7 @@ GenericValue entity = (GenericValue)entities.get(entityId); purposeList = (List)purposes.get(entityId); roleList = getUserRoles(entity, userLogin, delegator); - + String statusId = null; if (hasStatusOp && hasStatusField) { statusId = entity.getString("statusId"); @@ -486,35 +486,35 @@ if (hasPrivilegeOp && hasPrivilegeField) { targetPrivilegeEnumId = entity.getString("privilegeEnumId"); } - + passed = hasMatch(entityName, targetOperationEntityList, roleList, hasPurposeOp, purposeList, hasStatusOp, statusId); if (passed) break; alreadyCheckedIds.add(entityId); } */ - + return passed; } public static boolean checkPermissionMethod(GenericDelegator delegator, String partyId, String entityName, List<? extends Object> entityIdList, AuxiliaryValueGetter auxiliaryValueGetter, RelatedRoleGetter relatedRoleGetter, PermissionConditionGetter permissionConditionGetter) throws GenericEntityException { - + permissionConditionGetter.init(delegator); if (Debug.verboseOn()) Debug.logVerbose(permissionConditionGetter.dumpAsText(), module); boolean passed = false; - + boolean checkAncestors = false; boolean hasRoleOperation = checkHasRoleOperations(partyId, permissionConditionGetter, delegator); if ( hasRoleOperation ) { return true; } ModelEntity modelEntity = delegator.getModelEntity(entityName); - + if (relatedRoleGetter != null) { if (UtilValidate.isNotEmpty(partyId)) { - relatedRoleGetter.setList(UtilMisc.toList("LOGGEDIN")); + relatedRoleGetter.setList(UtilMisc.toList("LOGGEDIN")); } } - + // check permission for each id in passed list until success. // Note that "quickCheck" id come first in the list // Check with no roles or purposes on the chance that the permission fields contain _NA_ s. @@ -531,7 +531,7 @@ } //if (Debug.infoOn()) Debug.logInfo(entityIdString, module); } - + List alreadyCheckedIds = FastList.newInstance(); Map<String, GenericValue> entities = FastMap.newInstance(); //List purposeList = null; @@ -545,11 +545,11 @@ break; } } - + if (passed) { return true; } - + if (auxiliaryValueGetter != null) { //if (Debug.infoOn()) Debug.logInfo(auxiliaryValueGetter.dumpAsText(), module); // Check with just purposes next. @@ -558,18 +558,18 @@ if (entity == null) continue; checkAncestors = false; passed = hasMatch(entity, permissionConditionGetter, relatedRoleGetter, auxiliaryValueGetter, partyId, checkAncestors); - + if (passed) { break; } } } - + if (passed) return true; - + // TODO: need to return some information here about why it failed if (partyId == null) return false; - + // Check with roles. if (relatedRoleGetter != null) { for (Object id: entityIdList) { @@ -577,59 +577,59 @@ if (entity == null) continue; checkAncestors = false; passed = hasMatch(entity, permissionConditionGetter, relatedRoleGetter, auxiliaryValueGetter, partyId, checkAncestors); - + if (passed) { break; } } } - + if (passed) return true; - + if (relatedRoleGetter != null) { for (Object id: entityIdList) { GenericValue entity = getNextEntity(delegator, entityName, pkFieldName, id, entities); if (entity == null) continue; checkAncestors = true; passed = hasMatch(entity, permissionConditionGetter, relatedRoleGetter, auxiliaryValueGetter, partyId, checkAncestors); - + if (passed) { break; } } } - - + + return passed; } - - + + public static GenericValue getNextEntity(GenericDelegator delegator, String entityName, String pkFieldName, Object obj, Map<String, GenericValue> entities) throws GenericEntityException { GenericValue entity = null; if (obj instanceof String) { - String entityId = (String)obj; + String entityId = (String)obj; if (entities != null) entity = entities.get(entityId); - + if (entity == null) entity = delegator.findByPrimaryKeyCache(entityName,UtilMisc.toMap(pkFieldName, entityId)); } else if (obj instanceof GenericValue) { entity = (GenericValue)obj; } return entity; } - + public static boolean checkHasRoleOperations(String partyId, PermissionConditionGetter permissionConditionGetter , GenericDelegator delegator) { List<String> targetOperations = permissionConditionGetter.getOperationList(); return checkHasRoleOperations(partyId, targetOperations, delegator); } - + public static boolean checkHasRoleOperations(String partyId, List<String> targetOperations, GenericDelegator delegator) { //if (Debug.infoOn()) Debug.logInfo("targetOperations:" + targetOperations, module); //if (Debug.infoOn()) Debug.logInfo("userLoginId:" + userLoginId, module); if (targetOperations == null) return false; - + if (partyId != null && targetOperations.contains("HAS_USER_ROLE")) return true; - + boolean hasRoleOperation = false; boolean hasNeed = false; List<String> newHasRoleList = FastList.newInstance(); @@ -646,7 +646,7 @@ } } } - + if (hasNeed) { try { if (UtilValidate.isNotEmpty(partyId)) { @@ -670,7 +670,7 @@ } return hasRoleOperation; } - + public static boolean hasMatch(String entityName, List<GenericValue> targetOperations, List<String> roles, boolean hasPurposeOp, List<String> purposes, boolean hasStatusOp, String targStatusId) { boolean isMatch = false; int targPrivilegeSeq = 0; @@ -691,24 +691,24 @@ //if (hasPrivilegeOp) //testPrivilegeEnumId = (String)targetOp.get("privilegeEnumId"); //int testPrivilegeSeq = 0; - - boolean purposesCond = ( !hasPurposeOp || (purposes != null && purposes.contains(testContentPurposeTypeId) ) || testContentPurposeTypeId.equals("_NA_") ); - boolean statusCond = ( !hasStatusOp || testStatusId.equals("_NA_") || (targStatusId != null && targStatusId.equals(testStatusId) ) ); - //boolean privilegeCond = ( !hasPrivilegeOp || testPrivilegeEnumId.equals("_NA_") || testPrivilegeSeq <= targPrivilegeSeq || testPrivilegeEnumId.equals(targPrivilegeEnumId) ); + + boolean purposesCond = ( !hasPurposeOp || (purposes != null && purposes.contains(testContentPurposeTypeId) ) || testContentPurposeTypeId.equals("_NA_") ); + boolean statusCond = ( !hasStatusOp || testStatusId.equals("_NA_") || (targStatusId != null && targStatusId.equals(testStatusId) ) ); + //boolean privilegeCond = ( !hasPrivilegeOp || testPrivilegeEnumId.equals("_NA_") || testPrivilegeSeq <= targPrivilegeSeq || testPrivilegeEnumId.equals(targPrivilegeEnumId) ); boolean roleCond = ( testRoleTypeId.equals("_NA_") || (roles != null && roles.contains(testRoleTypeId) ) ); - - + + if (purposesCond && statusCond && roleCond) { - + isMatch = true; break; } } return isMatch; } - + public static boolean hasMatch(GenericValue entity, PermissionConditionGetter permissionConditionGetter, RelatedRoleGetter relatedRoleGetter, AuxiliaryValueGetter auxiliaryValueGetter, String partyId, boolean checkAncestors) throws GenericEntityException { - + ModelEntity modelEntity = entity.getModelEntity(); GenericDelegator delegator = entity.getDelegator(); String pkFieldName = modelEntity.getFirstPkFieldName(); @@ -736,22 +736,22 @@ } else { if (Debug.verboseOn()) Debug.logVerbose("NO ROLE GETTER", module); } - + String targStatusId = null; if (modelEntity.getField("statusId") != null) { - targStatusId = entity.getString("statusId"); + targStatusId = entity.getString("statusId"); } if (Debug.verboseOn()) Debug.logVerbose("STATUS:" + targStatusId, module); - + while (permissionConditionGetter.getNext() ) { String roleConditionId = permissionConditionGetter.getRoleValue(); String auxiliaryConditionId = permissionConditionGetter.getAuxiliaryValue(); String statusConditionId = permissionConditionGetter.getStatusValue(); - - boolean auxiliaryCond = ( auxiliaryConditionId == null || auxiliaryConditionId.equals("_NA_") || (auxiliaryValueList != null && auxiliaryValueList.contains(auxiliaryConditionId) ) ); - boolean statusCond = ( statusConditionId == null || statusConditionId.equals("_NA_") || (targStatusId != null && targStatusId.equals(statusConditionId) ) ); + + boolean auxiliaryCond = ( auxiliaryConditionId == null || auxiliaryConditionId.equals("_NA_") || (auxiliaryValueList != null && auxiliaryValueList.contains(auxiliaryConditionId) ) ); + boolean statusCond = ( statusConditionId == null || statusConditionId.equals("_NA_") || (targStatusId != null && targStatusId.equals(statusConditionId) ) ); boolean roleCond = ( roleConditionId == null || roleConditionId.equals("_NA_") || (roleValueList != null && roleValueList.contains(roleConditionId) ) ); - + if (auxiliaryCond && statusCond && roleCond) { if (Debug.verboseOn()) Debug.logVerbose("MATCHED: role:" + roleConditionId + " status:" + statusConditionId + " aux:" + auxiliaryConditionId, module); isMatch = true; @@ -760,14 +760,14 @@ } return isMatch; } - + /** * getRelatedPurposes */ public static List<String> getRelatedPurposes(GenericValue entity, List<String> passedPurposes) { - + if (entity == null) return passedPurposes; - + List<String> purposeIds = null; if (passedPurposes == null) { purposeIds = FastList.newInstance( ); @@ -775,10 +775,10 @@ purposeIds = FastList.newInstance( ); purposeIds.addAll( passedPurposes ); } - + String entityName = entity.getEntityName(); String lcEntityName = entityName.toLowerCase(); - + List<GenericValue> purposes = null; try { purposes = entity.getRelatedCache(entityName + "Purpose"); @@ -786,16 +786,16 @@ Debug.logError(e, "No associated purposes found. ", module); return purposeIds; } - + for (GenericValue val: purposes) { purposeIds.add((String) val.get(lcEntityName + "PurposeTypeId")); } - - + + return purposeIds; } - - + + /** * getUserRoles * Queries for the ContentRoles associated with a Content entity @@ -803,13 +803,13 @@ * Follows group parties to see if the user is a member. */ public static List<String> getUserRoles(GenericValue entity, GenericValue userLogin, GenericDelegator delegator) throws GenericEntityException { - + String entityName = entity.getEntityName(); List<String> roles = FastList.newInstance(); if (entity == null) return roles; // TODO: Need to use ContentManagementWorker.getAuthorContent first - - + + roles.remove("OWNER"); // always test with the owner of the current content if ( entity.get("createdByUserLogin") != null && userLogin != null) { String userLoginId = (String)userLogin.get("userLoginId"); @@ -820,7 +820,7 @@ //if (Debug.infoOn()) Debug.logInfo("in getUserRoles, passedRoles(0):" + passedRoles, null); } } - + String partyId = (String)userLogin.get("partyId"); List<GenericValue> relatedRoles = null; List<GenericValue> tmpRelatedRoles = entity.getRelatedCache(entityName + "Role"); @@ -842,7 +842,7 @@ partyTypeId = (String)party.get("partyTypeId"); if ( partyTypeId != null && partyTypeId.equals("PARTY_GROUP") ) { Map<String, Object> map = FastMap.newInstance(); - + // At some point from/thru date will need to be added map.put("partyIdFrom", partyId); map.put("partyIdTo", targPartyId); @@ -859,8 +859,8 @@ } return roles; } - - + + /** * Tests to see if the user belongs to a group */ @@ -872,7 +872,7 @@ String roleTypeIdTo = "PERMISSION_GROUP"; Timestamp fromDate = UtilDateTime.nowTimestamp(); Timestamp thruDate = UtilDateTime.getDayStart(UtilDateTime.nowTimestamp(), 1); - + if (partyRelationshipValues.get("roleTypeIdFrom") != null ) { roleTypeIdFrom = (String)partyRelationshipValues.get("roleTypeIdFrom") ; } @@ -885,22 +885,22 @@ if (partyRelationshipValues.get("thruDate") != null ) { thruDate = (Timestamp)partyRelationshipValues.get("thruDate") ; } - + EntityExpr partyFromExpr = EntityCondition.makeCondition("partyIdFrom", partyIdFrom); EntityExpr partyToExpr = EntityCondition.makeCondition("partyIdTo", partyIdTo); - + EntityExpr relationExpr = EntityCondition.makeCondition("partyRelationshipTypeId", "CONTENT_PERMISSION"); //EntityExpr roleTypeIdFromExpr = EntityCondition.makeCondition("roleTypeIdFrom", "CONTENT_PERMISSION_GROUP_MEMBER"); //EntityExpr roleTypeIdToExpr = EntityCondition.makeCondition("roleTypeIdTo", "CONTENT_PERMISSION_GROUP"); EntityExpr fromExpr = EntityCondition.makeCondition("fromDate", EntityOperator.LESS_THAN_EQUAL_TO, fromDate); EntityCondition thruCond = EntityCondition.makeCondition(UtilMisc.toList(EntityCondition.makeCondition("thruDate", null), EntityCondition.makeCondition("thruDate", EntityOperator.GREATER_THAN, thruDate)), EntityOperator.OR); - + // This method is simplified to make it work, these conditions need to be added back in. //List joinList = UtilMisc.toList(fromExpr, thruCond, partyFromExpr, partyToExpr, relationExpr); List<? extends EntityCondition> joinList = UtilMisc.toList( partyFromExpr, partyToExpr); EntityCondition condition = EntityCondition.makeCondition(joinList); - + List<GenericValue> partyRelationships = null; try { partyRelationships = delegator.findList("PartyRelationship", condition, null, null, null, false); @@ -911,13 +911,13 @@ if (partyRelationships.size() > 0) { isMember = true; } - + return isMember; } - - + + public interface PermissionConditionGetter { - + public boolean getNext(); public String getRoleValue(); public String getOperationValue(); @@ -932,9 +932,9 @@ public String dumpAsText(); public void clearList(); } - + public static class StdPermissionConditionGetter implements PermissionConditionGetter { - + protected List<GenericValue> entityList; protected List<String> operationList; protected ListIterator<GenericValue> iter; @@ -945,9 +945,9 @@ protected String privilegeFieldName; protected String auxiliaryFieldName; protected String entityName; - + public StdPermissionConditionGetter () { - + this.operationFieldName = "contentOperationId"; this.roleFieldName = "roleTypeId"; this.statusFieldName = "statusId"; @@ -955,9 +955,9 @@ this.auxiliaryFieldName = "contentPurposeTypeId"; this.entityName = "ContentPurposeOperation"; } - + public StdPermissionConditionGetter ( String entityName, String operationFieldName, String roleFieldName, String statusFieldName, String auxiliaryFieldName, String privilegeFieldName) { - + this.operationFieldName = operationFieldName; this.roleFieldName = roleFieldName ; this.statusFieldName = statusFieldName ; @@ -965,7 +965,7 @@ this.auxiliaryFieldName = auxiliaryFieldName ; this.entityName = entityName; } - + public StdPermissionConditionGetter ( Element getterElement) { this.operationFieldName = getterElement.getAttribute("operation-field-name"); this.roleFieldName = getterElement.getAttribute("role-field-name"); @@ -974,7 +974,7 @@ this.auxiliaryFieldName = getterElement.getAttribute("auxiliary-field-name"); this.entityName = getterElement.getAttribute("entity-name"); } - + public boolean getNext() { boolean hasNext = false; if (iter != null && iter.hasNext()) { @@ -983,83 +983,83 @@ } return hasNext; } - + public String getRoleValue() { return this.currentValue.getString(this.roleFieldName); } - + public String getOperationValue() { return this.currentValue.getString(this.operationFieldName); } public String getStatusValue() { return this.currentValue.getString(this.statusFieldName); - + } public int getPrivilegeValue() throws GenericEntityException { int privilegeEnumSeq = -1; String privilegeEnumId = null; GenericDelegator delegator = currentValue.getDelegator(); - + if (UtilValidate.isNotEmpty(privilegeFieldName)) { - privilegeEnumId = currentValue.getString(this.privilegeFieldName); + privilegeEnumId = currentValue.getString(this.privilegeFieldName); } if ( UtilValidate.isNotEmpty(privilegeEnumId)) { GenericValue privEnum = delegator.findByPrimaryKeyCache("Enumeration", UtilMisc.toMap("enumId", privilegeEnumId)); if (privEnum != null) { - String sequenceId = privEnum.getString("sequenceId"); + String sequenceId = privEnum.getString("sequenceId"); try { privilegeEnumSeq = Integer.parseInt(sequenceId); } catch (NumberFormatException e) { - // just leave it at -1 + // just leave it at -1 } } } return privilegeEnumSeq; - + } - + public String getAuxiliaryValue() { return this.currentValue.getString(this.auxiliaryFieldName); } - + public void setOperationList(String operationIdString) { - + this.operationList = null; if (UtilValidate.isNotEmpty(operationIdString)) { this.operationList = StringUtil.split(operationIdString, "|"); } } - + public void setOperationList(List<String> operationList) { this.operationList = operationList; } - + public List<String> getOperationList() { return this.operationList; } - + public void clearList() { this.entityList = FastList.newInstance(); } - + public void init( GenericDelegator delegator) throws GenericEntityException { EntityCondition opCond = EntityCondition.makeCondition(operationFieldName, EntityOperator.IN, this.operationList); this.entityList = delegator.findList(this.entityName, opCond, null, null, null, true); } - + public void restart() { this.iter = null; if (this.entityList != null) { - this.iter = this.entityList.listIterator(); + this.iter = this.entityList.listIterator(); } } - + public String dumpAsText() { List<String> fieldNames = UtilMisc.toList("roleFieldName", "auxiliaryFieldName", "statusFieldName"); Map<String, Integer> widths = UtilMisc.toMap("roleFieldName", Integer.valueOf(24), "auxiliaryFieldName", Integer.valueOf(24), "statusFieldName", Integer.valueOf(24)); StringBuilder buf = new StringBuilder(); Integer wid = null; - + buf.append("Dump for "); buf.append(this.entityName); buf.append(" ops:"); @@ -1067,7 +1067,7 @@ buf.append("\n"); for (String fld: fieldNames) { wid = (Integer)widths.get(fld); - buf.append(fld); + buf.append(fld); for (int i=0; i < (wid.intValue() - fld.length()); i++) buf.append("^"); buf.append(" "); } @@ -1086,108 +1086,108 @@ contentOperationId = ""; } wid = (Integer)widths.get("operationFieldName"); - buf.append(contentOperationId); + buf.append(contentOperationId); for (int i=0; i < (wid.intValue() - contentOperationId.length()); i++) buf.append("^"); buf.append(" "); */ - + String roleTypeId = contentPurposeOperation.getString(this.roleFieldName); if (UtilValidate.isEmpty(roleTypeId)) { roleTypeId = ""; } wid = (Integer)widths.get("roleFieldName"); - buf.append(roleTypeId); + buf.append(roleTypeId); for (int i=0; i < (wid.intValue() - roleTypeId.length()); i++) buf.append("^"); buf.append(" "); - + String auxiliaryFieldValue = contentPurposeOperation.getString(this.auxiliaryFieldName); if (UtilValidate.isEmpty(auxiliaryFieldValue)) { auxiliaryFieldValue = ""; } wid = (Integer)widths.get("auxiliaryFieldName"); - buf.append(auxiliaryFieldValue); + buf.append(auxiliaryFieldValue); for (int i=0; i < (wid.intValue() - auxiliaryFieldValue.length()); i++) buf.append("^"); buf.append(" "); - + String statusId = contentPurposeOperation.getString(this.statusFieldName); if (UtilValidate.isEmpty(statusId)) { statusId = ""; } - buf.append(statusId); + buf.append(statusId); /* wid = (Integer)widths.get("statusFieldName"); for (int i=0; i < (wid.intValue() - statusId.length()); i++) buf.append(" "); */ buf.append(" "); - + buf.append("\n"); } } return buf.toString(); } } - + public interface AuxiliaryValueGetter { public void init(GenericDelegator delegator, String entityId) throws GenericEntityException; public List<String> getList(); public void clearList(); public String dumpAsText(); } - + public static class StdAuxiliaryValueGetter implements AuxiliaryValueGetter { - + protected List<String> entityList = FastList.newInstance(); protected String auxiliaryFieldName; protected String entityName; protected String entityIdName; - + public StdAuxiliaryValueGetter () { - + this.auxiliaryFieldName = "contentPurposeTypeId"; this.entityName = "ContentPurpose"; this.entityIdName = "contentId"; } - + public StdAuxiliaryValueGetter ( String entityName, String auxiliaryFieldName, String entityIdName) { - + this.auxiliaryFieldName = auxiliaryFieldName ; this.entityName = entityName; this.entityIdName = entityIdName; } - + public StdAuxiliaryValueGetter ( Element getterElement) { - + this.auxiliaryFieldName = getterElement.getAttribute("auxiliary-field-name"); this.entityName = getterElement.getAttribute("entity-name"); this.entityIdName = getterElement.getAttribute("entity-id-name"); } - + public List<String> getList() { return entityList; } - + public void clearList() { this.entityList = FastList.newInstance(); } - + public void setList(List<String> lst) { this.entityList = lst; } - + public void init(GenericDelegator delegator, String entityId) throws GenericEntityException { - + if (this.entityList == null) { - this.entityList = FastList.newInstance(); + this.entityList = FastList.newInstance(); } if (UtilValidate.isEmpty(this.entityName)) { - return; + return; } List<GenericValue> values = delegator.findByAndCache(this.entityName, UtilMisc.toMap(this.entityIdName, entityId)); for (GenericValue entity: values) { - this.entityList.add(entity.getString(this.auxiliaryFieldName)); + this.entityList.add(entity.getString(this.auxiliaryFieldName)); } } - + public String dumpAsText() { StringBuilder buf = new StringBuilder(); buf.append("AUXILIARY: "); @@ -1200,7 +1200,7 @@ return buf.toString(); } } - + public interface RelatedRoleGetter { public void init(GenericDelegator delegator, String entityId, String partyId, GenericValue entity) throws GenericEntityException; public void initWithAncestors(GenericDelegator delegator, GenericValue entity, String partyId) throws GenericEntityException; @@ -1210,9 +1210,9 @@ public String dumpAsText(); public boolean isOwner(GenericValue entity, String targetPartyId); } - + public static class StdRelatedRoleGetter implements RelatedRoleGetter { - + protected List<String> roleIdList = FastList.newInstance(); protected String roleTypeFieldName; protected String partyFieldName; @@ -1220,9 +1220,9 @@ protected String roleEntityIdName; protected String roleEntityName; protected String ownerEntityFieldName; - + public StdRelatedRoleGetter () { - + this.roleTypeFieldName = "roleTypeId"; this.partyFieldName = "partyId"; this.ownerEntityFieldName = "ownerContentId"; @@ -1230,9 +1230,9 @@ this.roleEntityName = "ContentRole"; this.roleEntityIdName = "contentId"; } - + public StdRelatedRoleGetter ( String entityName, String roleTypeFieldName, String roleEntityIdName, String partyFieldName, String ownerEntityFieldName, String roleEntityName) { - + this.roleTypeFieldName = roleTypeFieldName ; this.partyFieldName = partyFieldName ; this.ownerEntityFieldName = ownerEntityFieldName ; @@ -1240,9 +1240,9 @@ this.roleEntityName = roleEntityName; this.roleEntityIdName = roleEntityIdName; } - + public StdRelatedRoleGetter ( Element getterElement) { - + this.roleTypeFieldName = getterElement.getAttribute("role-type-field-name"); this.partyFieldName = getterElement.getAttribute("party-field-name"); this.ownerEntityFieldName = getterElement.getAttribute("owner-entity-field-name"); @@ -1250,31 +1250,31 @@ this.roleEntityName = getterElement.getAttribute("role-entity-name"); this.roleEntityIdName = getterElement.getAttribute("entity-id-name"); } - + public List<String> getList() { return this.roleIdList; } - + public void clearList() { this.roleIdList = FastList.newInstance(); } - + public void setList(List<String> lst) { this.roleIdList = lst; } - + public void init(GenericDelegator delegator, String entityId, String partyId, GenericValue entity) throws GenericEntityException { - - List<String> lst = getUserRolesFromList(delegator, UtilMisc.toList(entityId), partyId, this.roleEntityIdName, + + List<String> lst = getUserRolesFromList(delegator, UtilMisc.toList(entityId), partyId, this.roleEntityIdName, this.partyFieldName, this.roleTypeFieldName, this.roleEntityName); this.roleIdList.addAll(lst); if (isOwner(entity, partyId)) { - this.roleIdList.add("OWNER"); + this.roleIdList.add("OWNER"); } } - + public void initWithAncestors(GenericDelegator delegator, GenericValue entity, String partyId) throws GenericEntityException { - + List<String> ownedContentIdList = FastList.newInstance(); getEntityOwners(delegator, entity, ownedContentIdList, this.entityName, this.ownerEntityFieldName); if (ownedContentIdList.size() > 0) { @@ -1282,11 +1282,11 @@ this.roleIdList.addAll(lst); } } - + public boolean isOwner( GenericValue entity, String targetPartyId) { boolean isOwner = false; if (entity == null || targetPartyId == null) { - return false; + return false; } GenericDelegator delegator = entity.getDelegator(); ModelEntity modelEntity = delegator.getModelEntity(entityName); @@ -1301,18 +1301,18 @@ String partyIdCB = userLogin.getString("partyId"); if (partyIdCB != null) { if (partyIdCB.equals(targetPartyId)) { - isOwner = true; + isOwner = true; } } } } catch (GenericEntityException e) { Debug.logInfo(e.getMessage() + " Returning false for 'isOwner'.", module); - + } } return isOwner; } - + public String dumpAsText() { StringBuilder buf = new StringBuilder(); buf.append("ROLES: "); @@ -1327,7 +1327,7 @@ } public static List<String> getUserRolesFromList(GenericDelegator delegator, List<String> idList, String partyId, String entityIdFieldName, String partyIdFieldName, String roleTypeIdFieldName, String entityName) throws GenericEntityException { - + EntityExpr expr = EntityCondition.makeCondition(entityIdFieldName, EntityOperator.IN, idList); EntityExpr expr2 = EntityCondition.makeCondition(partyIdFieldName, partyId); EntityConditionList condList = EntityCondition.makeCondition(UtilMisc.toList(expr, expr2)); @@ -1359,15 +1359,15 @@ public static int getPrivilegeEnumSeq(GenericDelegator delegator, String privilegeEnumId) throws GenericEntityException { int privilegeEnumSeq = -1; - + if ( UtilValidate.isNotEmpty(privilegeEnumId)) { GenericValue privEnum = delegator.findByPrimaryKeyCache("Enumeration", UtilMisc.toMap("enumId", privilegeEnumId)); if (privEnum != null) { - String sequenceId = privEnum.getString("sequenceId"); + String sequenceId = privEnum.getString("sequenceId"); try { privilegeEnumSeq = Integer.parseInt(sequenceId); } catch (NumberFormatException e) { - // just leave it at -1 + // just leave it at -1 } } } |
Free forum by Nabble | Edit this page |