@Test(expected=AuthorizeException.class) public void testCreateNoAuth() throws Exception { new NonStrictExpectations() { AuthorizeManager authManager; { AuthorizeManager.authorizeAction((Context) any, (Collection) any, Constants.ADD); result = new AuthorizeException(); } }; Collection coll = null; boolean template = false; WorkspaceItem created = null; coll = Collection.create(context); template = false; created = WorkspaceItem.create(context, coll, template); fail("Exception expected"); }
public static WorkspaceItem create(Context c, Collection coll, boolean template) throws AuthorizeException, SQLException, IOException { AuthorizeManager.authorizeAction(c, coll, Constants.ADD); Item i = Item.create(c); i.setSubmitter(c.getCurrentUser()); Group step1group = coll.getWorkflowGroup(1); Group step2group = coll.getWorkflowGroup(2); Group step3group = coll.getWorkflowGroup(3); EPerson e = c.getCurrentUser(); AuthorizeManager.addPolicy(c, i, Constants.READ, e); if (ConfigurationManager.getProperty("workflow", "workflow.framework").equals("originalworkflow")) { if (step1group != null) { AuthorizeManager.addPolicy(c, i, Constants.READ, step1group); } if (step2group != null) { AuthorizeManager.addPolicy(c, i, Constants.READ, step2group); } if (step3group != null) { AuthorizeManager.addPolicy(c, i, Constants.READ, step3group); } } AuthorizeManager.addPolicy(c, i, Constants.WRITE, e); if (ConfigurationManager.getProperty("workflow", "workflow.framework").equals("originalworkflow")) { if (step1group != null) { AuthorizeManager.addPolicy(c, i, Constants.WRITE, step1group); } if (step2group != null) { AuthorizeManager.addPolicy(c, i, Constants.WRITE, step2group); } if (step3group != null) { AuthorizeManager.addPolicy(c, i, Constants.WRITE, step3group); } } AuthorizeManager.addPolicy(c, i, Constants.ADD, e); if (ConfigurationManager.getProperty("workflow", "workflow.framework").equals("originalworkflow")) { if (step1group != null) { AuthorizeManager.addPolicy(c, i, Constants.ADD, step1group); } if (step2group != null) { AuthorizeManager.addPolicy(c, i, Constants.ADD, step2group); } if (step3group != null) { AuthorizeManager.addPolicy(c, i, Constants.ADD, step3group); } } AuthorizeManager.addPolicy(c, i, Constants.REMOVE, e); if (ConfigurationManager.getProperty("workflow", "workflow.framework").equals("originalworkflow")) { if (step1group != null) { AuthorizeManager.addPolicy(c, i, Constants.REMOVE, step1group); } if (step2group != null) { AuthorizeManager.addPolicy(c, i, Constants.REMOVE, step2group); } if (step3group != null) { AuthorizeManager.addPolicy(c, i, Constants.REMOVE, step3group); } } Item templateItem = coll.getTemplateItem(); if (template && (templateItem != null)) { DCValue[] md = templateItem.getMetadata(Item.ANY, Item.ANY, Item.ANY, Item.ANY); for (int n = 0; n < md.length; n++) { i.addMetadata(md[n].schema, md[n].element, md[n].qualifier, md[n].language, md[n].value); } } i.update(); TableRow row = DatabaseManager.row("workspaceitem"); row.setColumn("item_id", i.getID()); row.setColumn("collection_id", coll.getID()); log.info(LogManager.getHeader(c, "create_workspace_item", "workspace_item_id=" + row.getIntColumn("workspace_item_id") + "item_id=" + i.getID() + "collection_id=" + coll.getID())); DatabaseManager.insert(c, row); WorkspaceItem wi = new WorkspaceItem(c, row); return wi; }
WorkspaceItem implements InProgressSubmission { public static WorkspaceItem create(Context c, Collection coll, boolean template) throws AuthorizeException, SQLException, IOException { AuthorizeManager.authorizeAction(c, coll, Constants.ADD); Item i = Item.create(c); i.setSubmitter(c.getCurrentUser()); Group step1group = coll.getWorkflowGroup(1); Group step2group = coll.getWorkflowGroup(2); Group step3group = coll.getWorkflowGroup(3); EPerson e = c.getCurrentUser(); AuthorizeManager.addPolicy(c, i, Constants.READ, e); if (ConfigurationManager.getProperty("workflow", "workflow.framework").equals("originalworkflow")) { if (step1group != null) { AuthorizeManager.addPolicy(c, i, Constants.READ, step1group); } if (step2group != null) { AuthorizeManager.addPolicy(c, i, Constants.READ, step2group); } if (step3group != null) { AuthorizeManager.addPolicy(c, i, Constants.READ, step3group); } } AuthorizeManager.addPolicy(c, i, Constants.WRITE, e); if (ConfigurationManager.getProperty("workflow", "workflow.framework").equals("originalworkflow")) { if (step1group != null) { AuthorizeManager.addPolicy(c, i, Constants.WRITE, step1group); } if (step2group != null) { AuthorizeManager.addPolicy(c, i, Constants.WRITE, step2group); } if (step3group != null) { AuthorizeManager.addPolicy(c, i, Constants.WRITE, step3group); } } AuthorizeManager.addPolicy(c, i, Constants.ADD, e); if (ConfigurationManager.getProperty("workflow", "workflow.framework").equals("originalworkflow")) { if (step1group != null) { AuthorizeManager.addPolicy(c, i, Constants.ADD, step1group); } if (step2group != null) { AuthorizeManager.addPolicy(c, i, Constants.ADD, step2group); } if (step3group != null) { AuthorizeManager.addPolicy(c, i, Constants.ADD, step3group); } } AuthorizeManager.addPolicy(c, i, Constants.REMOVE, e); if (ConfigurationManager.getProperty("workflow", "workflow.framework").equals("originalworkflow")) { if (step1group != null) { AuthorizeManager.addPolicy(c, i, Constants.REMOVE, step1group); } if (step2group != null) { AuthorizeManager.addPolicy(c, i, Constants.REMOVE, step2group); } if (step3group != null) { AuthorizeManager.addPolicy(c, i, Constants.REMOVE, step3group); } } Item templateItem = coll.getTemplateItem(); if (template && (templateItem != null)) { DCValue[] md = templateItem.getMetadata(Item.ANY, Item.ANY, Item.ANY, Item.ANY); for (int n = 0; n < md.length; n++) { i.addMetadata(md[n].schema, md[n].element, md[n].qualifier, md[n].language, md[n].value); } } i.update(); TableRow row = DatabaseManager.row("workspaceitem"); row.setColumn("item_id", i.getID()); row.setColumn("collection_id", coll.getID()); log.info(LogManager.getHeader(c, "create_workspace_item", "workspace_item_id=" + row.getIntColumn("workspace_item_id") + "item_id=" + i.getID() + "collection_id=" + coll.getID())); DatabaseManager.insert(c, row); WorkspaceItem wi = new WorkspaceItem(c, row); return wi; } }
WorkspaceItem implements InProgressSubmission { public static WorkspaceItem create(Context c, Collection coll, boolean template) throws AuthorizeException, SQLException, IOException { AuthorizeManager.authorizeAction(c, coll, Constants.ADD); Item i = Item.create(c); i.setSubmitter(c.getCurrentUser()); Group step1group = coll.getWorkflowGroup(1); Group step2group = coll.getWorkflowGroup(2); Group step3group = coll.getWorkflowGroup(3); EPerson e = c.getCurrentUser(); AuthorizeManager.addPolicy(c, i, Constants.READ, e); if (ConfigurationManager.getProperty("workflow", "workflow.framework").equals("originalworkflow")) { if (step1group != null) { AuthorizeManager.addPolicy(c, i, Constants.READ, step1group); } if (step2group != null) { AuthorizeManager.addPolicy(c, i, Constants.READ, step2group); } if (step3group != null) { AuthorizeManager.addPolicy(c, i, Constants.READ, step3group); } } AuthorizeManager.addPolicy(c, i, Constants.WRITE, e); if (ConfigurationManager.getProperty("workflow", "workflow.framework").equals("originalworkflow")) { if (step1group != null) { AuthorizeManager.addPolicy(c, i, Constants.WRITE, step1group); } if (step2group != null) { AuthorizeManager.addPolicy(c, i, Constants.WRITE, step2group); } if (step3group != null) { AuthorizeManager.addPolicy(c, i, Constants.WRITE, step3group); } } AuthorizeManager.addPolicy(c, i, Constants.ADD, e); if (ConfigurationManager.getProperty("workflow", "workflow.framework").equals("originalworkflow")) { if (step1group != null) { AuthorizeManager.addPolicy(c, i, Constants.ADD, step1group); } if (step2group != null) { AuthorizeManager.addPolicy(c, i, Constants.ADD, step2group); } if (step3group != null) { AuthorizeManager.addPolicy(c, i, Constants.ADD, step3group); } } AuthorizeManager.addPolicy(c, i, Constants.REMOVE, e); if (ConfigurationManager.getProperty("workflow", "workflow.framework").equals("originalworkflow")) { if (step1group != null) { AuthorizeManager.addPolicy(c, i, Constants.REMOVE, step1group); } if (step2group != null) { AuthorizeManager.addPolicy(c, i, Constants.REMOVE, step2group); } if (step3group != null) { AuthorizeManager.addPolicy(c, i, Constants.REMOVE, step3group); } } Item templateItem = coll.getTemplateItem(); if (template && (templateItem != null)) { DCValue[] md = templateItem.getMetadata(Item.ANY, Item.ANY, Item.ANY, Item.ANY); for (int n = 0; n < md.length; n++) { i.addMetadata(md[n].schema, md[n].element, md[n].qualifier, md[n].language, md[n].value); } } i.update(); TableRow row = DatabaseManager.row("workspaceitem"); row.setColumn("item_id", i.getID()); row.setColumn("collection_id", coll.getID()); log.info(LogManager.getHeader(c, "create_workspace_item", "workspace_item_id=" + row.getIntColumn("workspace_item_id") + "item_id=" + i.getID() + "collection_id=" + coll.getID())); DatabaseManager.insert(c, row); WorkspaceItem wi = new WorkspaceItem(c, row); return wi; } WorkspaceItem(Context context, TableRow row); }
WorkspaceItem implements InProgressSubmission { public static WorkspaceItem create(Context c, Collection coll, boolean template) throws AuthorizeException, SQLException, IOException { AuthorizeManager.authorizeAction(c, coll, Constants.ADD); Item i = Item.create(c); i.setSubmitter(c.getCurrentUser()); Group step1group = coll.getWorkflowGroup(1); Group step2group = coll.getWorkflowGroup(2); Group step3group = coll.getWorkflowGroup(3); EPerson e = c.getCurrentUser(); AuthorizeManager.addPolicy(c, i, Constants.READ, e); if (ConfigurationManager.getProperty("workflow", "workflow.framework").equals("originalworkflow")) { if (step1group != null) { AuthorizeManager.addPolicy(c, i, Constants.READ, step1group); } if (step2group != null) { AuthorizeManager.addPolicy(c, i, Constants.READ, step2group); } if (step3group != null) { AuthorizeManager.addPolicy(c, i, Constants.READ, step3group); } } AuthorizeManager.addPolicy(c, i, Constants.WRITE, e); if (ConfigurationManager.getProperty("workflow", "workflow.framework").equals("originalworkflow")) { if (step1group != null) { AuthorizeManager.addPolicy(c, i, Constants.WRITE, step1group); } if (step2group != null) { AuthorizeManager.addPolicy(c, i, Constants.WRITE, step2group); } if (step3group != null) { AuthorizeManager.addPolicy(c, i, Constants.WRITE, step3group); } } AuthorizeManager.addPolicy(c, i, Constants.ADD, e); if (ConfigurationManager.getProperty("workflow", "workflow.framework").equals("originalworkflow")) { if (step1group != null) { AuthorizeManager.addPolicy(c, i, Constants.ADD, step1group); } if (step2group != null) { AuthorizeManager.addPolicy(c, i, Constants.ADD, step2group); } if (step3group != null) { AuthorizeManager.addPolicy(c, i, Constants.ADD, step3group); } } AuthorizeManager.addPolicy(c, i, Constants.REMOVE, e); if (ConfigurationManager.getProperty("workflow", "workflow.framework").equals("originalworkflow")) { if (step1group != null) { AuthorizeManager.addPolicy(c, i, Constants.REMOVE, step1group); } if (step2group != null) { AuthorizeManager.addPolicy(c, i, Constants.REMOVE, step2group); } if (step3group != null) { AuthorizeManager.addPolicy(c, i, Constants.REMOVE, step3group); } } Item templateItem = coll.getTemplateItem(); if (template && (templateItem != null)) { DCValue[] md = templateItem.getMetadata(Item.ANY, Item.ANY, Item.ANY, Item.ANY); for (int n = 0; n < md.length; n++) { i.addMetadata(md[n].schema, md[n].element, md[n].qualifier, md[n].language, md[n].value); } } i.update(); TableRow row = DatabaseManager.row("workspaceitem"); row.setColumn("item_id", i.getID()); row.setColumn("collection_id", coll.getID()); log.info(LogManager.getHeader(c, "create_workspace_item", "workspace_item_id=" + row.getIntColumn("workspace_item_id") + "item_id=" + i.getID() + "collection_id=" + coll.getID())); DatabaseManager.insert(c, row); WorkspaceItem wi = new WorkspaceItem(c, row); return wi; } WorkspaceItem(Context context, TableRow row); static WorkspaceItem find(Context context, int id); static WorkspaceItem create(Context c, Collection coll,
            boolean template); static WorkspaceItem[] findByEPerson(Context context, EPerson ep); static WorkspaceItem[] findByCollection(Context context, Collection c); static WorkspaceItem findByItem(Context context, Item i); static WorkspaceItem[] findAll(Context context); int getID(); int getStageReached(); void setStageReached(int v); int getPageReached(); void setPageReached(int v); void update(); boolean equals(Object o); int hashCode(); void deleteAll(); void deleteWrapper(); Item getItem(); Collection getCollection(); EPerson getSubmitter(); boolean hasMultipleFiles(); void setMultipleFiles(boolean b); boolean hasMultipleTitles(); void setMultipleTitles(boolean b); boolean isPublishedBefore(); void setPublishedBefore(boolean b); }
