07-01-2013 07:43 AM
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter;
Client client = Client.create();
final HTTPBasicAuthFilter authFilter = new HTTPBasicAuthFilter(username, password);
client.addFilter(authFilter);
WebResource r = client.resource(url);
ClientResponse response = r.get(ClientResponse.class);
BusinessPartner bp = response.getEntity(BusinessPartner.class);
SEVERE: A message body reader for Java class cdq.cdl.bpr.datamodel.BusinessPartner, and Java type class cdq.cdl.bpr.datamodel.BusinessPartner, and MIME media type application/x-java-serialized-object was not found
Jul 01, 2013 1:22:53 PM com.sun.jersey.api.client.ClientResponse getEntity
SEVERE: The registered message body readers compatible with the MIME media type are:
*/* ->
com.sun.jersey.core.impl.provider.entity.FormProvider
com.sun.jersey.core.impl.provider.entity.StringProvider
com.sun.jersey.core.impl.provider.entity.ByteArrayProvider
com.sun.jersey.core.impl.provider.entity.FileProvider
com.sun.jersey.core.impl.provider.entity.InputStreamProvider
com.sun.jersey.core.impl.provider.entity.DataSourceProvider
com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider$General
com.sun.jersey.core.impl.provider.entity.ReaderProvider
com.sun.jersey.core.impl.provider.entity.DocumentProvider
com.sun.jersey.core.impl.provider.entity.SourceProvider$StreamSourceReader
com.sun.jersey.core.impl.provider.entity.SourceProvider$SAXSourceReader
com.sun.jersey.core.impl.provider.entity.SourceProvider$DOMSourceReader
com.sun.jersey.json.impl.provider.entity.JSONJAXBElementProvider$General
com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$General
com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$General
com.sun.jersey.core.impl.provider.entity.XMLRootObjectProvider$General
com.sun.jersey.core.impl.provider.entity.EntityHolderReader
com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider$General
com.sun.jersey.json.impl.provider.entity.JSONListElementProvider$General
ClientResponse response = r.type("application/json").get(ClientResponse.class);
package cdq.cdl.bpr.datamodel;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.envers.Audited;
import cdq.cdl.bpr.shared.Constants;
@Audited
@Entity
@Table(name="BusinessPartner")
public class BusinessPartner extends ValidatableEntity implements Serializable {
private static final long serialVersionUID = -4791687256196212218L;
private String id;
private String name;
private BusinessPartnerType type;
private BusinessPartner parentBusinessPartner;
private LegalData legalData;
private Set<Address> addresses;
// Metadata attributes
private String dataSteward;
private Set<String> subscribers;
public BusinessPartner() {
super();
addresses = new HashSet<Address>();
subscribers = new HashSet<String>();
legalData = new LegalData();
}
@Id
public String getId() {
return this.id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public BusinessPartner getParentBusinessPartner() {
return parentBusinessPartner;
}
public void setParentBusinessPartner(BusinessPartner parentBusinessPartner) {
this.parentBusinessPartner = parentBusinessPartner;
}
public void setParentCompany(BusinessPartner parentBusinessPartner) {
this.parentBusinessPartner = parentBusinessPartner;
}
@ManyToOne
@Cascade(CascadeType.ALL)
@JoinColumn(name="businessPartnerType")
public BusinessPartnerType getType() {
return type;
}
public void setType(BusinessPartnerType type) {
this.type = type;
}
@OneToOne
@Cascade(CascadeType.ALL)
public LegalData getLegalData() {
return legalData;
}
public void setLegalData(LegalData legalData) {
this.legalData = legalData;
}
@ManyToMany
@Cascade(CascadeType.ALL)
@Fetch(FetchMode.JOIN) // Slows down, but required (to be checked …) to load all addresses also after adding a new address
@JoinTable(name = "BusinessPartnerAddresses", joinColumns = { @JoinColumn(name = "businessPartnerId") }, inverseJoinColumns = { @JoinColumn(name = "addressId") })
public Set<Address> getAddresses() {
return addresses;
}
public void setAddresses(Set<Address> addresses) {
this.addresses = addresses;
}
public String getDataSteward() {
return dataSteward;
}
public void setDataSteward(String dataSteward) {
this.dataSteward = dataSteward;
}
@Cascade(CascadeType.ALL)
@ElementCollection
public Set<String> getSubscribers() {
return subscribers;
}
public void setSubscribers(Set<String> subscribers) {
this.subscribers = subscribers;
}
public String toString() {
String retval = "";
retval += name;
if (type != null && type.getName().equals(Constants.BusinessPartnerType.LEGAL_ENTITY)) {
retval += " " + legalData.getLegalForm();
}
if (retval.equals("")) {
return "new business partner";
}
return retval;
}
}
07-02-2013 02:58 PM
07-02-2013 04:27 PM
07-03-2013 06:46 AM
07-03-2013 06:49 AM
It's possible to support additional variable-types with a custom JSON representation (either simple value or complex/nested JSON object). By extending the initializeVariableConverters() method on org.activiti.rest.api.RestResponseFactory, you can add additional org.activiti.rest.api.engine.variable.RestVariableConverter classes to support converting your POJO's to a format suitable for transerring through REST and converting the REST-value back to your POJO. The actual transformation to JSON is done by Jackson.
10-24-2014 09:10 AM
10-27-2014 07:08 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.