]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.graphfile/src/org/simantics/graphfile/hack/GraphFile.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.graphfile / src / org / simantics / graphfile / hack / GraphFile.java
1 /*******************************************************************************\r
2  * Copyright (c) 2013 Association for Decentralized Information Management\r
3  * in Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.graphfile.hack;\r
13 \r
14 import java.io.ByteArrayInputStream;\r
15 import java.io.ByteArrayOutputStream;\r
16 import java.io.IOException;\r
17 import java.io.InputStream;\r
18 import java.io.Reader;\r
19 import java.net.URI;\r
20 import java.util.Map;\r
21 \r
22 import org.eclipse.core.resources.IContainer;\r
23 import org.eclipse.core.resources.IFile;\r
24 import org.eclipse.core.resources.IFileState;\r
25 import org.eclipse.core.resources.IMarker;\r
26 import org.eclipse.core.resources.IPathVariableManager;\r
27 import org.eclipse.core.resources.IProject;\r
28 import org.eclipse.core.resources.IProjectDescription;\r
29 import org.eclipse.core.resources.IResource;\r
30 import org.eclipse.core.resources.IResourceProxy;\r
31 import org.eclipse.core.resources.IResourceProxyVisitor;\r
32 import org.eclipse.core.resources.IResourceVisitor;\r
33 import org.eclipse.core.resources.IWorkspace;\r
34 import org.eclipse.core.resources.ResourceAttributes;\r
35 import org.eclipse.core.runtime.CoreException;\r
36 import org.eclipse.core.runtime.IPath;\r
37 import org.eclipse.core.runtime.IProgressMonitor;\r
38 import org.eclipse.core.runtime.IStatus;\r
39 import org.eclipse.core.runtime.QualifiedName;\r
40 import org.eclipse.core.runtime.Status;\r
41 import org.eclipse.core.runtime.content.IContentDescription;\r
42 import org.eclipse.core.runtime.jobs.ISchedulingRule;\r
43 import org.simantics.Simantics;\r
44 import org.simantics.db.ReadGraph;\r
45 import org.simantics.db.Resource;\r
46 import org.simantics.db.WriteGraph;\r
47 import org.simantics.db.common.request.WriteRequest;\r
48 import org.simantics.db.exception.DatabaseException;\r
49 import org.simantics.db.request.Read;\r
50 import org.simantics.graphfile.Activator;\r
51 import org.simantics.graphfile.ontology.GraphFileResource;\r
52 import org.simantics.layer0.Layer0;\r
53 \r
54 /**\r
55  * This is an implementation of IFile that can be used to open external editor for any file.\r
56  * (Original implementation (org.eclipse.core.filesystem.File) doesn't work without project/file structure) \r
57  * \r
58  * @author Marko Luukkainen <Marko.Luukkainen@vtt.fi>\r
59  *\r
60  */\r
61 public class GraphFile implements IFile {\r
62         private Resource fileResource;\r
63         private IWorkspace workspace;\r
64         \r
65         \r
66         public GraphFile(Resource fileResource, IWorkspace ws) {\r
67                 this.fileResource = fileResource;\r
68                 this.workspace = ws;\r
69         }\r
70         \r
71         public Resource getFileResource() {\r
72                 return fileResource;\r
73         }\r
74         \r
75         private String getResourceName() {\r
76                 try {\r
77                         return Simantics.getSession().syncRequest(new Read<String>() {\r
78                                 @Override\r
79                                 public String perform(ReadGraph graph) throws DatabaseException {\r
80                                         Layer0 l0 = Layer0.getInstance(graph);\r
81                                         return graph.getPossibleRelatedValue(fileResource, l0.HasName);\r
82                                 }\r
83                         });\r
84                 } catch (DatabaseException e) {\r
85                         Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Failed to get resource name: " + fileResource, e));\r
86                         return e.getMessage();\r
87                 }\r
88         }\r
89         \r
90         \r
91         private byte[] getResourceData() throws DatabaseException {\r
92                 return Simantics.getSession().syncRequest(new Read<byte[]>() {\r
93                         @Override\r
94                         public byte[] perform(ReadGraph graph) throws DatabaseException {\r
95                                 return getResourceData(graph);\r
96                         }\r
97                 });\r
98         }\r
99         \r
100         private byte[] getResourceData(ReadGraph graph) throws DatabaseException {\r
101                 GraphFileResource gf = GraphFileResource.getInstance(graph);\r
102                 return graph.getRelatedValue(fileResource, gf.HasFiledata);\r
103         }\r
104         \r
105         private long getResourceModificationTime() {\r
106                 try {\r
107                         return Simantics.getSession().syncRequest(new Read<Long>() {\r
108                                 @Override\r
109                                 public Long perform(ReadGraph graph) throws DatabaseException {\r
110                                         return getResourceMofificationTime(graph);\r
111                                 }\r
112                         });\r
113                 } catch (DatabaseException e) {\r
114                         return IFile.NULL_STAMP;\r
115                 }\r
116         }\r
117         \r
118         private long getResourceMofificationTime(ReadGraph graph) throws DatabaseException {\r
119                 GraphFileResource gf = GraphFileResource.getInstance(graph);\r
120                 long time =  graph.getRelatedValue(fileResource, gf.LastModified);\r
121                 //System.out.println("Modification time is " + time +  " " + fileResource);\r
122                 return time;\r
123         }\r
124         \r
125         private void setResourceModificationTime(final long time) throws DatabaseException{\r
126                 \r
127                 Simantics.getSession().syncRequest(new WriteRequest() {\r
128 \r
129                         @Override\r
130                         public void perform(WriteGraph graph) throws DatabaseException {\r
131                                 setResourceModificationTime(graph, time);\r
132                         }\r
133                 });\r
134                 \r
135         }\r
136         \r
137         private void setResourceModificationTime(WriteGraph graph, long time) throws DatabaseException{\r
138                 GraphFileResource gf = GraphFileResource.getInstance(graph);\r
139                 graph.claimLiteral(fileResource, gf.LastModified, time);\r
140                 //System.out.println("Modification time set to " + time +  " " + fileResource);\r
141         }\r
142         \r
143         \r
144         @Override\r
145         public void accept(IResourceProxyVisitor visitor, int memberFlags) throws CoreException {\r
146                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));\r
147         }\r
148         \r
149         @Override\r
150         public void accept(IResourceVisitor visitor) throws CoreException {\r
151                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));\r
152         }\r
153         \r
154         @Override\r
155         public void accept(IResourceVisitor visitor, int depth, boolean includePhantoms) throws CoreException {\r
156                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));\r
157         }\r
158         \r
159         @Override\r
160         public void accept(IResourceVisitor visitor, int depth, int memberFlags) throws CoreException {\r
161                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));\r
162         }\r
163         \r
164         @Override\r
165         public void accept(IResourceProxyVisitor visitor, int depth, int memberFlags) throws CoreException {\r
166                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));\r
167         }\r
168 \r
169         @Override\r
170         public void clearHistory(IProgressMonitor monitor) throws CoreException {\r
171                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));\r
172         }\r
173 \r
174         @Override\r
175         public void copy(IPath destination, boolean force, IProgressMonitor monitor) throws CoreException {\r
176                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));\r
177                 \r
178         }\r
179 \r
180         @Override\r
181         public void copy(IPath destination, int updateFlags, IProgressMonitor monitor) throws CoreException {\r
182                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));\r
183                 \r
184         }\r
185 \r
186         @Override\r
187         public void copy(IProjectDescription description, boolean force, IProgressMonitor monitor) throws CoreException {\r
188                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));\r
189                 \r
190         }\r
191 \r
192         @Override\r
193         public void copy(IProjectDescription description, int updateFlags, IProgressMonitor monitor) throws CoreException {\r
194                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));\r
195                 \r
196         }\r
197 \r
198         @Override\r
199         public IMarker createMarker(String type) throws CoreException {\r
200                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));\r
201         }\r
202 \r
203         @Override\r
204         public IResourceProxy createProxy() {\r
205                 return null;\r
206         }\r
207 \r
208         @Override\r
209         public void delete(boolean force, IProgressMonitor monitor) throws CoreException {\r
210                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));\r
211         }\r
212 \r
213         @Override\r
214         public void delete(int updateFlags, IProgressMonitor monitor) throws CoreException {\r
215                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));\r
216                 \r
217         }\r
218 \r
219         @Override\r
220         public void deleteMarkers(String type, boolean includeSubtypes, int depth) throws CoreException {\r
221                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));\r
222         }\r
223 \r
224         @Override\r
225         public boolean exists() {\r
226                 return true;\r
227         }\r
228 \r
229         @Override\r
230         public IMarker findMarker(long id) throws CoreException {\r
231                 return null;\r
232         }\r
233 \r
234         @Override\r
235         public IMarker[] findMarkers(String type, boolean includeSubtypes, int depth) throws CoreException {\r
236                 return null;\r
237         }\r
238 \r
239         @Override\r
240         public int findMaxProblemSeverity(String type, boolean includeSubtypes, int depth) throws CoreException {\r
241                 return 0;\r
242         }\r
243         \r
244         \r
245 \r
246         @Override\r
247         public String getFileExtension() {\r
248                 String name = getResourceName();\r
249                 if (name == null)\r
250                         return null;\r
251                 int i = name.lastIndexOf(".");\r
252                 if (i > 0)\r
253                         return name.substring(i);\r
254                 else\r
255                         return null;\r
256                         \r
257         }\r
258 \r
259         @Override\r
260         public long getLocalTimeStamp() {\r
261                 return 0;\r
262         }\r
263         \r
264         @Override\r
265         public long setLocalTimeStamp(long value) throws CoreException {\r
266                 try {\r
267                         setResourceModificationTime(value);\r
268                 } catch (DatabaseException e) {\r
269                         throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"GraphFile transaction error",e));\r
270                 }\r
271                 return value;\r
272         }\r
273 \r
274         @Override\r
275         public IPath getLocation() {\r
276                 //return new Path(getResourceAbsolutePath());\r
277                 return new GraphPath(this);\r
278         }\r
279 \r
280         @Override\r
281         public URI getLocationURI() {\r
282                 return null;\r
283         }\r
284 \r
285         @Override\r
286         public IMarker getMarker(long id) {\r
287                 return null;\r
288         }\r
289 \r
290         @Override\r
291         public long getModificationStamp() {\r
292                 return getResourceModificationTime();\r
293         }\r
294 \r
295         @Override\r
296         public IContainer getParent() {\r
297                 return SystemProject.getDefault();\r
298         }\r
299 \r
300         @Override\r
301         public String getPersistentProperty(QualifiedName key)throws CoreException {\r
302                 return null;\r
303         }\r
304 \r
305         @Override\r
306         public IProject getProject() {\r
307                 return SystemProject.getDefault();\r
308         }\r
309 \r
310         @Override\r
311         public IPath getProjectRelativePath() {\r
312                 return null;\r
313         }\r
314 \r
315         @Override\r
316         public IPath getRawLocation() {\r
317                 //return new Path(getResourceAbsolutePath());\r
318                 return new GraphPath(this);\r
319         }\r
320 \r
321         @Override\r
322         public URI getRawLocationURI() {\r
323                 return null;\r
324         }\r
325 \r
326         @Override\r
327         public ResourceAttributes getResourceAttributes() {\r
328                 return null;\r
329         }\r
330 \r
331         @Override\r
332         public Object getSessionProperty(QualifiedName key) throws CoreException {\r
333                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));\r
334         }\r
335 \r
336         @Override\r
337         public int getType() {\r
338                 return IFile.FILE;\r
339         }\r
340 \r
341         @Override\r
342         public IWorkspace getWorkspace() {\r
343                 return workspace;\r
344         }\r
345 \r
346         @Override\r
347         public boolean isAccessible() {\r
348                 return true;\r
349         }\r
350 \r
351         @Override\r
352         public boolean isDerived() {\r
353                 return false;\r
354         }\r
355 \r
356         @Override\r
357         public boolean isLinked() {\r
358                 return false;\r
359         }\r
360 \r
361         @Override\r
362         public boolean isLinked(int options) {\r
363                 return false;\r
364         }\r
365 \r
366         @Override\r
367         public boolean isLocal(int depth) {\r
368                 return true;\r
369         }\r
370 \r
371         @Override\r
372         public boolean isPhantom() {\r
373                 return false;\r
374         }\r
375 \r
376         @Override\r
377         public boolean isSynchronized(int depth) {\r
378                 return true; // FIXME\r
379         }\r
380 \r
381         @Override\r
382         public boolean isTeamPrivateMember() {\r
383                 return false;\r
384         }\r
385 \r
386         @Override\r
387         public void move(IPath destination, boolean force, IProgressMonitor monitor) throws CoreException {\r
388                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));\r
389         }\r
390 \r
391         @Override\r
392         public void move(IPath destination, int updateFlags, IProgressMonitor monitor) throws CoreException {\r
393                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));\r
394         }\r
395 \r
396         @Override\r
397         public void move(IProjectDescription description, boolean force, boolean keepHistory, IProgressMonitor monitor) throws CoreException {\r
398                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));\r
399         }\r
400 \r
401         @Override\r
402         public void move(IProjectDescription description, int updateFlags, IProgressMonitor monitor) throws CoreException {\r
403                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));\r
404         }\r
405 \r
406         @Override\r
407         public void refreshLocal(int depth, IProgressMonitor monitor) throws CoreException {\r
408                 \r
409                 //throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));\r
410         }\r
411 \r
412         @Override\r
413         public void revertModificationStamp(long value) throws CoreException {\r
414                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));\r
415         }\r
416 \r
417         @Override\r
418         public void setDerived(boolean isDerived) throws CoreException {\r
419                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));\r
420         }\r
421 \r
422         @Override\r
423         public void setLocal(boolean flag, int depth, IProgressMonitor monitor) throws CoreException {\r
424                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));\r
425         }\r
426 \r
427         \r
428 \r
429         @Override\r
430         public void setPersistentProperty(QualifiedName key, String value) throws CoreException {\r
431                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));\r
432         }\r
433 \r
434         @Override\r
435         public void setReadOnly(boolean readOnly) {\r
436 \r
437         }\r
438 \r
439         @Override\r
440         public void setResourceAttributes(ResourceAttributes attributes) throws CoreException {\r
441                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));\r
442                 \r
443         }\r
444 \r
445         @Override\r
446         public void setSessionProperty(QualifiedName key, Object value) throws CoreException {\r
447                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));  \r
448         }\r
449 \r
450         @Override\r
451         public void setTeamPrivateMember(boolean isTeamPrivate) throws CoreException {\r
452                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));\r
453         }\r
454 \r
455         @Override\r
456         public void touch(IProgressMonitor monitor) throws CoreException {\r
457                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));  \r
458         }\r
459 \r
460         @SuppressWarnings({ "rawtypes" })\r
461         @Override\r
462         public Object getAdapter(Class adapter) {\r
463                 return null;\r
464         }\r
465 \r
466         @Override\r
467         public boolean contains(ISchedulingRule rule) {\r
468                 if (this.equals(rule))\r
469                         return true;\r
470                 return false;\r
471         }\r
472 \r
473         @Override\r
474         public boolean isConflicting(ISchedulingRule rule) {\r
475                 if (this.equals(rule)) // TODO : check cached timestamp\r
476                         return true;\r
477                 return false;\r
478         }\r
479 \r
480         @Override\r
481         public void appendContents(InputStream source, boolean force,boolean keepHistory, IProgressMonitor monitor) throws CoreException {\r
482                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));\r
483         }\r
484 \r
485         @Override\r
486         public void appendContents(InputStream source, int updateFlags, IProgressMonitor monitor) throws CoreException {\r
487                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));  \r
488         }\r
489 \r
490         @Override\r
491         public void create(InputStream source, boolean force, IProgressMonitor monitor) throws CoreException {\r
492                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));\r
493         }\r
494 \r
495         @Override\r
496         public void create(InputStream source, int updateFlags, IProgressMonitor monitor) throws CoreException {\r
497                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));\r
498                 \r
499         }\r
500 \r
501         @Override\r
502         public void createLink(IPath localLocation, int updateFlags, IProgressMonitor monitor) throws CoreException {\r
503                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));\r
504                 \r
505         }\r
506 \r
507         @Override\r
508         public void createLink(URI location, int updateFlags, IProgressMonitor monitor) throws CoreException {\r
509                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));\r
510         }\r
511 \r
512         @Override\r
513         public void delete(boolean force, boolean keepHistory, IProgressMonitor monitor) throws CoreException {\r
514                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));\r
515                 \r
516         }\r
517 \r
518         @Override\r
519         public String getCharset() throws CoreException {\r
520                 return getCharset(true);\r
521         }\r
522 \r
523         @Override\r
524         public String getCharset(boolean checkImplicit) throws CoreException {\r
525                 // FIXME\r
526                 return "UTF-8";\r
527         }\r
528         \r
529         @Override\r
530         public int getEncoding() throws CoreException {\r
531                 // FIXME\r
532                 return ENCODING_UTF_8;\r
533         }\r
534 \r
535         @Override\r
536         public String getCharsetFor(Reader reader) throws CoreException {\r
537                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));\r
538         }\r
539 \r
540         @Override\r
541         public IContentDescription getContentDescription() throws CoreException {\r
542                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));\r
543         }\r
544 \r
545         @Override\r
546         public InputStream getContents() throws CoreException {\r
547                 return getContents(false);\r
548         }\r
549 \r
550         @Override\r
551         public InputStream getContents(boolean force) throws CoreException {\r
552                 try {\r
553                         return new ByteArrayInputStream(getResourceData());\r
554                 } catch (DatabaseException e) {\r
555                         throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"GraphFile transaction error",e));\r
556                 }\r
557         }\r
558 \r
559         \r
560 \r
561         @Override\r
562         public IPath getFullPath() {\r
563                 //return new Path(getResourceAbsolutePath());\r
564                 return new GraphPath(this);\r
565         }\r
566 \r
567         @Override\r
568         public IFileState[] getHistory(IProgressMonitor monitor) throws CoreException {\r
569                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));\r
570         }\r
571 \r
572         @Override\r
573         public String getName() {\r
574                 return getResourceName();\r
575         }\r
576 \r
577         @Override\r
578         public boolean isReadOnly() {\r
579                 return false;\r
580         }\r
581 \r
582         @Override\r
583         public void move(IPath destination, boolean force, boolean keepHistory, IProgressMonitor monitor) throws CoreException {\r
584                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));\r
585         }\r
586 \r
587         @Override\r
588         public void setCharset(String newCharset, IProgressMonitor monitor) throws CoreException {\r
589                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));\r
590         }\r
591 \r
592         @Override\r
593         public void setCharset(String newCharset) throws CoreException {\r
594                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));\r
595         }\r
596 \r
597         @Override\r
598         public void setContents(IFileState source, boolean force, boolean keepHistory, IProgressMonitor monitor) throws CoreException {\r
599                 setContents(source.getContents(), force, keepHistory, monitor);\r
600                 setLocalTimeStamp(source.getModificationTime());\r
601         }\r
602 \r
603         @Override\r
604         public void setContents(IFileState source, int updateFlags,\r
605                         IProgressMonitor monitor) throws CoreException {\r
606                 setContents(source.getContents(), updateFlags, monitor);\r
607                 setLocalTimeStamp(source.getModificationTime());\r
608         }\r
609 \r
610         @Override\r
611         public void setContents(InputStream source, boolean force,\r
612                         boolean keepHistory, IProgressMonitor monitor)\r
613                         throws CoreException {\r
614                 setContents(source, (keepHistory ? KEEP_HISTORY : IResource.NONE) | (force ? FORCE : IResource.NONE), monitor);\r
615         }\r
616 \r
617         @Override\r
618         public void setContents(InputStream source, int updateFlags, IProgressMonitor monitor) throws CoreException {\r
619                 \r
620                 \r
621                 final ByteArrayOutputStream os = new ByteArrayOutputStream();\r
622                 try {\r
623                         byte buf[] = new byte[1024];\r
624                         int count = 0;\r
625                         while ((count = source.read(buf)) > 0) {\r
626                                 os.write(buf,0,count);\r
627                         }\r
628                         os.close();\r
629                         Simantics.getSession().syncRequest(new WriteRequest() {\r
630                                 \r
631                                 @Override\r
632                                 public void perform(WriteGraph graph) throws DatabaseException {\r
633                                         long time = System.currentTimeMillis();\r
634                                         GraphFileResource gf = GraphFileResource.getInstance(graph);\r
635                                         graph.claimLiteral(fileResource, gf.HasFiledata, os.toByteArray());\r
636                                         setResourceModificationTime(graph, time);\r
637                                 }\r
638                         });\r
639                 } catch (DatabaseException e ) {\r
640                         throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"GraphFile transaction error",e));\r
641                 } catch (IOException e) {\r
642                         throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"GraphFile IO error",e));\r
643                 }\r
644         }\r
645 \r
646         @SuppressWarnings({ "rawtypes" })\r
647         @Override\r
648         public Map getPersistentProperties() throws CoreException {\r
649                 return null;\r
650         }\r
651 \r
652         @SuppressWarnings({ "rawtypes" })\r
653         @Override\r
654         public Map getSessionProperties() throws CoreException {\r
655                 return null;\r
656         }\r
657 \r
658         @Override\r
659         public boolean isDerived(int options) {\r
660                 return false;\r
661         }\r
662 \r
663         @Override\r
664         public boolean isHidden() {\r
665                 return false;\r
666         }\r
667 \r
668         @Override\r
669         public void setHidden(boolean isHidden) throws CoreException {\r
670 \r
671         }\r
672 \r
673         @Override\r
674         public boolean isHidden(int options) {\r
675                 return false;\r
676         }\r
677 \r
678         @Override\r
679         public boolean isTeamPrivateMember(int options) {\r
680                 return false;\r
681         }\r
682         \r
683         @Override\r
684         public IPathVariableManager getPathVariableManager() {\r
685                 return null;\r
686         }\r
687         \r
688         @Override\r
689         public boolean isVirtual() {\r
690                 return false;\r
691         }\r
692         \r
693         @Override\r
694         public void setDerived(boolean isDerived, IProgressMonitor monitor)\r
695                         throws CoreException {\r
696                 throw new CoreException(new Status(Status.ERROR,Activator.PLUGIN_ID,"not supported"));          \r
697         }\r
698 \r
699         \r
700         @Override\r
701         public boolean equals(Object obj) {\r
702                 if (obj == null)\r
703                         return false;\r
704                 if (obj.getClass() != getClass())\r
705                         return false;\r
706                 GraphFile other = (GraphFile)obj;\r
707                 return fileResource.equals(other.fileResource);\r
708         }\r
709         \r
710         @Override\r
711         public int hashCode() {\r
712                 return fileResource.hashCode();\r
713         }\r
714 \r
715 }\r
716 \r