package com.c2kernel.lifecycle.routingHelpers; import com.c2kernel.common.ObjectNotFoundException; import com.c2kernel.entity.proxy.ItemProxy; import com.c2kernel.lookup.ItemPath; import com.c2kernel.persistency.ClusterStorage; import com.c2kernel.persistency.outcome.Outcome; import com.c2kernel.persistency.outcome.Viewpoint; import com.c2kernel.process.Gateway; import com.c2kernel.utils.XmlElementParser; public class ViewpointDataHelper { static Object[] errArr = { "" }; /** * Method get. * @param value * @return String[] * @throws Exception */ /**@param value : /UUID (or . if current) /SchemaName/Viewname/Path:XPathInOutcome */ public static Object [] get(String value) throws Exception { //Syntax of search : /: String entityPath; String viewpoint; String xpath; Object[] retArr; // find syskey, viewname, xpath int firstSlash = value.indexOf("/"); if (firstSlash > 0) { entityPath = value.substring(0, firstSlash); int startXPath = value.indexOf(":"); if (startXPath==-1) { viewpoint = value.substring(firstSlash + 1); xpath = null; } else { viewpoint = value.substring(firstSlash + 1, startXPath); xpath = value.substring(startXPath+1); } } else return errArr; // find entity ItemPath sourcePath; try { sourcePath = ItemPath.fromUUIDString(entityPath); } catch (Exception e) { sourcePath = new ItemPath(entityPath); } try { // load viewpoint ItemProxy dataSource = Gateway.getProxyManager().getProxy(sourcePath); Viewpoint view = (Viewpoint)dataSource.getObject(ClusterStorage.VIEWPOINT + "/" + viewpoint); Outcome outcome = view.getOutcome(); if (xpath == null) { retArr = new Object[1]; retArr[0] = outcome; } else retArr = XmlElementParser.parse(outcome.getData(), xpath); return retArr; } catch (ObjectNotFoundException e) { return errArr; } } }