You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(2) |
Sep
(3) |
Oct
(191) |
Nov
(124) |
Dec
(74) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(20) |
Feb
(20) |
Mar
(38) |
Apr
(67) |
May
(18) |
Jun
(6) |
Jul
(27) |
Aug
|
Sep
(20) |
Oct
(7) |
Nov
(5) |
Dec
(21) |
2006 |
Jan
(4) |
Feb
(4) |
Mar
(8) |
Apr
(26) |
May
(6) |
Jun
(17) |
Jul
(12) |
Aug
(3) |
Sep
(3) |
Oct
(10) |
Nov
|
Dec
(7) |
2007 |
Jan
|
Feb
|
Mar
|
Apr
(7) |
May
(3) |
Jun
(8) |
Jul
|
Aug
|
Sep
(12) |
Oct
|
Nov
(10) |
Dec
(3) |
2008 |
Jan
(8) |
Feb
|
Mar
(3) |
Apr
|
May
|
Jun
(8) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(2) |
Dec
|
From: Nico K. <nkl...@us...> - 2007-11-05 20:51:12
|
Update of /cvsroot/mmapps/mmapps/remotepublishing/src/org/mmbase/remotepublishing/builders In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv11467/remotepublishing/src/org/mmbase/remotepublishing/builders Modified Files: PublishingQueueBuilder.java PublishRelationBuilder.java PublishingBuilder.java Log Message: Cleanup and formatting Builders accept cloud name as property for publish. The name is the ckoud which may publish nodes of this type Index: PublishingBuilder.java =================================================================== RCS file: /cvsroot/mmapps/mmapps/remotepublishing/src/org/mmbase/remotepublishing/builders/PublishingBuilder.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PublishingBuilder.java 17 Oct 2006 10:02:54 -0000 1.3 --- PublishingBuilder.java 5 Nov 2007 20:50:35 -0000 1.4 *************** *** 14,20 **** package org.mmbase.remotepublishing.builders; ! import org.mmbase.module.core.MMObjectBuilder; import org.mmbase.module.core.MMObjectNode; import org.mmbase.remotepublishing.action.PublishingAction; import org.mmbase.remotepublishing.action.PublishingActionDummy; --- 14,21 ---- package org.mmbase.remotepublishing.builders; ! import org.mmbase.core.event.*; import org.mmbase.module.core.MMObjectBuilder; import org.mmbase.module.core.MMObjectNode; + import org.mmbase.remotepublishing.CloudManager; import org.mmbase.remotepublishing.action.PublishingAction; import org.mmbase.remotepublishing.action.PublishingActionDummy; *************** *** 23,39 **** import org.mmbase.util.logging.Logging; ! ! /** This builder is used when a content node should be published when the node is saved. ! * A publish property specifies if the builder should publish nodes in the current cloud. * ! * On a save the builder checks if there is a publishnow field to let the node decide ! * that it should be published. The navigation node uses this mechanisme to preview it ! * in the staging cloud. * ! * Another unused feature at the moment is in plac to perform an action when a node is ! * published to the current cloud. This could be handy when something has to be done ! * in the live site when the node is published * ! * @author keesj * @author Nico Klasens (Finalist IT Group) * @version PublishingBuilder.java,v 1.2 2003/07/28 09:43:51 nico Exp --- 24,39 ---- import org.mmbase.util.logging.Logging; ! /** ! * This builder is used when a content node should be published when the node is saved. A publish ! * property specifies if the builder should publish nodes in the current cloud. * ! * On a save the builder checks if there is a publishnow field to let the node decide that it should ! * be published. The navigation node uses this mechanisme to preview it in the staging cloud. * ! * Another unused feature at the moment is in plac to perform an action when a node is published to ! * the current cloud. This could be handy when something has to be done in the live site when the ! * node is published * ! * @author keesj * @author Nico Klasens (Finalist IT Group) * @version PublishingBuilder.java,v 1.2 2003/07/28 09:43:51 nico Exp *************** *** 41,160 **** public class PublishingBuilder extends MMObjectBuilder { ! private static Logger log = Logging.getLoggerInstance(PublishingBuilder.class.getName()); ! private boolean publish = false; ! ! /** PublishingAction class to use when a node is published to this cloud */ ! private String publishActionClassName = null; ! /** ! * test so see if mmbase doens't mix up builders and java classes ! **/ ! private String myRealName; ! public boolean init() { ! if ("true".equals(getInitParameter("publish"))) { ! publish = true; ! log.info(tableName + " is active"); ! } else { ! log.info(tableName + " is inactive"); ! } ! ! String classname = getInitParameter("publishaction"); ! if (classname != null && "".equals(classname.trim())) { ! publishActionClassName = classname; ! } ! myRealName = tableName; ! return super.init(); ! } ! public int insert(String owner, MMObjectNode node) { ! int number = super.insert(owner, node); ! if (number != -1) { ! if (publish) { ! PublishUtil.publishOrUpdateNode(number); ! } ! else { PublishingAction pa = getPublishingAction(); ! pa.inserted(number); ! } ! } ! return number; ! } ! public boolean commit(MMObjectNode objectNode) { ! if (!myRealName.equals(tableName)) { ! log.error( ! "object builder classes and object mixed the builder class was created for objects of type(" + ! myRealName + ") but is used for (" + tableName + ")"); ! } ! log.info(tableName + " commit"); ! boolean retval = super.commit(objectNode); ! if (publish) { ! boolean publishnow = true; ! ! if (getField("publishnow") != null) { ! publishnow = objectNode.getBooleanValue("publishnow"); ! } ! // no publishnow field or publishnow field was true. ! if (publishnow) { ! PublishUtil.publishOrUpdateNode(objectNode); ! } ! } ! else { ! PublishingAction pa = getPublishingAction(); ! pa.committed(objectNode); ! } ! return retval; ! } ! public void removeNode(MMObjectNode objectNode) { ! log.info(tableName + " remove"); ! if (publish) { ! PublishUtil.removeNode(objectNode); ! } ! else { ! PublishingAction pa = getPublishingAction(); ! pa.removed(objectNode); ! } - super.removeNode(objectNode); - } - - /** Get a PublishingAction instance - * - * @return PublishingAction instance - */ - private PublishingAction getPublishingAction() { - if (publishActionClassName != null) { - try { - Class publishActionClass = Class.forName(publishActionClassName); - PublishingAction pa = (PublishingAction) publishActionClass.newInstance(); - return pa; - } - catch (ClassNotFoundException e) { - log.warn("PublishingAction class not found: " + publishActionClassName); - } - catch (InstantiationException e) { - log.warn("Unable to instantiate: " + publishActionClassName); - } - catch (IllegalAccessException e) { - log.warn("Not allowed to load: " + publishActionClassName); - } - } - - return new PublishingActionDummy(); - } - protected boolean getPublish() { return publish; } } --- 41,228 ---- public class PublishingBuilder extends MMObjectBuilder { ! private static Logger log = Logging.getLoggerInstance(PublishingBuilder.class.getName()); ! private boolean publish = false; ! private boolean publishRelations = false; ! /** PublishingAction class to use when a node is published to this cloud */ ! private String publishActionClassName = null; ! /** ! * test so see if mmbase doens't mix up builders and java classes ! */ ! private String myRealName; ! @Override ! public boolean init() { ! String publishStr = getInitParameter("publish"); ! if (publishStr == null || "".equals(publishStr.trim()) ! || "false".equalsIgnoreCase(publishStr)) { ! log.info(getTableName() + " is inactive"); ! } ! else { ! if ("true".equalsIgnoreCase(publishStr)) { ! publish = true; ! log.info(getTableName() + " is active"); ! } ! else { ! String defaultCloud = CloudManager.getDefaultCloudName(); ! if (publishStr.equals(defaultCloud)) { ! publish = true; ! log.info(getTableName() + " is active for local mmbase instance"); ! } ! } ! } ! if ("true".equalsIgnoreCase(getInitParameter("publish-relations"))) { ! publishRelations = true; ! log.info(getTableName() + " monitors relations"); ! } ! String classname = getInitParameter("publishaction"); ! if (classname != null && "".equals(classname.trim())) { ! publishActionClassName = classname; ! } ! myRealName = getTableName(); ! ! return super.init(); ! } ! ! @Override ! public int insert(String owner, MMObjectNode node) { ! int number = super.insert(owner, node); ! ! if (number != -1) { ! if (publish) { ! PublishUtil.publishOrUpdateNode(number); ! } ! else { ! PublishingAction pa = getPublishingAction(); ! pa.inserted(number); ! } ! } ! return number; ! } ! ! @Override ! public boolean commit(MMObjectNode objectNode) { ! if (!myRealName.equals(getTableName())) { ! log.error("object builder classes and object mixed the builder class " ! + "was created for objects of type(" ! + myRealName + ") but is used for (" + getTableName() + ")"); ! } ! ! log.info(getTableName() + " commit"); ! ! boolean retval = super.commit(objectNode); ! ! if (publish) { ! boolean publishnow = true; ! ! if (getField("publishnow") != null) { ! publishnow = objectNode.getBooleanValue("publishnow"); ! } ! // no publishnow field or publishnow field was true. ! if (publishnow) { ! PublishUtil.publishOrUpdateNode(objectNode); ! } ! } ! else { PublishingAction pa = getPublishingAction(); ! pa.committed(objectNode); ! } ! return retval; ! } ! @Override ! public void removeNode(MMObjectNode objectNode) { ! log.info(getTableName() + " remove"); ! if (publish) { ! PublishUtil.removeNode(objectNode); ! } ! else { ! PublishingAction pa = getPublishingAction(); ! pa.removed(objectNode); ! } ! super.removeNode(objectNode); ! } ! /** ! * Get a PublishingAction instance ! * ! * @return PublishingAction instance ! */ ! private PublishingAction getPublishingAction() { ! if (publishActionClassName != null) { ! try { ! Class<?> publishActionClass = Class.forName(publishActionClassName); ! PublishingAction pa = (PublishingAction) publishActionClass.newInstance(); ! return pa; ! } ! catch (ClassNotFoundException e) { ! log.warn("PublishingAction class not found: " + publishActionClassName); ! } ! catch (InstantiationException e) { ! log.warn("Unable to instantiate: " + publishActionClassName); ! } ! catch (IllegalAccessException e) { ! log.warn("Not allowed to load: " + publishActionClassName); ! } ! } ! return new PublishingActionDummy(); ! } ! @Override ! public void notify(NodeEvent event) { ! super.notify(event); ! if (publish && publishRelations) { ! if (event.getType() == NodeEvent.TYPE_RELATION_CHANGE) { ! PublishUtil.publishOrUpdateRelations(event.getNodeNumber(), null); ! } ! } ! } ! ! @Override ! public void notify(RelationEvent event) { ! super.notify(event); ! if (publish && publishRelations) { ! if ("object".equals(event.getRelationSourceType()) ! || "object".equals(event.getRelationDestinationType())) { ! // ignore events for object ! return; ! } ! if (event.getRelationSourceType().equals(getTableName()) ! || event.getRelationDestinationType().equals(getTableName())) { ! switch (event.getType()) { ! case Event.TYPE_CHANGE: ! if (!event.getNodeEvent().getChangedFields().isEmpty()) { ! PublishUtil.publishOrUpdateNode(event.getNodeEvent().getNodeNumber()); ! } ! break; ! case Event.TYPE_NEW: ! case NodeEvent.TYPE_RELATION_CHANGE: ! PublishUtil.publishOrUpdateNode(event.getNodeEvent().getNodeNumber()); ! break; ! case Event.TYPE_DELETE: ! PublishUtil.removeNode(event.getNodeEvent().getNodeNumber()); ! break; ! default: ! break; ! } ! } ! } ! } protected boolean getPublish() { return publish; } + + protected void setPublish(boolean publish) { + this.publish = publish; + } } Index: PublishingQueueBuilder.java =================================================================== RCS file: /cvsroot/mmapps/mmapps/remotepublishing/src/org/mmbase/remotepublishing/builders/PublishingQueueBuilder.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PublishingQueueBuilder.java 4 Jun 2007 07:39:03 -0000 1.5 --- PublishingQueueBuilder.java 5 Nov 2007 20:50:33 -0000 1.6 *************** *** 36,252 **** * Main class that publishes or removes nodes to or from remote clouds. */ ! public class PublishingQueueBuilder extends MMObjectBuilder implements Runnable{ public static final String FIELD_TIMESTAMP = "timestamp"; public static final String FIELD_PUBLISHDATE = "publishdate"; public static final String FIELD_STATUS = "status"; public static final String FIELD_ACTION = "action"; public static final String FIELD_DESTINATIONCLOUD = "destinationcloud"; public static final String FIELD_SOURCENUMBER = "sourcenumber"; public static final String FIELD_RELATEDNODES = "relatednodes"; - - public static final String ACTION_UPDATE = "update"; - public static final String ACTION_UPDATE_NODE = "update-node"; - public static final String ACTION_UPDATE_RELATIONS = "update-relations"; ! public static final String ACTION_REMOVE = "remove"; ! public static final String STATUS_DONE = "done"; ! public static final String STATUS_FAIL = "fail"; ! private static Logger log = Logging.getLoggerInstance(PublishingQueueBuilder.class.getName()); ! /** thread performing the task */ ! private static Thread thread = null; ! private static int maxtrying = 5; ! int remoteCloudNumber = -1; ! ! /** List of cloud names where to publish to */ ! String remoteCloudName; ! /** Milliseconds how long the thread will sleep */ ! private int interval = 60 * 1000; ! private static List<PublishListener> publishListeners = new ArrayList<PublishListener>(); ! ! /** ! * MMBase builder init method. This method first looks for the ! * cloudlist property in the builder xml ! * starts a new publishing Tread. ! **/ ! public boolean init() { ! Map<String,Object> params = getInitParameters("mmbase/remotepublishing"); ! ! remoteCloudName = (String) params.get("remotecloud"); ! if ((remoteCloudName != null) && (!"".equals(remoteCloudName))) { ! log.info("remote cloud will be " + remoteCloudName); ! } ! else { ! remoteCloudName = null; ! log.warn("cloudlist parameter missing publishing disabled"); ! } ! // Initialize the module. ! String intervalStr = (String) params.get("interval"); ! if (intervalStr == null) { ! throw new IllegalArgumentException("interval"); ! } ! interval = Integer.parseInt(intervalStr) * 1000; ! if (thread == null) { ! thread = new Thread(this, "PublishQueue to " + remoteCloudName); ! thread.setDaemon(true); ! thread.start(); ! } ! else { ! log.warn("init() method of the PublishingQueueBuilder was called multiple times"); ! } ! return super.init(); ! } ! public boolean commit(MMObjectNode objectNodenode) { ! boolean retval = super.commit(objectNodenode); ! return retval; ! } ! public void setDefaults(MMObjectNode node) { ! super.setDefaults(node); ! if ((remoteCloudNumber == -1) && (remoteCloudName != null)) { ! remoteCloudNumber = getCloudNumber(remoteCloudName); ! } ! node.setValue(FIELD_DESTINATIONCLOUD, remoteCloudNumber); ! } ! /** ! * Get number of cloud from local system ! * @param name the name of the cloud ( in the cloud list) ! * @return cloud node number ! * @throws BridgeException if the cloud was not found ! */ ! public static int getCloudNumber(String name) throws BridgeException { ! MMObjectBuilder builder = MMBase.getMMBase().getBuilder("cloud"); ! NodeSearchQuery query = new NodeSearchQuery(builder); ! StepField nameStepField = query.getField(builder.getField("name")); ! BasicFieldValueConstraint cName = new BasicFieldValueConstraint(nameStepField, name); ! cName.setOperator(FieldCompareConstraint.EQUAL); ! query.setConstraint(cName); ! try { ! List<MMObjectNode> nodes = builder.getNodes(query); ! if (nodes.isEmpty()) { ! throw new BridgeException("can not find cloud with name(" ! + name ! + ") in nameServerCloud"); ! } ! return nodes.get(0).getNumber(); ! } catch (SearchQueryException e) { ! throw new BridgeException("can not find cloud with name(" ! + name ! + ") in nameServerCloud", e); ! } ! } ! ! public void run() { ! log.info("Publishing Queue initialised"); ! // Wait for mmbase to be up and running. ! MMBase.getMMBase(); ! try { ! Thread.sleep(interval); ! } ! catch (InterruptedException e) { ! log.warn("Interupted while sleeping , continuning"); ! } ! try { ! linkTypedefs(); ! } ! catch (Exception e) { ! log.error("Problem with linking typedefs together", e); ! } ! while (true) { ! try { Thread.sleep(interval); ! } ! catch (InterruptedException e) { log.warn("Interupted while sleeping , continuning"); ! } ! if (remoteCloudName == null) { ! log.warn("publising disabled"); ! } ! else { ! CloudInfo localCloudInfo = CloudInfo.getDefaultCloudInfo(); ! NodeManager nodeManager = localCloudInfo.getCloud().getNodeManager("publishqueue"); ! NodeQuery query = createQuery(nodeManager); ! NodeList list = null; ! while(list == null || !list.isEmpty()) { ! list = nodeManager.getList(query); ! for (int x = 0; x < list.size(); x++) { ! Node queueNode = list.getNode(x); ! if(queueNode != null) { ! try { ! // check if node is not removed from the cloud in between query and retrieval ! if (localCloudInfo.getCloud().hasNode(queueNode.getNumber())) { ! String action = queueNode.getStringValue(FIELD_ACTION); ! if (isUpdateAction(action)) { ! try { ! boolean finished = false; ! int trytimes = 0; ! while(!finished) { ! try { ! update(localCloudInfo, queueNode, action); ! finished=true; ! } catch (BridgeException e) { ! if ( handleRmiException(e) && ++trytimes<=maxtrying) { ! //if it was caused rmi connection exception and still within ! // the maximal tring times limitation, ! // continue to try publishing it again ! } else { ! //otherwise, throw the runtime exception ! throw e; ! } ! } ! } ! queueNode.setStringValue(FIELD_STATUS, STATUS_DONE); ! queueNode.commit(); ! } ! catch (BridgeException e) { ! log.error("Nodenumber : " + queueNode.getNumber() + ", " + e, e); ! publishFailed(localCloudInfo, queueNode, e); ! } ! } ! else { ! if (isRemoveAction(action)) { ! try { ! removeNode(localCloudInfo, queueNode); } ! catch (BridgeException e) { ! log.error("Removing published node (" + queueNode.getNumber() + ") failed", e); ! publishFailed(localCloudInfo, queueNode, e); } ! } ! } ! } ! } ! catch (Throwable e) { ! log.error("Throwable error with nodenumber: " + queueNode.getNumber() + ", " + e.getMessage()); ! log.debug(Logging.stackTrace(e)); ! } ! } ! } //end for ! log.debug("Published total "+list.size()+" nodes"); } ! } ! } ! } private boolean isRemoveAction(String action) { --- 36,270 ---- * Main class that publishes or removes nodes to or from remote clouds. */ ! public class PublishingQueueBuilder extends MMObjectBuilder implements Runnable { ! public static final String FIELD_TIMESTAMP = "timestamp"; + public static final String FIELD_PUBLISHDATE = "publishdate"; + public static final String FIELD_STATUS = "status"; + public static final String FIELD_ACTION = "action"; + public static final String FIELD_DESTINATIONCLOUD = "destinationcloud"; + public static final String FIELD_SOURCENUMBER = "sourcenumber"; + public static final String FIELD_RELATEDNODES = "relatednodes"; ! public static final String ACTION_UPDATE = "update"; ! public static final String ACTION_UPDATE_NODE = "update-node"; + public static final String ACTION_UPDATE_RELATIONS = "update-relations"; ! public static final String ACTION_REMOVE = "remove"; ! public static final String STATUS_DONE = "done"; ! public static final String STATUS_FAIL = "fail"; ! private static Logger log = Logging.getLoggerInstance(PublishingQueueBuilder.class.getName()); ! /** thread performing the task */ ! private static Thread thread = null; ! private static int maxtrying = 5; ! int remoteCloudNumber = -1; ! /** List of cloud names where to publish to */ ! String remoteCloudName; ! /** Milliseconds how long the thread will sleep */ ! private int interval = 60 * 1000; ! private static List<PublishListener> publishListeners = new ArrayList<PublishListener>(); ! /** ! * MMBase builder init method. This method first looks for the cloudlist property in the builder ! * xml starts a new publishing Tread. ! */ ! @Override ! public boolean init() { ! Map<String, String> params = getInitParameters("mmbase/remotepublishing"); ! remoteCloudName = params.get("remotecloud"); ! if ((remoteCloudName != null) && (!"".equals(remoteCloudName))) { ! log.info("remote cloud will be " + remoteCloudName); ! } ! else { ! remoteCloudName = null; ! log.warn("cloudlist parameter missing publishing disabled"); ! } ! // Initialize the module. ! String intervalStr = params.get("interval"); ! if (intervalStr == null) { throw new IllegalArgumentException("interval"); } ! interval = Integer.parseInt(intervalStr) * 1000; ! if (thread == null) { ! thread = new Thread(this, "PublishQueue to " + remoteCloudName); ! thread.setDaemon(true); ! thread.start(); ! } ! else { ! log.warn("init() method of the PublishingQueueBuilder was called multiple times"); ! } ! return super.init(); ! } ! @Override ! public boolean commit(MMObjectNode objectNodenode) { ! boolean retval = super.commit(objectNodenode); ! return retval; ! } ! @Override ! public void setDefaults(MMObjectNode node) { ! super.setDefaults(node); ! if ((remoteCloudNumber == -1) && (remoteCloudName != null)) { ! remoteCloudNumber = getCloudNumber(remoteCloudName); ! } ! node.setValue(FIELD_DESTINATIONCLOUD, remoteCloudNumber); ! } ! ! /** ! * Get number of cloud from local system ! * ! * @param name ! * the name of the cloud ( in the cloud list) ! * @return cloud node number ! * @throws BridgeException ! * if the cloud was not found ! */ ! public static int getCloudNumber(String name) throws BridgeException { ! MMObjectBuilder builder = MMBase.getMMBase().getBuilder("cloud"); ! NodeSearchQuery query = new NodeSearchQuery(builder); ! StepField nameStepField = query.getField(builder.getField("name")); ! BasicFieldValueConstraint cName = new BasicFieldValueConstraint(nameStepField, name); ! cName.setOperator(FieldCompareConstraint.EQUAL); ! query.setConstraint(cName); ! ! try { ! List<MMObjectNode> nodes = builder.getNodes(query); ! if (nodes.isEmpty()) { throw new BridgeException("can not find cloud with name(" + name ! + ") in nameServerCloud"); } ! return nodes.get(0).getNumber(); ! ! } ! catch (SearchQueryException e) { ! throw new BridgeException("can not find cloud with name(" + name ! + ") in nameServerCloud", e); ! } ! } ! ! public void run() { ! log.info("Publishing Queue initialised"); ! ! // Wait for mmbase to be up and running. ! MMBase.getMMBase(); ! ! try { Thread.sleep(interval); ! } ! catch (InterruptedException e) { log.warn("Interupted while sleeping , continuning"); ! } ! try { ! linkTypedefs(); ! } ! catch (Exception e) { ! log.error("Problem with linking typedefs together", e); ! } ! while (true) { ! try { ! Thread.sleep(interval); ! } ! catch (InterruptedException e) { ! log.warn("Interupted while sleeping , continuning"); ! } ! if (remoteCloudName == null) { ! log.warn("publising disabled"); ! } ! else { ! CloudInfo localCloudInfo = CloudInfo.getDefaultCloudInfo(); ! NodeManager nodeManager = localCloudInfo.getCloud().getNodeManager("publishqueue"); ! NodeQuery query = createQuery(nodeManager); ! NodeList list = null; ! while (list == null || !list.isEmpty()) { ! ! list = nodeManager.getList(query); ! ! for (int x = 0; x < list.size(); x++) { ! Node queueNode = list.getNode(x); ! if (queueNode != null) { ! try { ! // check if node is not removed from the cloud in between query and ! // retrieval ! if (localCloudInfo.getCloud().hasNode(queueNode.getNumber())) { ! String action = queueNode.getStringValue(FIELD_ACTION); ! if (isUpdateAction(action)) { ! try { ! boolean finished = false; ! int trytimes = 0; ! while (!finished) { ! try { ! update(localCloudInfo, queueNode, action); ! finished = true; ! } ! catch (BridgeException e) { ! if (handleRmiException(e) ! && ++trytimes <= maxtrying) { ! // if it was caused rmi connection exception ! // and still within ! // the maximal tring times limitation, ! // continue to try publishing it again ! } ! else { ! // otherwise, throw the runtime exception ! throw e; ! } ! } ! } ! queueNode.setStringValue(FIELD_STATUS, STATUS_DONE); ! queueNode.commit(); ! } ! catch (BridgeException e) { ! log.error("Nodenumber : " + queueNode.getNumber() ! + ", " + e, e); ! publishFailed(localCloudInfo, queueNode, e); ! } } ! else { ! if (isRemoveAction(action)) { ! try { ! removeNode(localCloudInfo, queueNode); ! } ! catch (BridgeException e) { ! log.error("Removing published node (" ! + queueNode.getNumber() + ") failed", e); ! publishFailed(localCloudInfo, queueNode, e); ! } ! } } ! } ! } ! catch (Throwable e) { ! log.error("Throwable error with nodenumber: " ! + queueNode.getNumber() + ", " + e.getMessage()); ! log.debug(Logging.stackTrace(e)); ! } ! } ! } // end for ! log.debug("Published total " + list.size() + " nodes"); ! } } ! } ! } private boolean isRemoveAction(String action) { *************** *** 255,265 **** private boolean isUpdateAction(String action) { ! return action.equalsIgnoreCase(ACTION_UPDATE) || action.equalsIgnoreCase(ACTION_UPDATE_NODE) ! || action.equalsIgnoreCase(ACTION_UPDATE_RELATIONS); } private NodeQuery createQuery(NodeManager nodeManager) { NodeQuery query = nodeManager.createQuery(); ! StepField statusField = query.getStepField(nodeManager.getField(FIELD_STATUS)); FieldValueConstraint failStatus = query.createConstraint(statusField, --- 273,284 ---- private boolean isUpdateAction(String action) { ! return action.equalsIgnoreCase(ACTION_UPDATE) ! || action.equalsIgnoreCase(ACTION_UPDATE_NODE) ! || action.equalsIgnoreCase(ACTION_UPDATE_RELATIONS); } private NodeQuery createQuery(NodeManager nodeManager) { NodeQuery query = nodeManager.createQuery(); ! StepField statusField = query.getStepField(nodeManager.getField(FIELD_STATUS)); FieldValueConstraint failStatus = query.createConstraint(statusField, *************** *** 269,288 **** FieldCompareConstraint.NOT_EQUAL, STATUS_DONE); query.setCaseSensitive(doneStatus, true); ! Constraint statusComposite = query.createConstraint( ! failStatus, CompositeConstraint.LOGICAL_AND, doneStatus); ! if (!nodeManager.hasField(FIELD_PUBLISHDATE)) { query.setConstraint(statusComposite); } else { ! StepField publishDateField = query.getStepField(nodeManager.getField(FIELD_PUBLISHDATE)); Constraint publishNull = query.createConstraint(publishDateField); ! Constraint publishNow = query.createConstraint( ! publishDateField, FieldCompareConstraint.LESS_EQUAL, new Date()); ! ! Constraint publishDateComposite = query.createConstraint( ! publishNow, CompositeConstraint.LOGICAL_OR, publishNull); ! Constraint composite = query.createConstraint( ! statusComposite, CompositeConstraint.LOGICAL_AND, publishDateComposite); query.setConstraint(composite); } --- 288,308 ---- FieldCompareConstraint.NOT_EQUAL, STATUS_DONE); query.setCaseSensitive(doneStatus, true); ! Constraint statusComposite = query.createConstraint(failStatus, ! CompositeConstraint.LOGICAL_AND, doneStatus); ! if (!nodeManager.hasField(FIELD_PUBLISHDATE)) { query.setConstraint(statusComposite); } else { ! StepField publishDateField = query ! .getStepField(nodeManager.getField(FIELD_PUBLISHDATE)); Constraint publishNull = query.createConstraint(publishDateField); ! Constraint publishNow = query.createConstraint(publishDateField, ! FieldCompareConstraint.LESS_EQUAL, new Date()); ! ! Constraint publishDateComposite = query.createConstraint(publishNow, ! CompositeConstraint.LOGICAL_OR, publishNull); ! Constraint composite = query.createConstraint(statusComposite, ! CompositeConstraint.LOGICAL_AND, publishDateComposite); query.setConstraint(composite); } *************** *** 290,304 **** StepField timestampField = query.getStepField(nodeManager.getField(FIELD_TIMESTAMP)); query.addSortOrder(timestampField, SortOrder.ORDER_ASCENDING); ! query.setCachePolicy(CachePolicy.NEVER); return query; } ! /** ! * handle exception, if the root cause is RMI's connection broken, ! * try to set cached cloud informaiton invalid. ! * @param e the exception which we should handled. ! * @return true, if the exception is caused by invalid RMI connect; false, otherwise. ! */ private boolean handleRmiException(BridgeException e) { Throwable rootCause = e; --- 310,326 ---- StepField timestampField = query.getStepField(nodeManager.getField(FIELD_TIMESTAMP)); query.addSortOrder(timestampField, SortOrder.ORDER_ASCENDING); ! query.setCachePolicy(CachePolicy.NEVER); return query; } ! /** ! * handle exception, if the root cause is RMI's connection broken, try to set cached cloud ! * informaiton invalid. ! * ! * @param e ! * the exception which we should handled. ! * @return true, if the exception is caused by invalid RMI connect; false, otherwise. ! */ private boolean handleRmiException(BridgeException e) { Throwable rootCause = e; *************** *** 311,334 **** if (rootCause instanceof ConnectException) { ! //if root cause is rmi connection exception String message = e.getCause().getMessage(); ! log.debug("rmi connection exception:"+message); int beginIndex = message.indexOf("rmi://"); if (beginIndex >= 0) { ! //if we know exactlly what cloud is died, we just reset this one int endIndex = message.indexOf(" ", beginIndex); String url = message.substring(beginIndex, endIndex); CloudInfo.setCloudInvalid(url); return true; ! } else { ! //if we aren't sure which cloud is died, reset all cached remote cloud CloudInfo.setRemoteCloudsInvalid(); return true; } ! ! } else if (rootCause instanceof NoSuchObjectException){ ! CloudInfo.setRemoteCloudsInvalid(); ! return true; } return false; } --- 333,359 ---- if (rootCause instanceof ConnectException) { ! // if root cause is rmi connection exception String message = e.getCause().getMessage(); ! log.debug("rmi connection exception:" + message); int beginIndex = message.indexOf("rmi://"); if (beginIndex >= 0) { ! // if we know exactlly what cloud is died, we just reset this one int endIndex = message.indexOf(" ", beginIndex); String url = message.substring(beginIndex, endIndex); CloudInfo.setCloudInvalid(url); return true; ! } ! else { ! // if we aren't sure which cloud is died, reset all cached remote cloud CloudInfo.setRemoteCloudsInvalid(); return true; } ! } + else + if (rootCause instanceof NoSuchObjectException) { + CloudInfo.setRemoteCloudsInvalid(); + return true; + } return false; } *************** *** 337,466 **** node.setStringValue(FIELD_STATUS, STATUS_FAIL); node.commit(); ! for(PublishListener listener : publishListeners) { ! int number = node.getIntValue(FIELD_SOURCENUMBER); ! if (localCloudInfo.getCloud().hasNode(number)) { ! StringBuffer message = new StringBuffer(); ! Throwable t = e; ! while(t != null) { ! message.append(t.getMessage()); ! t = t.getCause(); ! if(t != null) { ! message.append(" | "); ! } ! } ! ! listener.publishedFailed(localCloudInfo.getCloud().getNode(number),message.toString()); ! } } } - - private void update(CloudInfo localCloudInfo, Node queueNode, String action) { - int localNodeNumber = queueNode.getIntValue(FIELD_SOURCENUMBER); - int remoteCloudNumber = queueNode.getIntValue(FIELD_DESTINATIONCLOUD); - CloudInfo remoteCloudInfo = CloudInfo.getCloudInfo(remoteCloudNumber); - Node localNode = localCloudInfo.getCloud().getNode(localNodeNumber); - String nodeManagerName = localNode.getNodeManager().getName(); ! try { ! if (!PublishManager.isImported(localCloudInfo, localNode)) { ! ! if (PublishManager.isPublished(localCloudInfo, localNode)) { ! if (localNode instanceof Relation) { ! log.debug(nodeManagerName + " update relation with number " + localNodeNumber); ! } else { ! log.debug(nodeManagerName + " update node with number " + localNodeNumber); ! } ! if (action.equalsIgnoreCase(ACTION_UPDATE_NODE)) { ! PublishManager.updateNodesAndRelations(localCloudInfo, localNode, true, false); ! } ! if (action.equalsIgnoreCase(ACTION_UPDATE)) { ! PublishManager.updateNodesAndRelations(localCloudInfo, localNode, true, true); ! } ! if (action.equalsIgnoreCase(ACTION_UPDATE_RELATIONS)) { ! String relatedNodes = queueNode.getStringValue(FIELD_RELATEDNODES); ! if (relatedNodes != null && relatedNodes.length() > 0) { ! List<Integer> related = new ArrayList<Integer>(); ! StringTokenizer tokenizer = new StringTokenizer(relatedNodes, ","); ! while(tokenizer.hasMoreTokens()) { ! int relatedNodeNumber = Integer.valueOf(tokenizer.nextToken()); ! related.add(relatedNodeNumber); ! } ! PublishManager.updateNodesAndRelations(localCloudInfo, localNode, false, true, related); ! } ! else { ! PublishManager.updateNodesAndRelations(localCloudInfo, localNode, false, true); ! } ! } ! } else { ! if (localNode instanceof Relation) { ! log.debug(nodeManagerName + " publish relation with number " + ! localNodeNumber); ! } else { ! log.debug(nodeManagerName + " publish node with number " + ! localNodeNumber); ! } ! if (action.equalsIgnoreCase(ACTION_UPDATE_NODE)) { ! PublishManager.createNodeAndRelations(localCloudInfo, localNode, remoteCloudInfo, false); ! } ! if (action.equalsIgnoreCase(ACTION_UPDATE)) { ! PublishManager.createNodeAndRelations(localCloudInfo, localNode, remoteCloudInfo, true); ! } ! } ! for(PublishListener listener : publishListeners) { ! listener.published(localNode); } ! } ! else { //if it is imported from other cloud, ignore this node ! log.debug("imported node in publishqueue " + localNode.getNumber()); ! } ! } catch (Exception e) { ! throw new BridgeException("PublishManager could not publish " + localNode.getNumber(), e); ! } finally { ! log.debug("Published one node("+localNode.getNumber()+")"); ! } ! } ! private void removeNode(CloudInfo localCloudInfo, Node queueNode) { ! int number = queueNode.getIntValue(FIELD_SOURCENUMBER); ! PublishManager.deletePublishedNode(localCloudInfo, number); ! queueNode.setStringValue(FIELD_STATUS, STATUS_DONE); ! queueNode.commit(); ! } ! public static void addPublishListener(PublishListener publishListener) { ! publishListeners.add(publishListener); ! } ! public static void removePublishListener(PublishListener publishListener) { ! publishListeners.remove(publishListener); ! } ! private void linkTypedefs() { ! CloudInfo localCloudInfo = CloudInfo.getDefaultCloudInfo(); ! CloudInfo remoteCloudInfo = CloudInfo.getCloudInfoByName(remoteCloudName); ! NodeList typedefList = SearchUtil.findNodeList(localCloudInfo.getCloud(), "typedef"); ! NodeIterator typedefIterator = typedefList.nodeIterator(); ! while (typedefIterator.hasNext()) { ! Node typedefNode = typedefIterator.nextNode(); ! if (!PublishManager.isPublished(localCloudInfo, typedefNode)) { ! // not published ! Node remoteTypeDefNode = SearchUtil.findNode(remoteCloudInfo.getCloud(), "typedef", "name", typedefNode.getStringValue("name")); ! if (remoteTypeDefNode != null) { ! PublishManager.createPublishingInfo(localCloudInfo, typedefNode, remoteCloudInfo, remoteTypeDefNode); ! log.info("Added remoteinfo for typedef with name : " + typedefNode.getStringValue("name")); } else { ! log.debug("No remote node found to link with for typedef with name : " + typedefNode.getStringValue("name")); } ! } ! else { ! log.debug("Found remoteinfo for typedef with name : " + typedefNode.getStringValue("name")); ! } ! } ! } } --- 362,509 ---- node.setStringValue(FIELD_STATUS, STATUS_FAIL); node.commit(); ! for (PublishListener listener : publishListeners) { ! int number = node.getIntValue(FIELD_SOURCENUMBER); ! if (localCloudInfo.getCloud().hasNode(number)) { ! StringBuffer message = new StringBuffer(); ! Throwable t = e; ! while (t != null) { ! message.append(t.getMessage()); ! t = t.getCause(); ! if (t != null) { ! message.append(" | "); ! } ! } ! ! listener.publishedFailed(localCloudInfo.getCloud().getNode(number), message ! .toString()); ! } } } ! private void update(CloudInfo localCloudInfo, Node queueNode, String action) { ! int localNodeNumber = queueNode.getIntValue(FIELD_SOURCENUMBER); ! int remoteCloudNumber = queueNode.getIntValue(FIELD_DESTINATIONCLOUD); ! CloudInfo remoteCloudInfo = CloudInfo.getCloudInfo(remoteCloudNumber); ! Node localNode = localCloudInfo.getCloud().getNode(localNodeNumber); ! String nodeManagerName = localNode.getNodeManager().getName(); ! try { ! if (!PublishManager.isImported(localCloudInfo, localNode)) { ! if (PublishManager.isPublished(localCloudInfo, localNode)) { ! if (localNode instanceof Relation) { ! log.debug(nodeManagerName + " update relation with number " ! + localNodeNumber); ! } ! else { ! log.debug(nodeManagerName + " update node with number " + localNodeNumber); ! } ! if (action.equalsIgnoreCase(ACTION_UPDATE_NODE)) { ! PublishManager.updateNodesAndRelations(localCloudInfo, localNode, true, ! false); ! } ! if (action.equalsIgnoreCase(ACTION_UPDATE)) { ! PublishManager.updateNodesAndRelations(localCloudInfo, localNode, true, ! true); ! } ! if (action.equalsIgnoreCase(ACTION_UPDATE_RELATIONS)) { ! String relatedNodes = queueNode.getStringValue(FIELD_RELATEDNODES); ! if (relatedNodes != null && relatedNodes.length() > 0) { ! List<Integer> related = new ArrayList<Integer>(); ! StringTokenizer tokenizer = new StringTokenizer(relatedNodes, ","); ! while (tokenizer.hasMoreTokens()) { ! int relatedNodeNumber = Integer.valueOf(tokenizer.nextToken()); ! related.add(relatedNodeNumber); ! } ! PublishManager.updateNodesAndRelations(localCloudInfo, localNode, ! false, true, related); ! } ! else { ! PublishManager.updateNodesAndRelations(localCloudInfo, localNode, ! false, true); ! } ! } ! } ! else { ! if (localNode instanceof Relation) { ! log.debug(nodeManagerName + " publish relation with number " ! + localNodeNumber); ! } ! else { ! log.debug(nodeManagerName + " publish node with number " + localNodeNumber); ! } ! ! if (action.equalsIgnoreCase(ACTION_UPDATE_NODE)) { ! PublishManager.createNodeAndRelations(localCloudInfo, localNode, ! remoteCloudInfo, false); ! } ! if (action.equalsIgnoreCase(ACTION_UPDATE)) { ! PublishManager.createNodeAndRelations(localCloudInfo, localNode, ! remoteCloudInfo, true); ! } ! } ! ! for (PublishListener listener : publishListeners) { ! listener.published(localNode); ! } } ! else { // if it is imported from other cloud, ignore this node ! log.debug("imported node in publishqueue " + localNode.getNumber()); ! } ! } ! catch (Exception e) { ! throw new BridgeException("PublishManager could not publish " + localNode.getNumber(), ! e); ! } ! finally { ! log.debug("Published one node(" + localNode.getNumber() + ")"); ! } ! } ! private void removeNode(CloudInfo localCloudInfo, Node queueNode) { ! int number = queueNode.getIntValue(FIELD_SOURCENUMBER); ! PublishManager.deletePublishedNode(localCloudInfo, number); ! queueNode.setStringValue(FIELD_STATUS, STATUS_DONE); ! queueNode.commit(); ! } ! public static void addPublishListener(PublishListener publishListener) { ! publishListeners.add(publishListener); ! } ! public static void removePublishListener(PublishListener publishListener) { ! publishListeners.remove(publishListener); ! } ! private void linkTypedefs() { ! CloudInfo localCloudInfo = CloudInfo.getDefaultCloudInfo(); ! CloudInfo remoteCloudInfo = CloudInfo.getCloudInfoByName(remoteCloudName); ! NodeList typedefList = SearchUtil.findNodeList(localCloudInfo.getCloud(), "typedef"); ! NodeIterator typedefIterator = typedefList.nodeIterator(); ! while (typedefIterator.hasNext()) { ! Node typedefNode = typedefIterator.nextNode(); ! if (!PublishManager.isPublished(localCloudInfo, typedefNode)) { ! // not published ! Node remoteTypeDefNode = SearchUtil.findNode(remoteCloudInfo.getCloud(), "typedef", ! "name", typedefNode.getStringValue("name")); ! if (remoteTypeDefNode != null) { ! PublishManager.createPublishingInfo(localCloudInfo, typedefNode, ! remoteCloudInfo, remoteTypeDefNode); ! log.info("Added remoteinfo for typedef with name : " ! + typedefNode.getStringValue("name")); ! } ! else { ! log.debug("No remote node found to link with for typedef with name : " ! + typedefNode.getStringValue("name")); ! } } else { ! log.debug("Found remoteinfo for typedef with name : " ! + typedefNode.getStringValue("name")); } ! } ! } } Index: PublishRelationBuilder.java =================================================================== RCS file: /cvsroot/mmapps/mmapps/remotepublishing/src/org/mmbase/remotepublishing/builders/PublishRelationBuilder.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PublishRelationBuilder.java 17 Oct 2006 10:02:54 -0000 1.2 --- PublishRelationBuilder.java 5 Nov 2007 20:50:34 -0000 1.3 *************** *** 14,17 **** --- 14,18 ---- package org.mmbase.remotepublishing.builders; + import org.mmbase.remotepublishing.CloudManager; import org.mmbase.remotepublishing.util.PublishUtil; *************** *** 23,64 **** public class PublishRelationBuilder extends InsRel { ! private static Logger log = Logging.getLoggerInstance(PublishRelationBuilder.class.getName()); ! private boolean publish = false; ! public boolean init() { ! if ("true".equals(getInitParameter("publish"))) { ! publish = true; ! log.info(tableName + " is active"); ! } else { ! log.info(tableName + " is inactive"); ! } ! return super.init(); ! } ! public int insert(String owner, MMObjectNode node) { ! int number = super.insert(owner, node); ! if (number != -1) { ! if (publish) { ! PublishUtil.publishOrUpdateNode(number); ! } ! } ! return number; ! } ! public boolean commit(MMObjectNode objectNode) { ! boolean retval = super.commit(objectNode); ! if (publish) { ! PublishUtil.publishOrUpdateNode(objectNode); ! } ! return retval; ! } ! public void removeNode(MMObjectNode objectNode) { ! if (publish) { ! PublishUtil.removeNode(objectNode); ! } ! super.removeNode(objectNode); ! } } --- 24,82 ---- public class PublishRelationBuilder extends InsRel { ! private static Logger log = Logging.getLoggerInstance(PublishRelationBuilder.class.getName()); ! private boolean publish = false; ! @Override ! public boolean init() { ! String publishStr = getInitParameter("publish"); ! if (publishStr == null || "".equals(publishStr.trim()) ! || "false".equalsIgnoreCase(publishStr)) { ! log.info(getTableName() + " is inactive"); ! } ! else { ! if ("true".equalsIgnoreCase(publishStr)) { ! publish = true; ! log.info(getTableName() + " is active"); ! } ! else { ! String defaultCloud = CloudManager.getDefaultCloudName(); ! if (publishStr.equals(defaultCloud)) { ! publish = true; ! log.info(getTableName() + " is active for local mmbase instance"); ! } ! } ! } ! return super.init(); ! } ! @Override ! public int insert(String owner, MMObjectNode node) { ! int number = super.insert(owner, node); ! if (number != -1) { ! if (publish) { ! PublishUtil.publishOrUpdateNode(number); ! } ! } ! return number; ! } ! @Override ! public boolean commit(MMObjectNode objectNode) { ! boolean retval = super.commit(objectNode); ! if (publish) { ! PublishUtil.publishOrUpdateNode(objectNode); ! } ! return retval; ! } ! ! @Override ! public void removeNode(MMObjectNode objectNode) { ! if (publish) { ! PublishUtil.removeNode(objectNode); ! } ! super.removeNode(objectNode); ! } } |
From: Nico K. <nkl...@us...> - 2007-11-05 20:51:12
|
Update of /cvsroot/mmapps/mmapps/remotepublishing/src/org/mmbase/remotepublishing/util In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv11467/remotepublishing/src/org/mmbase/remotepublishing/util Modified Files: PublishUtil.java Removed Files: GenericNodeList.java GenericNodeIterator.java Log Message: Cleanup and formatting Builders accept cloud name as property for publish. The name is the ckoud which may publish nodes of this type Index: PublishUtil.java =================================================================== RCS file: /cvsroot/mmapps/mmapps/remotepublishing/src/org/mmbase/remotepublishing/util/PublishUtil.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PublishUtil.java 4 Jun 2007 07:39:04 -0000 1.6 --- PublishUtil.java 5 Nov 2007 20:50:31 -0000 1.7 *************** *** 23,111 **** import org.mmbase.util.logging.*; - /** * Util class to put nodes in a publish queue. ! * @author Ronald Kramp * @version PublishUtil.java,v 1.2 2003/07/28 09:44:16 nico Exp */ public class PublishUtil { - private static Logger log = Logging.getLoggerInstance(PublishUtil.class.getName()); ! /** ! * add a node to the publish queue ! * @param objectNodenode the node to put in the publish queue ! **/ ! public static void publishOrUpdateNode(MMObjectNode objectNodenode) { ! int number = objectNodenode.getIntValue("number"); ! publishOrUpdateNode(getAdminCloud(), number, null); ! } ! /** ! * add a node to the publish queue ! * @param number the node to put in the publish queue ! **/ ! public static void publishOrUpdateNode(int number) { ! publishOrUpdateNode(getAdminCloud(), number, null); ! } ! ! /** ! * add a node to the publish queue ! * @param node the node to put in the publish queue ! **/ ! public static void publishOrUpdateNode(Node node) { ! int number = node.getNumber(); ! publishOrUpdateNode(node.getCloud(), number, null); ! } ! /** ! * add a node to the publish queue ! * @param number the number of the node to put in the publish queue ! * @param cloud cloud instance ! **/ ! public static void publishOrUpdateNode(Cloud cloud, int number) { ! publishOrUpdateNode(cloud, number, null); ! } ! ! /** ! * add a node to the publish queue ! * @param number the number of the node to put in the publish queue ! * @param cloud cloud instance ! * @param publishDate publish when this date has passed ! **/ ! public static void publishOrUpdateNode(Cloud cloud, int number, Date publishDate) { ! log.debug("PublishOrUpdateNode with number = " + number); ! createQueueNode(cloud, number, -1, PublishingQueueBuilder.ACTION_UPDATE, publishDate, null); ! } ! /** ! * add the node to the queue to remove all published instances of a node ! * @param objectNodenode the node to be removed ! **/ ! public static void removeNode(MMObjectNode objectNodenode) { ! int number = objectNodenode.getIntValue("number"); ! removeNode(getAdminCloud(), number); ! } ! /** ! * add the node to the queue to remove all published instances of a node ! * @param number the number of the node to be removed ! * @param cloud cloud instance ! **/ ! public static void removeNode(Cloud cloud, int number) { ! removeNode(cloud, number, null); ! } ! public static void removeNode(Cloud cloud, int number, Date publishDate) { ! log.debug("removeNode with number = " + number); ! String action = PublishingQueueBuilder.ACTION_REMOVE; ! createQueueNode(cloud, number, -1, action, publishDate, null); ! } ! public static void removeFromQueue(Node node) { log.debug("removeFromQueue with number = " + node.getNumber()); NodeManager nodeManager = node.getCloud().getNodeManager("publishqueue"); NodeList list = nodeManager.getList( ! "[status] != 'fail' and [status] != 'done' and sourcenumber = " + node.getNumber(), null, null); NodeIterator iter = list.nodeIterator(); while (iter.hasNext()) { --- 23,129 ---- import org.mmbase.util.logging.*; /** * Util class to put nodes in a publish queue. ! * ! * @author Ronald Kramp * @version PublishUtil.java,v 1.2 2003/07/28 09:44:16 nico Exp */ public class PublishUtil { ! private static Logger log = Logging.getLoggerInstance(PublishUtil.class.getName()); ! /** ! * add a node to the publish queue ! * ! * @param objectNodenode the node to put in the publish queue ! */ ! public static void publishOrUpdateNode(MMObjectNode objectNodenode) { ! int number = objectNodenode.getIntValue("number"); ! publishOrUpdateNode(getAdminCloud(), number, null); ! } ! /** ! * add a node to the publish queue ! * ! * @param number the node to put in the publish queue ! */ ! public static void publishOrUpdateNode(int number) { ! publishOrUpdateNode(getAdminCloud(), number, null); ! } ! /** ! * add a node to the publish queue ! * ! * @param node the node to put in the publish queue ! */ ! public static void publishOrUpdateNode(Node node) { ! int number = node.getNumber(); ! publishOrUpdateNode(node.getCloud(), number, null); ! } ! /** ! * add a node to the publish queue ! * ! * @param number the number of the node to put in the publish queue ! * @param cloud cloud instance ! */ ! public static void publishOrUpdateNode(Cloud cloud, int number) { ! publishOrUpdateNode(cloud, number, null); ! } ! /** ! * add a node to the publish queue ! * ! * @param number the number of the node to put in the publish queue ! * @param cloud cloud instance ! * @param publishDate publish when this date has passed ! */ ! public static void publishOrUpdateNode(Cloud cloud, int number, Date publishDate) { ! log.debug("PublishOrUpdateNode with number = " + number); ! createQueueNode(cloud, number, -1, PublishingQueueBuilder.ACTION_UPDATE, publishDate, null); ! } ! /** ! * add the node to the queue to remove all published instances of a node ! * ! * @param objectNodenode the node to be removed ! */ ! public static void removeNode(MMObjectNode objectNodenode) { ! int number = objectNodenode.getIntValue("number"); ! removeNode(getAdminCloud(), number); ! } ! ! /** ! * add the node to the queue to remove all published instances of a node ! * ! * @param number the number of the node to be removed ! */ ! public static void removeNode(int number) { ! removeNode(getAdminCloud(), number, null); ! } ! ! /** ! * add the node to the queue to remove all published instances of a node ! * ! * @param number the number of the node to be removed ! * @param cloud cloud instance ! */ ! public static void removeNode(Cloud cloud, int number) { ! removeNode(cloud, number, null); ! } ! ! public static void removeNode(Cloud cloud, int number, Date publishDate) { ! log.debug("removeNode with number = " + number); ! String action = PublishingQueueBuilder.ACTION_REMOVE; ! createQueueNode(cloud, number, -1, action, publishDate, null); ! } ! ! public static void removeFromQueue(Node node) { log.debug("removeFromQueue with number = " + node.getNumber()); NodeManager nodeManager = node.getCloud().getNodeManager("publishqueue"); NodeList list = nodeManager.getList( ! "[status] != 'fail' and [status] != 'done' and sourcenumber = " + node.getNumber(), ! null, null); NodeIterator iter = list.nodeIterator(); while (iter.hasNext()) { *************** *** 114,140 **** } } ! ! public static void removeFromQueue(Node node, List<Node> clouds) { ! log.debug("removeFromQueue with number = " + node.getNumber()); ! NodeManager nodeManager = node.getCloud().getNodeManager("publishqueue"); ! ! for (Iterator<Node> cloudIter = clouds.iterator(); cloudIter.hasNext();) { ! Node cloudNode = cloudIter.next(); ! NodeList list = nodeManager.getList("[status] != 'fail' and [status] != 'done' and sourcenumber = " + node.getNumber() + " and sourcecloud = " + cloudNode.getNumber() , null, null); ! NodeIterator iter = list.nodeIterator(); ! while (iter.hasNext()) { ! Node element = iter.nextNode(); ! element.delete(); } - } } public static void publishOrUpdateNode(Node node, Node cloudNode) { ! if (node == null) { ! throw new IllegalArgumentException("Node = null"); ! } ! if (cloudNode == null) { ! throw new IllegalArgumentException("CloudNode = null " + (node == null ? -1: node.getNumber())); ! } publishOrUpdateNode(node.getCloud(), node.getNumber(), cloudNode.getNumber()); } --- 132,157 ---- } } ! ! public static void removeFromQueue(Node node, List<Node> clouds) { ! log.debug("removeFromQueue with number = " + node.getNumber()); ! NodeManager nodeManager = node.getCloud().getNodeManager("publishqueue"); ! ! for (Node cloudNode : clouds) { ! NodeList list = nodeManager.getList( ! "[status] != 'fail' and [status] != 'done' and sourcenumber = " ! + node.getNumber() + " and sourcecloud = " + cloudNode.getNumber(), ! null, null); ! NodeIterator iter = list.nodeIterator(); ! while (iter.hasNext()) { ! Node element = iter.nextNode(); ! element.delete(); ! } } } public static void publishOrUpdateNode(Node node, Node cloudNode) { ! if (node == null) { throw new IllegalArgumentException("Node = null"); } ! if (cloudNode == null) { throw new IllegalArgumentException("CloudNode = null " ! + (node == null ? -1 : node.getNumber())); } publishOrUpdateNode(node.getCloud(), node.getNumber(), cloudNode.getNumber()); } *************** *** 144,152 **** } ! public static void publishOrUpdateNode(Cloud cloud, int number, int cloudNumber, Date publishDate) { publishOrUpdateNode(cloud, number, cloudNumber, publishDate, true); } ! ! public static void publishOrUpdateNode(Cloud cloud, int number, int cloudNumber, Date publishDate, boolean relations) { log.debug("PublishOrUpdateNode with number = " + number); String action; --- 161,171 ---- } ! public static void publishOrUpdateNode(Cloud cloud, int number, int cloudNumber, ! Date publishDate) { publishOrUpdateNode(cloud, number, cloudNumber, publishDate, true); } ! ! public static void publishOrUpdateNode(Cloud cloud, int number, int cloudNumber, ! Date publishDate, boolean relations) { log.debug("PublishOrUpdateNode with number = " + number); String action; *************** *** 157,178 **** action = PublishingQueueBuilder.ACTION_UPDATE_NODE; } ! createQueueNode(cloud, number, cloudNumber, action, publishDate, null); } ! public static void publishOrUpdateRelations(Cloud cloud, int number, List<Integer> relatedNodes) { publishOrUpdateRelations(cloud, number, -1, relatedNodes); } ! ! public static void publishOrUpdateRelations(Cloud cloud, int number, int cloudNumber, List<Integer> relatedNodes) { String action = PublishingQueueBuilder.ACTION_UPDATE_RELATIONS; createQueueNode(cloud, number, cloudNumber, action, null, relatedNodes); } ! private static Cloud getAdminCloud() { return CloudProviderFactory.getCloudProvider().getAdminCloud(); } ! ! private static void createQueueNode(Cloud cloud, int number, int cloudNumber, String action, Date publishDate, List<Integer> relatedNodes) { NodeManager nodeManager = cloud.getNodeManager("publishqueue"); --- 176,202 ---- action = PublishingQueueBuilder.ACTION_UPDATE_NODE; } ! createQueueNode(cloud, number, cloudNumber, action, publishDate, null); } ! ! public static void publishOrUpdateRelations(int number, List<Integer> relatedNodes) { ! publishOrUpdateRelations(getAdminCloud(), number, -1, relatedNodes); ! } ! public static void publishOrUpdateRelations(Cloud cloud, int number, List<Integer> relatedNodes) { publishOrUpdateRelations(cloud, number, -1, relatedNodes); } ! ! public static void publishOrUpdateRelations(Cloud cloud, int number, int cloudNumber, ! List<Integer> relatedNodes) { String action = PublishingQueueBuilder.ACTION_UPDATE_RELATIONS; createQueueNode(cloud, number, cloudNumber, action, null, relatedNodes); } ! private static Cloud getAdminCloud() { return CloudProviderFactory.getCloudProvider().getAdminCloud(); } ! ! private static void createQueueNode(Cloud cloud, int number, int cloudNumber, String action, Date publishDate, List<Integer> relatedNodes) { NodeManager nodeManager = cloud.getNodeManager("publishqueue"); *************** *** 193,197 **** node.setStringValue(PublishingQueueBuilder.FIELD_RELATEDNODES, localNumbers); } ! node.commit(); } --- 217,221 ---- node.setStringValue(PublishingQueueBuilder.FIELD_RELATEDNODES, localNumbers); } ! node.commit(); } --- GenericNodeList.java DELETED --- --- GenericNodeIterator.java DELETED --- |
From: Nico K. <nkl...@us...> - 2007-11-05 20:50:59
|
Update of /cvsroot/mmapps/mmapps/remotepublishing/src/org/mmbase/remotepublishing In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv11467/remotepublishing/src/org/mmbase/remotepublishing Modified Files: CloudManager.java Log Message: Cleanup and formatting Builders accept cloud name as property for publish. The name is the ckoud which may publish nodes of this type Index: CloudManager.java =================================================================== RCS file: /cvsroot/mmapps/mmapps/remotepublishing/src/org/mmbase/remotepublishing/CloudManager.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CloudManager.java 16 Dec 2006 13:14:45 -0000 1.3 --- CloudManager.java 5 Nov 2007 20:50:19 -0000 1.4 *************** *** 25,28 **** --- 25,30 ---- import org.mmbase.bridge.Node; import org.mmbase.bridge.util.SearchUtil; + import org.mmbase.module.core.MMBase; + import org.mmbase.module.core.MMObjectNode; import org.mmbase.util.logging.Logger; import org.mmbase.util.logging.Logging; *************** *** 33,41 **** public final class CloudManager { private static final String CLOUD = "cloud"; private static final String CLOUD_DEFAULT = "cloud.default"; - - static Logger log = Logging.getLoggerInstance(CloudManager.class.getName()); private CloudManager() { --- 35,48 ---- public final class CloudManager { + static Logger log = Logging.getLoggerInstance(CloudManager.class.getName()); + + private static final String FIELD_NAME = "name"; + private static final String FIELD_RMIURL = "rmiurl"; + private static final String FIELD_USERNAME = "username"; + private static final String FIELD_PASSWORD = "password"; + private static final String CLOUD = "cloud"; private static final String CLOUD_DEFAULT = "cloud.default"; private CloudManager() { *************** *** 52,56 **** */ public static int getCloudNumber(Cloud nameServerCloud, String name) throws BridgeException { ! Node cloud = SearchUtil.findNode(nameServerCloud, CLOUD, "name", name); if (cloud == null) { --- 59,63 ---- */ public static int getCloudNumber(Cloud nameServerCloud, String name) throws BridgeException { ! Node cloud = SearchUtil.findNode(nameServerCloud, CLOUD, FIELD_NAME, name); if (cloud == null) { *************** *** 80,86 **** public static Node getCloudNode(Cloud nameServerCloud, Cloud cloud) { //get the name of the cloud ! String cloudName = cloud.getNodeByAlias(CLOUD_DEFAULT).getStringValue("name"); ! Node cloudNode = SearchUtil.findNode(nameServerCloud, CLOUD, "name", cloudName); if (cloudNode == null) { throw new BridgeException("remote cloud's number could not be established"); --- 87,93 ---- public static Node getCloudNode(Cloud nameServerCloud, Cloud cloud) { //get the name of the cloud ! String cloudName = cloud.getNodeByAlias(CLOUD_DEFAULT).getStringValue(FIELD_NAME); ! Node cloudNode = SearchUtil.findNode(nameServerCloud, CLOUD, FIELD_NAME, cloudName); if (cloudNode == null) { throw new BridgeException("remote cloud's number could not be established"); *************** *** 104,108 **** public static Node getCloudNodeByName(Cloud nameServerCloud, String name) throws BridgeException { ! Node cloudNode = SearchUtil.findNode(nameServerCloud, CLOUD, "name", name); if (cloudNode == null) { throw new BridgeException("can not find cloud with name(" --- 111,115 ---- public static Node getCloudNodeByName(Cloud nameServerCloud, String name) throws BridgeException { ! Node cloudNode = SearchUtil.findNode(nameServerCloud, CLOUD, FIELD_NAME, name); if (cloudNode == null) { throw new BridgeException("can not find cloud with name(" *************** *** 138,142 **** public static Cloud getCloudWithName(Cloud cloud, String name) { Node defaultCloud = cloud.getNode("cloud.default"); ! if (name.equals(defaultCloud.getStringValue("name"))) { return cloud; } --- 145,149 ---- public static Cloud getCloudWithName(Cloud cloud, String name) { Node defaultCloud = cloud.getNode("cloud.default"); ! if (name.equals(defaultCloud.getStringValue(FIELD_NAME))) { return cloud; } *************** *** 185,191 **** } ! String rmiUrl = cloudNode.getStringValue("rmiurl"); ! String username = cloudNode.getStringValue("username"); ! String password = cloudNode.getStringValue("password"); CloudContext cloudContext = ContextProvider.getCloudContext(rmiUrl); --- 192,198 ---- } ! String rmiUrl = cloudNode.getStringValue(FIELD_RMIURL); ! String username = cloudNode.getStringValue(FIELD_USERNAME); ! String password = cloudNode.getStringValue(FIELD_PASSWORD); CloudContext cloudContext = ContextProvider.getCloudContext(rmiUrl); *************** *** 193,198 **** if ((username != null) && !username.equals("")) { Map<String, String> user = new HashMap<String, String>(); ! user.put("username", username); ! user.put("password", password); return cloudContext.getCloud("mmbase", "name/password", user); } --- 200,205 ---- if ((username != null) && !username.equals("")) { Map<String, String> user = new HashMap<String, String>(); ! user.put(FIELD_USERNAME, username); ! user.put(FIELD_PASSWORD, password); return cloudContext.getCloud("mmbase", "name/password", user); } *************** *** 203,206 **** return CloudProviderFactory.getCloudProvider().getAdminCloud(); } ! } --- 210,221 ---- return CloudProviderFactory.getCloudProvider().getAdminCloud(); } ! ! public static String getDefaultCloudName() { ! MMObjectNode cloudNode = MMBase.getMMBase().getBuilder(CLOUD).getNode(CLOUD_DEFAULT); ! if (cloudNode != null) { ! return cloudNode.getStringValue(FIELD_NAME); ! } ! return null; ! } ! } |
From: Nico K. <nkl...@us...> - 2007-11-05 20:50:41
|
Update of /cvsroot/mmapps/mmapps/remotepublishing In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv11467/remotepublishing Modified Files: project.xml Log Message: Cleanup and formatting Builders accept cloud name as property for publish. The name is the ckoud which may publish nodes of this type Index: project.xml =================================================================== RCS file: /cvsroot/mmapps/mmapps/remotepublishing/project.xml,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** project.xml 20 Sep 2007 18:26:02 -0000 1.8 --- project.xml 5 Nov 2007 20:50:36 -0000 1.9 *************** *** 5,9 **** <artifactId>remotepublishing</artifactId> <name>MMBase Remote Publishing</name> ! <currentVersion>1.0.13-SNAPSHOT</currentVersion> <package>org.mmbase.remotepublishing</package> <shortDescription>The MMBase Remote Publishing module provides a way to clone nodes from one cloud to the other</shortDescription> --- 5,9 ---- <artifactId>remotepublishing</artifactId> <name>MMBase Remote Publishing</name> ! <currentVersion>1.0.13</currentVersion> <package>org.mmbase.remotepublishing</package> <shortDescription>The MMBase Remote Publishing module provides a way to clone nodes from one cloud to the other</shortDescription> *************** *** 53,57 **** <groupId>mmapps</groupId> <artifactId>maven-mmbase-module-plugin</artifactId> ! <version>1.1.1</version> <type>plugin</type> <url>http://mmapps.sourceforge.net/maven-mmbase-module-plugin/</url> --- 53,57 ---- <groupId>mmapps</groupId> <artifactId>maven-mmbase-module-plugin</artifactId> ! <version>1.2</version> <type>plugin</type> <url>http://mmapps.sourceforge.net/maven-mmbase-module-plugin/</url> |
From: Nico K. <nkl...@us...> - 2007-11-05 20:50:37
|
Update of /cvsroot/mmapps/mmapps/remotepublishing/examples/nl/vodafone/builders In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv11467/remotepublishing/examples/nl/vodafone/builders Added Files: PublishingQueueBuilder.java Log Message: Cleanup and formatting Builders accept cloud name as property for publish. The name is the ckoud which may publish nodes of this type --- NEW FILE: PublishingQueueBuilder.java --- package nl.vodafone.builders; import java.util.Iterator; import nl.vodafone.channel.SiteUtil; import nl.vodafone.content.ContentTypeHelper; import nl.vodafone.asset.AssetManager; import org.mmbase.bridge.Cloud; import org.mmbase.bridge.Node; import org.mmbase.bridge.NodeList; import org.mmbase.remotepublishing.builders.PublishQueue; import org.mmbase.util.CloudFactory; /** * @TODO: javadoc * * @author Nico Klasens */ public class PublishingQueueBuilder extends org.mmbase.remotepublishing.builders.PublishingQueueBuilder { /** * @param publishQueueNode * @return */ protected boolean isAllowedToPublish(Node publishQueueNode) { int number = publishQueueNode.getIntValue("sourcenumber"); Node node = publishQueueNode.getCloud().getNode(number); if (ContentTypeHelper.isContentElement(node)) { int embargo = node.getIntValue("embargodate"); return embargo == -1 || embargo < (System.currentTimeMillis() / 1000); } else { return true; } } protected void process() { log.debug("Starting a PublishQueue run"); PublishQueue queue = new PublishQueue(this); queue.publishQueue(); queue.report(); log.debug("Finished a PublishQueue run"); } /** * This method gets called for each node in the publish queue when the * queue item is to be published. * @param publishQueueNode publishqueue node item. The source of the * publishqueue node is the node to be published. */ protected void publish(Node publishQueueNode) { super.publish(publishQueueNode); int nodeNumber = publishQueueNode.getIntValue("sourcenumber"); Cloud cloud = CloudFactory.getCloud(); Node node = cloud.getNode(nodeNumber); String nodeManagerName = node.getNodeManager().getName(); // If the node being published is asset-based, handle the asset publishing AssetManager assetMan = AssetManager.getInstance(); if (assetMan.isAssetNode(node)) { int cloudNumber = publishQueueNode.getIntValue("destinationcloud"); Node cloudNode = cloud.getNode(cloudNumber); NodeList sites = SiteUtil.getSitesForCloud(cloudNode); for (Iterator iter = sites.iterator(); iter.hasNext();) { Node site = (Node) iter.next(); assetMan.publishAsset(node, site); } } } } |
From: Nico K. <nkl...@us...> - 2007-11-05 20:50:15
|
Update of /cvsroot/mmapps/mmapps/remotepublishing/examples/nl/vodafone In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv11380/remotepublishing/examples/nl/vodafone Log Message: Directory /cvsroot/mmapps/mmapps/remotepublishing/examples/nl/vodafone added to the repository |
From: Nico K. <nkl...@us...> - 2007-11-05 20:50:15
|
Update of /cvsroot/mmapps/mmapps/remotepublishing/examples/nl In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv11380/remotepublishing/examples/nl Log Message: Directory /cvsroot/mmapps/mmapps/remotepublishing/examples/nl added to the repository |
From: Nico K. <nkl...@us...> - 2007-11-05 20:50:15
|
Update of /cvsroot/mmapps/mmapps/remotepublishing/examples/nl/vodafone/builders In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv11380/remotepublishing/examples/nl/vodafone/builders Log Message: Directory /cvsroot/mmapps/mmapps/remotepublishing/examples/nl/vodafone/builders added to the repository |
From: Nico K. <nkl...@us...> - 2007-11-05 20:50:12
|
Update of /cvsroot/mmapps/mmapps/remotepublishing/examples In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv11380/remotepublishing/examples Log Message: Directory /cvsroot/mmapps/mmapps/remotepublishing/examples added to the repository |
From: Nico K. <nkl...@us...> - 2007-09-27 16:07:45
|
Update of /cvsroot/mmapps/maven-plugins/maven-mmbase-module-plugin In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv6594/maven-mmbase-module-plugin Modified Files: plugin.jelly project.xml Log Message: Improved INDEX file generation and cleanup of files Index: plugin.jelly =================================================================== RCS file: /cvsroot/mmapps/maven-plugins/maven-mmbase-module-plugin/plugin.jelly,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** plugin.jelly 24 Oct 2005 12:07:32 -0000 1.3 --- plugin.jelly 27 Sep 2007 16:07:40 -0000 1.4 *************** *** 196,200 **** </j:choose> - <j:if test="${dep.getProperty('mmbase.templates.bundle')!='false'}"> <j:set var="templatesPath" value="${dep.getProperty('mmbase.templates.path')}"/> --- 196,199 ---- *************** *** 205,211 **** </ant:unjar> <util:available file="${build.temp.templates}/${maven.mmbasemodule.templates.dir}"> ! <ant:move todir="${build.temp.webapp.dir}/${templatesPath}" overwrite="${overwriteSources}" preservelastmodified="true"> <ant:fileset dir="${build.temp.templates}/${maven.mmbasemodule.templates.dir}"/> ! </ant:move> </util:available> </j:if> --- 204,212 ---- </ant:unjar> <util:available file="${build.temp.templates}/${maven.mmbasemodule.templates.dir}"> ! <ant:move todir="${build.temp.webapp.dir}/${templatesPath}" ! overwrite="${overwriteSources}" preservelastmodified="true" includeEmptyDirs="no"> <ant:fileset dir="${build.temp.templates}/${maven.mmbasemodule.templates.dir}"/> ! </ant:move> ! <ant:delete dir="${build.temp.templates}/${maven.mmbasemodule.templates.dir}" /> </util:available> </j:if> *************** *** 219,225 **** </ant:unjar> <util:available file="${build.temp.examples}/${maven.mmbasemodule.examples.dir}"> ! <ant:move todir="${build.temp.webapp.dir}/${examplesPath}" overwrite="${overwriteSources}" preservelastmodified="true"> <ant:fileset dir="${build.temp.examples}/${maven.mmbasemodule.examples.dir}"/> </ant:move> </util:available> </j:if> --- 220,228 ---- </ant:unjar> <util:available file="${build.temp.examples}/${maven.mmbasemodule.examples.dir}"> ! <ant:move todir="${build.temp.webapp.dir}/${examplesPath}" ! overwrite="${overwriteSources}" preservelastmodified="true" includeEmptyDirs="no"> <ant:fileset dir="${build.temp.examples}/${maven.mmbasemodule.examples.dir}"/> </ant:move> + <ant:delete dir="${build.temp.examples}/${maven.mmbasemodule.examples.dir}" /> </util:available> </j:if> *************** *** 233,239 **** <!-- merge some config files? --> <util:available file="${build.temp.config}/${maven.mmbasemodule.config.dir}"> ! <ant:move todir="${build.temp.webapp.dir}/WEB-INF/config" overwrite="${overwriteSources}" preservelastmodified="true"> <ant:fileset dir="${build.temp.config}/${maven.mmbasemodule.config.dir}"/> ! </ant:move> </util:available> </j:if> --- 236,244 ---- <!-- merge some config files? --> <util:available file="${build.temp.config}/${maven.mmbasemodule.config.dir}"> ! <ant:move todir="${build.temp.webapp.dir}/WEB-INF/config" ! overwrite="${overwriteSources}" preservelastmodified="true" includeEmptyDirs="no"> <ant:fileset dir="${build.temp.config}/${maven.mmbasemodule.config.dir}"/> ! </ant:move> ! <ant:delete dir="${build.temp.config}/${maven.mmbasemodule.config.dir}" /> </util:available> </j:if> *************** *** 244,248 **** </patternset> </ant:unjar> - </j:if> </j:forEach> --- 249,252 ---- *************** *** 253,257 **** <util:available file="${build.temp.webapp.dir}"> ! <ant:move todir="${maven.mmbasemodule.webapp.dir}" overwrite="false"> <ant:fileset dir="${build.temp.webapp.dir}"/> </ant:move> --- 257,261 ---- <util:available file="${build.temp.webapp.dir}"> ! <ant:move todir="${maven.mmbasemodule.webapp.dir}" overwrite="false" includeEmptyDirs="no"> <ant:fileset dir="${build.temp.webapp.dir}"/> </ant:move> *************** *** 269,272 **** --- 273,335 ---- </goal> + <goal name="mmbase-module:install-builders"> + <util:available file="${maven.war.webapp.dir}/WEB-INF/lib"> + <fileScanner var="libScanner"> + <fileset dir="${maven.war.webapp.dir}/WEB-INF/lib" /> + </fileScanner> + <j:forEach var="library" items="${libScanner.iterator()}"> + <ant:unjar src="${library}" dest="${maven.war.webapp.dir}/WEB-INF/classes"> + <patternset> + <include name="org/mmbase/config/applications/**/builders/**" /> + </patternset> + </ant:unjar> + </j:forEach> + </util:available> + + <util:available file="${maven.war.webapp.dir}/WEB-INF/classes/org/mmbase/config/applications"> + <fileScanner var="scanner"> + <fileset dir="${maven.war.webapp.dir}/WEB-INF/classes/org/mmbase/config/applications" /> + </fileScanner> + <j:forEach var="dir" items="${scanner.directories()}"> + <j:if test="${dir.path.endsWith('builders')}"> + <ant:copy todir="${maven.war.webapp.dir}/WEB-INF/classes/org/mmbase/config/builders/applications"> + <ant:fileset dir="${dir.path}" /> + </ant:copy> + </j:if> + </j:forEach> + </util:available> + + <util:available file="${maven.war.webapp.dir}/WEB-INF/classes/org/mmbase/config"> + <fileScanner var="scanner"> + <fileset dir="${maven.war.webapp.dir}/WEB-INF/classes/org/mmbase/config"/> + </fileScanner> + <j:forEach var="dir" items="${scanner.directories()}"> + <fileScanner var="filescan"> + <fileset dir="${dir.path}" > + <exclude name="INDEX"/> + <include name="*"/> + </fileset> + </fileScanner> + <!-- ## Generate INDEX file with each filename and directory on a new line ## --> + <echo file="${dir.path}/INDEX"><j:forEach var="file" items="${filescan.iterator()}">${file.name} + </j:forEach><j:forEach var="filedir" items="${filescan.directories()}">${filedir.name}/ + </j:forEach></echo> + </j:forEach> + </util:available> + + <util:available file="${maven.war.webapp.dir}/WEB-INF/config/applications"> + <fileScanner var="scanner"> + <fileset dir="${maven.war.webapp.dir}/WEB-INF/config/applications" /> + </fileScanner> + <j:forEach var="dir" items="${scanner.directories()}"> + <j:if test="${dir.path.endsWith('builders')}"> + <ant:copy todir="${maven.war.webapp.dir}/WEB-INF/config/builders/applications"> + <ant:fileset dir="${dir.path}" /> + </ant:copy> + </j:if> + </j:forEach> + </util:available> + </goal> + <!--==================================================================--> <!-- Install the mmbase-module in the local repository --> *************** *** 385,393 **** </goal> ! <goal name="maven-example-plugin:deregister"> ! <doc:deregisterReport name="Download Example"/> </goal> ! ! </project> ! --- 448,454 ---- </goal> ! <goal name="maven-mmbase-module-plugin:deregister"> ! <doc:deregisterReport name="mmbase-module installation"/> </goal> ! </project> \ No newline at end of file Index: project.xml =================================================================== RCS file: /cvsroot/mmapps/maven-plugins/maven-mmbase-module-plugin/project.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** project.xml 24 Oct 2005 12:07:33 -0000 1.3 --- project.xml 27 Sep 2007 16:07:40 -0000 1.4 *************** *** 6,10 **** <name>MMBase module plugin</name> <groupId>mmapps</groupId> ! <currentVersion>1.1.1</currentVersion> <shortDescription>maven plugin to assemble a mmbase module</shortDescription> <inceptionYear>2004</inceptionYear> --- 6,10 ---- <name>MMBase module plugin</name> <groupId>mmapps</groupId> ! <currentVersion>1.2</currentVersion> <shortDescription>maven plugin to assemble a mmbase module</shortDescription> <inceptionYear>2004</inceptionYear> |
From: Nico K. <nkl...@us...> - 2007-09-20 18:26:06
|
Update of /cvsroot/mmapps/mmapps/remotepublishing In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv31774/remotepublishing Modified Files: project.xml Log Message: 1.0.13 snapshot Index: project.xml =================================================================== RCS file: /cvsroot/mmapps/mmapps/remotepublishing/project.xml,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** project.xml 4 Jun 2007 07:39:03 -0000 1.7 --- project.xml 20 Sep 2007 18:26:02 -0000 1.8 *************** *** 5,9 **** <artifactId>remotepublishing</artifactId> <name>MMBase Remote Publishing</name> ! <currentVersion>1.0.12</currentVersion> <package>org.mmbase.remotepublishing</package> <shortDescription>The MMBase Remote Publishing module provides a way to clone nodes from one cloud to the other</shortDescription> --- 5,9 ---- <artifactId>remotepublishing</artifactId> <name>MMBase Remote Publishing</name> ! <currentVersion>1.0.13-SNAPSHOT</currentVersion> <package>org.mmbase.remotepublishing</package> <shortDescription>The MMBase Remote Publishing module provides a way to clone nodes from one cloud to the other</shortDescription> |
From: Nico K. <nkl...@us...> - 2007-09-20 18:25:31
|
Update of /cvsroot/mmapps/mmapps/mmcommons In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv31675/mmcommons Modified Files: project.xml Log Message: version 1.4 Index: project.xml =================================================================== RCS file: /cvsroot/mmapps/mmapps/mmcommons/project.xml,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** project.xml 13 Sep 2007 12:12:16 -0000 1.10 --- project.xml 20 Sep 2007 18:25:25 -0000 1.11 *************** *** 6,10 **** <artifactId>mmcommons</artifactId> <name>MMBase Commons</name> ! <currentVersion>1.3.8</currentVersion> <package>net.sf.mmapps.commons</package> <shortDescription>MMCommons - Java components for MMbase apps</shortDescription> --- 6,10 ---- <artifactId>mmcommons</artifactId> <name>MMBase Commons</name> ! <currentVersion>1.4</currentVersion> <package>net.sf.mmapps.commons</package> <shortDescription>MMCommons - Java components for MMbase apps</shortDescription> |
From: Nico K. <nkl...@us...> - 2007-09-20 18:24:52
|
Update of /cvsroot/mmapps/mmapps/remotepublishing/src/org/mmbase/remotepublishing In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv31275/remotepublishing/src/org/mmbase/remotepublishing Modified Files: PublishManager.java Log Message: Typo Index: PublishManager.java =================================================================== RCS file: /cvsroot/mmapps/mmapps/remotepublishing/src/org/mmbase/remotepublishing/PublishManager.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PublishManager.java 5 Jun 2007 12:21:28 -0000 1.7 --- PublishManager.java 20 Sep 2007 18:24:45 -0000 1.8 *************** *** 1003,1007 **** } NodeList publishInfoNodes = getPublishInfoNodes(localCloudInfo, localNode.getNumber()); ! List<Integer> updatedAfterTimestamo = new ArrayList<Integer>(); if (updateNode) { Date lastmodified = getLastModifiedDate(localNode); --- 1003,1007 ---- } NodeList publishInfoNodes = getPublishInfoNodes(localCloudInfo, localNode.getNumber()); ! List<Integer> updatedAfterTimestamp = new ArrayList<Integer>(); if (updateNode) { Date lastmodified = getLastModifiedDate(localNode); *************** *** 1010,1014 **** Date timestamp = publishInfoNode.getDateValue(TIMESTAMP); if (lastmodified.after(timestamp)) { ! updatedAfterTimestamo.add(localNode.getNumber()); } } --- 1010,1014 ---- Date timestamp = publishInfoNode.getDateValue(TIMESTAMP); if (lastmodified.after(timestamp)) { ! updatedAfterTimestamp.add(localNode.getNumber()); } } *************** *** 1023,1027 **** Node remoteNode = publishedNodesMap.get(remoteCloudNumber); ! if (updateNode && updatedAfterTimestamo.contains(localNode.getNumber())) { syncNode(localCloudInfo, localNode, remoteCloudInfo, remoteNode); } --- 1023,1027 ---- Node remoteNode = publishedNodesMap.get(remoteCloudNumber); ! if (updateNode && updatedAfterTimestamp.contains(localNode.getNumber())) { syncNode(localCloudInfo, localNode, remoteCloudInfo, remoteNode); } *************** *** 1192,1196 **** private static void removeRemoteRelationWhenLocalRemoved(CloudInfo localCloudInfo, ! CloudInfo remoteCloudInfo, List<Node> remoteRelationList) { int size = remoteRelationList.size(); for (int x = 0; x < size; x++) { --- 1192,1196 ---- private static void removeRemoteRelationWhenLocalRemoved(CloudInfo localCloudInfo, ! CloudInfo remoteCloudInfo, List<? extends Node> remoteRelationList) { int size = remoteRelationList.size(); for (int x = 0; x < size; x++) { |
From: Nico K. <nkl...@us...> - 2007-09-20 18:24:32
|
Update of /cvsroot/mmapps/mmapps/mmcommons/src/java/net/sf/mmapps/commons/beans In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv31234/mmcommons/src/java/net/sf/mmapps/commons/beans Modified Files: NodeBean.java MMBaseNodeMapper.java Log Message: java5 constructs Index: MMBaseNodeMapper.java =================================================================== RCS file: /cvsroot/mmapps/mmapps/mmcommons/src/java/net/sf/mmapps/commons/beans/MMBaseNodeMapper.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** MMBaseNodeMapper.java 17 Oct 2006 10:02:24 -0000 1.3 --- MMBaseNodeMapper.java 20 Sep 2007 18:24:27 -0000 1.4 *************** *** 19,22 **** --- 19,23 ---- /** * Maps fields from a MMBase node to a Java Object + * @param <T> Type of object to copy node to * * @param node MMBase Node to use *************** *** 24,28 **** * @return The initialized Java object */ ! public static Object copyNode(Node node, Object nodeClass) { if (node != null && nodeClass != null) { --- 25,29 ---- * @return The initialized Java object */ ! public static <T> T copyNode(Node node, T nodeClass) { if (node != null && nodeClass != null) { *************** *** 82,85 **** --- 83,88 ---- * Maps fields from a MMBase node to a Java Class * + * @param <T> Type of object to copy node to + * * @param node MMBase Node to use * @param clazz Java class to place values from source Node fields into *************** *** 87,92 **** * Node */ ! public static Object copyNode(Node node, Class clazz) { ! Object nodeClass = null; if (node != null && clazz != null) { --- 90,95 ---- * Node */ ! public static <T> T copyNode(Node node, Class<T> clazz) { ! T nodeClass = null; if (node != null && clazz != null) { *************** *** 105,112 **** } ! public static List convertList(NodeList l, Class clazz) { ! List result = new ArrayList(); for (int i = 0; i < l.size(); i++) { ! Object object = copyNode(l.getNode(i), clazz); result.add(object); } --- 108,115 ---- } ! public static <T> List<T> convertList(NodeList l, Class<T> clazz) { ! List<T> result = new ArrayList<T>(); for (int i = 0; i < l.size(); i++) { ! T object = copyNode(l.getNode(i), clazz); result.add(object); } Index: NodeBean.java =================================================================== RCS file: /cvsroot/mmapps/mmapps/mmcommons/src/java/net/sf/mmapps/commons/beans/NodeBean.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NodeBean.java 6 Apr 2006 10:00:33 -0000 1.1 --- NodeBean.java 20 Sep 2007 18:24:27 -0000 1.2 *************** *** 41,44 **** --- 41,45 ---- * @see java.lang.Object#hashCode() */ + @Override public final int hashCode() { return id; *************** *** 48,51 **** --- 49,53 ---- * @see java.lang.Object#equals(java.lang.Object) */ + @Override public final boolean equals(Object obj) { if (this == obj) return true; |
Update of /cvsroot/mmapps/mmapps/mmcommons/src/java/net/sf/mmapps/commons/util In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv31234/mmcommons/src/java/net/sf/mmapps/commons/util Modified Files: FileUtil.java UploadUtil.java HttpUtil.java XmlUtil.java ReflectionUtil.java KeywordUtil.java Log Message: java5 constructs Index: FileUtil.java =================================================================== RCS file: /cvsroot/mmapps/mmapps/mmcommons/src/java/net/sf/mmapps/commons/util/FileUtil.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** FileUtil.java 6 Apr 2006 10:00:33 -0000 1.1 --- FileUtil.java 20 Sep 2007 18:24:27 -0000 1.2 *************** *** 4,8 **** import java.util.ArrayList; import java.util.Comparator; - import java.util.Iterator; import java.util.List; import java.util.regex.Matcher; --- 4,7 ---- *************** *** 69,75 **** destinationFolder.mkdirs(); } ! for (int i = 0; i < filesInThisDirectory.length; i++) { ! String originFile = filesInThisDirectory[i].getPath(); ! String originFileName = filesInThisDirectory[i].getName(); String destinationFile = destination + File.separator + originFileName; File fileInput = new File(originFile); --- 68,74 ---- destinationFolder.mkdirs(); } ! for (File element : filesInThisDirectory) { ! String originFile = element.getPath(); ! String originFileName = element.getName(); String destinationFile = destination + File.separator + originFileName; File fileInput = new File(originFile); *************** *** 87,93 **** File[] dirsInThisDirectory = originFolder.listFiles(new DirectoryOnlyFilter()); ! for (int i = 0; i < dirsInThisDirectory.length; i++) { ! String originFile = dirsInThisDirectory[i].getPath(); ! String originFileName = dirsInThisDirectory[i].getName(); String destinationFile = destination + File.separator + originFileName; moveFolderContent(originFile, destinationFile, filter); --- 86,92 ---- File[] dirsInThisDirectory = originFolder.listFiles(new DirectoryOnlyFilter()); ! for (File element : dirsInThisDirectory) { ! String originFile = element.getPath(); ! String originFileName = element.getName(); String destinationFile = destination + File.separator + originFileName; moveFolderContent(originFile, destinationFile, filter); *************** *** 113,121 **** destinationFolder.mkdirs(); } ! for (int i = 0; i < filesInThisDirectory.length; i++) { ! String originFile = filesInThisDirectory[i].getPath(); ! String originFileName = filesInThisDirectory[i].getName(); String destinationFile = destination + File.separator + originFileName; ! if (filesInThisDirectory[i].isFile()) { writeFileInFile(originFile, destinationFile); } --- 112,120 ---- destinationFolder.mkdirs(); } ! for (File element : filesInThisDirectory) { ! String originFile = element.getPath(); ! String originFileName = element.getName(); String destinationFile = destination + File.separator + originFileName; ! if (element.isFile()) { writeFileInFile(originFile, destinationFile); } *************** *** 123,129 **** File[] dirsInThisDirectory = originFolder.listFiles(new DirectoryOnlyFilter()); ! for (int i = 0; i < dirsInThisDirectory.length; i++) { ! String originFile = dirsInThisDirectory[i].getPath(); ! String originFileName = dirsInThisDirectory[i].getName(); String destinationFile = destination + File.separator + originFileName; copyFolderContent(originFile, destinationFile, filter); --- 122,128 ---- File[] dirsInThisDirectory = originFolder.listFiles(new DirectoryOnlyFilter()); ! for (File element : dirsInThisDirectory) { ! String originFile = element.getPath(); ! String originFileName = element.getName(); String destinationFile = destination + File.separator + originFileName; copyFolderContent(originFile, destinationFile, filter); *************** *** 308,317 **** File[] files = f.listFiles(); ! for (int i = 0; i < files.length; i++) { ! if (files[i].isFile()) { ! files[i].delete(); } else { ! deleteFile(files[i], false); } } --- 307,316 ---- File[] files = f.listFiles(); ! for (File element : files) { ! if (element.isFile()) { ! element.delete(); } else { ! deleteFile(element, false); } } *************** *** 424,430 **** * @param ignores list of names to ignore */ ! public IgnoreFilter(List ignores) { ! for (Iterator iter = ignores.iterator(); iter.hasNext();) { ! String element = (String) iter.next(); Pattern pattern = Pattern.compile(element); this.ignores.add(pattern); --- 423,428 ---- * @param ignores list of names to ignore */ ! public IgnoreFilter(List<String> ignores) { ! for (String element : ignores) { Pattern pattern = Pattern.compile(element); this.ignores.add(pattern); *************** *** 449,465 **** } ! static class LastModifiedComparator implements Comparator { /** * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) */ ! public int compare(Object arg0, Object arg1) { ! if (arg0 != null && arg1 != null && ! arg0 instanceof File && arg1 instanceof File) { ! File f1 = (File) arg0; ! File f2 = (File) arg1; ! return (int)((f1.lastModified()/1000) - (f2.lastModified()/1000)); ! } ! return 0; } } --- 447,457 ---- } ! static class LastModifiedComparator implements Comparator<File> { /** * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) */ ! public int compare(File f1, File f2) { ! return (int)((f1.lastModified()/1000) - (f2.lastModified()/1000)); } } Index: XmlUtil.java =================================================================== RCS file: /cvsroot/mmapps/mmapps/mmcommons/src/java/net/sf/mmapps/commons/util/XmlUtil.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** XmlUtil.java 17 Jul 2006 08:39:46 -0000 1.5 --- XmlUtil.java 20 Sep 2007 18:24:27 -0000 1.6 *************** *** 448,452 **** } ! public static List getElements(Element element) { List<Element> elements = new ArrayList<Element>(); --- 448,452 ---- } ! public static List<Element> getElements(Element element) { List<Element> elements = new ArrayList<Element>(); Index: KeywordUtil.java =================================================================== RCS file: /cvsroot/mmapps/mmapps/mmcommons/src/java/net/sf/mmapps/commons/util/KeywordUtil.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** KeywordUtil.java 25 May 2007 12:58:46 -0000 1.2 --- KeywordUtil.java 20 Sep 2007 18:24:27 -0000 1.3 *************** *** 349,356 **** --- 349,358 ---- } + @Override public int hashCode() { return key.hashCode(); } + @Override public boolean equals(Object obj) { if (obj == null) return false; Index: UploadUtil.java =================================================================== RCS file: /cvsroot/mmapps/mmapps/mmcommons/src/java/net/sf/mmapps/commons/util/UploadUtil.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** UploadUtil.java 13 Sep 2007 12:11:19 -0000 1.2 --- UploadUtil.java 20 Sep 2007 18:24:27 -0000 1.3 *************** *** 13,17 **** import java.io.InputStream; import java.util.ArrayList; - import java.util.Iterator; import java.util.List; --- 13,16 ---- *************** *** 53,58 **** List<FileItem> fileItems = fu.parseRequest(request); ! for (Iterator<FileItem> i = fileItems.iterator(); i.hasNext();) { ! FileItem fi = i.next(); if (!fi.isFormField()) { String fullFileName = fi.getName(); --- 52,56 ---- List<FileItem> fileItems = fu.parseRequest(request); ! for (FileItem fi : fileItems) { if (!fi.isFormField()) { String fullFileName = fi.getName(); Index: HttpUtil.java =================================================================== RCS file: /cvsroot/mmapps/mmapps/mmcommons/src/java/net/sf/mmapps/commons/util/HttpUtil.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** HttpUtil.java 25 May 2007 12:58:46 -0000 1.6 --- HttpUtil.java 20 Sep 2007 18:24:27 -0000 1.7 *************** *** 451,457 **** // request headers msg += IDENT + "headers: " + ENDL; ! Enumeration en = request.getHeaderNames(); while (en.hasMoreElements()) { ! String name = (String) en.nextElement(); msg += IDENT + IDENT + name + ": " + request.getHeader(name) + ENDL; } --- 451,457 ---- // request headers msg += IDENT + "headers: " + ENDL; ! Enumeration<String> en = request.getHeaderNames(); while (en.hasMoreElements()) { ! String name = en.nextElement(); msg += IDENT + IDENT + name + ": " + request.getHeader(name) + ENDL; } *************** *** 461,465 **** en = request.getParameterNames(); while (en.hasMoreElements()) { ! String name = (String) en.nextElement(); msg += IDENT + IDENT + name+": " + request.getParameter(name) + ENDL; } --- 461,465 ---- en = request.getParameterNames(); while (en.hasMoreElements()) { ! String name = en.nextElement(); msg += IDENT + IDENT + name+": " + request.getParameter(name) + ENDL; } *************** *** 469,473 **** en = request.getAttributeNames(); while (en.hasMoreElements()) { ! String name = (String) en.nextElement(); if (!name.startsWith("javax.servlet")) { msg += IDENT + IDENT + name+": " + request.getAttribute(name) + ENDL; --- 469,473 ---- en = request.getAttributeNames(); while (en.hasMoreElements()) { ! String name = en.nextElement(); if (!name.startsWith("javax.servlet")) { msg += IDENT + IDENT + name+": " + request.getAttribute(name) + ENDL; *************** *** 483,488 **** if (cookies != null) { msg += IDENT + "COOKIES: " + ENDL; ! for (int i = 0; i < cookies.length; i++) { ! Cookie cookie = cookies[i]; msg += IDENT + IDENT + "name: " + cookie.getName(); msg += IDENT + "domain: " + cookie.getDomain(); --- 483,487 ---- if (cookies != null) { msg += IDENT + "COOKIES: " + ENDL; ! for (Cookie cookie : cookies) { msg += IDENT + IDENT + "name: " + cookie.getName(); msg += IDENT + "domain: " + cookie.getDomain(); *************** *** 512,518 **** // session attributes msg += IDENT + "attributes: " + ENDL; ! Enumeration en = session.getAttributeNames(); while (en.hasMoreElements()) { ! String name = (String) en.nextElement(); msg += IDENT + IDENT + name+": " + session.getAttribute(name) + ENDL; } --- 511,517 ---- // session attributes msg += IDENT + "attributes: " + ENDL; ! Enumeration<String> en = session.getAttributeNames(); while (en.hasMoreElements()) { ! String name = en.nextElement(); msg += IDENT + IDENT + name+": " + session.getAttribute(name) + ENDL; } Index: ReflectionUtil.java =================================================================== RCS file: /cvsroot/mmapps/mmapps/mmcommons/src/java/net/sf/mmapps/commons/util/ReflectionUtil.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ReflectionUtil.java 6 Apr 2006 10:00:33 -0000 1.1 --- ReflectionUtil.java 20 Sep 2007 18:24:27 -0000 1.2 *************** *** 24,28 **** public static Object createInstance(String className, Object[] arguments) throws Exception { if (arguments != null && arguments.length > 0) { ! Class[] classes = getClasses(arguments); return createInstance(className, classes, arguments); } --- 24,28 ---- public static Object createInstance(String className, Object[] arguments) throws Exception { if (arguments != null && arguments.length > 0) { ! Class<?>[] classes = getClasses(arguments); return createInstance(className, classes, arguments); } *************** *** 32,40 **** } ! public static Object createInstance(String className, Class[] classes, Object[] arguments) throws Exception { ! Class type = Class.forName(className); if (type != null) { if (classes != null && classes.length > 0) { ! Constructor constr = null; try { constr = type.getConstructor(classes); --- 32,40 ---- } ! public static Object createInstance(String className, Class<?>[] classes, Object[] arguments) throws Exception { ! Class<?> type = Class.forName(className); if (type != null) { if (classes != null && classes.length > 0) { ! Constructor<?> constr = null; try { constr = type.getConstructor(classes); *************** *** 66,75 **** public static boolean hasConstructor(String className, Object[] arguments) throws ClassNotFoundException { ! Class[] classes = getClasses(arguments); return hasConstructor(className, classes); } ! public static boolean hasConstructor(String className, Class[] classes) throws ClassNotFoundException { ! Class type = Class.forName(className); if (type != null) { try { --- 66,75 ---- public static boolean hasConstructor(String className, Object[] arguments) throws ClassNotFoundException { ! Class<?>[] classes = getClasses(arguments); return hasConstructor(className, classes); } ! public static boolean hasConstructor(String className, Class<?>[] classes) throws ClassNotFoundException { ! Class<?> type = Class.forName(className); if (type != null) { try { *************** *** 86,91 **** } ! public static Class[] getClasses(Object[] arguments) { ! Class[] classes = null; if (arguments != null && arguments.length > 0) { classes = new Class[arguments.length]; --- 86,91 ---- } ! public static Class<?>[] getClasses(Object[] arguments) { ! Class<?>[] classes = null; if (arguments != null && arguments.length > 0) { classes = new Class[arguments.length]; |
From: Nico K. <nkl...@us...> - 2007-09-20 18:24:30
|
Update of /cvsroot/mmapps/mmapps/mmcommons/src/java/net/sf/mmapps/commons/bridge In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv31234/mmcommons/src/java/net/sf/mmapps/commons/bridge Modified Files: CloudThreadLocal.java CloudUtil.java Log Message: java5 constructs Index: CloudThreadLocal.java =================================================================== RCS file: /cvsroot/mmapps/mmapps/mmcommons/src/java/net/sf/mmapps/commons/bridge/CloudThreadLocal.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CloudThreadLocal.java 6 Apr 2006 10:00:34 -0000 1.1 --- CloudThreadLocal.java 20 Sep 2007 18:24:27 -0000 1.2 *************** *** 23,30 **** * A ThreadLocal maintaining current cloud for the given execution thread. */ ! private static final ThreadLocal context = new ThreadLocal(); public static Cloud currentCloud() { ! return (Cloud) context.get(); } --- 23,30 ---- * A ThreadLocal maintaining current cloud for the given execution thread. */ ! private static final ThreadLocal<Cloud> context = new ThreadLocal<Cloud>(); public static Cloud currentCloud() { ! return context.get(); } *************** *** 62,66 **** private static Cloud doUnbind() { ! Cloud cloud = (Cloud) context.get(); if ( cloud != null ) { context.set( null ); --- 62,66 ---- private static Cloud doUnbind() { ! Cloud cloud = context.get(); if ( cloud != null ) { context.set( null ); Index: CloudUtil.java =================================================================== RCS file: /cvsroot/mmapps/mmapps/mmcommons/src/java/net/sf/mmapps/commons/bridge/CloudUtil.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CloudUtil.java 17 Oct 2006 10:02:24 -0000 1.4 --- CloudUtil.java 20 Sep 2007 18:24:27 -0000 1.5 *************** *** 48,52 **** if (!StringUtil.isEmptyOrWhitespace(username) && !StringUtil.isEmptyOrWhitespace(password)) { String authenticate = req.getParameter("authenticate"); ! final Map loginInfo = getUserCredentials(username, password); cloud = createCloud(req, sessionname, authenticate, loginInfo); --- 48,52 ---- if (!StringUtil.isEmptyOrWhitespace(username) && !StringUtil.isEmptyOrWhitespace(password)) { String authenticate = req.getParameter("authenticate"); ! final Map<String,String> loginInfo = getUserCredentials(username, password); cloud = createCloud(req, sessionname, authenticate, loginInfo); *************** *** 56,64 **** } ! public static Cloud createCloud(HttpServletRequest req, String authenticate, final Map loginInfo) { return createCloud(req, DEFAULT_SESSIONNAME, authenticate, loginInfo); } ! public static Cloud createCloud(HttpServletRequest req, String sessionname, String authenticate, final Map loginInfo) { String cloudName = req.getParameter("cloud"); if (StringUtil.isEmptyOrWhitespace(cloudName)) { --- 56,64 ---- } ! public static Cloud createCloud(HttpServletRequest req, String authenticate, final Map<String,String> loginInfo) { return createCloud(req, DEFAULT_SESSIONNAME, authenticate, loginInfo); } ! public static Cloud createCloud(HttpServletRequest req, String sessionname, String authenticate, final Map<String,String> loginInfo) { String cloudName = req.getParameter("cloud"); if (StringUtil.isEmptyOrWhitespace(cloudName)) { *************** *** 82,86 **** } ! public static Map getUserCredentials(String username, String password) { Map<String,String> result = new HashMap<String,String>(3, 0.7f); result.put("username", username); --- 82,86 ---- } ! public static Map<String,String> getUserCredentials(String username, String password) { Map<String,String> result = new HashMap<String,String>(3, 0.7f); result.put("username", username); |
From: Nico K. <nkl...@us...> - 2007-09-20 18:24:30
|
Update of /cvsroot/mmapps/mmapps/mmcommons/src/java/net/sf/mmapps/commons/web In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv31234/mmcommons/src/java/net/sf/mmapps/commons/web Modified Files: CloudThreadFilter.java Log Message: java5 constructs Index: CloudThreadFilter.java =================================================================== RCS file: /cvsroot/mmapps/mmapps/mmcommons/src/java/net/sf/mmapps/commons/web/CloudThreadFilter.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CloudThreadFilter.java 6 Apr 2006 13:37:04 -0000 1.1 --- CloudThreadFilter.java 20 Sep 2007 18:24:27 -0000 1.2 *************** *** 20,23 **** --- 20,24 ---- * @see javax.servlet.Filter#init(javax.servlet.FilterConfig) */ + @SuppressWarnings("unused") public void init(FilterConfig config) { // nix |
From: Nico K. <nkl...@us...> - 2007-09-20 18:24:23
|
Update of /cvsroot/mmapps/mmapps/mmcommons/src/java/net/sf/mmapps/commons/bridge In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv31196/mmcommons/src/java/net/sf/mmapps/commons/bridge Modified Files: RelationUtil.java Log Message: More efficient reorder Index: RelationUtil.java =================================================================== RCS file: /cvsroot/mmapps/mmapps/mmcommons/src/java/net/sf/mmapps/commons/bridge/RelationUtil.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** RelationUtil.java 6 Jun 2007 10:50:18 -0000 1.5 --- RelationUtil.java 20 Sep 2007 18:24:09 -0000 1.6 *************** *** 13,47 **** public final static String RELATION_POS_FIELD = "pos"; ! public static void reorder(Cloud cloud, String parent, String childs, String role) { ! reorder(cloud, parent, childs, role, null); } ! public static void reorder(Cloud cloud, String parent, String children, String role, String nodeManagerName) { Node parentNode = cloud.getNode(parent); ! reorder(parentNode, children, role, nodeManagerName); } ! public static void reorder(Cloud cloud, String parent, String[] children, String role) { ! reorder(cloud, parent, children, role, null); } ! public static void reorder(Cloud cloud, String parent, String[] children, String role, String nodeManagerName) { Node parentNode = cloud.getNode(parent); ! reorder(parentNode, children, role, nodeManagerName); } ! public static void reorder(Node parentNode, List children, String role) { ! reorder(parentNode, children, role, null); } ! public static void reorder(Node parentNode, Object children, String role, String nodeManagerName) { ! reorder(parentNode, children, role, nodeManagerName, 0); } ! public static void reorder(Node parentNode, Object children, String role, String nodeManagerName, int offset) { ! reorder(parentNode, children, role, nodeManagerName, RELATION_POS_FIELD, offset); } ! private static void reorder(Node parentNode, Object children, String role, String nodeManagerName, String field, int offset) { List<String> childrenList = null; if (children instanceof List) { --- 13,78 ---- public final static String RELATION_POS_FIELD = "pos"; ! public static List<Integer> reorder(Cloud cloud, String parent, String childs, String role) { ! return reorder(cloud, parent, childs, role, null); } ! public static List<Integer> reorder(Cloud cloud, String parent, String children, String role, String nodeManagerName) { Node parentNode = cloud.getNode(parent); ! return reorder(parentNode, children, role, nodeManagerName); } ! public static List<Integer> reorder(Cloud cloud, String parent, String[] children, String role) { ! return reorder(cloud, parent, children, role, null); } ! public static List<Integer> reorder(Cloud cloud, String parent, String[] children, String role, String nodeManagerName) { Node parentNode = cloud.getNode(parent); ! return reorder(parentNode, children, role, nodeManagerName); } ! public static List<Integer> reorder(Node parentNode, List<String> children, String role) { ! return reorder(parentNode, children, role, null); } ! public static List<Integer> reorder(Node parentNode, Object children, String role, String nodeManagerName) { ! return reorder(parentNode, children, role, nodeManagerName, 0); } ! public static List<Integer> reorder(Node parentNode, Object children, String role, String nodeManagerName, int offset) { ! return reorder(parentNode, children, role, nodeManagerName, RELATION_POS_FIELD, offset); } ! private static List<Integer> reorder(Node parentNode, Object children, String role, String nodeManagerName, String field, int offset) { ! ! List<String> childrenList = convertChildrenToList(children); ! ! List<Integer> changedPositions = new ArrayList<Integer>(); ! RelationList list = null; ! Cloud cloud = parentNode.getCloud(); ! if (!StringUtil.isEmpty(nodeManagerName)) { ! list = parentNode.getRelations(role, cloud.getNodeManager(nodeManagerName), "DESTINATION"); ! } ! else { ! list = parentNode.getRelations(role); ! } ! RelationIterator iter = list.relationIterator(); ! while (iter.hasNext()) { ! Relation rel = iter.nextRelation(); ! int destination = rel.getDestination().getNumber(); ! int posOfRelation = rel.getIntValue(field); ! String destNumber = String.valueOf(destination); ! if (childrenList.contains(destNumber)) { ! int pos = offset + childrenList.indexOf(destNumber) + 1; ! if (pos != posOfRelation) { ! rel.setIntValue(field, pos); ! rel.commit(); ! changedPositions.add(destination); ! } ! } ! } ! return changedPositions; ! } ! ! private static List<String> convertChildrenToList(Object children) { List<String> childrenList = null; if (children instanceof List) { *************** *** 64,87 **** throw new IllegalArgumentException("Children not of the supported types (String, String[], List)"); } ! ! RelationList list = null; ! Cloud cloud = parentNode.getCloud(); ! if (!StringUtil.isEmpty(nodeManagerName)) { ! list = parentNode.getRelations(role, cloud.getNodeManager(nodeManagerName), "DESTINATION"); ! } ! else { ! list = parentNode.getRelations(role); ! } ! RelationIterator iter = list.relationIterator(); ! while (iter.hasNext()) { ! Relation rel = iter.nextRelation(); ! int destination = rel.getDestination().getNumber(); ! String destNumber = String.valueOf(destination); ! if (childrenList.contains(destNumber)) { ! int pos = offset + childrenList.indexOf(destNumber); ! rel.setIntValue(field, pos); ! rel.commit(); ! } ! } } --- 95,99 ---- throw new IllegalArgumentException("Children not of the supported types (String, String[], List)"); } ! return childrenList; } *************** *** 96,101 **** RelationList list = SearchUtil.findRelations(parentNode, nodeManagerName, role, sortName, null); int pos = 1; ! for (Iterator iter = list.iterator(); iter.hasNext(); pos++) { ! Relation relation = (Relation) iter.next(); int currentPos = relation.getIntValue(field); if (pos != currentPos) { --- 108,113 ---- RelationList list = SearchUtil.findRelations(parentNode, nodeManagerName, role, sortName, null); int pos = 1; ! for (Iterator<Relation> iter = list.iterator(); iter.hasNext(); pos++) { ! Relation relation = iter.next(); int currentPos = relation.getIntValue(field); if (pos != currentPos) { |
From: Nico K. <nkl...@us...> - 2007-09-13 12:12:19
|
Update of /cvsroot/mmapps/mmapps/mmcommons In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv3740/mmcommons Modified Files: project.xml Log Message: version 1.3.8 Index: project.xml =================================================================== RCS file: /cvsroot/mmapps/mmapps/mmcommons/project.xml,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** project.xml 25 May 2007 12:59:58 -0000 1.9 --- project.xml 13 Sep 2007 12:12:16 -0000 1.10 *************** *** 6,10 **** <artifactId>mmcommons</artifactId> <name>MMBase Commons</name> ! <currentVersion>1.3.7</currentVersion> <package>net.sf.mmapps.commons</package> <shortDescription>MMCommons - Java components for MMbase apps</shortDescription> --- 6,10 ---- <artifactId>mmcommons</artifactId> <name>MMBase Commons</name> ! <currentVersion>1.3.8</currentVersion> <package>net.sf.mmapps.commons</package> <shortDescription>MMCommons - Java components for MMbase apps</shortDescription> *************** *** 21,25 **** <groupId>mmbase</groupId> <artifactId>mmbase</artifactId> ! <version>1.8.1-SNAPSHOT</version> <url>http://www.mmbase.org/</url> </dependency> --- 21,25 ---- <groupId>mmbase</groupId> <artifactId>mmbase</artifactId> ! <version>1.8.4-20070502</version> <url>http://www.mmbase.org/</url> </dependency> |
From: Nico K. <nkl...@us...> - 2007-09-13 12:11:53
|
Update of /cvsroot/mmapps/mmapps/mmcommons/src/java/net/sf/mmapps/commons/bridge In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv3352/mmcommons/src/java/net/sf/mmapps/commons/bridge Removed Files: GenericNodeIterator.java GenericNodeList.java Log Message: Removed files because cloud.createNodeList can be used for this --- GenericNodeIterator.java DELETED --- --- GenericNodeList.java DELETED --- |
From: Nico K. <nkl...@us...> - 2007-09-13 12:11:24
|
Update of /cvsroot/mmapps/mmapps/mmcommons/src/java/net/sf/mmapps/commons/util In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv3318/mmcommons/src/java/net/sf/mmapps/commons/util Modified Files: UploadUtil.java Log Message: java 5 generic Index: UploadUtil.java =================================================================== RCS file: /cvsroot/mmapps/mmapps/mmcommons/src/java/net/sf/mmapps/commons/util/UploadUtil.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** UploadUtil.java 6 Apr 2006 10:00:33 -0000 1.1 --- UploadUtil.java 13 Sep 2007 12:11:19 -0000 1.2 *************** *** 35,39 **** * @return List of UploadUtil.BinaryData objects */ ! public static List uploadFiles(HttpServletRequest request, int maxsize) { // Initialization DiskFileUpload fu = new DiskFileUpload(); --- 35,39 ---- * @return List of UploadUtil.BinaryData objects */ ! public static List<BinaryData> uploadFiles(HttpServletRequest request, int maxsize) { // Initialization DiskFileUpload fu = new DiskFileUpload(); *************** *** 51,58 **** try { List<BinaryData> binaries = new ArrayList<BinaryData>(); ! List fileItems = fu.parseRequest(request); ! for (Iterator i = fileItems.iterator(); i.hasNext();) { ! FileItem fi = (FileItem) i.next(); if (!fi.isFormField()) { String fullFileName = fi.getName(); --- 51,58 ---- try { List<BinaryData> binaries = new ArrayList<BinaryData>(); ! List<FileItem> fileItems = fu.parseRequest(request); ! for (Iterator<FileItem> i = fileItems.iterator(); i.hasNext();) { ! FileItem fi = i.next(); if (!fi.isFormField()) { String fullFileName = fi.getName(); |
From: Nico K. <nkl...@us...> - 2007-06-06 10:50:31
|
Update of /cvsroot/mmapps/mmapps/mmcommons/src/java/net/sf/mmapps/commons/bridge In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv8041/mmcommons/src/java/net/sf/mmapps/commons/bridge Modified Files: RelationUtil.java Log Message: Shoudl be 0 Index: RelationUtil.java =================================================================== RCS file: /cvsroot/mmapps/mmapps/mmcommons/src/java/net/sf/mmapps/commons/bridge/RelationUtil.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** RelationUtil.java 16 Dec 2006 13:13:47 -0000 1.4 --- RelationUtil.java 6 Jun 2007 10:50:18 -0000 1.5 *************** *** 161,165 **** NodeList list = getRelations(manager, source, destination); if (!list.isEmpty()) { ! Node node = list.getNode(9); if (node.isRelation()) { return node.toRelation(); --- 161,165 ---- NodeList list = getRelations(manager, source, destination); if (!list.isEmpty()) { ! Node node = list.getNode(0); if (node.isRelation()) { return node.toRelation(); |
From: Nico K. <nkl...@us...> - 2007-06-05 12:21:33
|
Update of /cvsroot/mmapps/mmapps/remotepublishing/src/org/mmbase/remotepublishing In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv23887/remotepublishing/src/org/mmbase/remotepublishing Modified Files: PublishManager.java Log Message: Sync only relations when latmodified is older than timestamp Index: PublishManager.java =================================================================== RCS file: /cvsroot/mmapps/mmapps/remotepublishing/src/org/mmbase/remotepublishing/PublishManager.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PublishManager.java 4 Jun 2007 07:39:02 -0000 1.6 --- PublishManager.java 5 Jun 2007 12:21:28 -0000 1.7 *************** *** 115,118 **** --- 115,133 ---- * @param localNode the node to be published * @param remoteCloudInfo the external cloud + * @return the published copy of inNode + * @throws PublishException - when publication fails + */ + public static Node createNodeAndRelations(CloudInfo localCloudInfo, Node localNode, + CloudInfo remoteCloudInfo) throws PublishException { + return createNodeAndRelations(localCloudInfo, localNode, remoteCloudInfo, true); + } + + /** + * Publish a node to a different cloud, keeping records This will also publish + * all relations inNode has with other published nodes + * + * @param localCloudInfo the cloud which the local node come from + * @param localNode the node to be published + * @param remoteCloudInfo the external cloud * @param createRelations create the relations to other nodes * @return the published copy of inNode *************** *** 943,947 **** } } ! /** --- 958,973 ---- } } ! ! /** ! * syncronize all nodes that are published from this one ! * ! * @param localCloudInfo the cloud from which the local node are published ! * @param localNode the source node ! * @throws PublishException - when publication fails ! **/ ! public static void updateNodesAndRelations(CloudInfo localCloudInfo, Node localNode) throws PublishException { ! updateNodesAndRelations(localCloudInfo, localNode, true, true, null); ! } ! /** *************** *** 977,989 **** } NodeList publishInfoNodes = getPublishInfoNodes(localCloudInfo, localNode.getNumber()); ! ! Date lastmodified = getLastModifiedDate(localNode); ! for (Iterator<Node> iterator = publishInfoNodes.iterator(); iterator.hasNext();) { ! Node publishInfoNode = iterator.next(); ! Date timestamp = publishInfoNode.getDateValue(TIMESTAMP); ! if (lastmodified.before(timestamp)) { ! iterator.remove(); ! } ! } Map<Integer,Node> publishedNodesMap = getPublishedNodes(publishInfoNodes); --- 1003,1017 ---- } NodeList publishInfoNodes = getPublishInfoNodes(localCloudInfo, localNode.getNumber()); ! List<Integer> updatedAfterTimestamo = new ArrayList<Integer>(); ! if (updateNode) { ! Date lastmodified = getLastModifiedDate(localNode); ! for (Iterator<Node> iterator = publishInfoNodes.iterator(); iterator.hasNext();) { ! Node publishInfoNode = iterator.next(); ! Date timestamp = publishInfoNode.getDateValue(TIMESTAMP); ! if (lastmodified.after(timestamp)) { ! updatedAfterTimestamo.add(localNode.getNumber()); ! } ! } ! } Map<Integer,Node> publishedNodesMap = getPublishedNodes(publishInfoNodes); *************** *** 994,1011 **** CloudInfo remoteCloudInfo = CloudInfo.getCloudInfo(remoteCloudNumber); Node remoteNode = publishedNodesMap.get(remoteCloudNumber); ! if (updateNode && updateRelations) { ! syncNodeAndRelations(localCloudInfo, localNode, remoteCloudInfo, remoteNode); } ! else { ! if (updateNode) { ! syncNode(localCloudInfo, localNode, remoteCloudInfo, remoteNode); } ! if (updateRelations) { ! if (relatedNodes != null && relatedNodes.size() > 0) { ! syncRelations(localCloudInfo, localNode, remoteCloudInfo, remoteNode, relatedNodes); ! } ! else { ! syncRelations(localCloudInfo, localNode, remoteCloudInfo, remoteNode); ! } } } --- 1022,1035 ---- CloudInfo remoteCloudInfo = CloudInfo.getCloudInfo(remoteCloudNumber); Node remoteNode = publishedNodesMap.get(remoteCloudNumber); ! ! if (updateNode && updatedAfterTimestamo.contains(localNode.getNumber())) { ! syncNode(localCloudInfo, localNode, remoteCloudInfo, remoteNode); } ! if (updateRelations) { ! if (relatedNodes != null && relatedNodes.size() > 0) { ! syncRelations(localCloudInfo, localNode, remoteCloudInfo, remoteNode, relatedNodes); } ! else { ! syncRelations(localCloudInfo, localNode, remoteCloudInfo, remoteNode); } } |
From: Nico K. <nkl...@us...> - 2007-06-04 07:39:53
|
Update of /cvsroot/mmapps/mmapps/remotepublishing In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv11260/remotepublishing Added Files: migration.txt Log Message: Added support for updates of relations between nodes --- NEW FILE: migration.txt --- Version 1.0.12 ========================================= ALTER TABLE mm_publishqueue MODIFY COLUMN action varchar(32) NOT NULL default ''; ALTER TABLE live_publishqueue MODIFY COLUMN action varchar(32) NOT NULL default ''; ALTER TABLE mm_publishqueue ADD COLUMN relatednodes text NOT NULL default ''; ALTER TABLE live_publishqueue ADD COLUMN relatednodes text NOT NULL default ''; |
From: Nico K. <nkl...@us...> - 2007-06-04 07:39:16
|
Update of /cvsroot/mmapps/mmapps/remotepublishing/src/org/mmbase/remotepublishing/builders In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv10757/remotepublishing/src/org/mmbase/remotepublishing/builders Modified Files: PublishingQueueBuilder.java Log Message: Added support for updates of relations between nodes Index: PublishingQueueBuilder.java =================================================================== RCS file: /cvsroot/mmapps/mmapps/remotepublishing/src/org/mmbase/remotepublishing/builders/PublishingQueueBuilder.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PublishingQueueBuilder.java 18 Apr 2007 07:50:11 -0000 1.4 --- PublishingQueueBuilder.java 4 Jun 2007 07:39:03 -0000 1.5 *************** *** 35,42 **** /** * Main class that publishes or removes nodes to or from remote clouds. - * @author keesj - * @version PublishingQueueBuilder.java,v 1.2 2003/07/28 09:43:51 nico Exp */ public class PublishingQueueBuilder extends MMObjectBuilder implements Runnable{ private static Logger log = Logging.getLoggerInstance(PublishingQueueBuilder.class.getName()); --- 35,58 ---- /** * Main class that publishes or removes nodes to or from remote clouds. */ public class PublishingQueueBuilder extends MMObjectBuilder implements Runnable{ + public static final String FIELD_TIMESTAMP = "timestamp"; + public static final String FIELD_PUBLISHDATE = "publishdate"; + public static final String FIELD_STATUS = "status"; + public static final String FIELD_ACTION = "action"; + public static final String FIELD_DESTINATIONCLOUD = "destinationcloud"; + public static final String FIELD_SOURCENUMBER = "sourcenumber"; + public static final String FIELD_RELATEDNODES = "relatednodes"; + + public static final String ACTION_UPDATE = "update"; + public static final String ACTION_UPDATE_NODE = "update-node"; + public static final String ACTION_UPDATE_RELATIONS = "update-relations"; + + public static final String ACTION_REMOVE = "remove"; + + public static final String STATUS_DONE = "done"; + public static final String STATUS_FAIL = "fail"; + + private static Logger log = Logging.getLoggerInstance(PublishingQueueBuilder.class.getName()); *************** *** 101,105 **** } ! node.setValue("destinationcloud", remoteCloudNumber); } --- 117,121 ---- } ! node.setValue(FIELD_DESTINATIONCLOUD, remoteCloudNumber); } *************** *** 169,252 **** CloudInfo localCloudInfo = CloudInfo.getDefaultCloudInfo(); NodeManager nodeManager = localCloudInfo.getCloud().getNodeManager("publishqueue"); ! NodeQuery query = nodeManager.createQuery(); ! ! StepField statusField = query.getStepField(nodeManager.getField("status")); ! FieldValueConstraint failStatus = query.createConstraint(statusField, ! FieldCompareConstraint.NOT_EQUAL, "fail"); ! query.setCaseSensitive(failStatus, true); ! FieldValueConstraint doneStatus = query.createConstraint(statusField, ! FieldCompareConstraint.NOT_EQUAL, "done"); ! query.setCaseSensitive(doneStatus, true); ! Constraint statusComposite = query.createConstraint( ! failStatus, CompositeConstraint.LOGICAL_AND, doneStatus); ! ! if (!nodeManager.hasField("publishdate")) { ! query.setConstraint(statusComposite); ! } ! else { ! StepField publishDateField = query.getStepField(nodeManager.getField("publishdate")); ! Constraint publishNull = query.createConstraint(publishDateField); ! Constraint publishNow = query.createConstraint( ! publishDateField, FieldCompareConstraint.LESS_EQUAL, new Date()); ! ! Constraint publishDateComposite = query.createConstraint( ! publishNow, CompositeConstraint.LOGICAL_OR, publishNull); ! Constraint composite = query.createConstraint( ! statusComposite, CompositeConstraint.LOGICAL_AND, publishDateComposite); ! query.setConstraint(composite); ! } ! query.setMaxNumber(10); ! ! query.setCachePolicy(CachePolicy.NEVER); NodeList list = null; while(list == null || !list.isEmpty()) { - //FIXME: add this timestamp as debug information for performance inspector - long timestamp = System.currentTimeMillis(); list = nodeManager.getList(query); for (int x = 0; x < list.size(); x++) { ! Node node = list.getNode(x); ! if(node != null) { try { // check if node is not removed from the cloud in between query and retrieval ! if (localCloudInfo.getCloud().hasNode(node.getNumber())) { ! if (node.getStringValue("action").equalsIgnoreCase("update")) { try { ! if (isAllowedToPublish(node)) { ! boolean finished = false; ! int trytimes = 0; ! while(!finished) { ! try { ! publish(localCloudInfo, node); ! finished=true; ! } catch (BridgeException e) { ! if ( handleRmiException(e) && ++trytimes<=maxtrying) { ! //if it was caused rmi connection exception and still within ! // the maximal tring times limitation, ! // continue to try publishing it again ! } else { ! //otherwise, throw the runtime exception ! throw e; ! } } ! }; ! node.setStringValue("status", "done"); ! node.commit(); } ! } catch (BridgeException e) { ! log.error("Nodenumber : " + node.getNumber() + ", " + e, e); ! publishFailed(localCloudInfo, node, e); } ! } ! else { ! if (node.getStringValue("action").equalsIgnoreCase("remove")) { try { ! removeNode(localCloudInfo, node); } catch (BridgeException e) { ! log.error("Removing published node (" + node.getNumber() + ") failed", e); ! publishFailed(localCloudInfo, node, e); } } --- 185,236 ---- CloudInfo localCloudInfo = CloudInfo.getDefaultCloudInfo(); NodeManager nodeManager = localCloudInfo.getCloud().getNodeManager("publishqueue"); ! NodeQuery query = createQuery(nodeManager); NodeList list = null; while(list == null || !list.isEmpty()) { list = nodeManager.getList(query); for (int x = 0; x < list.size(); x++) { ! Node queueNode = list.getNode(x); ! if(queueNode != null) { try { // check if node is not removed from the cloud in between query and retrieval ! if (localCloudInfo.getCloud().hasNode(queueNode.getNumber())) { ! String action = queueNode.getStringValue(FIELD_ACTION); ! if (isUpdateAction(action)) { try { ! boolean finished = false; ! int trytimes = 0; ! while(!finished) { ! try { ! update(localCloudInfo, queueNode, action); ! finished=true; ! } catch (BridgeException e) { ! if ( handleRmiException(e) && ++trytimes<=maxtrying) { ! //if it was caused rmi connection exception and still within ! // the maximal tring times limitation, ! // continue to try publishing it again ! } else { ! //otherwise, throw the runtime exception ! throw e; } ! } } ! queueNode.setStringValue(FIELD_STATUS, STATUS_DONE); ! queueNode.commit(); ! } catch (BridgeException e) { ! log.error("Nodenumber : " + queueNode.getNumber() + ", " + e, e); ! publishFailed(localCloudInfo, queueNode, e); } ! } ! else { ! if (isRemoveAction(action)) { try { ! removeNode(localCloudInfo, queueNode); } catch (BridgeException e) { ! log.error("Removing published node (" + queueNode.getNumber() + ") failed", e); ! publishFailed(localCloudInfo, queueNode, e); } } *************** *** 255,265 **** } catch (Throwable e) { ! log.error("Throwable error with nodenumber: " + node.getNumber() + ", " + e.getMessage()); log.debug(Logging.stackTrace(e)); } ! } } //end for ! //FIXME: add this log message as debug information for performance inspector ! log.debug("Published total "+list.size()+" nodes in "+(System.currentTimeMillis()-timestamp)+" ms!"); } } --- 239,248 ---- } catch (Throwable e) { ! log.error("Throwable error with nodenumber: " + queueNode.getNumber() + ", " + e.getMessage()); log.debug(Logging.stackTrace(e)); } ! } } //end for ! log.debug("Published total "+list.size()+" nodes"); } } *************** *** 267,270 **** --- 250,298 ---- } + private boolean isRemoveAction(String action) { + return action.equalsIgnoreCase(ACTION_REMOVE); + } + + private boolean isUpdateAction(String action) { + return action.equalsIgnoreCase(ACTION_UPDATE) || action.equalsIgnoreCase(ACTION_UPDATE_NODE) + || action.equalsIgnoreCase(ACTION_UPDATE_RELATIONS); + } + + private NodeQuery createQuery(NodeManager nodeManager) { + NodeQuery query = nodeManager.createQuery(); + + StepField statusField = query.getStepField(nodeManager.getField(FIELD_STATUS)); + FieldValueConstraint failStatus = query.createConstraint(statusField, + FieldCompareConstraint.NOT_EQUAL, STATUS_FAIL); + query.setCaseSensitive(failStatus, true); + FieldValueConstraint doneStatus = query.createConstraint(statusField, + FieldCompareConstraint.NOT_EQUAL, STATUS_DONE); + query.setCaseSensitive(doneStatus, true); + Constraint statusComposite = query.createConstraint( + failStatus, CompositeConstraint.LOGICAL_AND, doneStatus); + + if (!nodeManager.hasField(FIELD_PUBLISHDATE)) { + query.setConstraint(statusComposite); + } + else { + StepField publishDateField = query.getStepField(nodeManager.getField(FIELD_PUBLISHDATE)); + Constraint publishNull = query.createConstraint(publishDateField); + Constraint publishNow = query.createConstraint( + publishDateField, FieldCompareConstraint.LESS_EQUAL, new Date()); + + Constraint publishDateComposite = query.createConstraint( + publishNow, CompositeConstraint.LOGICAL_OR, publishNull); + Constraint composite = query.createConstraint( + statusComposite, CompositeConstraint.LOGICAL_AND, publishDateComposite); + query.setConstraint(composite); + } + query.setMaxNumber(10); + StepField timestampField = query.getStepField(nodeManager.getField(FIELD_TIMESTAMP)); + query.addSortOrder(timestampField, SortOrder.ORDER_ASCENDING); + + query.setCachePolicy(CachePolicy.NEVER); + return query; + } + /** * handle exception, if the root cause is RMI's connection broken, *************** *** 307,314 **** private void publishFailed(CloudInfo localCloudInfo, Node node, BridgeException e) { ! node.setStringValue("status", "fail"); node.commit(); for(PublishListener listener : publishListeners) { ! int number = node.getIntValue("sourcenumber"); if (localCloudInfo.getCloud().hasNode(number)) { StringBuffer message = new StringBuffer(); --- 335,342 ---- private void publishFailed(CloudInfo localCloudInfo, Node node, BridgeException e) { ! node.setStringValue(FIELD_STATUS, STATUS_FAIL); node.commit(); for(PublishListener listener : publishListeners) { ! int number = node.getIntValue(FIELD_SOURCENUMBER); if (localCloudInfo.getCloud().hasNode(number)) { StringBuffer message = new StringBuffer(); *************** *** 326,337 **** } } ! ! protected boolean isAllowedToPublish(Node publishQueueNode) { ! return true; ! } ! ! private void publish(CloudInfo localCloudInfo, Node publishQueueNode) { ! int localNodeNumber = publishQueueNode.getIntValue("sourcenumber"); ! int remoteCloudNumber = publishQueueNode.getIntValue("destinationcloud"); CloudInfo remoteCloudInfo = CloudInfo.getCloudInfo(remoteCloudNumber); Node localNode = localCloudInfo.getCloud().getNode(localNodeNumber); --- 354,361 ---- } } ! ! private void update(CloudInfo localCloudInfo, Node queueNode, String action) { ! int localNodeNumber = queueNode.getIntValue(FIELD_SOURCENUMBER); ! int remoteCloudNumber = queueNode.getIntValue(FIELD_DESTINATIONCLOUD); CloudInfo remoteCloudInfo = CloudInfo.getCloudInfo(remoteCloudNumber); Node localNode = localCloudInfo.getCloud().getNode(localNodeNumber); *************** *** 343,354 **** if (PublishManager.isPublished(localCloudInfo, localNode)) { if (localNode instanceof Relation) { ! log.debug(nodeManagerName + " update relation with number " + ! localNodeNumber); } else { ! log.debug(nodeManagerName + " update node with number " + ! localNodeNumber); } - - PublishManager.updatePublishedNodes(localCloudInfo, localNode); } else { if (localNode instanceof Relation) { --- 367,395 ---- if (PublishManager.isPublished(localCloudInfo, localNode)) { if (localNode instanceof Relation) { ! log.debug(nodeManagerName + " update relation with number " + localNodeNumber); } else { ! log.debug(nodeManagerName + " update node with number " + localNodeNumber); ! } ! if (action.equalsIgnoreCase(ACTION_UPDATE_NODE)) { ! PublishManager.updateNodesAndRelations(localCloudInfo, localNode, true, false); ! } ! if (action.equalsIgnoreCase(ACTION_UPDATE)) { ! PublishManager.updateNodesAndRelations(localCloudInfo, localNode, true, true); ! } ! if (action.equalsIgnoreCase(ACTION_UPDATE_RELATIONS)) { ! String relatedNodes = queueNode.getStringValue(FIELD_RELATEDNODES); ! if (relatedNodes != null && relatedNodes.length() > 0) { ! List<Integer> related = new ArrayList<Integer>(); ! StringTokenizer tokenizer = new StringTokenizer(relatedNodes, ","); ! while(tokenizer.hasMoreTokens()) { ! int relatedNodeNumber = Integer.valueOf(tokenizer.nextToken()); ! related.add(relatedNodeNumber); ! } ! PublishManager.updateNodesAndRelations(localCloudInfo, localNode, false, true, related); ! } ! else { ! PublishManager.updateNodesAndRelations(localCloudInfo, localNode, false, true); ! } } } else { if (localNode instanceof Relation) { *************** *** 360,364 **** } ! PublishManager.publishNode(localCloudInfo, localNode, remoteCloudInfo); } --- 401,410 ---- } ! if (action.equalsIgnoreCase(ACTION_UPDATE_NODE)) { ! PublishManager.createNodeAndRelations(localCloudInfo, localNode, remoteCloudInfo, false); ! } ! if (action.equalsIgnoreCase(ACTION_UPDATE)) { ! PublishManager.createNodeAndRelations(localCloudInfo, localNode, remoteCloudInfo, true); ! } } *************** *** 377,386 **** } ! private void removeNode(CloudInfo localCloudInfo, Node publishQueueNode) { ! int number = publishQueueNode.getIntValue("sourcenumber"); PublishManager.deletePublishedNode(localCloudInfo, number); ! publishQueueNode.setStringValue("status", "done"); ! publishQueueNode.commit(); } --- 423,432 ---- } ! private void removeNode(CloudInfo localCloudInfo, Node queueNode) { ! int number = queueNode.getIntValue(FIELD_SOURCENUMBER); PublishManager.deletePublishedNode(localCloudInfo, number); ! queueNode.setStringValue(FIELD_STATUS, STATUS_DONE); ! queueNode.commit(); } |