ExternalSystemObjectSetService.java revision 620865564adab361873e1e245aad56c91ffb9f13
/*
* 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]"
* $Id$
*/
/**
* ExternalSystemObjectSetService implement the {@link org.forgerock.openidm.objset.ObjectSet}.
*
* @author $author$
* @version $Revision$ $Date$
*/
@Component(name = "org.forgerock.openidm.provisioner.rest", policy = ConfigurationPolicy.IGNORE, description = "OpenIDM System Object Set REST Service")
@Properties({
//@Property(name = "openidm.router.prefix", value = "external-system"), // internal object set router
})
public class ExternalSystemObjectSetService implements ObjectSet {
/**
* The name of the system property that can be used to enable
* for the debug on startup.
*/
public static final String PROPERTY_DEBUG_ENABLE =
"org.forgerock.openidm.server.debug.enable";
target = "(service.pid=org.forgerock.openidm.router)")
target = "(service.pid=org.forgerock.openidm.provisioner)")
private ObjectSet provisioner;
}
}
/**
* Creates a new object in the object set.
* <p/>
* This method sets the {@code _id} property to the assigned identifier for the object,
* and the {@code _rev} property to the revised object version if optimistic concurrency
* is supported.
*
* @param id the client-generated identifier to use, or {@code null} if server-generated identifier is requested.
* @param object the contents of the object to create in the object set.
* @throws org.forgerock.openidm.objset.NotFoundException
* if the specified id could not be resolve.
* @throws org.forgerock.openidm.objset.ForbiddenException
* if access to the object or object set is forbidden.
*/
@Override // ObjectSet
// Id identifier = new Id(id);
}
/**
* Reads an object from the object set.
* <p/>
* The object will contain metadata properties, including object identifier {@code _id},
* and object version {@code _rev} if optimistic concurrency is supported. If optimistic
* concurrency is not supported, then {@code _rev} must be absent or {@code null}.
*
* @param id the identifier of the object to retrieve from the object set.
* @return the requested object.
* @throws org.forgerock.openidm.objset.NotFoundException
* if the specified object could not be found.
* @throws org.forgerock.openidm.objset.ForbiddenException
* if access to the object is forbidden.
*/
@Override // ObjectSet
// Id identifier = new Id(id);
// Map<String, Object> object = null;
// return object;
return null;
}
/**
* Updates an existing specified object in the object set.
* <p/>
* This method updates the {@code _rev} property to the revised object version on update
* if optimistic concurrency is supported.
*
* @param id the identifier of the object to be updated.
* @param rev the version of the object to update; or {@code null} if not provided.
* @param object the contents of the object to updated in the object set.
* @throws org.forgerock.openidm.objset.ConflictException
* if version is required but is {@code null}.
* @throws org.forgerock.openidm.objset.ForbiddenException
* if access to the object is forbidden.
* @throws org.forgerock.openidm.objset.NotFoundException
* if the specified object could not be found.
* @throws org.forgerock.openidm.objset.PreconditionFailedException
* if version did not match the existing object in the set.
*/
@Override // ObjectSet
// Id identifier = new Id(id);
}
/**
* Deletes the specified object from the object set.
*
* @param id the identifier of the object to be deleted.
* @param rev the version of the object to delete or {@code null} if not provided.
* @throws org.forgerock.openidm.objset.NotFoundException
* if the specified object could not be found.
* @throws org.forgerock.openidm.objset.ForbiddenException
* if access to the object is forbidden.
* @throws org.forgerock.openidm.objset.ConflictException
* if version is required but is {@code null}.
* @throws org.forgerock.openidm.objset.PreconditionFailedException
* if version did not match the existing object in the set.
*/
@Override // ObjectSet
// Id identifier = new Id(id);
}
/**
* 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 org.forgerock.openidm.objset.ConflictException
* if patch could not be applied object state or if version is required.
* @throws org.forgerock.openidm.objset.ForbiddenException
* if access to the object is forbidden.
* @throws org.forgerock.openidm.objset.NotFoundException
* if the specified object could not be found.
* @throws org.forgerock.openidm.objset.PreconditionFailedException
* if version did not match the existing object in the set.
*/
@Override // ObjectSet
// Id identifier = new Id(id);
}
/**
* Performs a query on the specified object and returns the associated results.
* <p/>
* Queries are parametric; a set of named parameters is provided as the query criteria.
* The query result is a JSON object structure composed of basic Java types.
*
* @param id identifies the object to query.
* @param params the parameters of the query to perform.
* @return the query results object.
* @throws org.forgerock.openidm.objset.NotFoundException
* if the specified object could not be found.
* @throws org.forgerock.openidm.objset.ForbiddenException
* if access to the object or specified query is forbidden.
*/
@Override // ObjectSet
// Id identifier = new Id(id);
return result;
}
@Override // ObjectSet
public Map<String, Object> action(String id, Map<String, Object> params) throws ObjectSetException {
throw new BadRequestException("Missing required _action parameter");
}
//Throws org.forgerock.json.fluent.JsonNodeException if the action is not supported.
case EXECUTESCRIPT:
//TODO Use the _scriptid to retrieve the storedObject
continue;
}
}
}
break;
case DEBUGEXECUTESCRIPT:
if (isDebugEnabled()) {
}
} else {
throw new ForbiddenException("Action is only allowed in debug mode");
}
break;
case GETCONFIGURATION:
//TODO resolve circular reference for ConnectorInfoProviderService via admin interface
break;
}
ActivityLog.log(getRouter(), Action.ACTION, "Action parameters " + params, id, result, null, Status.SUCCESS);
return result;
}
return router;
}
private ObjectSet getProvisioner() {
return provisioner;
}
private boolean isDebugEnabled() {
}
private void validateActionRequest(SystemAction action, String id, Map<String, Object> params) throws ObjectSetException {
throw new BadRequestException("Missing required id");
}
throw new BadRequestException("Missing required attribute(s) " + action.getRequiredAttributes().toString());
}
}
private enum SystemAction {
GETCONFIGURATION(null, true);
private boolean requireId = true;
}
return requiredAttributes;
}
public boolean isRequireId() {
return requireId;
}
}
}