WorkspaceItem implements InProgressSubmission { public static WorkspaceItem create(Context c, Collection coll, boolean template) throws AuthorizeException, SQLException, IOException { AuthorizeManager.authorizeAction(c, coll, Constants.ADD); Item i = Item.create(c); i.setSubmitter(c.getCurrentUser()); Group step1group = coll.getWorkflowGroup(1); Group step2group = coll.getWorkflowGroup(2); Group step3group = coll.getWorkflowGroup(3); EPerson e = c.getCurrentUser(); AuthorizeManager.addPolicy(c, i, Constants.READ, e); if (ConfigurationManager.getProperty("workflow", "workflow.framework").equals("originalworkflow")) { if (step1group != null) { AuthorizeManager.addPolicy(c, i, Constants.READ, step1group); } if (step2group != null) { AuthorizeManager.addPolicy(c, i, Constants.READ, step2group); } if (step3group != null) { AuthorizeManager.addPolicy(c, i, Constants.READ, step3group); } } AuthorizeManager.addPolicy(c, i, Constants.WRITE, e); if (ConfigurationManager.getProperty("workflow", "workflow.framework").equals("originalworkflow")) { if (step1group != null) { AuthorizeManager.addPolicy(c, i, Constants.WRITE, step1group); } if (step2group != null) { AuthorizeManager.addPolicy(c, i, Constants.WRITE, step2group); } if (step3group != null) { AuthorizeManager.addPolicy(c, i, Constants.WRITE, step3group); } } AuthorizeManager.addPolicy(c, i, Constants.ADD, e); if (ConfigurationManager.getProperty("workflow", "workflow.framework").equals("originalworkflow")) { if (step1group != null) { AuthorizeManager.addPolicy(c, i, Constants.ADD, step1group); } if (step2group != null) { AuthorizeManager.addPolicy(c, i, Constants.ADD, step2group); } if (step3group != null) { AuthorizeManager.addPolicy(c, i, Constants.ADD, step3group); } } AuthorizeManager.addPolicy(c, i, Constants.REMOVE, e); if (ConfigurationManager.getProperty("workflow", "workflow.framework").equals("originalworkflow")) { if (step1group != null) { AuthorizeManager.addPolicy(c, i, Constants.REMOVE, step1group); } if (step2group != null) { AuthorizeManager.addPolicy(c, i, Constants.REMOVE, step2group); } if (step3group != null) { AuthorizeManager.addPolicy(c, i, Constants.REMOVE, step3group); } } Item templateItem = coll.getTemplateItem(); if (template && (templateItem != null)) { DCValue[] md = templateItem.getMetadata(Item.ANY, Item.ANY, Item.ANY, Item.ANY); for (int n = 0; n < md.length; n++) { i.addMetadata(md[n].schema, md[n].element, md[n].qualifier, md[n].language, md[n].value); } } i.update(); TableRow row = DatabaseManager.row("workspaceitem"); row.setColumn("item_id", i.getID()); row.setColumn("collection_id", coll.getID()); log.info(LogManager.getHeader(c, "create_workspace_item", "workspace_item_id=" + row.getIntColumn("workspace_item_id") + "item_id=" + i.getID() + "collection_id=" + coll.getID())); DatabaseManager.insert(c, row); WorkspaceItem wi = new WorkspaceItem(c, row); return wi; } WorkspaceItem(Context context, TableRow row); static WorkspaceItem find(Context context, int id); static WorkspaceItem create(Context c, Collection coll,
            boolean template); static WorkspaceItem[] findByEPerson(Context context, EPerson ep); static WorkspaceItem[] findByCollection(Context context, Collection c); static WorkspaceItem findByItem(Context context, Item i); static WorkspaceItem[] findAll(Context context); int getID(); int getStageReached(); void setStageReached(int v); int getPageReached(); void setPageReached(int v); void update(); boolean equals(Object o); int hashCode(); void deleteAll(); void deleteWrapper(); Item getItem(); Collection getCollection(); EPerson getSubmitter(); boolean hasMultipleFiles(); void setMultipleFiles(boolean b); boolean hasMultipleTitles(); void setMultipleTitles(boolean b); boolean isPublishedBefore(); void setPublishedBefore(boolean b);  }