cancel
Showing results for 
Search instead for 
Did you mean: 

The current user is not authorized to complete task

Former Member
0 Kudos

Hey it's me again.
I made some efforts with my uwl, but I dont understand the following Problem. Whehn the Servlet tries to complete the task I get an error with the following description.

Cannot process an HTTP request to servlet [AbschlussController] in [example.org~bachelor1~ui~web] web application.

[EXCEPTION]

com.sap.bpm.exception.api.BPMIllegalAccessException: The current user is not authorized to complete task with id: bpm://bpm.sap.com/task-instance/4722f1bb33e211e3b501000000600d42

at com.sap.bpem.tm.impl.TaskInstanceManagerBean.complete(TaskInstanceManagerBean.java:155)

at com.sap.bpem.tm.impl.TaskInstanceManagerBean.complete(TaskInstanceManagerBean.java:112)

.

.

.

Caused by: com.sap.bpem.tm.exception.InvalidAuthorizationException: The user 'USER.PRIVATE_DATASOURCE.un:xxxxxxx' is not authorized to complete the task '4722f1bb33e211e3b501000000600d42'.

Did I forgot anything in the configuration?


Here is my Javacode of the Servlet

public class AbschlussController extends HttpServlet {

          private static final long serialVersionUID = 1L;

          public TaskInstanceManager manager = BPMFactory.getTaskInstanceManager();

          protected void doPost(HttpServletRequest request,

                              HttpServletResponse response) throws ServletException, IOException {

                    // Initialisierung der Session und des TaskInstanceManagers

                    HttpSession session = request.getSession();

                    TaskInstanceManager manager = BPMFactory.getTaskInstanceManager();

                    // Initialisierung der Logindaten

                    IAuthentication auth = UMFactory.getAuthenticator();

                    IUser user = auth.forceLoggedInUser(request, response);

                    // Initialiserung der Metadaten der ausgewählten Task

                    TaskMetaData metaData = (TaskMetaData) session.getAttribute("metaData");

                    // Initialisierung der Bean TaskData zur späteren Verwendung in der JSP

                    TaskData taskData = TaskData.getInstance();

                    // Initialisierung des TaskInput-Objects aus dem Task

                    URI taskIntanceId = metaData.getTaskId();

                    TaskDetail taskDetail = manager.getTaskDetail(taskIntanceId);

                    DataObject taskOutput = taskDetail.getOutputDataObject();

 

                    //Ermittlung der Task-Art

                    String name= metaData.getName();

                    if(name.equals(new String("Anfrage formulieren"))){

                              taskOutput.setString("Notebook", (String)request.getAttribute("Notebook"));

//                              taskOutput.setFloat("Preis", (Float)request.getAttribute("Preis"));

//                              taskOutput.setShort("Stueckzahl", (Short)request.getAttribute("Stueckzahl"));

                              taskOutput.setString("Anmerkung", (String)request.getAttribute("Anmerkung"));

 

                    }else if(name.equals(new String("Anfrage genehmigen"))){

                              taskOutput.setString("Notebook", (String)request.getAttribute("Notebook"));

                              taskOutput.setFloat("Preis", (Float)request.getAttribute("Preis"));

                              taskOutput.setShort("Stueckzahl", (Short)request.getAttribute("Stueckzahl"));

                              taskOutput.setString("Anmerkung", (String)request.getAttribute("Anmerkung"));

 

                              String check=(String)request.getAttribute("Genehmigen");

                              if(check.equals(new String("Ja"))){

                                        taskOutput.setBoolean("genehmigt", true);

                              }else taskOutput.setBoolean("genehmigt", false);

                    }

 

 

                    // Abschließen der Task

                    manager.complete(metaData.getTaskId(), taskOutput);

 

                    // Entfernen der Taskabhängigen Datenobjekte aus der Session

                    session.removeAttribute("taskData");

                    session.removeAttribute("metaData");

 

                    response.sendRedirect("UWL.jsp");

          }

Is it perhaps due to the fact that I implemented the code...

IAuthentication auth = UMFactory.getAuthenticator();

