01: /*
02:
03: This software is OSI Certified Open Source Software.
04: OSI Certified is a certification mark of the Open Source Initiative.
05:
06: The license (Mozilla version 1.0) can be read at the MMBase site.
07: See http://www.MMBase.org/license
08:
09: */
10: package org.mmbase.module.builders;
11:
12: import java.util.*;
13:
14: import org.mmbase.module.core.*;
15: import org.mmbase.util.logging.*;
16:
17: /**
18: * @javadoc
19: * @deprecated is this (cacheversionfile) used? seems obsolete now
20: * @author Daniel Ockeloen
21: * @version $Id: VersionCacheNode.java,v 1.7 2007/02/11 19:21:12 nklasens Exp $
22: */
23: public class VersionCacheNode extends Object {
24:
25: private static Logger log = Logging
26: .getLoggerInstance(VersionCacheNode.class.getName());
27: private MMObjectNode versionnode;
28: private Vector<VersionCacheWhenNode> whens = new Vector<VersionCacheWhenNode>();
29: private MMBase mmb;
30:
31: public VersionCacheNode(MMBase mmb) {
32: this .mmb = mmb;
33: }
34:
35: public void handleChanged(String buildername, int number) {
36: // method checks if this really something valid
37: // and we should signal a new version
38:
39: boolean dirty = false;
40: for (VersionCacheWhenNode whennode : whens) {
41: Vector<String> types = whennode.getTypes();
42:
43: // check if im known in the types part
44: if (types.contains(buildername)) {
45: // is there only 1 builder type ?
46: if (log.isDebugEnabled())
47: log.debug("types=" + types.toString());
48: if (types.size() == 1) {
49: dirty = true;
50: } else {
51: // so multiple prepare a multilevel !
52: Vector<String> nodes = whennode.getNodes();
53:
54: Vector<String> fields = new Vector<String>();
55: fields.addElement(buildername + ".number");
56: Vector<String> ordervec = new Vector<String>();
57: Vector<String> dirvec = new Vector<String>();
58:
59: Vector<MMObjectNode> vec = mmb.getClusterBuilder()
60: .searchMultiLevelVector(nodes, fields,
61: "YES", types,
62: buildername + ".number==" + number,
63: ordervec, dirvec);
64: if (log.isDebugEnabled())
65: log.debug("VEC=" + vec);
66: if (vec != null && vec.size() > 0) {
67: dirty = true;
68: }
69: }
70: }
71: }
72:
73: if (dirty) {
74: // add one to the version of this counter
75: int version = versionnode.getIntValue("version");
76: versionnode.setValue("version", version + 1);
77: versionnode.commit();
78: if (log.isDebugEnabled())
79: log.debug("Changed = " + (version + 1));
80: }
81: }
82:
83: public void setVersionNode(MMObjectNode versionnode) {
84: this .versionnode = versionnode;
85: }
86:
87: public void addWhen(VersionCacheWhenNode when) {
88: whens.addElement(when);
89: }
90:
91: }
|