@Test(expected=AuthorizeException.class) public void testSetLogoNoAuth() throws Exception { new NonStrictExpectations() { AuthorizeManager authManager; { AuthorizeManager.authorizeActionBoolean((Context) any, (Community) any, Constants.ADD,true); result = false; AuthorizeManager.authorizeActionBoolean((Context) any, (Community) any, Constants.WRITE,true); result = false; AuthorizeManager.authorizeAction((Context) any, (Collection) any, Constants.WRITE,true); result = new AuthorizeException(); } }; File f = new File(testProps.get("test.bitstream").toString()); Bitstream logo = c.setLogo(new FileInputStream(f)); fail("EXception expected"); }
public Bitstream setLogo(InputStream is) throws AuthorizeException, IOException, SQLException { if (!((is == null) && AuthorizeManager.authorizeActionBoolean( ourContext, this, Constants.DELETE))) { canEdit(true); } if (!collectionRow.isColumnNull("logo_bitstream_id")) { logo.delete(); } if (is == null) { collectionRow.setColumnNull("logo_bitstream_id"); logo = null; log.info(LogManager.getHeader(ourContext, "remove_logo", "collection_id=" + getID())); } else { Bitstream newLogo = Bitstream.create(ourContext, is); collectionRow.setColumn("logo_bitstream_id", newLogo.getID()); logo = newLogo; List<ResourcePolicy> policies = AuthorizeManager.getPoliciesActionFilter(ourContext, this, Constants.READ); AuthorizeManager.addPolicies(ourContext, policies, newLogo); log.info(LogManager.getHeader(ourContext, "set_logo", "collection_id=" + getID() + "logo_bitstream_id=" + newLogo.getID())); } modified = true; return logo; }
Collection extends DSpaceObject { public Bitstream setLogo(InputStream is) throws AuthorizeException, IOException, SQLException { if (!((is == null) && AuthorizeManager.authorizeActionBoolean( ourContext, this, Constants.DELETE))) { canEdit(true); } if (!collectionRow.isColumnNull("logo_bitstream_id")) { logo.delete(); } if (is == null) { collectionRow.setColumnNull("logo_bitstream_id"); logo = null; log.info(LogManager.getHeader(ourContext, "remove_logo", "collection_id=" + getID())); } else { Bitstream newLogo = Bitstream.create(ourContext, is); collectionRow.setColumn("logo_bitstream_id", newLogo.getID()); logo = newLogo; List<ResourcePolicy> policies = AuthorizeManager.getPoliciesActionFilter(ourContext, this, Constants.READ); AuthorizeManager.addPolicies(ourContext, policies, newLogo); log.info(LogManager.getHeader(ourContext, "set_logo", "collection_id=" + getID() + "logo_bitstream_id=" + newLogo.getID())); } modified = true; return logo; } }
Collection extends DSpaceObject { public Bitstream setLogo(InputStream is) throws AuthorizeException, IOException, SQLException { if (!((is == null) && AuthorizeManager.authorizeActionBoolean( ourContext, this, Constants.DELETE))) { canEdit(true); } if (!collectionRow.isColumnNull("logo_bitstream_id")) { logo.delete(); } if (is == null) { collectionRow.setColumnNull("logo_bitstream_id"); logo = null; log.info(LogManager.getHeader(ourContext, "remove_logo", "collection_id=" + getID())); } else { Bitstream newLogo = Bitstream.create(ourContext, is); collectionRow.setColumn("logo_bitstream_id", newLogo.getID()); logo = newLogo; List<ResourcePolicy> policies = AuthorizeManager.getPoliciesActionFilter(ourContext, this, Constants.READ); AuthorizeManager.addPolicies(ourContext, policies, newLogo); log.info(LogManager.getHeader(ourContext, "set_logo", "collection_id=" + getID() + "logo_bitstream_id=" + newLogo.getID())); } modified = true; return logo; } Collection(Context context, TableRow row); }
Collection extends DSpaceObject { public Bitstream setLogo(InputStream is) throws AuthorizeException, IOException, SQLException { if (!((is == null) && AuthorizeManager.authorizeActionBoolean( ourContext, this, Constants.DELETE))) { canEdit(true); } if (!collectionRow.isColumnNull("logo_bitstream_id")) { logo.delete(); } if (is == null) { collectionRow.setColumnNull("logo_bitstream_id"); logo = null; log.info(LogManager.getHeader(ourContext, "remove_logo", "collection_id=" + getID())); } else { Bitstream newLogo = Bitstream.create(ourContext, is); collectionRow.setColumn("logo_bitstream_id", newLogo.getID()); logo = newLogo; List<ResourcePolicy> policies = AuthorizeManager.getPoliciesActionFilter(ourContext, this, Constants.READ); AuthorizeManager.addPolicies(ourContext, policies, newLogo); log.info(LogManager.getHeader(ourContext, "set_logo", "collection_id=" + getID() + "logo_bitstream_id=" + newLogo.getID())); } modified = true; return logo; } Collection(Context context, TableRow row); static Collection find(Context context, int id); static Collection[] findAll(Context context); ItemIterator getItems(); ItemIterator getAllItems(); int getID(); String getHandle(); String getMetadata(String field); void setMetadata(String field, String value); String getName(); Bitstream getLogo(); Bitstream setLogo(InputStream is); Group createWorkflowGroup(int step); void setWorkflowGroup(int step, Group g); Group getWorkflowGroup(int step); Group createSubmitters(); void removeSubmitters(); Group getSubmitters(); Group createAdministrators(); void removeAdministrators(); Group getAdministrators(); String getLicense(); String getLicenseCollection(); boolean hasCustomLicense(); void setLicense(String license); Item getTemplateItem(); void createTemplateItem(); void removeTemplateItem(); void addItem(Item item); void removeItem(Item item); void update(); boolean canEditBoolean(); boolean canEditBoolean(boolean useInheritance); void canEdit(); void canEdit(boolean useInheritance); Community[] getCommunities(); @Override boolean equals(Object other); @Override int hashCode(); int getType(); static Collection[] findAuthorized(Context context, Community comm,
            int actionID); int countItems(); DSpaceObject getAdminObject(int action); @Override DSpaceObject getParentObject(); }
