handle default index/cache dirs if not set
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@991851 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/sigil/common/obr/src/org/apache/felix/sigil/common/obr/OBRRepositoryProvider.java b/sigil/common/obr/src/org/apache/felix/sigil/common/obr/OBRRepositoryProvider.java
index 535e8b7..bd75a88 100644
--- a/sigil/common/obr/src/org/apache/felix/sigil/common/obr/OBRRepositoryProvider.java
+++ b/sigil/common/obr/src/org/apache/felix/sigil/common/obr/OBRRepositoryProvider.java
@@ -36,8 +36,8 @@
private static final String IN_MEMORY = "inmemory";
private static final String UPDATE_PERIOD = "updatePeriod";
private static final String AUTH_FILE = "auth";
- private static final String CACHE_DIRECTORY = "cache";
- private static final String INDEX_CACHE_FILE = "index";
+ public static final String CACHE_DIRECTORY = "cache";
+ public static final String INDEX_CACHE_FILE = "index";
public IBundleRepository createRepository(String id, Properties preferences)
throws RepositoryException
diff --git a/sigil/eclipse/obr/plugin.xml b/sigil/eclipse/obr/plugin.xml
index df40b46..206ad09 100644
--- a/sigil/eclipse/obr/plugin.xml
+++ b/sigil/eclipse/obr/plugin.xml
@@ -22,7 +22,7 @@
<extension
point="org.apache.felix.sigil.repositoryprovider">
<provider
- class="org.apache.felix.sigil.common.obr.OBRRepositoryProvider"
+ class="org.apache.felix.sigil.obr.eclipse.EclipseOBRRepositoryProvider"
dynamic="true"
id="org.apache.felix.sigil.obr.provider"
alias="obr"
diff --git a/sigil/eclipse/obr/sigil.properties b/sigil/eclipse/obr/sigil.properties
index 0da3da1..8023a1f 100644
--- a/sigil/eclipse/obr/sigil.properties
+++ b/sigil/eclipse/obr/sigil.properties
@@ -16,8 +16,9 @@
-imports: \
org.apache.felix.sigil.common.obr, \
+ org.apache.felix.sigil.common.repository, \
org.apache.felix.sigil.eclipse.model.repository, \
- org.apache.felix.sigil.eclipse.ui.wizard.repository;version=0.9.0, \
+ org.apache.felix.sigil.eclipse.ui.wizard.repository, \
org.eclipse.jface.preference, \
org.eclipse.jface.wizard, \
org.eclipse.ui.plugin, \
diff --git a/sigil/eclipse/obr/src/org/apache/felix/sigil/obr/eclipse/EclipseOBRRepositoryProvider.java b/sigil/eclipse/obr/src/org/apache/felix/sigil/obr/eclipse/EclipseOBRRepositoryProvider.java
new file mode 100644
index 0000000..d372184
--- /dev/null
+++ b/sigil/eclipse/obr/src/org/apache/felix/sigil/obr/eclipse/EclipseOBRRepositoryProvider.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.sigil.obr.eclipse;
+
+import java.util.Properties;
+
+import org.apache.felix.sigil.common.obr.OBRRepositoryProvider;
+import org.apache.felix.sigil.common.repository.IBundleRepository;
+import org.apache.felix.sigil.common.repository.RepositoryException;
+import org.eclipse.core.runtime.IPath;
+
+/**
+ * @author dave
+ *
+ */
+public class EclipseOBRRepositoryProvider extends OBRRepositoryProvider
+{
+
+ @Override
+ public IBundleRepository createRepository(String id, Properties preferences)
+ throws RepositoryException
+ {
+ Properties props = new Properties(preferences);
+
+ if ( !preferences.containsKey(INDEX_CACHE_FILE) ) {
+ String index = newStatePath(id, "index.obr");
+ props.put(INDEX_CACHE_FILE, index);
+ }
+
+ if ( !preferences.containsKey(CACHE_DIRECTORY) ) {
+ String dir = newStatePath(id, "dir");
+ props.put(CACHE_DIRECTORY, dir);
+ }
+
+ return super.createRepository(id, props);
+ }
+
+ /**
+ * @param id
+ * @param string
+ * @return
+ */
+ private String newStatePath(String id, String string)
+ {
+ IPath state = Activator.getDefault().getStateLocation();
+ state.append("cache").append(id).append(string);
+ return state.toOSString();
+ }
+
+}