X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.project%2Fsrc%2Forg%2Fsimantics%2Fproject%2Fmanagement%2FPlatformUtil.java;h=8f93d24ab293d937467e78ca233a0056c5462abe;hb=195c63dd5c7600170f594750de96793ebf06a0ad;hp=dafb8f10d47f3ce074e31cda6eebc42a5e73fd00;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git
diff --git a/bundles/org.simantics.project/src/org/simantics/project/management/PlatformUtil.java b/bundles/org.simantics.project/src/org/simantics/project/management/PlatformUtil.java
index dafb8f10d..8f93d24ab 100644
--- a/bundles/org.simantics.project/src/org/simantics/project/management/PlatformUtil.java
+++ b/bundles/org.simantics.project/src/org/simantics/project/management/PlatformUtil.java
@@ -1,393 +1,502 @@
-/*******************************************************************************
- * 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.project.management;
-
-import java.io.BufferedInputStream;
-import java.io.Closeable;
-import java.io.DataInput;
-import java.io.DataInputStream;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.FilenameFilter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.net.URL;
-import java.net.URLDecoder;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.Map.Entry;
-import java.util.jar.Attributes;
-import java.util.jar.Manifest;
-
-import org.eclipse.core.internal.runtime.PlatformActivator;
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.equinox.p2.metadata.IVersionedId;
-import org.eclipse.equinox.p2.metadata.Version;
-import org.eclipse.equinox.p2.metadata.VersionedId;
-import org.osgi.framework.Bundle;
-import org.simantics.databoard.adapter.AdaptException;
-import org.simantics.databoard.binding.Binding;
-import org.simantics.databoard.binding.mutable.Variant;
-import org.simantics.databoard.container.DataContainer;
-import org.simantics.databoard.container.DataContainers;
-import org.simantics.databoard.serialization.SerializationException;
-import org.simantics.db.common.utils.Logger;
-import org.simantics.graph.compiler.CompilationResult;
-import org.simantics.graph.compiler.GraphCompiler;
-import org.simantics.graph.compiler.GraphCompilerPreferences;
-import org.simantics.graph.compiler.ValidationMode;
-import org.simantics.graph.representation.TransferableGraph1;
-import org.simantics.ltk.FileSource;
-import org.simantics.ltk.ISource;
-import org.simantics.ltk.Problem;
-import org.simantics.scl.reflection.OntologyVersions;
-
-/**
- * This class contains utilities for managing bundles in a active platform.
- *
- */
-@SuppressWarnings("restriction")
-public class PlatformUtil {
-
-
- /**
- * Get all bundles in the platform.
- *
- * @return
- */
- public static Bundle[] getBundles() {
- return PlatformActivator.getContext().getBundles();
- }
-
- /**
- * Get the manifest file of a bundle
- *
- * @param bundle bundle
- * @return manifest or null if doesn't not exist
- * @throws IOException
- */
- public static Manifest getManifest(Bundle bundle) throws IOException {
- URL url = bundle.getEntry("META-INF/MANIFEST.MF");
- if (url==null) return null;
- InputStream is = url.openStream();
- try {
- return new Manifest(is);
- } finally {
- is.close();
- }
- }
-
- /**
- * Get the manifest file of a bundle
- *
- * @param bundle bundle
- * @return manifest or null if doesn't not exist
- * @throws IOException
- */
- public static Manifest getSimanticsManifest(Bundle bundle) throws IOException {
- URL url = bundle.getEntry("META-INF/SIMANTICS.MF");
- if (url==null) return null;
- InputStream is = url.openStream();
- try {
- return new Manifest(is);
- } finally {
- is.close();
- }
- }
-
- /**
- * Get a list (BundleIds) of all user installable units. These are the
- * top-level items that are visible for the end-user.
- * The list is acquired from the bundles of the current application.
- *
- * @param list of simantics features URIs
- * @throws IOException
- */
- public static void getUserInstallableUnits(Collection list)
- throws IOException
- {
- for (Bundle bundle : getBundles()) {
- Manifest manifest = getSimanticsManifest(bundle);
- if (manifest==null) continue;
- Attributes attributes = manifest.getMainAttributes();
- for (Entry