/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import java.util.*; import org.ofbiz.entity.*; import org.ofbiz.base.util.*; //delegator = request.getAttribute("delegator"); //security = request.getAttribute("security"); //userLogin = session.getAttribute("userLogin"); shipmentId = parameters.get("shipmentId"); if (shipmentId == null) { shipmentId = request.getAttribute("shipmentId"); } shipment = delegator.findByPrimaryKey("Shipment", UtilMisc.toMap("shipmentId", shipmentId)); context.put("shipmentId", shipmentId); context.put("shipment", shipment); if (shipment != null) { context.put("shipmentType", shipment.getRelatedOne("ShipmentType")); context.put("statusItem", shipment.getRelatedOne("StatusItem")); context.put("primaryOrderHeader", shipment.getRelatedOne("PrimaryOrderHeader")); context.put("toPerson", shipment.getRelatedOne("ToPerson")); context.put("toPartyGroup", shipment.getRelatedOne("ToPartyGroup")); context.put("fromPerson", shipment.getRelatedOne("FromPerson")); context.put("fromPartyGroup", shipment.getRelatedOne("FromPartyGroup")); context.put("originFacility", shipment.getRelatedOne("OriginFacility")); context.put("destinationFacility", shipment.getRelatedOne("DestinationFacility")); context.put("originPostalAddress", shipment.getRelatedOne("OriginPostalAddress")); context.put("destinationPostalAddress", shipment.getRelatedOne("DestinationPostalAddress")); } // check permission hasPermission = false; if (security.hasEntityPermission("FACILITY", "_VIEW", userLogin)) { hasPermission = true; } else { if (shipment != null) { if (UtilValidate.isNotEmpty(shipment.get("primaryOrderId"))) { // allow if userLogin is associated with the primaryOrderId with the SUPPLIER_AGENT roleTypeId orderRoleCheckMap = UtilMisc.toMap("orderId", shipment.get("primaryOrderId"), "partyId", userLogin.get("partyId"), "roleTypeId", "SUPPLIER_AGENT"); orderRole = delegator.findByPrimaryKey("OrderRole", orderRoleCheckMap); if (orderRole != null) { hasPermission = true; } } } } context.put("hasPermission", hasPermission);