diff options
Diffstat (limited to 'client/trunk/src/com/fourisland')
3 files changed, 46 insertions, 16 deletions
diff --git a/client/trunk/src/com/fourisland/instadisc/Item/WellFormedItem.java b/client/trunk/src/com/fourisland/instadisc/Item/WellFormedItem.java index 9b54f96..91d95aa 100644 --- a/client/trunk/src/com/fourisland/instadisc/Item/WellFormedItem.java +++ b/client/trunk/src/com/fourisland/instadisc/Item/WellFormedItem.java | |||
@@ -40,22 +40,54 @@ public class WellFormedItem { | |||
40 | return good; | 40 | return good; |
41 | } | 41 | } |
42 | 42 | ||
43 | private boolean checkForEqualFilters() { | ||
44 | boolean good = true; | ||
45 | |||
46 | Filter[] filters = Wrapper.getAllFilter(); | ||
47 | int i = 0; | ||
48 | for (i = 0; i < filters.length; i++) { | ||
49 | if (filters[i].getSubscription().equals(aThis.headerMap.get("Subscription"))) { | ||
50 | if (filters[i].getEqual()) { | ||
51 | good = (good ? aThis.headerMap.get(filters[i].getField()).contains(filters[i].getTest()) : false); | ||
52 | } | ||
53 | } | ||
54 | } | ||
55 | |||
56 | return good; | ||
57 | } | ||
58 | |||
43 | private boolean checkForFilterInvalidation() { | 59 | private boolean checkForFilterInvalidation() { |
44 | boolean good = true; | 60 | boolean good = true; |
45 | 61 | good = (good ? checkForEqualFilters() : false); | |
62 | good = (good ? checkForInequalFilters() : false); | ||
63 | |||
64 | if (!good) { | ||
65 | XmlRpc xmlrpc = new XmlRpc("deleteItem"); | ||
66 | xmlrpc.addParam(Integer.decode(aThis.headerMap.get("ID"))); | ||
67 | xmlrpc.execute(); | ||
68 | } | ||
69 | |||
70 | return good; | ||
71 | } | ||
72 | |||
73 | private boolean checkForInequalFilters() { | ||
74 | boolean good = true; | ||
75 | boolean start = false; | ||
76 | |||
46 | Filter[] filters = Wrapper.getAllFilter(); | 77 | Filter[] filters = Wrapper.getAllFilter(); |
47 | int i = 0; | 78 | int i = 0; |
48 | for (i = 0; i < filters.length; i++) { | 79 | for (i = 0; i < filters.length; i++) { |
49 | if (filters[i].getSubscription().equals(aThis.headerMap.get("Subscription"))) { | 80 | if (filters[i].getSubscription().equals(aThis.headerMap.get("Subscription"))) { |
50 | if (filters[i].getEqual()) | 81 | if (!filters[i].getEqual()) { |
51 | { | 82 | if (!start) { |
52 | good = (good ? (!aThis.headerMap.get(filters[i].getField()).equals(filters[i].getTest())) : false); | 83 | good = false; |
53 | } else { | 84 | start = true; |
54 | good = (good ? (aThis.headerMap.get(filters[i].getField()).equals(filters[i].getTest())) : false); | 85 | } |
86 | good = (good ? true : !aThis.headerMap.get(filters[i].getField()).contains(filters[i].getTest())); | ||
55 | } | 87 | } |
56 | } | 88 | } |
57 | } | 89 | } |
58 | 90 | ||
59 | return good; | 91 | return good; |
60 | } | 92 | } |
61 | 93 | ||
@@ -107,9 +139,8 @@ public class WellFormedItem { | |||
107 | private boolean checkForRequiredHeader(String string) { | 139 | private boolean checkForRequiredHeader(String string) { |
108 | return checkForRequiredHeader(aThis.headerMap, string); | 140 | return checkForRequiredHeader(aThis.headerMap, string); |
109 | } | 141 | } |
110 | 142 | ||
111 | public static boolean checkForRequiredHeader(HashMap<String, String> headerMap, String string) | 143 | public static boolean checkForRequiredHeader(HashMap<String, String> headerMap, String string) { |
112 | { | ||
113 | return headerMap.containsKey(string); | 144 | return headerMap.containsKey(string); |
114 | } | 145 | } |
115 | 146 | ||
@@ -117,7 +148,7 @@ public class WellFormedItem { | |||
117 | try { | 148 | try { |
118 | URL url = new URL(aThis.headerMap.get("URL")); | 149 | URL url = new URL(aThis.headerMap.get("URL")); |
119 | URI subUrl = new URI(aThis.headerMap.get("Subscription")); | 150 | URI subUrl = new URI(aThis.headerMap.get("Subscription")); |
120 | 151 | ||
121 | return url.getHost().equals(subUrl.getHost()); | 152 | return url.getHost().equals(subUrl.getHost()); |
122 | } catch (URISyntaxException ex) { | 153 | } catch (URISyntaxException ex) { |
123 | Logger.getLogger(WellFormedItem.class.getName()).log(Level.SEVERE, null, ex); | 154 | Logger.getLogger(WellFormedItem.class.getName()).log(Level.SEVERE, null, ex); |
@@ -130,8 +161,7 @@ public class WellFormedItem { | |||
130 | 161 | ||
131 | private boolean checkForSubscription() { | 162 | private boolean checkForSubscription() { |
132 | boolean good = Wrapper.existsSubscription(aThis.headerMap.get("Subscription")); | 163 | boolean good = Wrapper.existsSubscription(aThis.headerMap.get("Subscription")); |
133 | if (!good) | 164 | if (!good) { |
134 | { | ||
135 | SubscriptionFile.deleteSubscription(Wrapper.getSubscription(aThis.headerMap.get("Subscription")), false); | 165 | SubscriptionFile.deleteSubscription(Wrapper.getSubscription(aThis.headerMap.get("Subscription")), false); |
136 | } | 166 | } |
137 | return good; | 167 | return good; |
diff --git a/client/trunk/src/com/fourisland/instadisc/ManageFiltersForm.form b/client/trunk/src/com/fourisland/instadisc/ManageFiltersForm.form index 3f1e603..fcf64df 100644 --- a/client/trunk/src/com/fourisland/instadisc/ManageFiltersForm.form +++ b/client/trunk/src/com/fourisland/instadisc/ManageFiltersForm.form | |||
@@ -88,9 +88,6 @@ | |||
88 | <Properties> | 88 | <Properties> |
89 | <Property name="text" type="java.lang.String" resourceKey="jLabel2.text"/> | 89 | <Property name="text" type="java.lang.String" resourceKey="jLabel2.text"/> |
90 | <Property name="name" type="java.lang.String" value="jLabel2" noResource="true"/> | 90 | <Property name="name" type="java.lang.String" value="jLabel2" noResource="true"/> |
91 | <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> | ||
92 | <Dimension value="[625, 17]"/> | ||
93 | </Property> | ||
94 | </Properties> | 91 | </Properties> |
95 | </Component> | 92 | </Component> |
96 | <Container class="javax.swing.JScrollPane" name="jScrollPane1"> | 93 | <Container class="javax.swing.JScrollPane" name="jScrollPane1"> |
diff --git a/client/trunk/src/com/fourisland/instadisc/ManageFiltersForm.java b/client/trunk/src/com/fourisland/instadisc/ManageFiltersForm.java index cd4426e..620665d 100644 --- a/client/trunk/src/com/fourisland/instadisc/ManageFiltersForm.java +++ b/client/trunk/src/com/fourisland/instadisc/ManageFiltersForm.java | |||
@@ -162,6 +162,7 @@ public class ManageFiltersForm extends javax.swing.JDialog { | |||
162 | }// </editor-fold>//GEN-END:initComponents | 162 | }// </editor-fold>//GEN-END:initComponents |
163 | private void jList1ValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jList1ValueChanged | 163 | private void jList1ValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jList1ValueChanged |
164 | refreshFilterPane(); | 164 | refreshFilterPane(); |
165 | jList2.setSelectedIndex(0); | ||
165 | }//GEN-LAST:event_jList1ValueChanged | 166 | }//GEN-LAST:event_jList1ValueChanged |
166 | 167 | ||
167 | private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed | 168 | private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed |
@@ -173,9 +174,11 @@ public class ManageFiltersForm extends javax.swing.JDialog { | |||
173 | try { | 174 | try { |
174 | if (filter.getID() == -65536) { | 175 | if (filter.getID() == -65536) { |
175 | jButton1.setText("Add"); | 176 | jButton1.setText("Add"); |
177 | jButton1.setEnabled(true); | ||
176 | jButton2.setEnabled(false); | 178 | jButton2.setEnabled(false); |
177 | } else { | 179 | } else { |
178 | jButton1.setText("Edit"); | 180 | jButton1.setText("Edit"); |
181 | jButton1.setEnabled(true); | ||
179 | jButton2.setEnabled(true); | 182 | jButton2.setEnabled(true); |
180 | } | 183 | } |
181 | } catch (Exception ex) { | 184 | } catch (Exception ex) { |