public StringApiResponse updateResource(JAXBResource jaxbResource, Properties properties)
     throws Throwable {
   StringApiResponse response = new StringApiResponse();
   BaseResourceDataBean bean = null;
   try {
     UserDetails user = (UserDetails) properties.get(SystemConstants.API_USER_PARAMETER);
     this.check(jaxbResource, user, response, false);
     if (null != response.getErrors() && !response.getErrors().isEmpty()) {
       return response;
     }
     bean = jaxbResource.createBataBean(this.getCategoryManager());
     this.getResourceManager().updateResource(bean);
     response.setResult(IResponseBuilder.SUCCESS);
   } catch (Throwable t) {
     ApsSystemUtils.logThrowable(t, this, "updateResource");
     throw new ApsSystemException("Error into API method", t);
   } finally {
     if (null != bean && null != bean.getFile()) {
       bean.getFile().delete();
     }
   }
   return response;
 }
 public StringApiResponse addResource(JAXBResource jaxbResource, Properties properties)
     throws ApiException, Throwable {
   StringApiResponse response = new StringApiResponse();
   BaseResourceDataBean bean = null;
   try {
     UserDetails user = (UserDetails) properties.get(SystemConstants.API_USER_PARAMETER);
     this.check(jaxbResource, user, response, true);
     if (null != response.getErrors() && !response.getErrors().isEmpty()) {
       return response;
     }
     bean = jaxbResource.createBataBean(this.getCategoryManager());
     String id = bean.getResourceId();
     if (null != id && id.trim().length() > 0) {
       Pattern pattern = Pattern.compile("^[a-zA-Z]+$");
       Matcher matcher = pattern.matcher(id);
       if (!matcher.matches()) {
         throw new ApiException(
             IApiErrorCodes.API_PARAMETER_VALIDATION_ERROR,
             "The resourceId can contain only alphabetic characters",
             Response.Status.CONFLICT);
       }
     }
     this.getResourceManager().addResource(bean);
     response.setResult(IResponseBuilder.SUCCESS);
   } catch (ApiException ae) {
     throw ae;
   } catch (Throwable t) {
     ApsSystemUtils.logThrowable(t, this, "addResource");
     throw new ApsSystemException("Error into API method", t);
   } finally {
     if (null != bean && null != bean.getFile()) {
       bean.getFile().delete();
     }
   }
   return response;
 }