Search in sources :

Example 1 with UserDetail

use of org.silverpeas.core.admin.user.model.UserDetail in project Silverpeas-Components by Silverpeas.

the class ResourcesManagerRequestRouter method getDestination.

/**
 * @see ComponentRequestRouter
 */
@Override
public String getDestination(String function, ResourcesManagerSessionController resourcesManagerSC, HttpRequest request) {
    Long categoryId;
    Long reservationId;
    Long resourceId;
    String destination = "";
    request.setAttribute("rsc", resourcesManagerSC);
    String flag = getFlag(resourcesManagerSC.getUserRoles());
    String userId = resourcesManagerSC.getUserId();
    request.setAttribute("Profile", flag);
    request.setAttribute("UserId", userId);
    // Reservation view context is allways filled into request
    request.setAttribute("viewContext", resourcesManagerSC.getViewContext());
    resourcesManagerSC.getViewContext().setWithWeekend(!resourcesManagerSC.isWeekendNotVisible());
    try {
        if (function.startsWith("Main")) {
            resourcesManagerSC.getViewContext().resetFilters();
            destination = displayCalendarView(request, resourcesManagerSC);
        } else if ("NewCategory".equals(function)) {
            request.setAttribute("listTemplates", getForms(resourcesManagerSC));
            destination = ROOT + "categoryManager.jsp";
        } else if ("SaveCategory".equals(function)) {
            Category category = request2CategoryDetail(resourcesManagerSC, request);
            resourcesManagerSC.createCategory(category);
            destination = getDestination("ViewCategories", resourcesManagerSC, request);
        } else if ("EditCategory".equals(function)) {
            Category category = resourcesManagerSC.getCategory(request.getParameterAsLong("id"));
            List<PublicationTemplate> listTemplates = getForms(resourcesManagerSC);
            request.setAttribute("listTemplates", listTemplates);
            request.setAttribute("category", category);
            destination = ROOT + "categoryManager.jsp";
        } else if ("ModifyCategory".equals(function)) {
            Category category = request2CategoryDetail(resourcesManagerSC, request);
            resourcesManagerSC.updateCategory(category);
            destination = getDestination("ViewCategories", resourcesManagerSC, request);
        } else if ("ViewCategories".equals(function)) {
            List<Category> list = resourcesManagerSC.getCategories();
            request.setAttribute("categories", list);
            destination = ROOT + "categories.jsp";
        } else if ("DeleteCategory".equals(function)) {
            resourcesManagerSC.deleteCategory(request.getParameterAsLong("id"));
            destination = getDestination("ViewCategories", resourcesManagerSC, request);
        } else if ("NewResource".equals(function)) {
            resourcesManagerSC.setResourceIdForResource(null);
            resourcesManagerSC.setCategoryIdForResource(request.getParameterAsLong("categoryId"));
            // categorie pré-séléctionnée
            List<Category> list = resourcesManagerSC.getCategories();
            request.setAttribute("listCategories", list);
            request.setAttribute("categoryId", resourcesManagerSC.getCategoryIdForResource());
            setXMLFormIntoRequest(request, resourcesManagerSC);
            destination = ROOT + "resourceManager.jsp";
        } else if ("SaveResource".equals(function)) {
            // récupération des données saisies dans le formulaire
            List<FileItem> items = request.getFileItems();
            Resource resource = request2ResourceDetail(resourcesManagerSC, items);
            resourcesManagerSC.createResource(resource);
            List<Long> managers = getManagers(items);
            resourcesManagerSC.updateResource(resource, managers);
            request.setAttribute("resourceId", resource.getIdAsLong());
            request.setAttribute("provenance", "resources");
            resourcesManagerSC.setResourceIdForResource(resource.getIdAsLong());
            updateXMLForm(resourcesManagerSC, items);
            destination = getDestination("ViewResource", resourcesManagerSC, request);
        } else if ("EditResource".equals(function)) {
            resourceId = request.getParameterAsLong("resourceId");
            if (resourceId == null) {
                resourceId = resourcesManagerSC.getCurrentResource();
            }
            Resource resource = resourcesManagerSC.getResource(resourceId);
            // on récupère l'ensemble des catégories pour la liste déroulante
            List<Category> list = resourcesManagerSC.getCategories();
            request.setAttribute("listCategories", list);
            request.setAttribute("categoryId", resource.getCategoryId());
            request.setAttribute("resource", resource);
            // liste des responsables sur la ressource
            resourcesManagerSC.setCurrentResource(resourceId);
            List<UserDetail> managers = resourcesManagerSC.getManagers(resourceId);
            request.setAttribute("Managers", managers);
            resourcesManagerSC.setResourceIdForResource(resourceId);
            resourcesManagerSC.setCategoryIdForResource(resource.getCategoryId());
            setXMLFormIntoRequest(request, resourcesManagerSC);
            destination = ROOT + "resourceManager.jsp";
        } else if ("ModifyResource".equals(function)) {
            // récupération des données saisies dans le formulaire
            List<FileItem> items = request.getFileItems();
            Resource resource = request2ResourceDetail(resourcesManagerSC, items);
            List<Long> managers = getManagers(items);
            resourcesManagerSC.updateResource(resource, managers);
            resourcesManagerSC.setResourceIdForResource(resource.getIdAsLong());
            updateXMLForm(resourcesManagerSC, items);
            request.setAttribute("id", resource.getCategoryId());
            destination = getDestination("ViewResources", resourcesManagerSC, request);
        } else if ("ViewResources".equals(function)) {
            categoryId = request.getAttributeAsLong("id");
            if (categoryId == null) {
                categoryId = request.getParameterAsLong("id");
            }
            List<Resource> list = resourcesManagerSC.getResourcesByCategory(categoryId);
            List<Category> listcategories = resourcesManagerSC.getCategories();
            request.setAttribute("listCategories", listcategories);
            request.setAttribute("list", list);
            request.setAttribute("categoryId", categoryId);
            destination = ROOT + "resources.jsp";
        } else if ("ViewResource".equals(function)) {
            String provenance;
            if (request.getParameter("provenance") != null) {
                provenance = request.getParameter("provenance");
                resourcesManagerSC.setProvenanceResource(provenance);
            } else if (request.getAttribute("provenance") != null) {
                provenance = (String) request.getAttribute("provenance");
                resourcesManagerSC.setProvenanceResource(provenance);
            } else {
                provenance = resourcesManagerSC.getProvenanceResource();
            }
            reservationId = request.getParameterAsLong("reservationId");
            if (reservationId != null) {
                resourcesManagerSC.setReservationIdForResource(reservationId);
            }
            resourceId = request.getParameterAsLong("resourceId");
            if (resourceId == null) {
                resourceId = request.getAttributeAsLong("resourceId");
            }
            if (resourceId != null) {
                resourcesManagerSC.setResourceIdForResource(resourceId);
            } else {
                resourceId = resourcesManagerSC.getResourceIdForResource();
            }
            Resource resource = resourcesManagerSC.getResource(resourceId);
            List<UserDetail> managers = resourcesManagerSC.getManagers(resourceId);
            request.setAttribute("Managers", managers);
            Category category = resourcesManagerSC.getCategory(resource.getCategoryId());
            resourcesManagerSC.setCategoryIdForResource(category.getIdAsLong());
            if (StringUtil.isDefined(category.getForm())) {
                putXMLDisplayerIntoRequest(resource, request, resourcesManagerSC);
            }
            String objectView = request.getParameter("objectView");
            request.setAttribute("objectView", objectView);
            request.setAttribute("category", category);
            request.setAttribute("provenance", provenance);
            request.setAttribute("resource", resource);
            request.setAttribute("ShowComments", resourcesManagerSC.areCommentsEnabled());
            destination = ROOT + "resource.jsp";
        } else if ("DeleteRessource".equals(function)) {
            resourcesManagerSC.deleteResource(request.getParameterAsLong("resourceId"));
            request.setAttribute("id", request.getParameterAsLong("categoryId"));
            destination = getDestination("ViewResources", resourcesManagerSC, request);
        } else if ("NewReservation".equals(function)) {
            request.setAttribute("objectView", request.getParameter("objectView"));
            String iso8601Date = request.getParameter("Day");
            if (StringUtil.isDefined(iso8601Date)) {
                Date date = DateUtil.parseISO8601Date(iso8601Date);
                request.setAttribute("defaultDate", DateUtil.dateToString(date, resourcesManagerSC.getLanguage()));
                if (DateUtil.resetHour(date).compareTo(date) != 0) {
                    // Time is defined
                    request.setAttribute("defaultTime", DateUtil.getOutputHour(date, resourcesManagerSC.getLanguage()));
                }
            }
            destination = ROOT + "reservationManager.jsp";
        } else if ("GetAvailableResources".equals(function)) {
            reservationId = request.getParameterAsLong("reservationId");
            if (reservationId == null) {
                reservationId = request.getAttributeAsLong("reservationId");
            }
            @SuppressWarnings("unchecked") List<Resource> unavailableReservationResources = (List<Resource>) request.getAttribute("unavailableReservationResources");
            List<Resource> resourcesOfReservation = null;
            // si unavailableReservationResources c'est qu'il n y a pas eu de problème d'enregistrement
            if (unavailableReservationResources == null) {
                Reservation reservation = request2ReservationDetail(request);
                if (reservation != null) {
                    resourcesManagerSC.createReservation(reservation);
                    resourcesManagerSC.setBeginDateReservation(reservation.getBeginDate());
                    resourcesManagerSC.setEndDateReservation(reservation.getEndDate());
                }
            }
            Reservation reservation = resourcesManagerSC.getReservationCourante();
            List<Resource> reservableResources = resourcesManagerSC.getResourcesReservable(reservation.getBeginDate(), reservation.getEndDate());
            if (reservationId != null) {
                resourcesOfReservation = resourcesManagerSC.getResourcesofReservation(reservationId);
                reservableResources.removeAll(resourcesOfReservation);
                if (unavailableReservationResources == null) {
                    // When update process, verify resource collisions with other reservations to warn
                    // the user immediately if any
                    unavailableReservationResources = resourcesManagerSC.verifyUnavailableResources(ResourceUtil.toIdList(resourcesOfReservation), resourcesManagerSC.getBeginDateReservation(), resourcesManagerSC.getEndDateReservation(), reservationId);
                }
                // Resources that are not available are removed from the list of resource reservation
                if (resourcesOfReservation != null && !resourcesOfReservation.isEmpty() && unavailableReservationResources != null && !unavailableReservationResources.isEmpty()) {
                    resourcesOfReservation.removeAll(unavailableReservationResources);
                }
            }
            List<Category> categories = resourcesManagerSC.getCategories();
            Map<Long, List<Resource>> resourcesAvailablePerCategory = new HashMap<>(categories.size());
            for (Resource resourceReservable : reservableResources) {
                if (resourcesAvailablePerCategory.containsKey(resourceReservable.getCategoryId())) {
                    resourcesAvailablePerCategory.get(resourceReservable.getCategoryId()).add(resourceReservable);
                } else {
                    List<Resource> resourceReservables = new ArrayList<>();
                    resourceReservables.add(resourceReservable);
                    resourcesAvailablePerCategory.put(resourceReservable.getCategoryId(), resourceReservables);
                }
            }
            // on envoie l'id de la réservation et l'ensemble des resources
            // associées à celles -ci
            request.setAttribute("objectView", request.getParameter("objectView"));
            request.setAttribute("idReservation", reservationId);
            request.setAttribute("listResourceEverReserved", resourcesOfReservation);
            request.setAttribute("mapResourcesReservable", resourcesAvailablePerCategory);
            request.setAttribute("reservation", reservation);
            request.setAttribute("unavailableReservationResources", unavailableReservationResources);
            request.setAttribute("categories", categories);
            destination = ROOT + "cart.jsp";
        } else if ("FinalReservation".equals(function)) {
            // resourceIds est la liste complète des ressources réservées lors
            // d'une création ou d'une édition de réservation
            // modifiedReservationId est l'id de la réservation à modifié lors d'une
            // édition de réservation
            // on doit vérifier que celles-ci n'ont pas été prises avant de mettre à
            // jour la réservation.
            Long modifiedReservationId = request.getParameterAsLong("modifiedReservationId");
            List<Long> resourceIds = ResourceUtil.toIdList(request.getParameter("listeResa"));
            // sinon on est en train de créer une réservation
            if (modifiedReservationId != null) {
                // on vérifie que les nouvelles ressources que l'on veut réserver ne
                // sont pas déjà prises.
                List<Resource> listeResourcesProblemeReservationTotal = resourcesManagerSC.verifyUnavailableResources(resourceIds, resourcesManagerSC.getBeginDateReservation(), resourcesManagerSC.getEndDateReservation(), modifiedReservationId);
                if (listeResourcesProblemeReservationTotal.isEmpty()) {
                    // regarder si les dates ont été modifiées
                    Reservation resa = resourcesManagerSC.getReservation(modifiedReservationId);
                    boolean updateDate = false;
                    if (!resourcesManagerSC.getBeginDateReservation().equals(resa.getBeginDate()) || !resourcesManagerSC.getEndDateReservation().equals(resa.getEndDate())) {
                        updateDate = true;
                    }
                    resourcesManagerSC.updateReservation(resa, resourceIds, updateDate);
                    // redirection vers la réservation
                    request.setAttribute("reservationId", modifiedReservationId);
                    destination = getDestination("ViewReservation", resourcesManagerSC, request);
                } else {
                    request.setAttribute("unavailableReservationResources", listeResourcesProblemeReservationTotal);
                    request.setAttribute("reservationId", modifiedReservationId);
                    destination = getDestination("GetAvailableResources", resourcesManagerSC, request);
                }
            } else {
                resourcesManagerSC.setListReservationCurrent(resourceIds);
                List<Resource> listeResourcesProblem = resourcesManagerSC.verifyUnavailableResources(resourceIds);
                if (listeResourcesProblem.isEmpty()) {
                    resourcesManagerSC.saveReservation();
                    request.setAttribute("reservationId", resourcesManagerSC.getReservationCourante().getId());
                    resourcesManagerSC.getViewContext().setReferenceDay(resourcesManagerSC.getReservationCourante().getBeginDate());
                    destination = getDestination("ViewReservation", resourcesManagerSC, request);
                } else {
                    request.setAttribute("unavailableReservationResources", listeResourcesProblem);
                    destination = getDestination("GetAvailableResources", resourcesManagerSC, request);
                }
            }
        } else if ("EditReservation".equals(function)) {
            // listResources est la liste des ressources qui peuvent poser problème
            // quand on change la date de réservation
            List listResourcesProblem = null;
            reservationId = request.getParameterAsLong("id");
            if (reservationId == null) {
                reservationId = request.getAttributeAsLong("id");
                listResourcesProblem = (List) request.getAttribute("listResources");
            }
            Reservation reservation = resourcesManagerSC.getReservation(reservationId);
            // on envoie la réservation de l'id et la liste des ressources associées
            // ainsi que la liste qui posent problème quand on change les dates
            request.setAttribute("reservation", reservation);
            request.setAttribute("listResourcesProblem", listResourcesProblem);
            destination = ROOT + "reservationManager.jsp";
        } else if ("ViewReservation".equals(function)) {
            reservationId = request.getParameterAsLong("reservationId");
            if (reservationId == null) {
                reservationId = request.getAttributeAsLong("reservationId");
            }
            String objectView = getView(request, resourcesManagerSC);
            // session controler
            if (reservationId == null) {
                reservationId = resourcesManagerSC.getReservationIdForResource();
            }
            Reservation reservation = resourcesManagerSC.getReservation(reservationId);
            List<Resource> listResourcesofReservation = resourcesManagerSC.getResourcesofReservation(reservationId);
            request.setAttribute("listResourcesofReservation", listResourcesofReservation);
            request.setAttribute("reservationId", reservationId);
            request.setAttribute("reservation", reservation);
            request.setAttribute("objectView", objectView);
            destination = ROOT + "viewReservation.jsp";
        } else if ("ViewReservations".equals(function)) {
            List<Reservation> listOfReservation = resourcesManagerSC.getReservationUser();
            request.setAttribute("listOfReservation", listOfReservation);
            destination = ROOT + "viewReservations.jsp";
        } else if ("DeleteReservation".equals(function)) {
            resourcesManagerSC.deleteReservation(request.getParameterAsLong("id"));
            destination = displayCalendarView(request, resourcesManagerSC);
        } else if ("CategoryIdFilter".equals(function)) {
            resourcesManagerSC.getViewContext().setCategoryId(request.getParameterAsLong("categoryIdFilter"));
            resourcesManagerSC.getViewContext().setResourceId(null);
            destination = displayCalendarView(request, resourcesManagerSC);
        } else if ("ResourceIdFilter".equals(function)) {
            resourcesManagerSC.getViewContext().setResourceId(request.getParameterAsLong("resourceIdFilter"));
            destination = displayCalendarView(request, resourcesManagerSC);
        } else if ("Calendar".equals(function)) {
            destination = displayCalendarView(request, resourcesManagerSC);
        } else if ("ViewReservationData".equals(function)) {
            resourcesManagerSC.getViewContext().setDataViewType(ResourceManagerDataViewType.reservations);
            destination = displayCalendarView(request, resourcesManagerSC);
        } else if ("ViewResourceData".equals(function)) {
            resourcesManagerSC.getViewContext().setDataViewType(ResourceManagerDataViewType.resources);
            destination = displayCalendarView(request, resourcesManagerSC);
        } else if ("ViewReservationListingData".equals(function)) {
            resourcesManagerSC.getViewContext().setDataViewType(ResourceManagerDataViewType.reservationListing);
            destination = displayCalendarView(request, resourcesManagerSC);
        } else if ("ViewByMonth".equals(function)) {
            resourcesManagerSC.getViewContext().setViewType(CalendarViewType.MONTHLY);
            destination = displayCalendarView(request, resourcesManagerSC);
        } else if ("ViewByWeek".equals(function)) {
            resourcesManagerSC.getViewContext().setViewType(CalendarViewType.WEEKLY);
            destination = displayCalendarView(request, resourcesManagerSC);
        } else if ("PreviousPeriod".equals(function)) {
            resourcesManagerSC.getViewContext().previous();
            destination = displayCalendarView(request, resourcesManagerSC);
        } else if ("NextPeriod".equals(function)) {
            resourcesManagerSC.getViewContext().next();
            destination = displayCalendarView(request, resourcesManagerSC);
        } else if ("GoToday".equals(function)) {
            Date selectedDate = request.getParameterAsDate("selectedDate");
            if (selectedDate == null) {
                resourcesManagerSC.getViewContext().today();
            } else {
                resourcesManagerSC.getViewContext().setReferenceDay(selectedDate);
            }
            destination = displayCalendarView(request, resourcesManagerSC);
        } else if ("Comments".equals(function)) {
            String provenance = resourcesManagerSC.getProvenanceResource();
            resourceId = resourcesManagerSC.getResourceIdForResource();
            Resource myResource = resourcesManagerSC.getResource(resourceId);
            MultiSilverpeasBundle resources = resourcesManagerSC.getResources();
            String chemin = "";
            if ("resources".equals(provenance)) {
                // on vient de resources
                chemin = "<a href=\"ViewCategories\">" + WebEncodeHelper.javaStringToHtmlString(resources.getString("resourcesManager.listCategorie")) + "</a>";
                String chemin2 = "<a href=\"ViewResources?id=" + myResource.getCategoryId() + "\">" + WebEncodeHelper.javaStringToHtmlString(resources.getString("resourcesManager.categorie")) + "</a>";
                chemin = chemin + " > " + chemin2;
            } else if ("reservation".equals(provenance)) {
                // on vient du récapitulatif de la réservation
                chemin = "<a href=\"ViewReservation\">" + WebEncodeHelper.javaStringToHtmlString(resources.getString("resourcesManager.recapitulatifReservation")) + "</a>";
            }
            request.setAttribute("Path", chemin);
            request.setAttribute("resourceId", resourceId);
            request.setAttribute("resourceName", myResource.getName());
            request.setAttribute("resourceType", getSessionControlBeanName());
            destination = ROOT + "comments.jsp";
        } else if ("SelectManager".equals(function)) {
            destination = resourcesManagerSC.initUPToSelectManager("");
        } else if (function.startsWith("ChooseOtherPlanning")) {
            destination = resourcesManagerSC.initUserPanelOtherPlanning();
        } else if (function.startsWith("ViewOtherPlanning")) {
            // userPanel return
            UserDetail selectedUser = resourcesManagerSC.getSelectedUser();
            if (selectedUser != null) {
                request.setAttribute("userId", selectedUser.getId());
                // on indique au rooter qu'on regarde le calandrier de quelqu un
                request.setAttribute("objectView", "PlanningOtherUser");
            }
            destination = displayCalendarView(request, resourcesManagerSC);
        } else if (function.startsWith("searchResult")) {
            resourcesManagerSC.getViewContext().resetFilters();
            // traitement des recherches
            Long id = request.getParameterAsLong("Id");
            String type = request.getParameter("Type");
            if ("Reservation".equals(type)) {
                // traitement des réservations
                request.setAttribute("reservationId", id);
                resourcesManagerSC.getViewContext().setReferenceDay(resourcesManagerSC.getReservation(id).getBeginDate());
                destination = getDestination("ViewReservation", resourcesManagerSC, request);
            } else if ("Category".equals(type)) {
                resourcesManagerSC.getViewContext().setDataViewType(ResourceManagerDataViewType.resources);
                resourcesManagerSC.getViewContext().setCategoryId(id);
                destination = displayCalendarView(request, resourcesManagerSC);
            } else if ("Resource".equals(type)) {
                resourcesManagerSC.getViewContext().setDataViewType(ResourceManagerDataViewType.resources);
                resourcesManagerSC.getViewContext().setCategoryId(resourcesManagerSC.getResource(id).getCategoryId());
                resourcesManagerSC.getViewContext().setResourceId(id);
                request.setAttribute("resourceId", id);
                request.setAttribute("provenance", "calendar");
                destination = getDestination("ViewResource", resourcesManagerSC, request);
            }
        } else if ("ToSelectManagers".equals(function)) {
            // récupération de la liste des responsables
            Collection<String> currentManagers = request2Managers(request);
            destination = initUserSelection(resourcesManagerSC, destination, currentManagers);
        } else if ("FromUserSelect".equals(function)) {
            // récupération des valeurs de userPanel
            Selection sel = resourcesManagerSC.getSelection();
            // Get users selected in User Panel
            String[] userIds = SelectionUsersGroups.getDistinctUserIds(sel.getSelectedElements(), null);
            if (userIds.length != 0) {
                UserDetail[] userDetails = SelectionUsersGroups.getUserDetails(userIds);
                request.setAttribute("Managers", Arrays.asList(userDetails));
            }
            destination = ROOT + "refreshFromUserSelect.jsp";
        } else if ("ValidateResource".equals(function)) {
            resourceId = request.getParameterAsLong("ResourceId");
            reservationId = request.getParameterAsLong("reservationId");
            String objectView = request.getParameter("objectView");
            resourcesManagerSC.validateResource(resourceId, reservationId);
            request.setAttribute("reservationId", reservationId);
            request.setAttribute("objectView", objectView);
            destination = getDestination("ViewReservation", resourcesManagerSC, request);
        } else if ("ForRefuseResource".equals(function)) {
            resourceId = request.getParameterAsLong("ResourceId");
            reservationId = request.getParameterAsLong("reservationId");
            String resourceName = request.getParameter("ResourceName");
            String objectView = request.getParameter("objectView");
            request.setAttribute("reservationId", reservationId);
            request.setAttribute("ResourceId", resourceId);
            request.setAttribute("ResourceName", resourceName);
            request.setAttribute("objectView", objectView);
            destination = ROOT + "refuseResource.jsp";
        } else if ("RefuseResource".equals(function)) {
            resourceId = request.getParameterAsLong("ResourceId");
            reservationId = request.getParameterAsLong("reservationId");
            String motive = request.getParameter("Motive");
            String objectView = request.getParameter("objectView");
            resourcesManagerSC.refuseResource(resourceId, reservationId, motive);
            request.setAttribute("reservationId", reservationId);
            request.setAttribute("objectView", objectView);
            destination = getDestination("ViewReservation", resourcesManagerSC, request);
        } else {
            resourcesManagerSC.getViewContext().resetFilters();
            displayCalendarView(request, resourcesManagerSC);
            destination = ROOT + function + ".jsp";
        }
    } catch (Exception e) {
        request.setAttribute("javax.servlet.jsp.jspException", e);
        destination = "/admin/jsp/errorpageMain.jsp";
    }
    return destination;
}
Also used : Category(org.silverpeas.components.resourcesmanager.model.Category) Selection(org.silverpeas.core.web.selection.Selection) Resource(org.silverpeas.components.resourcesmanager.model.Resource) Date(java.util.Date) FormException(org.silverpeas.core.contribution.content.form.FormException) ParseException(java.text.ParseException) PublicationTemplateException(org.silverpeas.core.contribution.template.publication.PublicationTemplateException) UserDetail(org.silverpeas.core.admin.user.model.UserDetail) FileItem(org.apache.commons.fileupload.FileItem) Reservation(org.silverpeas.components.resourcesmanager.model.Reservation) Collection(java.util.Collection) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) MultiSilverpeasBundle(org.silverpeas.core.util.MultiSilverpeasBundle)