Collection extends DSpaceObject { public Bitstream setLogo(InputStream is) throws AuthorizeException, IOException, SQLException { if (!((is == null) && AuthorizeManager.authorizeActionBoolean( ourContext, this, Constants.DELETE))) { canEdit(true); } if (!collectionRow.isColumnNull("logo_bitstream_id")) { logo.delete(); } if (is == null) { collectionRow.setColumnNull("logo_bitstream_id"); logo = null; log.info(LogManager.getHeader(ourContext, "remove_logo", "collection_id=" + getID())); } else { Bitstream newLogo = Bitstream.create(ourContext, is); collectionRow.setColumn("logo_bitstream_id", newLogo.getID()); logo = newLogo; List<ResourcePolicy> policies = AuthorizeManager.getPoliciesActionFilter(ourContext, this, Constants.READ); AuthorizeManager.addPolicies(ourContext, policies, newLogo); log.info(LogManager.getHeader(ourContext, "set_logo", "collection_id=" + getID() + "logo_bitstream_id=" + newLogo.getID())); } modified = true; return logo; } Collection(Context context, TableRow row); static Collection find(Context context, int id); static Collection[] findAll(Context context); ItemIterator getItems(); ItemIterator getAllItems(); int getID(); String getHandle(); String getMetadata(String field); void setMetadata(String field, String value); String getName(); Bitstream getLogo(); Bitstream setLogo(InputStream is); Group createWorkflowGroup(int step); void setWorkflowGroup(int step, Group g); Group getWorkflowGroup(int step); Group createSubmitters(); void removeSubmitters(); Group getSubmitters(); Group createAdministrators(); void removeAdministrators(); Group getAdministrators(); String getLicense(); String getLicenseCollection(); boolean hasCustomLicense(); void setLicense(String license); Item getTemplateItem(); void createTemplateItem(); void removeTemplateItem(); void addItem(Item item); void removeItem(Item item); void update(); boolean canEditBoolean(); boolean canEditBoolean(boolean useInheritance); void canEdit(); void canEdit(boolean useInheritance); Community[] getCommunities(); @Override boolean equals(Object other); @Override int hashCode(); int getType(); static Collection[] findAuthorized(Context context, Community comm,
            int actionID); int countItems(); DSpaceObject getAdminObject(int action); @Override DSpaceObject getParentObject();  }