X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.message%2Fsrc%2Forg%2Fsimantics%2Fmessage%2Futil%2FResourceSerializerUtil.java;h=2a8213ed11c288bd431642541858627be48dc972;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hp=2dfa47689b78cc69f1f0a8c0607dba3ba3a6c898;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.message/src/org/simantics/message/util/ResourceSerializerUtil.java b/bundles/org.simantics.message/src/org/simantics/message/util/ResourceSerializerUtil.java index 2dfa47689..2a8213ed1 100644 --- a/bundles/org.simantics.message/src/org/simantics/message/util/ResourceSerializerUtil.java +++ b/bundles/org.simantics.message/src/org/simantics/message/util/ResourceSerializerUtil.java @@ -1,51 +1,51 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.message.util; - -import java.net.URI; -import java.net.URISyntaxException; - -import org.simantics.db.Resource; -import org.simantics.db.ResourceSerializer; -import org.simantics.db.Session; -import org.simantics.db.exception.InvalidResourceReferenceException; -import org.simantics.db.service.SerialisationSupport; -import org.simantics.message.ReferenceSerializationException; - -/** - * @author Tuukka Lehtonen - */ -public class ResourceSerializerUtil { - - public static Resource deserialize(Session s, URI data) throws ReferenceSerializationException { - SerialisationSupport support = s.getService(SerialisationSupport.class); - ResourceSerializer rs = support.getResourceSerializer(); - try { - return rs.getResource(data.getSchemeSpecificPart()); - } catch (InvalidResourceReferenceException e) { - throw new ReferenceSerializationException(e); - } - } - - public static URI serialize(Session s, Resource r) throws ReferenceSerializationException { - SerialisationSupport support = s.getService(SerialisationSupport.class); - ResourceSerializer rs = support.getResourceSerializer(); - try { - return new URI("resource", rs.createRandomAccessId(r), null); - } catch (InvalidResourceReferenceException e) { - throw new ReferenceSerializationException(e); - } catch (URISyntaxException e) { - throw new ReferenceSerializationException(e); - } - } - -} +/******************************************************************************* + * Copyright (c) 2007, 2010 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.message.util; + +import java.net.URI; +import java.net.URISyntaxException; + +import org.simantics.db.Resource; +import org.simantics.db.ResourceSerializer; +import org.simantics.db.Session; +import org.simantics.db.exception.InvalidResourceReferenceException; +import org.simantics.db.service.SerialisationSupport; +import org.simantics.message.ReferenceSerializationException; + +/** + * @author Tuukka Lehtonen + */ +public class ResourceSerializerUtil { + + public static Resource deserialize(Session s, URI data) throws ReferenceSerializationException { + SerialisationSupport support = s.getService(SerialisationSupport.class); + ResourceSerializer rs = support.getResourceSerializer(); + try { + return rs.getResource(data.getSchemeSpecificPart()); + } catch (InvalidResourceReferenceException e) { + throw new ReferenceSerializationException(e); + } + } + + public static URI serialize(Session s, Resource r) throws ReferenceSerializationException { + SerialisationSupport support = s.getService(SerialisationSupport.class); + ResourceSerializer rs = support.getResourceSerializer(); + try { + return new URI("resource", rs.createRandomAccessId(r), null); + } catch (InvalidResourceReferenceException e) { + throw new ReferenceSerializationException(e); + } catch (URISyntaxException e) { + throw new ReferenceSerializationException(e); + } + } + +}