Package org.dspace.content

Examples of org.dspace.content.Community


        // now ensure communities have READ policies
        Community[] communities = Community.findAll(c);

        for (int i = 0; i < communities.length; i++)
        {
            Community t = communities[i];

            System.out.println("Community " + t + " " + t.getMetadata("name"));

            // check for READ
            if (checkForPolicy(c, t, Constants.READ))
            {
                System.out.println("\tFound READ policies!");
View Full Code Here


        c.setIgnoreAuthorization(true);

        try
        {
            // validate and resolve the parent and child IDs into commmunities
            Community parent = filiator.resolveCommunity(c, parentID);
            Community child = filiator.resolveCommunity(c, childID);

            if (parent == null)
            {
                System.out.println("Error, parent community cannot be found: "
                        + parentID);
View Full Code Here

            throws SQLException, AuthorizeException, IOException
    {
        // check that a valid filiation would be established
        // first test - proposed child must currently be an orphan (i.e.
        // top-level)
        Community childDad = child.getParentCommunity();

        if (childDad != null)
        {
            System.out.println("Error, child community: " + child.getID()
                    + " already a child of: " + childDad.getID());
            System.exit(1);
        }

        // second test - circularity: parent's parents can't include proposed
        // child
View Full Code Here

    }

    private Community resolveCommunity(Context c, String communityID)
            throws SQLException
    {
        Community community = null;

        if (communityID.indexOf('/') != -1)
        {
            // has a / must be a handle
            community = (Community) HandleManager.resolveToObject(c,
                    communityID);

            // ensure it's a community
            if ((community == null)
                    || (community.getType() != Constants.COMMUNITY))
            {
                community = null;
            }
        }
        else
View Full Code Here

        int communityID = UIUtil.getIntParameter(request, "community_id");

        if (communityID > -1)
        {
            // We have a community ID, "create new collection" button pressed
            Community c = Community.find(context, communityID);

            if (c == null)
            {
                log.warn(LogManager.getHeader(context, "integrity_error",
                        UIUtil.getRequestLogInfo(request)));
                JSPManager.showIntegrityError(request, response);

                return;
            }

            // Create the collection
            Collection newCollection = c.createCollection();
            request.setAttribute("collection", newCollection);

            if (AuthorizeManager.isAdmin(context))
            {
                // set a variable to show all buttons
View Full Code Here

            // get the community or collection location for the browse request
            // Note that we are only interested in getting the "smallest" container,
            // so if we find a collection, we don't bother looking up the community
            Collection collection = null;
            Community community = null;
            collection = UIUtil.getCollectionLocation(request);
            if (collection == null)
            {
                community = UIUtil.getCommunityLocation(request);
            }

            // process the input, performing some inline validation
            BrowseIndex bi = null;
            if (type != null && !"".equals(type))
            {
                bi = BrowseIndex.getBrowseIndex(type);
            }

            if (bi == null)
            {
                if (sortBy > 0)
                    bi = BrowseIndex.getBrowseIndex(SortOption.getSortOption(sortBy));
                else
                    bi = BrowseIndex.getBrowseIndex(SortOption.getDefaultSortOption());
            }

            // If we don't have a sort column
            if (bi != null && sortBy == -1)
            {
                // Get the default one
                SortOption so = bi.getSortOption();
                if (so != null)
                {
                    sortBy = so.getNumber();
                }
            }
            else if (bi != null && bi.isItemIndex() && !bi.isInternalIndex())
            {
                // If a default sort option is specified by the index, but it isn't
                // the same as sort option requested, attempt to find an index that
                // is configured to use that sort by default
                // This is so that we can then highlight the correct option in the navigation
                SortOption bso = bi.getSortOption();
                SortOption so = SortOption.getSortOption(sortBy);
                if ( bso != null && bso != so)
                {
                    BrowseIndex newBi = BrowseIndex.getBrowseIndex(so);
                    if (newBi != null)
                    {
                        bi   = newBi;
                        type = bi.getName();
                    }
                }
            }

            if (order == null && bi != null)
            {
                order = bi.getDefaultOrder();
            }

            // If the offset is invalid, reset to 0
            if (offset < 0)
            {
                offset = 0;
            }

            // if no resultsperpage set, default to 20
            if (resultsperpage < 0)
            {
                resultsperpage = 20;
            }

            // if year and perhaps month have been selected, we translate these into "startsWith"
            // if startsWith has already been defined then it is overwritten
            if (year != null && !"".equals(year) && !"-1".equals(year))
            {
                startsWith = year;
                if ((month != null) && !"-1".equals(month) && !"".equals(month))
                {
                    // subtract 1 from the month, so the match works appropriately
                    if ("ASC".equals(order))
                    {
                        month = Integer.toString((Integer.parseInt(month) - 1));
                    }

                    // They've selected a month as well
                    if (month.length() == 1)
                    {
                        // Ensure double-digit month number
                        month = "0" + month;
                    }

                    startsWith = year + "-" + month;

                    if ("ASC".equals(order))
                    {
                        startsWith = startsWith + "-32";
                    }
                }
            }

            // determine which level of the browse we are at: 0 for top, 1 for second
            int level = 0;
            if (value != null || authority != null)
            {
                level = 1;
            }

            // if sortBy is still not set, set it to 0, which is default to use the primary index value
            if (sortBy == -1)
            {
                sortBy = 0;
            }

            // figure out the setting for author list truncation
            if (etAl == -1)     // there is no limit, or the UI says to use the default
            {
                int limitLine = ConfigurationManager.getIntProperty("webui.browse.author-limit");
                if (limitLine != 0)
                {
                    etAl = limitLine;
                }
            }
            else  // if the user has set a limit
            {
                if (etAl == 0// 0 is the user setting for unlimited
                {
                    etAl = -1// but -1 is the application setting for unlimited
                }
            }

            // log the request
            String comHandle = "n/a";
            if (community != null)
            {
                comHandle = community.getHandle();
            }
            String colHandle = "n/a";
            if (collection != null)
            {
                colHandle = collection.getHandle();
View Full Code Here

      main.setHead(T_main_head_collection.parameterize(col.getMetadata("name"),col.getHandle(),col.getID()));
      policies = (ArrayList<ResourcePolicy>)AuthorizeManager.getPolicies(context, col);
      }
    else
    {
      Community com = Community.find(context, containerID);
      main.setHead(T_main_head_community.parameterize(com.getMetadata("name"),com.getHandle(),com.getID()));
      policies = (ArrayList<ResourcePolicy>)AuthorizeManager.getPolicies(context, com);
    }
   
    /* Adding a new policy link */
    main.addPara().addXref(baseURL + "&submit_add", T_add_link);
View Full Code Here

                        "SELECT community_id FROM community "
                                + "WHERE admin = ?", getID());

                if (qResult != null)
                {
                    Community community = Community.find(myContext, qResult
                            .getIntColumn("community_id"));
                    return community;
                }
            }
        }
View Full Code Here

    {
        Element[] elements = new Element[communities.getLength()];
       
        for (int i = 0; i < communities.getLength(); i++)
        {
            Community community;
            Element element = new Element("community");
           
            // create the community or sub community
            if (parent != null)
            {
                community = parent.createSubcommunity();
            }
            else
            {
                community = Community.create(null, context);
            }
           
            // default the short description to be an empty string
            community.setMetadata("short_description", " ");
           
            // now update the metadata
            Node tn = communities.item(i);
            Enumeration keys = communityMap.keys();
            while (keys.hasMoreElements())
            {
                Node node = null;
                String key = (String) keys.nextElement();
                NodeList nl = XPathAPI.selectNodeList(tn, key);
                if (nl.getLength() == 1)
                {
                    node = nl.item(0);
                    community.setMetadata((String) communityMap.get(key), getStringValue(node));
                }
            }
           
            // FIXME: at the moment, if the community already exists by name
            // then this will throw a PSQLException on a duplicate key
            // violation
            // Ideally we'd skip this row and continue to create sub
            // communities
            // and so forth where they don't exist, but it's proving
            // difficult
            // to isolate the community that already exists without hitting
            // the database directly.
            community.update();
           
            // build the element with the handle that identifies the new
            // community
            // along with all the information that we imported here
            // This looks like a lot of repetition of getting information
            // from above
            // but it's here to keep it separate from the create process in
            // case
            // we want to move it or make it switchable later
            element.setAttribute("identifier", community.getHandle());
           
            Element nameElement = new Element("name");
            nameElement.setText(community.getMetadata("name"));
            element.addContent(nameElement);
           
            if (community.getMetadata("short_description") != null)
            {
                Element descriptionElement = new Element("description");
                descriptionElement.setText(community.getMetadata("short_description"));
                element.addContent(descriptionElement);
            }
           
            if (community.getMetadata("introductory_text") != null)
            {
                Element introElement = new Element("intro");
                introElement.setText(community.getMetadata("introductory_text"));
                element.addContent(introElement);
            }
           
            if (community.getMetadata("copyright_text") != null)
            {
                Element copyrightElement = new Element("copyright");
                copyrightElement.setText(community.getMetadata("copyright_text"));
                element.addContent(copyrightElement);
            }
           
            if (community.getMetadata("side_bar_text") != null)
            {
                Element sidebarElement = new Element("sidebar");
                sidebarElement.setText(community.getMetadata("side_bar_text"));
                element.addContent(sidebarElement);
            }
           
            // handle sub communities
            NodeList subCommunities = XPathAPI.selectNodeList(tn, "community");
View Full Code Here

        final ArrayList<Integer> items = new ArrayList<Integer>();
        for (DSpaceObject dso : dsObjects)
        {
            if (dso.getType() == Constants.COMMUNITY)
            {
                Community community = (Community) dso;
                // get all the collections in the community
                Collection[] collections = community.getCollections();
                for (Collection collection : collections)
                {
                    // get all the items in each collection
                    ItemIterator iitems = collection.getItems();
                    try
View Full Code Here

TOP

Related Classes of org.dspace.content.Community

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.