001/* 002 * Licensed to DuraSpace under one or more contributor license agreements. 003 * See the NOTICE file distributed with this work for additional information 004 * regarding copyright ownership. 005 * 006 * DuraSpace licenses this file to you under the Apache License, 007 * Version 2.0 (the "License"); you may not use this file except in 008 * compliance with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.fcrepo.camel.processor; 019 020import static java.net.URLEncoder.encode; 021 022import java.io.IOException; 023 024import org.apache.camel.Exchange; 025import org.apache.camel.Message; 026import org.apache.camel.Processor; 027 028/** 029 * Represents a Processor class that formulates a Sparql DESCRIBE query 030 * that is ready to be POSTed to a Sparql endpoint. 031 * 032 * The processor expects the following headers: 033 * org.fcrepo.jms.identifier 034 * org.fcrepo.jms.baseURL 035 * each of which can be overridden with the following: 036 * FCREPO_IDENTIFIER 037 * FCREPO_BASE_URL 038 * 039 * @author Aaron Coburn 040 * @since November 6, 2014 041 */ 042public class SparqlDescribeProcessor implements Processor { 043 /** 044 * Define how this message should be processed 045 * 046 * @param exchange the current camel message exchange 047 */ 048 public void process(final Exchange exchange) throws IOException { 049 050 final Message in = exchange.getIn(); 051 final String subject = ProcessorUtils.getSubjectUri(in); 052 053 exchange.getIn().setBody("query=" + encode("DESCRIBE <" + subject + ">", "UTF-8")); 054 exchange.getIn().setHeader(Exchange.HTTP_METHOD, "POST"); 055 exchange.getIn().setHeader(Exchange.ACCEPT_CONTENT_TYPE, "application/rdf+xml"); 056 exchange.getIn().setHeader(Exchange.CONTENT_TYPE, "application/x-www-form-urlencoded; charset=utf-8"); 057 } 058}