use of org.eclipse.winery.common.interfaces.QNameAlreadyExistsException in project winery by eclipse.
the class WineryRepositoryClient method createComponent.
@Override
public void createComponent(QName qname, Class<? extends DefinitionsChildId> idClass) throws QNameAlreadyExistsException {
WebResource resource = this.primaryWebResource.path(Util.getRootPathFragment(idClass));
MultivaluedMap<String, String> map = new MultivaluedMapImpl();
map.putSingle("namespace", qname.getNamespaceURI());
map.putSingle("name", qname.getLocalPart());
ClientResponse response = resource.type(MediaType.APPLICATION_FORM_URLENCODED).accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, map);
if (response.getClientResponseStatus() != ClientResponse.Status.CREATED) {
// TODO: pass ClientResponse.Status somehow
// TODO: more fine grained checking for error message. Not all failures are that the QName already exists
LOGGER.debug(String.format("Error %d when creating id %s from URI %s", response.getStatus(), qname.toString(), this.primaryWebResource.getURI().toString()));
throw new QNameAlreadyExistsException();
}
// no further return is made
}
use of org.eclipse.winery.common.interfaces.QNameAlreadyExistsException in project winery by eclipse.
the class WineryRepositoryClient method createArtifactTemplate.
/**
* Does NOT check for global QName uniqueness, only in the scope of all
* artifact templates
*/
@Override
public void createArtifactTemplate(QName qname, QName artifactType) throws QNameAlreadyExistsException {
WebResource artifactTemplates = this.primaryWebResource.path("artifacttemplates");
MultivaluedMap<String, String> map = new MultivaluedMapImpl();
map.putSingle("namespace", qname.getNamespaceURI());
map.putSingle("name", qname.getLocalPart());
map.putSingle("type", artifactType.toString());
ClientResponse response = artifactTemplates.type(MediaType.APPLICATION_FORM_URLENCODED).accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, map);
if (response.getClientResponseStatus() != ClientResponse.Status.CREATED) {
// TODO: pass ClientResponse.Status somehow
// TODO: more fine grained checking for error message. Not all
// failures are that the QName already exists
LOGGER.debug(String.format("Error %d when creating id %s from URI %s", response.getStatus(), qname.toString(), this.primaryWebResource.getURI().toString()));
throw new QNameAlreadyExistsException();
}
// no further return is made
}
Aggregations