diff --git a/.gitignore b/.gitignore index 08023a5ad2..f6185e2882 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,4 @@ nb-configuration.xml ##Ignore JRebel project configuration rebel.xml + diff --git a/dspace-spring-rest/src/main/java/org/dspace/app/rest/repository/BitstreamRestRepository.java b/dspace-spring-rest/src/main/java/org/dspace/app/rest/repository/BitstreamRestRepository.java index cb4f648ee8..dc7f042a11 100644 --- a/dspace-spring-rest/src/main/java/org/dspace/app/rest/repository/BitstreamRestRepository.java +++ b/dspace-spring-rest/src/main/java/org/dspace/app/rest/repository/BitstreamRestRepository.java @@ -26,6 +26,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; +import org.springframework.data.rest.webmvc.ResourceNotFoundException; import org.springframework.stereotype.Component; @@ -53,6 +54,9 @@ public class BitstreamRestRepository extends DSpaceRestRepository { } - public static BitstreamBuilder createLogoBitstream(Context context, Community community, InputStream is) - throws SQLException, AuthorizeException, IOException { - BitstreamBuilder builder = new BitstreamBuilder(context); - return builder.create_logo(context, community, is); - } - - private BitstreamBuilder create_logo(Context context, Community community, InputStream is) - throws SQLException, AuthorizeException, IOException { - this.context = context; - this.community = community; - - bitstream = bitstreamService.create(context, is); - - return this; - } - public static BitstreamBuilder createBitstream(Context context, Item item, InputStream is) throws SQLException, AuthorizeException, IOException { BitstreamBuilder builder = new BitstreamBuilder(context); return builder.create(context, item, is); } + public static BitstreamBuilder createLogo(Context context, Community community, InputStream is) + throws SQLException, AuthorizeException, IOException { + BitstreamBuilder builder = new BitstreamBuilder(context); + return builder.logo(context, community, is); + } + private BitstreamBuilder create(Context context, Item item, InputStream is) throws SQLException, AuthorizeException, IOException { this.context = context; @@ -75,6 +65,16 @@ public class BitstreamBuilder extends AbstractDSpaceObjectBuilder { return this; } + private BitstreamBuilder logo(Context context, Community community, InputStream is) + throws SQLException, AuthorizeException, IOException { + this.context = context; + this.community = community; + + bitstream = communityService.setLogo(context, community, is); + + return this; + } + public BitstreamBuilder withName(String name) throws SQLException { bitstream.setName(context, name); return this; @@ -140,6 +140,23 @@ public class BitstreamBuilder extends AbstractDSpaceObjectBuilder { return bitstream; } + public Bitstream buildLogo() { + try { + bitstreamService.update(context, bitstream); + communityService.update(context, community); + + context.dispatchEvents(); + + indexingService.commit(); + + } catch (Exception e) { + System.out.println(e); + return null; + } + + return bitstream; + } + protected void cleanup() throws Exception { delete(bitstream); }