io.rny.dropwizard.cmis.managed.ManagedCmisBinding Maven / Gradle / Ivy
package io.rny.dropwizard.cmis.managed;
import io.dropwizard.lifecycle.Managed;
import io.rny.dropwizard.cmis.config.CmisConfiguration;
import org.apache.chemistry.opencmis.client.bindings.CmisBindingFactory;
import org.apache.chemistry.opencmis.commons.SessionParameter;
import org.apache.chemistry.opencmis.commons.spi.CmisBinding;
import java.util.HashMap;
import java.util.Map;
import static com.google.common.base.Preconditions.checkNotNull;
public class ManagedCmisBinding implements Managed {
private CmisBinding cmisBinding;
private Map parameters;
private CmisBindingFactory factory;
public ManagedCmisBinding(final CmisConfiguration config) {
checkNotNull(config, "CMISConfiguration must not be null");
parameters = new HashMap<>();
parameters.put(SessionParameter.USER, config.getCmisUser());
parameters.put(SessionParameter.PASSWORD, config.getCmisPassword());
parameters.put(SessionParameter.ATOMPUB_URL, config.getCmisUrl());
factory = CmisBindingFactory.newInstance();
}
@Override
public void start() throws Exception {
this.cmisBinding = factory.createCmisAtomPubBinding(parameters);
}
@Override
public void stop() throws Exception {
this.cmisBinding.close();
}
public CmisBinding getCmisBinding() {
return cmisBinding;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy