01: /*
02: *
03: * Copyright (c) 2004 SourceTap - www.sourcetap.com
04: *
05: * The contents of this file are subject to the SourceTap Public License
06: * ("License"); You may not use this file except in compliance with the
07: * License. You may obtain a copy of the License at http://www.sourcetap.com/license.htm
08: * Software distributed under the License is distributed on an "AS IS" basis,
09: * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
10: * the specific language governing rights and limitations under the License.
11: *
12: * The above copyright notice and this permission notice shall be included
13: * in all copies or substantial portions of the Software.
14: *
15: */
16:
17: package com.sourcetap.sfa.security;
18:
19: import java.util.List;
20:
21: import org.ofbiz.entity.GenericDelegator;
22: import org.ofbiz.entity.GenericValue;
23:
24: import com.sourcetap.sfa.event.GenericEventProcessor;
25: import com.sourcetap.sfa.util.UserInfo;
26:
27: /**
28: * DOCUMENT ME!
29: *
30: */
31: public class EntityAccessEventProcessor extends GenericEventProcessor {
32:
33: /**
34: * DOCUMENT ME!
35: *
36: * @param userInfo
37: * @param delegator
38: * @param originatingEntityName
39: * @param entityGV
40: *
41: * @return
42: */
43: public int deleteAllRelated(UserInfo userInfo,
44: GenericDelegator delegator, String originatingEntityName,
45: GenericValue entityGV) {
46:
47: int status = STATUS_CONTINUE;
48:
49: // Delete related teams.
50: status = deleteOneRelated(userInfo, delegator, entityGV, "",
51: "Team", originatingEntityName, new TeamEventProcessor());
52:
53: if (status != STATUS_CONTINUE) {
54: return status;
55: }
56:
57: return STATUS_CONTINUE;
58: }
59:
60: /**
61: * DOCUMENT ME!
62: *
63: * @param userInfo
64: * @param delegator
65: * @param entityGV
66: * @param relationTitle
67: * @param relatedEntityName
68: *
69: * @return
70: */
71: public List findOneRelated(UserInfo userInfo,
72: GenericDelegator delegator, GenericValue entityGV,
73: String relationTitle, String relatedEntityName) {
74: // Find instances of an entity related to the current entity so the instances can be deleted.
75:
76: if (relatedEntityName.equals("Team")) {
77: return TeamHelper.findRelated(userInfo, delegator,
78: entityGV, relationTitle);
79: } else {
80: // Not finding EntityAccess records. Just use the standard processing using relations.
81: return super.findOneRelated(userInfo, delegator, entityGV,
82: relationTitle, relatedEntityName);
83: }
84: }
85: }
|