@@ -2046,45 +2046,39 @@ public Response updateTemplateMetadata(@Context ContainerRequestContext crc, Str
20462046 /*
20472047 You can also set a new name for your template in the json
20482048 */
2049-
20502049 if (json .containsKey ("name" ) && !json .getString ("name" ).isBlank ()) {
2051- template .setName (json .getString ("name" ));
2052- nameOnly = true ;
2050+ template .setName (json .getString ("name" ));
2051+ nameOnly = true ;
20532052 }
2054-
20552053
20562054 List <DatasetField > updatedFields = new ArrayList <>();
20572055 //if it doesn't contain fields, instructions or name it better have a single dataset field
20582056 //to be updated
20592057 if (json .getJsonArray ("fields" ) == null ) {
2060- if (!json .containsKey ("instructions" ) && !json .containsKey ("name" )){
2058+ if (!json .containsKey ("instructions" ) && !json .containsKey ("name" )) {
20612059 updatedFields .add (jsonParser ().parseField (json , Boolean .FALSE , replaceData ));
20622060 }
20632061 } else {
20642062 updatedFields = jsonParser ().parseMultipleFields (json , replaceData );
2065- }
2063+ }
20662064
20672065 Map <String , String > instructionsMap = jsonParser ().parseRequestBodyInstructionsMap (json );
2068-
2069-
2066+
20702067 //if we're only updating the name then return the metadata and instructions to previous
2071- nameOnly = nameOnly && updatedFields .isEmpty () && instructionsMap == null ;
2072-
2073- if (nameOnly ){
2068+ nameOnly = nameOnly && updatedFields .isEmpty () && instructionsMap == null ;
2069+
2070+ if (nameOnly ) {
20742071 updatedFields = template .getDatasetFields ();
20752072 instructionsMap = template .getInstructionsMap ();
20762073 }
2077-
20782074
2079-
2080- Template updated = execCommand (new UpdateTemplateFieldsCommand (template , dataverse , updatedFields , instructionsMap , replaceData , createDataverseRequest (getRequestUser (crc ))));
2081-
2075+ Template updated = execCommand (new UpdateTemplateFieldsCommand (template , dataverse , updatedFields , instructionsMap , replaceData , createDataverseRequest (getRequestUser (crc ))));
2076+
20822077 return created ("/dataverses/template/" + updated .getId (), jsonTemplate (updated ));
2083- } catch (JsonParseException ex ) {
2078+ } catch (JsonParseException ex ) {
20842079 logger .log (Level .SEVERE , "Semantic error parsing dataset update Json: " + ex .getMessage (), ex );
20852080 return error (Response .Status .BAD_REQUEST , BundleUtil .getStringFromBundle ("datasets.api.editMetadata.error.parseUpdate" , List .of (ex .getMessage ())));
2086-
2087-
2081+
20882082 } catch (WrappedResponse e ) {
20892083 return e .getResponse ();
20902084 }
0 commit comments