public String buildWorkflow()

in taverna-server-webapp/src/main/java/org/apache/taverna/server/master/TavernaServerSupport.java [730:772]


	public String buildWorkflow(Workflow workflow) throws NoCreateException {
		UsernamePrincipal p = getPrincipal();
		if (getSelfAuthority() != null)
			throw new NoCreateException(
					"runs may not create workflows on their host server");
		if (!stateModel.getAllowNewWorkflowRuns())
			throw new NoCreateException("run creation not currently enabled");
		try {
			if (stateModel.getLogIncomingWorkflows()) {
				log.info(workflow.marshal());
			}
		} catch (JAXBException e) {
			log.warn("problem when logging workflow", e);
		}

		// Security checks
		policy.permitCreate(p, workflow);
		if (idMapper != null && idMapper.getUsernameForPrincipal(p) == null) {
			log.error("cannot map principal to local user id");
			throw new NoCreateException(
					"failed to map security token to local user id");
		}

		TavernaRun run;
		try {
			run = runFactory.create(p, workflow);
			TavernaSecurityContext c = run.getSecurityContext();
			c.initializeSecurityFromContext(SecurityContextHolder.getContext());
			/*
			 * These next pieces of security initialisation are (hopefully)
			 * obsolete now that we use Spring Security, but we keep them Just
			 * In Case.
			 */
			boolean doRESTinit = webapp.initObsoleteSOAPSecurity(c);
			if (doRESTinit)
				webapp.initObsoleteRESTSecurity(c);
		} catch (Exception e) {
			log.error("failed to build workflow run worker", e);
			throw new NoCreateException("failed to build workflow run worker");
		}

		return runStore.registerRun(run);
	}