Example 2 with UserDetail

use of org.silverpeas.core.admin.user.model.UserDetail in project Silverpeas-Components by Silverpeas.

the class ResourcesManagerSessionController method getSelectedUser.

public UserDetail getSelectedUser() {
    Selection sel = getSelection();
    UserDetail selectedUser = null;
    String[] selectedUsers = sel.getSelectedElements();
    if (selectedUsers != null && selectedUsers.length > 0) {
        selectedUser = getUserDetail(selectedUsers[0]);
    }
    return selectedUser;
}
Also used : UserDetail(org.silverpeas.core.admin.user.model.UserDetail) Selection(org.silverpeas.core.web.selection.Selection)

Example 3 with UserDetail

use of org.silverpeas.core.admin.user.model.UserDetail in project Silverpeas-Components by Silverpeas.

the class SurveySessionController method userIsAnonymous.

/**
 * Return if currentUser is anonymous
 * @return true or false
 */
private boolean userIsAnonymous() {
    boolean userIsAnonymous = false;
    UserDetail user = getUserDetail();
    if (user.isAnonymous() && (getComponentId() != null && getOrganisationController().isComponentAvailableToUser(getComponentId(), user.getId()))) {
        userIsAnonymous = true;
    }
    return userIsAnonymous;
}
Also used : UserDetail(org.silverpeas.core.admin.user.model.UserDetail)

