X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.layer0.utils%2Fsrc%2Forg%2Fsimantics%2Flayer0%2Futils%2Fdirect%2FExceptionUtils.java;h=684cafd187fb8e0119de151b57bd2f1062e918ae;hb=refs%2Fchanges%2F69%2F1969%2F7;hp=552cbddb3a4343fb6f26d1457cf8469ea198e999;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.layer0.utils/src/org/simantics/layer0/utils/direct/ExceptionUtils.java b/bundles/org.simantics.layer0.utils/src/org/simantics/layer0/utils/direct/ExceptionUtils.java index 552cbddb3..684cafd18 100644 --- a/bundles/org.simantics.layer0.utils/src/org/simantics/layer0/utils/direct/ExceptionUtils.java +++ b/bundles/org.simantics.layer0.utils/src/org/simantics/layer0/utils/direct/ExceptionUtils.java @@ -1,83 +1,83 @@ -/******************************************************************************* - * 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.layer0.utils.direct; - -import java.util.ArrayList; -import java.util.Collection; - -import org.simantics.db.AsyncReadGraph; -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.common.utils.NameUtils; -import org.simantics.db.exception.DatabaseException; -import org.simantics.db.procedure.AsyncProcedure; -import org.simantics.db.request.Read; - -public class ExceptionUtils { - - public static void decipher(AsyncReadGraph graph, Throwable throwable, final AsyncProcedure procedure) { - - if(throwable instanceof DatabaseException) { - - System.out.println("decipher " + throwable); - - final DatabaseException e = (DatabaseException)throwable; - - Collection resources = e.getResources(); - if(resources != null) { - - graph.asyncRequest(new Read>() { - - @Override - public ArrayList perform(ReadGraph graph) throws DatabaseException { - - Collection resources = e.getResources(); - ArrayList names = new ArrayList(); - - for(Resource r : resources) { - names.add(NameUtils.getSafeName(graph, r)); - } - - return names; - - } - - }, new AsyncProcedure>() { - - @Override - public void exception(AsyncReadGraph graph, Throwable throwable) { - procedure.exception(graph, throwable); - } - - @Override - public void execute(AsyncReadGraph graph, ArrayList names) { - e.setNames(names); - procedure.exception(graph, e); - } - - }); - - } else { - - procedure.exception(graph, throwable); - - } - - } else { - - procedure.exception(graph, throwable); - - } - - } - -} +/******************************************************************************* + * 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.layer0.utils.direct; + +import java.util.ArrayList; +import java.util.Collection; + +import org.simantics.db.AsyncReadGraph; +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.common.utils.NameUtils; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.procedure.AsyncProcedure; +import org.simantics.db.request.Read; + +public class ExceptionUtils { + + public static void decipher(AsyncReadGraph graph, Throwable throwable, final AsyncProcedure procedure) { + + if(throwable instanceof DatabaseException) { + + System.out.println("decipher " + throwable); + + final DatabaseException e = (DatabaseException)throwable; + + Collection resources = e.getResources(); + if(resources != null) { + + graph.asyncRequest(new Read>() { + + @Override + public ArrayList perform(ReadGraph graph) throws DatabaseException { + + Collection resources = e.getResources(); + ArrayList names = new ArrayList(); + + for(Resource r : resources) { + names.add(NameUtils.getSafeName(graph, r)); + } + + return names; + + } + + }, new AsyncProcedure>() { + + @Override + public void exception(AsyncReadGraph graph, Throwable throwable) { + procedure.exception(graph, throwable); + } + + @Override + public void execute(AsyncReadGraph graph, ArrayList names) { + e.setNames(names); + procedure.exception(graph, e); + } + + }); + + } else { + + procedure.exception(graph, throwable); + + } + + } else { + + procedure.exception(graph, throwable); + + } + + } + +}