palominolabs / sf-api-connector

Java API to Salesforce's REST and SOAP APIs
http://blog.palominolabs.com/2011/03/03/a-new-java-salesforce-api-library/
36 stars 22 forks source link

Issue when I use RestConnectionImpl.describeSObject on "User" #1

Closed gregorylaporte closed 12 years ago

gregorylaporte commented 12 years ago

Stackstrace:

com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "passwordUtilities" (class com.teamlazerbeez.crm.sf.rest.SObjectUrls), not marked as ignorable (3 known properties: , "rowTemplateUrlPath", "describeUrlPath", "sobjectUrlPath"]) at [Source: java.io.StringReader@7f0dd76d; line: 1, column: 104192](through reference chain: com.teamlazerbeez.crm.sf.rest.SObjectUrls["passwordUtilities"]) at com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:79) at com.fasterxml.jackson.databind.DeserializationContext.reportUnknownProperty(DeserializationContext.java:568) at com.fasterxml.jackson.databind.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:650) at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownProperty(BeanDeserializerBase.java:830) at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownProperties(BeanDeserializerBase.java:850) at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeUsingPropertyBased(BeanDeserializer.java:555) at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObjectUsingNonDefault(BeanDeserializer.java:374) at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:271) at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:112) at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:336) at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeUsingPropertyBased(BeanDeserializer.java:540) at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObjectUsingNonDefault(BeanDeserializer.java:374) at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:271) at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:112) at com.fasterxml.jackson.databind.ObjectReader._bindAndClose(ObjectReader.java:937) at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:627) at com.teamlazerbeez.crm.sf.rest.RestConnectionImpl.describeSObject(RestConnectionImpl.java:86)

gregorylaporte commented 12 years ago

Here is the fix:

/*

package com.teamlazerbeez.crm.sf.rest;

import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty;

import javax.annotation.Nonnull; import javax.annotation.concurrent.Immutable;

@Immutable public final class SObjectUrls extends AbstractSObjectUrls {

private final String uiEditTemplate;

private final String uiDetailTemplate;
private final String uiNewRecord;
private final String passwordUtilities;

@JsonCreator
SObjectUrls(
        @Nonnull @JsonProperty("uiEditTemplate") String uiEditTemplate,
        @Nonnull @JsonProperty("sobject") String sobjectUrlPath,
        @Nonnull @JsonProperty("uiDetailTemplate") String uiDetailTemplate,
        @Nonnull @JsonProperty("describe") String describeUrlPath,
        @Nonnull @JsonProperty("rowTemplate") String rowTemplateUrlPath,
        @Nonnull @JsonProperty("uiNewRecord") String uiNewRecord, 
        @Nonnull @JsonProperty("passwordUtilities") String passwordUtilities){
    super(describeUrlPath, rowTemplateUrlPath, sobjectUrlPath);
    this.uiEditTemplate = uiEditTemplate;
    this.uiDetailTemplate = uiDetailTemplate;
    this.uiNewRecord = uiNewRecord;
    this.passwordUtilities = passwordUtilities;
}

@Nonnull
public String getPasswordUtilities() {
    return passwordUtilities;
}

@Nonnull
public String getUiEditTemplate() {
    return uiEditTemplate;
}

@Nonnull
public String getUiDetailTemplate() {
    return uiDetailTemplate;
}

@Nonnull
public String getUiNewRecord() {
    return uiNewRecord;
}

}

marshallpierce commented 12 years ago

Interesting; my tests still pass. Which SObject are you describing?

gregorylaporte commented 12 years ago

The object i'm trying to get is "User"

The problem was with "passwordUtilities" that wasn't define in SObjectsUrls, I joined the fix in attachement.

Thanks a lot!

Request:

_GET /services/data/v24.0/sobjects/User HTTP/1.1_X-HostCommonName: na12.salesforce.comAuthorization:OAuth ***X-PrettyPrint:1Host: na12.salesforce.comUser-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5 X-Target-URI:https://na12.salesforce.comContent-Type:application/json Connection:Keep-Alive Response:

_HTTP/1.1 200 OK_Date:Thu, 02 Aug 2012 15:26:54 GMTContent-Length:1622 Content-Type:application/json; charset=UTF-8Connection:closeServer:

{ "objectDescribe": { "name": "User", "label": "User", "updateable": true, "keyPrefix": "005", "custom": false, "urls": { "sobject": "/services/data/v24.0/sobjects/User", "describe": "/services/data/v24.0/sobjects/User/describe", "rowTemplate": "/services/data/v24.0/sobjects/User/{ID}", "passwordUtilities": "/services/data/v24.0/sobjects/User/{ID}/password" }, "searchable": true, "labelPlural": "Users", "layoutable": false, "activateable": false, "createable": true, "deprecatedAndHidden": false, "deletable": false, "customSetting": false, "feedEnabled": true, "mergeable": false, "queryable": true, "replicateable": true, "retrieveable": true, "undeletable": false, "triggerable": true }, "recentItems": [ { "attributes": { "type": "User", "url": "/services/data/v24.0/sobjects/User/_" }, "Id": "_", "Name": "***" } ]}

https://apigee.com/console

On Thu, Aug 2, 2012 at 11:25 AM, Marshall Pierce < reply@reply.github.com

wrote:

Interesting; my tests still pass. Which SObject are you describing?


Reply to this email directly or view it on GitHub:

https://github.com/teamlazerbeez/sf-api-connector/issues/1#issuecomment-7458509

marshallpierce commented 12 years ago

Thanks for finding this bug! I've committed your fix (slightly modified -- that field is null for objects other than User, it looks like) with tests to make sure that all other objects work.

gregorylaporte commented 12 years ago

Thanks!!

Gregory

On 2012-08-02, at 11:59, Marshall Pierce reply@reply.github.com wrote:

Thanks for finding this bug! I've committed your fix (slightly modified -- that field is null for objects other than User, it looks like) with tests to make sure that all other objects work.


Reply to this email directly or view it on GitHub: https://github.com/teamlazerbeez/sf-api-connector/issues/1#issuecomment-7459582