if ( "".equals(thisQual) ) { thisQual = null; }
    private void processEditMetadata(Context context,        HttpServletRequest request,        HttpServletResponse response,        SubmissionInfo subInfo,		int curStep)        throws ServletException, IOException, SQLException, AuthorizeException    {        String buttonPressed = UIUtil.getSubmitButton(request, "submit_next");        // Firstly, check for a click of the cancel button.        if (buttonPressed.equals("submit_cancel"))        {            doCancellation(request, response, subInfo, curStep, curStep);            return;        }        Item item = subInfo.submission.getItem();                // lookup applicable inputs        Collection c = subInfo.submission.getCollection();        DCInput[] inputs = inputsReader.getInputs(c.getHandle()).getPageRows(curStep - EDIT_METADATA_1,									 subInfo.submission.hasMultipleTitles(),									 subInfo.submission.isPublishedBefore());         // clear out all item metadata defined for this collection and page        for (int i = 0; i < inputs.length; i++)        {        	String dcQualifier = inputs[i].getQualifier();        	if (dcQualifier == null && inputs[i].getInputType().equals("qualdrop_value"))        	{        		dcQualifier = Item.ANY;        	}        	item.clearDC(inputs[i].getElement(), dcQualifier, Item.ANY);        }        // now update the item metadata.      	String fieldName;        boolean moreInput = false;    	for (int j = 0; j < inputs.length; j++)    	{    	   String dcElement = inputs[j].getElement();           String dcQualifier = inputs[j].getQualifier();    	   if (dcQualifier != null && ! dcQualifier.equals(Item.ANY))    	   {    	   		fieldName = dcElement + '_' + dcQualifier;    	   }    	   else    	   {    	   		fieldName = dcElement;    	   }    	   String inputType = inputs[j].getInputType();    	   if (inputType.equals("name"))    	   {    	   		readNames(request, item, dcElement, dcQualifier,     	   				  inputs[j].getRepeatable());    	   }    	   else if (inputType.equals("date"))    	   {    	   		readDate(request, item, dcElement, dcQualifier);    	   }    	   else if (inputType.equals("series"))    	   {    	   		readSeriesNumbers(request, item, dcElement, dcQualifier,     	   						  inputs[j].getRepeatable());    	   }    	   else if (inputType.equals("qualdrop_value"))    	   {    	      List quals = getRepeatedParameter(request, dcElement + "_qualifier");    	      List vals = getRepeatedParameter(request, dcElement + "_value");    	      for (int z = 0; z < vals.size(); z++)    	      {    	      		String thisQual = (String)quals.get(z);    	      		String thisVal = (String)vals.get(z);    	      		if (! buttonPressed.equals("submit_" + dcElement + "_remove_" + z) &&    	      			! thisVal.equals(""))    	      		{    	      			item.addDC(dcElement, thisQual, null, thisVal);    	      		}    	      }    	   }    	   else if (inputType.equals("dropdown"))    	   {    	      String[] vals = request.getParameterValues(fieldName);    	      if (vals != null)    	      {    	      	for (int z = 0; z < vals.length; z++)    	      	{    	      		item.addDC(dcElement, dcQualifier, "en", vals[z]);    	      	}    	      }    	   }    	   else if ((inputType.equals("onebox")) || (inputType.equals("twobox")) ||     	   			(inputType.equals("textarea")))    	   {    	   		readText(request, item, dcElement, dcQualifier,     	   				 inputs[j].getRepeatable(), "en");    	   }    	   else     	   {    	       throw new ServletException("Field "+ fieldName +     	       		                      " has an unknown input type: " + inputType);    	   }           // Proceed according to button pressed    	   if (! moreInput && buttonPressed.equals("submit_" + fieldName + "_more"))    	   {    	      subInfo.moreBoxesFor = fieldName;    	      subInfo.jumpToField = fieldName;    	      moreInput = true;    	   }    	}    	        int nextStep = -1;        if ( moreInput )        {        	nextStep = curStep;        }    	        if (buttonPressed.equals("submit_prev"))        {            // NB: code here assumes steps are sequentially numbered!            nextStep = curStep-1;        }        else if (buttonPressed.equals("submit_next"))        {        	// scan for missing fields        	String gotoField = null;        	subInfo.missingFields = new ArrayList();        	//subInfo.missingRowNums = new Vector();        	for (int i = 0; i < inputs.length; i++)        	{        	    String element = inputs[i].getElement();        	    String qual = inputs[i].getQualifier();        	    DCValue[] valArray = item.getDC(element, qual, Item.ANY);        	    boolean isEmpty = (valArray.length == 0);        	    if (inputs[i].isRequired() && isEmpty)        	    {        	    	subInfo.missingFields.add( new Integer(i) );        	    	if (qual != null && !qual.equals("*"))        	    	{        	    		gotoField = element + '_' + qual;        	    	}        	    	else        	    	{        	    		gotoField = element;        	    	}        	    }        	}        	// return to current edit metadata screen if any fields missing        	if (subInfo.missingFields.size() > 0 )        	{        		subInfo.jumpToField = gotoField;        		nextStep = curStep;        	}        	else        	{        		// determine next step - skipping unused MD pages        		int lastMDPage = EDIT_METADATA_1 + inputsReader.getNumberInputPages(c.getHandle()) - 1;        		if ( curStep == lastMDPage )        		{        		    curStep = EDIT_METADATA_2;        		}        		userHasReached(subInfo, curStep+1);        		nextStep = curStep+1;        	}        }        else if (buttonPressed.indexOf("remove") > -1)        {            // Remove button pressed - stay with same form            nextStep = curStep;        }        // Write changes to database        subInfo.submission.update();        if (nextStep != -1)        {            doStep(context, request, response, subInfo, nextStep);        }        else        {            doStepJump(context, request, response, subInfo);        }        context.complete();    }