Changeset 1838
- Timestamp:
- 04/02/12 21:09:37 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
MDService2/branches/MDService_simple3/src/eu/clarin/cmdi/mdservice/model/WorkspaceProfile.java
r1835 r1838 11 11 import java.text.SimpleDateFormat; 12 12 import java.util.Date; 13 import java.util.HashMap;14 13 15 14 import javax.xml.namespace.QName; … … 45 44 46 45 /** 47 46 * Main WorkspaceProfile functionality, it means loading data from file to DOM Document, 47 * retrieving data or data parts as XMLStream and possibilities of save changed or 48 * new XML elements. 49 * 50 * @author gaba 48 51 */ 49 52 … … 73 76 public static String SERVER = "server"; 74 77 78 // xpaths definitions for lookup in workspaceprofile 75 79 public static String XPATH_EXPR_WORKSPACE = "//Profiles/WorkspaceProfiles/WorkspaceProfile[@user='dummy']"; 76 80 public static String XPATH_EXPR_REPOSITORIES = "//Profiles/WorkspaceProfiles/WorkspaceProfile[@user='server']/Repositories"; … … 116 120 } 117 121 122 /** 123 * Contructor provides initialisation. 124 * 125 * @return 126 */ 118 127 public WorkspaceProfile() { 119 128 Init(); 120 129 } 121 130 131 /** 132 * Instance of WorkspaceProfile is created. 133 * 134 * @return 135 */ 122 136 public static WorkspaceProfile getWorkspaceProfile() { 123 137 if (singleton == null) { … … 127 141 } 128 142 143 /** 144 * Initialisation constists of 145 * a) loading configuration 146 * b) setting up the filename of workspaceprofile.xml 147 * c) calling the document initialisation 148 * 149 */ 129 150 public void Init(){ 130 151 //configure … … 138 159 } 139 160 161 /** 162 * Initialisation of the DOM Document, representation of the XML file. 163 * If none workspaceprofile.xml exists, the new DOM document containig profile data is 164 * created and saved as WorkspaceProfile.xml 165 * 166 */ 140 167 public void initDocument() { 141 168 … … 201 228 } 202 229 230 /** 231 * Saving DOM Document representing workspace data into WorkspaceProfile.xml 232 */ 203 233 public void saveDocument() { 204 234 //public void writeQuerycounter (Integer i) { … … 250 280 } 251 281 282 /** 283 * Creates the XPath expression text from constant-defined text by replacing the 'dummy' 284 * 285 * @param xpath_expr 286 * @param new_dummy 287 * @return 288 */ 252 289 public String getXPathExpressionDummy(String xpath_expr, String new_dummy){ 253 290 … … 255 292 } 256 293 294 /** 295 * TODO Utils ? 296 * Apply the xpath expression to retrieve the particular data from the workspace. 297 * 298 * @param xpath_str 299 * @param type 300 * @return 301 * @throws XPathExpressionException 302 */ 257 303 public Object getWorkspaceData(String xpath_str, QName type) throws XPathExpressionException{ 258 304 XPathFactory factory = XPathFactory.newInstance(); … … 270 316 return result; 271 317 } 272 318 /* 319 * Creates new workspaceprofile structure. 320 * 321 */ 273 322 public void addWorkspaceToDocument(){ 274 323 //{'WorkspaceProfile':{'CustomTermsets':'null', … … 311 360 } 312 361 362 /** 363 * 364 * Creates the XMLStream from the particular part of the workspaceprofile 365 * according the xpath expression text. 366 * If document is empty, none data is retrieved the new document is created. 367 */ 313 368 public InputStream getXMLStream(String xpath_expr) throws XPathExpressionException, TransformerConfigurationException, TransformerException, TransformerFactoryConfigurationError{ 314 369 InputStream is; … … 368 423 } 369 424 425 /** 426 * Save the data of the profile element defined in json structure into DOM document , which 427 * represents the workspaceprofile. 428 * 429 * @param jsonData 430 * @return 431 * @throws ParserConfigurationException 432 * @throws SAXException 433 * @throws IOException 434 * @throws DOMException 435 * @throws XPathExpressionException 436 * @throws TransformerException 437 * @throws TransformerFactoryConfigurationError 438 */ 370 439 public String save(String jsonData) throws ParserConfigurationException, SAXException, IOException, DOMException, XPathExpressionException, TransformerException, TransformerFactoryConfigurationError{ 371 440 … … 401 470 } 402 471 472 /** 473 * Appends or replace the profile element (new_doc) into workspaceprofile DOM Document. 474 * 475 * @param new_doc 476 * @return 477 * @throws XPathExpressionException 478 */ 403 479 public String DocumentReplaceNewElement(Document new_doc) throws XPathExpressionException{ 404 480 String newid = "";
Note: See TracChangeset
for help on using the changeset viewer.