RestService.java revision 88f2d7061bb42999901dcff81c37089b000d32e0
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright © 2011 ForgeRock AS. All rights reserved.
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*/
//import org.forgerock.openidm.core.IdentityServer;
/**
* External REST connectivity
*
* @author aegloff
*/
@Component(name = RestService.PID, immediate=true, policy=ConfigurationPolicy.OPTIONAL, enabled=true)
@Properties({
})
public class RestService implements ObjectSet {
// Keys in the JSON configuration
//public static final String CONFIG_X = "X";
// Keys in the request parameters to override config
/**
* Currently not supported by this implementation.
*
* Gets an object from the repository by identifier.
*
* @param fullId the identifier of the object to retrieve from the object set.
* @throws NotFoundException if the specified object could not be found.
* @throws ForbiddenException if access to the object is forbidden.
* @throws BadRequestException if the passed identifier is invalid
* @return the requested object.
*/
throw new UnsupportedOperationException();
}
/**
* Currently not supported by this implementation.
*
* Creates a new object in the object set.
*
* @param fullId the client-generated identifier to use, or {@code null} if server-generated identifier is requested.
* @param obj the contents of the object to create in the object set.
* @throws NotFoundException if the specified id could not be resolved.
* @throws ForbiddenException if access to the object or object set is forbidden.
* @throws PreconditionFailedException if an object with the same ID already exists.
*/
throw new UnsupportedOperationException();
}
/**
* Currently not supported by this implementation.
*
* Updates the specified object in the object set.
*
* @param fullId the identifier of the object to be put, or {@code null} to request a generated identifier.
* @param rev the version of the object to update; or {@code null} if not provided.
* @param obj the contents of the object to put in the object set.
* @throws ConflictException if version is required but is {@code null}.
* @throws ForbiddenException if access to the object is forbidden.
* @throws NotFoundException if the specified object could not be found.
* @throws PreconditionFailedException if version did not match the existing object in the set.
* @throws BadRequestException if the passed identifier is invalid
*/
throw new UnsupportedOperationException();
}
/**
* Currently not supported by this implementation.
*
* Deletes the specified object from the object set.
*
* @param fullId the identifier of the object to be deleted.
* @param rev the version of the object to delete or {@code null} if not provided.
* @throws NotFoundException if the specified object could not be found.
* @throws ForbiddenException if access to the object is forbidden.
* @throws ConflictException if version is required but is {@code null}.
* @throws PreconditionFailedException if version did not match the existing object in the set.
*/
throw new UnsupportedOperationException();
}
/**
* Currently not supported by this implementation.
*
* Applies a patch (partial change) to the specified object in the object set.
*
* @param id the identifier of the object to be patched.
* @param rev the version of the object to patch or {@code null} if not provided.
* @param patch the partial change to apply to the object.
* @throws ConflictException if patch could not be applied object state or if version is required.
* @throws ForbiddenException if access to the object is forbidden.
* @throws NotFoundException if the specified object could not be found.
* @throws PreconditionFailedException if version did not match the existing object in the set.
*/
throw new UnsupportedOperationException();
}
/**
* Currently not supported by this implementation.
*
* Performs the query on the specified object and returns the associated results.
*
* @param fullId identifies the object to query.
* @param params the parameters of the query to perform.
* @return the query results, which includes meta-data and the result records in JSON object structure format.
* @throws NotFoundException if the specified object could not be found.
* @throws BadRequestException if the specified params contain invalid arguments, e.g. a query id that is not
* configured, a query expression that is invalid, or missing query substitution tokens.
* @throws ForbiddenException if access to the object or specified query is forbidden.
*/
public Map<String, Object> query(String fullId, Map<String, Object> params) throws ObjectSetException {
throw new UnsupportedOperationException();
}
public Map<String, Object> action(String id, Map<String, Object> params) throws ObjectSetException {
//TODO: This is work in progress, expect enhancements and changes.
throw new BadRequestException("Invalid action call on " + id + " : missing parameters to define what to invoke.");
}
// Handle Document coming from external, currently wrapped in an _entity object
// TODO: Review inbound Restlet Mapping
}
//int timeout = params.get("_timeout");
// Whether the data type format to return to the caller should be inferred, or is explicitly defined
boolean detectResultFormat = true;
detectResultFormat = false;
}
throw new BadRequestException("Invalid action call on " + id + " : missing required argument " + ARG_URL);
}
try {
if (reqHeaders == null) {
}
}
}
type = "basic";
}
logger.debug("Using basic authentication for {} secret supplied: {}", identifier, (secret != null));
ChallengeResponse challengeResponse = new ChallengeResponse(ChallengeScheme.HTTP_BASIC, identifier, secret);
}
}
// Default method if none supplied
method = "post";
}
// TODO: media type arg?
} else {
}
|| (detectResultFormat && representation.getMediaType().isCompatible(MediaType.APPLICATION_JSON))) {
try {
}
}
}
}
return result;
}
try {
} catch (RuntimeException ex) {
logger.warn("Configuration invalid and could not be parsed, can not start external REST connectivity: "
throw ex;
}
}
/**
* Initialize the instance with the given configuration.
*
* @param config the configuration
*/
}
/* Currently rely on deactivate/activate to be called by DS if config changes instead
@Modified
void modified(ComponentContext compContext) {
}
*/
}
}