Example 4 with UserDetail

use of org.silverpeas.core.admin.user.model.UserDetail in project Silverpeas-Components by Silverpeas.

the class SurveySessionController method initAlertResultUsers.

// pour la notification des résultats
public void initAlertResultUsers(QuestionContainerDetail surveyDetail) {
    UserDetail[] users = getOrganisationController().getAllUsers(getComponentId());
    UserNotificationHelper.buildAndSend(new SurveyUserNotification(surveyDetail, getUserDetail(), users));
}
Also used : UserDetail(org.silverpeas.core.admin.user.model.UserDetail) SurveyUserNotification(org.silverpeas.components.survey.notification.SurveyUserNotification)

Example 5 with UserDetail

use of org.silverpeas.core.admin.user.model.UserDetail in project Silverpeas-Components by Silverpeas.

the class WhitePagesSessionController method getUserDetailSelected.

/**
 * Appel UserPannel pour récup du user sélectionné : UserDetail[]
 * UserPanel.getUserDetailSelected()
 */
public UserDetail getUserDetailSelected() {
    UserDetail user = null;
    String selUser = getSelection().getFirstSelectedElement();
    if (StringUtil.isDefined(selUser)) {
        user = getOrganisationController().getUserDetail(selUser);
    }
    return user;
}
Also used : UserDetail(org.silverpeas.core.admin.user.model.UserDetail)

Aggregations

UserDetail (org.silverpeas.core.admin.user.model.UserDetail)80 ArrayList (java.util.ArrayList)20 ContactDetail (org.silverpeas.core.contact.model.ContactDetail)11 Path (javax.ws.rs.Path)10 OrganizationController (org.silverpeas.core.admin.service.OrganizationController)10 Produces (javax.ws.rs.Produces)9 List (java.util.List)8 GET (javax.ws.rs.GET)7 GroupDetail (org.silverpeas.core.admin.user.model.GroupDetail)7 IOException (java.io.IOException)6 Date (java.util.Date)6 File (java.io.File)5 AdminException (org.silverpeas.core.admin.service.AdminException)5 SimpleDocument (org.silverpeas.core.contribution.attachment.model.SimpleDocument)5 Form (org.silverpeas.core.contribution.content.form.Form)5 PublicationTemplateException (org.silverpeas.core.contribution.template.publication.PublicationTemplateException)5 DetailUserDTO (org.silverpeas.mobile.shared.dto.DetailUserDTO)5 WebApplicationException (javax.ws.rs.WebApplicationException)4 Group (org.silverpeas.core.admin.user.model.Group)4 ContactFatherDetail (org.silverpeas.core.contact.model.ContactFatherDetail)4