[ 
https://issues.apache.org/jira/browse/OODT-118?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12985237#action_12985237
 ] 

Chris A. Mattmann commented on OODT-118:
----------------------------------------

OK, I've got a work-around for this. Interestingly enough, Paul decided to 
*not* use the same approach in updating metadata in the staging area, as he did 
for the catalog, see this:

{code:java}
  @POST
  @Path(STAGING)
  @Consumes("application/x-www-form-urlencoded")
  @Produces("text/plain")
  public String setStagingMetadata(MultivaluedMap<String, String> formParams) {
    try {
      this.writeMetFile(formParams.getFirst("id"), this
          .getMetadataFromMap(formParams));
    } catch (Exception e) {
      return "<div class=\"error\">" + e.getMessage() + "</div>";
    }
    return "";
  }
{code}

Note there he is calling formParams.getFirst to get the id field instead of 
making it an explicit method param and attaching the @FormParam tag to it like 
he did in:

{code:java}
  @POST
  @Path(CATALOG)
  @Consumes("application/x-www-form-urlencoded")
  @Produces("text/plain")
  public String setCatalogMetadata(MultivaluedMap<String, String> formParams,
      @FormParam("id") String id) {
    Product prod;
    Metadata metadata = this.getMetadataFromMap(formParams);
    String productId = id.substring(id.lastIndexOf("/") + 1);

    try {
      prod = CurationService.config.getFileManagerClient().getProductById(
          productId);
      this.updateCatalogMetadata(prod, metadata);
    } catch (Exception e) {
      e.printStackTrace();
      return "<div class=\"error\">" + e.getMessage() + "</div>";
    }

    return this.getMetadataAsHTML(metadata);
  }
{code}

Note, here is my proposed fix:

{code:java}
  @POST
  @Path(CATALOG)
  @Consumes("application/x-www-form-urlencoded")
  @Produces("text/plain")
  public String setCatalogMetadata(MultivaluedMap<String, String> formParams,
      @FormParam("id") String id) {
    Product prod;
    Metadata metadata = this.getMetadataFromMap(formParams);
    
    //FIXME: when https://issues.apache.org/jira/browse/CXF-3274
    //is addressed
    if (id == null) id = formParams.getFirst("id");
    String productId = id.substring(id.lastIndexOf("/") + 1);

    try {
      prod = CurationService.config.getFileManagerClient().getProductById(
          productId);
      this.updateCatalogMetadata(prod, metadata);
    } catch (Exception e) {
      e.printStackTrace();
      return "<div class=\"error\">" + e.getMessage() + "</div>";
    }

    return this.getMetadataAsHTML(metadata);
  }

{code}

I'll commit this shortly. It still seems odd to me that CXF doesn't directly 
support this -- since it seemed like Jersey did (maybe incorrectly?)

> CAS Curator doesn't allow metadata update on file manager browser
> -----------------------------------------------------------------
>
>                 Key: OODT-118
>                 URL: https://issues.apache.org/jira/browse/OODT-118
>             Project: OODT
>          Issue Type: Bug
>          Components: curator
>    Affects Versions: 0.1-incubating
>         Environment: Testing out locally
>            Reporter: Chris A. Mattmann
>            Assignee: Chris A. Mattmann
>            Priority: Blocker
>             Fix For: 0.2
>
>
> While fixing OODT-116 I found out that the curator doesn't allow metadata to 
> be updated in the catalog. This is a direct result of porting over to Apache 
> CXF from the old Jersey dependencies. As it turns out line 260 in 
> MetadataResource gives an NPE which is the cause of the error. The root cause 
> is trickier though -- it has to do with @FormParam("id") being null and 
> @Consumes("application/x-www-form-urlencoded"). If you see this issue here 
> http://osdir.com/ml/issues-cxf-apache/2010-03/msg00129.html I think what they 
> are saying is that old versions of Apache CXF pre version 2.3 (we are 
> currently on 2.2.7 in curator) don't support this correctly. So I am going to 
> try upgrading to CXF 2.3.0 (which looks like the latest release for Jax RS) 
> and see if that fixes it.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to