import static org.argeo.api.DataModelNamespace.CMS_DATA_MODEL_NAMESPACE;
import java.io.File;
+import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.lang.management.ManagementFactory;
private Long availableSince;
- private final boolean cleanState;
+// private final boolean cleanState;
private NodeHttp nodeHttp;
private boolean httpAvailable = false;
public CmsDeployment() {
- ServiceReference<NodeState> nodeStateSr = bc.getServiceReference(NodeState.class);
- if (nodeStateSr == null)
- throw new CmsException("No node state available");
+// ServiceReference<NodeState> nodeStateSr = bc.getServiceReference(NodeState.class);
+// if (nodeStateSr == null)
+// throw new CmsException("No node state available");
- NodeState nodeState = bc.getService(nodeStateSr);
- cleanState = nodeState.isClean();
+// NodeState nodeState = bc.getService(nodeStateSr);
+// cleanState = nodeState.isClean();
- nodeHttp = new NodeHttp(cleanState);
+ nodeHttp = new NodeHttp();
dataModels = new DataModels(bc);
initTrackers();
}
@Override
public ConfigurationAdmin addingService(ServiceReference<ConfigurationAdmin> reference) {
ConfigurationAdmin configurationAdmin = bc.getService(reference);
- deployConfig = new DeployConfig(configurationAdmin, dataModels, cleanState);
+ boolean isClean;
+ try {
+ Configuration[] confs = configurationAdmin
+ .listConfigurations("(service.factoryPid=" + NodeConstants.NODE_USER_ADMIN_PID + ")");
+ isClean = confs == null || confs.length == 0;
+ } catch (Exception e) {
+ throw new CmsException("Cannot analize clean state", e);
+ }
+ deployConfig = new DeployConfig(configurationAdmin, dataModels, isClean);
httpExpected = deployConfig.getProps(KernelConstants.JETTY_FACTORY_PID, "default") != null;
try {
- // Configuration[] configs = configurationAdmin
- // .listConfigurations("(service.factoryPid=" +
- // NodeConstants.NODE_REPOS_FACTORY_PID + ")");
- // for (Configuration config : configs) {
- // Object cn = config.getProperties().get(NodeConstants.CN);
- // if (log.isDebugEnabled())
- // log.debug("Standalone repo cn: " + cn);
- // }
Configuration[] configs = configurationAdmin
.listConfigurations("(service.factoryPid=" + NodeConstants.NODE_USER_ADMIN_PID + ")");
}
// home
- prepareDataModel(NodeConstants.NODE, deployedNodeRepository);
+ prepareDataModel(NodeConstants.NODE_REPOSITORY, deployedNodeRepository);
}
private void prepareHomeRepository(RepositoryImpl deployedRepository) {
// Publish home with the highest service ranking
Hashtable<String, Object> regProps = new Hashtable<>();
- regProps.put(NodeConstants.CN, NodeConstants.EGO);
+ regProps.put(NodeConstants.CN, NodeConstants.EGO_REPOSITORY);
regProps.put(Constants.SERVICE_RANKING, Integer.MAX_VALUE);
Repository egoRepository = new EgoRepository(deployedRepository, false);
bc.registerService(Repository.class, egoRepository, regProps);
BundleWiring wiring = bundle.adapt(BundleWiring.class);
if (wiring == null)
continue bundles;
- if (NodeConstants.NODE.equals(cn))// process all data models
+ if (NodeConstants.NODE_REPOSITORY.equals(cn))// process all data models
processWiring(cn, adminSession, wiring, processed, false);
else {
List<BundleCapability> capabilities = wiring.getCapabilities(CMS_DATA_MODEL_NAMESPACE);
boolean publishLocalRepo;
if (isStandalone && name.equals(cn))// includes the node itself
publishLocalRepo = true;
- else if (!isStandalone && cn.equals(NodeConstants.NODE))
+ else if (!isStandalone && cn.equals(NodeConstants.NODE_REPOSITORY))
publishLocalRepo = true;
else
publishLocalRepo = false;
RepositoryContext repoContext = bc.getService(reference);
String cn = (String) reference.getProperty(NodeConstants.CN);
if (cn != null) {
- if (cn.equals(NodeConstants.NODE)) {
+ if (cn.equals(NodeConstants.NODE_REPOSITORY)) {
prepareNodeRepository(repoContext.getRepository());
// TODO separate home repository
prepareHomeRepository(repoContext.getRepository());