Source code: com/webobjects/directtoweb/ERD2WRuleEditorModel.java
1 //
2 // RuleEditorModel.java
3 // Project RuleEditor
4 //
5 // Created by ak on Fri Jun 21 2002
6 //
7 package com.webobjects.directtoweb;
8 import com.webobjects.foundation.*;
9 import com.webobjects.appserver.*;
10 import com.webobjects.eocontrol.*;
11 import java.io.*;
12 import java.util.*;
13
14 public class ERD2WRuleEditorModel extends D2WModel {
15
16 public ERD2WRuleEditorModel(File file) {
17 super(new EOKeyValueUnarchiver(ERD2WRuleEditorModel._dictionaryFromFile(file)));
18
19 }
20
21 public NSArray publicRules() {
22 return rules();
23 }
24
25 public void setPublicRules(NSArray rules) {
26 setRules(rules);
27 }
28
29 public Enumeration publicTasks() {
30 return tasks();
31 }
32
33 public Vector publicDynamicPages() {
34 return dynamicPages();
35 }
36
37 protected static NSDictionary _dictionaryFromFile(File file) {
38 NSDictionary model = null;
39 try {
40 model = Services.dictionaryFromFile(file);
41 NSArray rules = (NSArray)model.objectForKey("rules");
42 Enumeration e = rules.objectEnumerator();
43 while(e.hasMoreElements()) {
44 NSMutableDictionary dict = (NSMutableDictionary)e.nextElement();
45 if("com.webobjects.directtoweb.Rule".equals(dict.objectForKey("class"))) {
46 dict.setObjectForKey("ERD2WExtendedRule", "class");
47 }
48 }
49 } catch (Throwable throwable) {
50 NSLog.err.appendln("****** DirectToWeb: Problem reading file "
51 + file + " reason:" + throwable);
52 if (NSLog.debugLoggingAllowedForLevelAndGroups(1, 40L)) {
53 NSLog.err.appendln("STACKTRACE:");
54 NSLog.err.appendln(throwable);
55 }
56 throw NSForwardException._runtimeExceptionForThrowable(throwable);
57 }
58 return model;
59 }
60 }