                    IUser user = auth.forceLoggedInUser(request, response);

...in every Servlet I use?

Best Regards

Dominik

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hey Siddhant,

thx for your help. I got this Problem fixed. But I still got some issues with the InputData and OutputDataObjects. When I run the project I get this error:

Cannot process an HTTP request to servlet [AbschlussController] in [example.org~bachelor1~ui~web] web application.

[EXCEPTION]

java.lang.IllegalArgumentException: Path Notebook can not be resolved on data object [http://example.org/wd/TestFormulieren/ports#TFCompleteEventTypeOUTPUT]{TFCompleteEvent:[UNSET] default=null}

at com.sap.sdo.impl.objects.GenericDataObject.set(GenericDataObject.java:160)

at com.sap.sdo.impl.objects.GenericDataObject.setString(GenericDataObject.java:453)

at org.Domae.Controller.AbschlussController.doPost(AbschlussController.java:51)

My implementation code for the Data object is:

import commonj.sdo.DataObject;

// Initialisierung des TaskInput-Objects aus dem Task

  URI taskInstanceId = metaData.getTaskId();

  TaskDetail taskDetail = manager.getTaskDetail(taskInstanceId);

  DataObject taskOutput = taskDetail.getOutputDataObject();

  // Ermittlung der Task-Art

  String name = metaData.getName();

  if (name.equals(new String("testFormulieren"))) {

 

  taskOutput.setString("Notebook", (String) request

  .getAttribute("Notebook"));

  taskOutput.setFloat("Preis", (Float) request.getAttribute("Preis"));

  taskOutput.setShort("Stueckzahl", (Short) request

  .getAttribute("Stueckzahl"));

  taskOutput.setString("Anmerkung", (String) request

  .getAttribute("Anmerkung"));

}

I think it is a bit more complicated to map the data in the Dataobjects. Do I have to convert it into xml or something?

Regards

Dominik

Jocelyn_Dart
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Dominik, Ok that's a really a separate question at this point. Can you please raise it as a separate question? We find that if you put more than one issue on the same question everyone just gets confused and you don't get the answers you need.

Rgds,

Jocelyn

stefan_henke
Contributor
0 Kudos

Hi Dominik,

I haven´t seen a separate post for this question (as Jocelyn suggested). However, I don´t want to hold back the solution

The output data object typically has one more inner data object which you first of all have to create as the object you get from the API is completely empty. Try putting the following line before you set the actual data in the data object:

DataObject innerDO = taskOutput.createDataObject("TFCompleteEvent"); //TFCompleteEvent I took from your stack trace

innerDO.setString("Notebook", (String) request.getAttribute("Notebook"));

...

This should do the job in your case.

Best regards,Stefan

Former Member
0 Kudos

Hey Jocelyn, sorry for that. At the moment I have a lot of questions so I didn't wanted to post each day two or three new questions in the forum . But from now on I will seperate my questions. Promise

Regards

Dominik

former_member191643
Active Contributor
0 Kudos

Hi Dominik,

Stefan is right. You need to insert/set the inner data object in your code.

Please make sure that the Input mapping for this task(UI) is correct in CE.

To answer your last query, I would suggest it is always better to handle data in XML to avoid issues similar to this. Handling data in XML also provides the ease to import/export context data in case there is a need. If there is a change in the data structure in the near future, it would be easier just to change your XML structure than to change your code every time. Just a suggestion.

Regards,

Siddhant

Former Member
0 Kudos

Hi Dominik,

What is the user role you have used to over come "The current user is not authorized to complete task'' issue. I am facing the same issue right now. Really appreciate if you can mention the solution.

Thanks

Ashwin.

Astashonok
Participant
0 Kudos

How have you fixed this problem?

Answers (3)

Answers (3)

Former Member
0 Kudos

Hey thx both of you Stefan and Siddhant for your answers. Unfortunately I get a new Error message. But I dont want to post a new comment everytime I get an error so as Jocelyn mentioned I will start a new discussion and ask for some theoreticaly information about how the Dataobjects in my Java code and those of the mapping in the pricess context are connected.
So then perhaps I don't have to ask so much questions anymore

Best Regards
Dominik

former_member191643
Active Contributor
junwu
Active Contributor
0 Kudos

you need to add some role to the user in ume,

it should be BPEM End User

Former Member
0 Kudos

Hey Jun,

I lokked in the ume and I allready have the ume role.

Do you have any clue?

Best Regards

Dominik