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.attachment;
18:
19: import java.io.File;
20:
21: import org.ofbiz.base.util.Debug;
22: import org.ofbiz.entity.GenericDelegator;
23: import org.ofbiz.entity.GenericValue;
24:
25: import com.sourcetap.sfa.event.GenericEventProcessor;
26: import com.sourcetap.sfa.util.UserInfo;
27:
28: /**
29: * DOCUMENT ME!
30: *
31: */
32: public class AbstractAttachmentEP extends GenericEventProcessor {
33: private static final boolean DEBUG = false;
34: public static final String module = AbstractAttachmentEP.class
35: .getName();
36:
37: /**
38: * DOCUMENT ME!
39: *
40: * @param userInfo
41: * @param delegator
42: * @param originatingEntityName
43: * @param entityGV
44: *
45: * @return
46: */
47: public int deleteAllRelated(UserInfo userInfo,
48: GenericDelegator delegator, String originatingEntityName,
49: GenericValue entityGV) {
50: if (DEBUG) {
51: Debug.logVerbose(
52: "-->[AbstractAttachmentEP.deleteAllRelated]",
53: module);
54: }
55:
56: int status = STATUS_CONTINUE;
57:
58: // Delete the physical file represented by this record.
59: String fileLocation = entityGV.getString("fileLocation");
60:
61: if (fileLocation.equals("") || (fileLocation == null)) {
62: return status;
63: }
64:
65: File file = new File(fileLocation);
66:
67: Debug.logVerbose(
68: "-->[AbstractAttachmentEP.deleteAllRelated] Deleting file "
69: + fileLocation, module);
70:
71: file.delete();
72:
73: Debug.logVerbose(
74: "-->[AbstractAttachmentEP.deleteAllRelated] Deleted file "
75: + fileLocation, module);
76:
77: return status;
78: }
79: }
|