Changeset 1250


Ignore:
Timestamp:
04/27/11 13:27:18 (13 years ago)
Author:
twagoo
Message:

Also accept group name on update & publish profile

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/ComponentRegistryRestService.java

    r1244 r1250  
    5454    @Context
    5555    private HttpServletRequest request;
    56 
    5756    private final static Logger LOG = LoggerFactory.getLogger(ComponentRegistryRestService.class);
    58 
    5957    public static final String DATA_FORM_FIELD = "data";
    6058    public static final String NAME_FORM_FIELD = "name";
     
    9290    @GET
    9391    @Path("/components")
    94     @Produces( { MediaType.TEXT_XML, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
     92    @Produces({MediaType.TEXT_XML, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
    9593    public List<ComponentDescription> getRegisteredComponents(@QueryParam(USERSPACE_PARAM) @DefaultValue("false") boolean userspace) {
    9694        long start = System.currentTimeMillis();
     
    103101    @GET
    104102    @Path("/profiles")
    105     @Produces( { MediaType.TEXT_XML, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
     103    @Produces({MediaType.TEXT_XML, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
    106104    public List<ProfileDescription> getRegisteredProfiles(@QueryParam(USERSPACE_PARAM) @DefaultValue("false") boolean userspace) {
    107105        long start = System.currentTimeMillis();
     
    114112    @GET
    115113    @Path("/components/{componentId}")
    116     @Produces( { MediaType.TEXT_XML, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
     114    @Produces({MediaType.TEXT_XML, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
    117115    public CMDComponentSpec getRegisteredComponent(@PathParam("componentId") String componentId,
    118116            @QueryParam(USERSPACE_PARAM) @DefaultValue("false") boolean userspace) {
     
    123121    @GET
    124122    @Path("/components/{componentId}/{rawType}")
    125     @Produces( { MediaType.TEXT_XML, MediaType.APPLICATION_XML })
     123    @Produces({MediaType.TEXT_XML, MediaType.APPLICATION_XML})
    126124    public Response getRegisteredComponentRawType(@PathParam("componentId") final String componentId, @PathParam("rawType") String rawType) {
    127125        LOG.info("Component with id: " + componentId + " and rawType:" + rawType + " is requested.");
     
    136134        if ("xml".equalsIgnoreCase(rawType)) {
    137135            result = new StreamingOutput() {
     136
    138137                public void write(OutputStream output) throws IOException, WebApplicationException {
    139138                    registry.getMDComponentAsXml(componentId, output);
     
    142141        } else if ("xsd".equalsIgnoreCase(rawType)) {
    143142            result = new StreamingOutput() {
     143
    144144                public void write(OutputStream output) throws IOException, WebApplicationException {
    145145                    registry.getMDComponentAsXsd(componentId, output);
     
    172172    @GET
    173173    @Path("/profiles/{profileId}")
    174     @Produces( { MediaType.TEXT_XML, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
     174    @Produces({MediaType.TEXT_XML, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
    175175    public CMDComponentSpec getRegisteredProfile(@PathParam("profileId") String profileId,
    176176            @QueryParam(USERSPACE_PARAM) @DefaultValue("false") boolean userspace) {
     
    203203    public Response publishRegisteredProfile(@PathParam("profileId") String profileId, @FormDataParam(DATA_FORM_FIELD) InputStream input,
    204204            @FormDataParam(NAME_FORM_FIELD) String name, @FormDataParam(DESCRIPTION_FORM_FIELD) String description,
    205             @FormDataParam(DOMAIN_FORM_FIELD) String domainName) {
     205            @FormDataParam(GROUP_FORM_FIELD) String group, @FormDataParam(DOMAIN_FORM_FIELD) String domainName) {
    206206        Principal principal = checkAndGetUserPrincipal();
    207207        ProfileDescription desc = getRegistry(true).getProfileDescription(profileId);
    208208        if (desc != null) {
    209             updateDescription(desc, name, description, domainName, null);
     209            updateDescription(desc, name, description, domainName, group);
    210210            return register(input, desc, getUserCredentials(principal), true, new PublishAction(principal));
    211211        } else {
     
    221221            @QueryParam(USERSPACE_PARAM) @DefaultValue("false") boolean userspace, @FormDataParam(DATA_FORM_FIELD) InputStream input,
    222222            @FormDataParam(NAME_FORM_FIELD) String name, @FormDataParam(DESCRIPTION_FORM_FIELD) String description,
    223             @FormDataParam(DOMAIN_FORM_FIELD) String domainName) {
     223            @FormDataParam(GROUP_FORM_FIELD) String group, @FormDataParam(DOMAIN_FORM_FIELD) String domainName) {
    224224        Principal principal = checkAndGetUserPrincipal();
    225225        UserCredentials userCredentials = getUserCredentials(principal);
    226226        ProfileDescription desc = getRegistry(userspace).getProfileDescription(profileId);
    227227        if (desc != null) {
    228             updateDescription(desc, name, description, domainName, null);
     228            updateDescription(desc, name, description, domainName, group);
    229229            return register(input, desc, userCredentials, userspace, new UpdateAction());
    230230        } else {
     
    344344    @GET
    345345    @Path("/profiles/{profileId}/{rawType}")
    346     @Produces( { MediaType.TEXT_XML, MediaType.APPLICATION_XML })
     346    @Produces({MediaType.TEXT_XML, MediaType.APPLICATION_XML})
    347347    public Response getRegisteredProfileRawType(@PathParam("profileId") final String profileId, @PathParam("rawType") String rawType) {
    348348        LOG.info("Profile with id: " + profileId + " and rawType:" + rawType + " is requested.");
     
    358358        if ("xml".equalsIgnoreCase(rawType)) {
    359359            result = new StreamingOutput() {
     360
    360361                public void write(OutputStream output) throws IOException, WebApplicationException {
    361362                    registry.getMDProfileAsXml(profileId, output);
     
    364365        } else if ("xsd".equalsIgnoreCase(rawType)) {
    365366            result = new StreamingOutput() {
     367
    366368                public void write(OutputStream output) throws IOException, WebApplicationException {
    367369                    registry.getMDProfileAsXsd(profileId, output);
     
    391393    @POST
    392394    @Path("/profiles")
    393     @Produces( { MediaType.TEXT_XML, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
     395    @Produces({MediaType.TEXT_XML, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
    394396    @Consumes("multipart/form-data")
    395397    public Response registerProfile(@FormDataParam(DATA_FORM_FIELD) InputStream input, @FormDataParam(NAME_FORM_FIELD) String name,
     
    411413    @POST
    412414    @Path("/components")
    413     @Produces( { MediaType.TEXT_XML, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
     415    @Produces({MediaType.TEXT_XML, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
    414416    @Consumes("multipart/form-data")
    415417    public Response registerComponent(@FormDataParam(DATA_FORM_FIELD) InputStream input, @FormDataParam(NAME_FORM_FIELD) String name,
     
    431433    @GET
    432434    @Path("/pingSession")
    433     @Produces( { MediaType.TEXT_XML, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
     435    @Produces({MediaType.TEXT_XML, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
    434436    public Response pingSession() {
    435437        boolean stillActive = false;
Note: See TracChangeset for help on using the changeset viewer.