141 lines
4.3 KiB
Java
141 lines
4.3 KiB
Java
package org.gcube.smartgears.connector.resourceregistry;
|
|
|
|
import java.util.Set;
|
|
import java.util.UUID;
|
|
|
|
import org.gcube.smartgears.connector.resourceregistry.resourcemanager.HostingNodeManager;
|
|
import org.gcube.smartgears.context.Property;
|
|
import org.gcube.smartgears.context.application.ApplicationContext;
|
|
import org.gcube.smartgears.context.container.ContainerContext;
|
|
import org.gcube.smartgears.publishing.Publisher;
|
|
import org.gcube.smartgears.publishing.SmartgearsProfilePublisher;
|
|
import org.gcube.smartgears.security.AuthorizationProvider;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
@SmartgearsProfilePublisher
|
|
public class FacetBasedPublisher implements Publisher {
|
|
|
|
|
|
private static Logger logger = LoggerFactory.getLogger(FacetBasedPublisher.class);
|
|
|
|
@Override
|
|
public boolean create(ContainerContext containerContext, Set<String> contexts) {
|
|
// Used at startup and in add to context
|
|
HostingNodeManager hostingNodeManager = new HostingNodeManager(containerContext);
|
|
AuthorizationProvider authorizationProvider = containerContext.configuration().authorizationProvider();
|
|
boolean first = true;
|
|
for (String context : contexts) {
|
|
try {
|
|
UUID contextUUID = ContextUtility.getContextUUID(context);
|
|
if(first) {
|
|
hostingNodeManager.createHostingNode();
|
|
Property property = new Property(Constants.HOSTING_NODE_MANAGER_PROPERTY, hostingNodeManager);
|
|
containerContext.properties().add(property);
|
|
first = false;
|
|
}else {
|
|
|
|
}
|
|
}catch (Exception e) {
|
|
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public boolean create(ApplicationContext applicationContext, Set<String> contexts) {
|
|
// Used at startup and in add to context
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public boolean remove(ApplicationContext applicationContext, Set<String> contexts) {
|
|
// Remove from contexts
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public boolean remove(ContainerContext containerContext, Set<String> contexts) {
|
|
// Remove from contexts
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public boolean update(ApplicationContext applicationContext) {
|
|
// Periodic updates
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public boolean update(ContainerContext containerContext) {
|
|
// Periodic updates
|
|
return false;
|
|
}
|
|
|
|
|
|
|
|
// @Override
|
|
// public boolean publishContainer(ContainerContext containerContext, Set<String> contexts) {
|
|
// HostingNodeManager hostingNodeManager = new HostingNodeManager(containerContext);
|
|
//
|
|
// AuthorizationProvider authorizationProvider = containerContext.configuration().authorizationProvider();
|
|
// Set<String> authorizedContexts = authorizationProvider.getContexts();
|
|
// for (String context : authorizedContexts) {
|
|
//
|
|
// }
|
|
// return true;
|
|
// }
|
|
//
|
|
// @Override
|
|
// public boolean publishApplication(ApplicationContext applicationContext, Set<String> contexts) {
|
|
// EServiceManager eServiceManager = new EServiceManager(applicationContext);
|
|
//
|
|
// AuthorizationProvider provider = applicationContext.container().configuration().authorizationProvider();
|
|
//
|
|
// for (String context : provider.getContexts())
|
|
// try {
|
|
// logger.info("publishing application in context {}", context);
|
|
// AuthorizedTasks.executeSafely(new Runnable() {
|
|
//
|
|
// @Override
|
|
// public void run() {
|
|
// try {
|
|
// logger.info("(inside task)publishing application in context {}", context);
|
|
// String resource = toXml(enpoint);
|
|
// registry.getStubs().create(resource, enpoint.type().toString());
|
|
// logger.debug("publisher resource in context {} : {}",context, resource);
|
|
// }catch (Exception e) {
|
|
// logger.error("erro publishing application", e);
|
|
// throw new RuntimeException(e);
|
|
// }
|
|
//
|
|
// }
|
|
// }, provider.getSecretForContext(context));
|
|
// }catch (Throwable e) {
|
|
// logger.error("error publisshing application profile in context {}", context, e);
|
|
// }
|
|
//
|
|
// return true;
|
|
// }
|
|
//
|
|
// @Override
|
|
// public boolean unpublishContainer(ContainerContext container, Set<String> contexts) {
|
|
// // TODO Auto-generated method stub
|
|
// return false;
|
|
// }
|
|
//
|
|
// @Override
|
|
// public boolean unpublishApplication(ApplicationContext application, Set<String> contexts) {
|
|
// // TODO Auto-generated method stub
|
|
// return false;
|
|
// }
|
|
//
|
|
// private String toXml(Resource resource){
|
|
// StringWriter writer = new StringWriter();
|
|
// Resources.marshal(resource, writer);
|
|
// return writer.toString();
|
|
// }
|
|
|
|
}
|