[ 
https://jira.duraspace.org/browse/DS-906?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=20361#action_20361
 ] 

Mark Diggory edited comment on DS-906 at 5/17/11 7:07 PM:
----------------------------------------------------------

And you can even see in the code for the method that this is true... no part of 
this code "requires" access to the internals of the DSpace Item and could be 
encapsulated external of the Domain Object as a separate Business Service / 
Action.

{code}
    /**
     * remove all policies on an item and its contents, and replace them with
     * the DEFAULT_ITEM_READ and DEFAULT_BITSTREAM_READ policies belonging to
     * the collection.
     *
     * @param c
     *            Collection
     * @throws java.sql.SQLException
     *             if an SQL error or if no default policies found. It's a bit
     *             draconian, but default policies must be enforced.
     * @throws AuthorizeException
     */
    public void inheritCollectionDefaultPolicies(Collection c)
            throws java.sql.SQLException, AuthorizeException
    {
        List<ResourcePolicy> policies;

        // remove the submit authorization policies
        // and replace them with the collection's default READ policies
        policies = AuthorizeManager.getPoliciesActionFilter(ourContext, c,
                Constants.DEFAULT_ITEM_READ);

        // MUST have default policies
        if (policies.size() < 1)
        {
            throw new java.sql.SQLException("Collection " + c.getID()
                    + " (" + c.getHandle() + ")"
                    + " has no default item READ policies");
        }

        // change the action to just READ
        // just don't call update on the resourcepolicies!!!
        for (ResourcePolicy rp : policies)
        {
            rp.setAction(Constants.READ);
        }

        replaceAllItemPolicies(policies);

        policies = AuthorizeManager.getPoliciesActionFilter(ourContext, c,
                Constants.DEFAULT_BITSTREAM_READ);

        if (policies.size() < 1)
        {
            throw new java.sql.SQLException("Collection " + c.getID()
                    + " (" + c.getHandle() + ")"
                    + " has no default bitstream READ policies");
        }

        // change the action to just READ
        // just don't call update on the resourcepolicies!!!
        for (ResourcePolicy rp : policies)
        {
            rp.setAction(Constants.READ);
        }

        replaceAllBitstreamPolicies(policies);

        log.debug(LogManager.getHeader(ourContext, 
"item_inheritCollectionDefaultPolicies",
                                                   "item_id=" + getID()));
    }
{code}


What on earth???!!!!  Non SQL services throwing SQLExceptions!!!!! very scary

{code}

        // MUST have default policies
        if (policies.size() < 1)
        {
            throw new java.sql.SQLException("Collection " + c.getID()
                    + " (" + c.getHandle() + ")"
                    + " has no default item READ policies");
        }

{code}



      was (Author: mdiggory):
    And you can even see in the code for the method that this is true...

{code}
    /**
     * remove all policies on an item and its contents, and replace them with
     * the DEFAULT_ITEM_READ and DEFAULT_BITSTREAM_READ policies belonging to
     * the collection.
     *
     * @param c
     *            Collection
     * @throws java.sql.SQLException
     *             if an SQL error or if no default policies found. It's a bit
     *             draconian, but default policies must be enforced.
     * @throws AuthorizeException
     */
    public void inheritCollectionDefaultPolicies(Collection c)
            throws java.sql.SQLException, AuthorizeException
    {
        List<ResourcePolicy> policies;

        // remove the submit authorization policies
        // and replace them with the collection's default READ policies
        policies = AuthorizeManager.getPoliciesActionFilter(ourContext, c,
                Constants.DEFAULT_ITEM_READ);

        // MUST have default policies
        if (policies.size() < 1)
        {
            throw new java.sql.SQLException("Collection " + c.getID()
                    + " (" + c.getHandle() + ")"
                    + " has no default item READ policies");
        }

        // change the action to just READ
        // just don't call update on the resourcepolicies!!!
        for (ResourcePolicy rp : policies)
        {
            rp.setAction(Constants.READ);
        }

        replaceAllItemPolicies(policies);

        policies = AuthorizeManager.getPoliciesActionFilter(ourContext, c,
                Constants.DEFAULT_BITSTREAM_READ);

        if (policies.size() < 1)
        {
            throw new java.sql.SQLException("Collection " + c.getID()
                    + " (" + c.getHandle() + ")"
                    + " has no default bitstream READ policies");
        }

        // change the action to just READ
        // just don't call update on the resourcepolicies!!!
        for (ResourcePolicy rp : policies)
        {
            rp.setAction(Constants.READ);
        }

        replaceAllBitstreamPolicies(policies);

        log.debug(LogManager.getHeader(ourContext, 
"item_inheritCollectionDefaultPolicies",
                                                   "item_id=" + getID()));
    }
{code}


What on earth???!!!!  Non SQL services throwing SQLExceptions!!!!! very scary

{code}

        // MUST have default policies
        if (policies.size() < 1)
        {
            throw new java.sql.SQLException("Collection " + c.getID()
                    + " (" + c.getHandle() + ")"
                    + " has no default item READ policies");
        }

{code}


  
> For moving items in the Admin UI, add checkbox option to replace resource 
> policies with defaults of the new collection
> ----------------------------------------------------------------------------------------------------------------------
>
>                 Key: DS-906
>                 URL: https://jira.duraspace.org/browse/DS-906
>             Project: DSpace
>          Issue Type: Improvement
>          Components: XMLUI
>    Affects Versions: 1.7.2, 1.8.0
>            Reporter: Bill Hays
>
> This is a single call in the API: 
> item.inheritCollectionDefaultPolicies(targetCollection)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
https://jira.duraspace.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
Dspace-devel mailing list
Dspace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dspace-devel

Reply via email to