Package org.fao.geonet.exceptions

Examples of org.fao.geonet.exceptions.OperationAbortedEx


    String to      = elEmail.getChildText("to");
    String content = elEmail.getChildText("content");
   
    // send change link via email
        if (!MailUtil.sendMail(to, subject, content, sm, adminEmail, "")) {
            throw new OperationAbortedEx("Could not send email");
    }

    return new Element(Jeeves.Elem.RESPONSE);
  }
View Full Code Here


                access = param.split("=")[1];
            }
        }

        if ("".equals(filename))
            throw new OperationAbortedEx("Empty filename. Unable to delete resource.");

        // Remove the file and update the file upload/downloads tables
        IResourceRemoveHandler removeHook = (IResourceRemoveHandler) context.getApplicationContext().getBean("resourceRemoveHandler");
        removeHook.onDelete(context, request, Integer.parseInt(id), filename, access);
View Full Code Here

    String to      = elEmail.getChildText("to");
    String content = elEmail.getChildText("content");
   
    // send password changed email
        if (!MailUtil.sendMail(to, subject, content, sm, adminEmail, "")) {
            throw new OperationAbortedEx("Could not send email");
    }

    return new Element(Jeeves.Elem.RESPONSE);
  }
View Full Code Here

        // delete the file
        File dir = new File(Lib.resource.getDir(context, access, id));
        File file = new File(dir, filename);

        if (file.exists() && !file.delete())
            throw new OperationAbortedEx("unable to delete resource");

        Element response = new Element(Jeeves.Elem.RESPONSE)
                .addContent(new Element(Geonet.Elem.ID).setText(id));
        return response;
    }
View Full Code Here

      throw new ConcurrentUpdateEx(id);

    Element result = dataMan.getThumbnails(context, id);

    if (result == null)
      throw new OperationAbortedEx("Metadata not found", id);

    result = result.getChild(type);

    if (result == null)
      throw new OperationAbortedEx("Metadata has no thumbnail", id);

    String file = Lib.resource.getDir(context, Params.Access.PUBLIC, id) + getFileName(result.getText());

    //-----------------------------------------------------------------------
    //--- remove thumbnail
View Full Code Here

      GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
      DataManager dm = gc.getBean(DataManager.class);

      String id = dm.getMetadataId(uuid.toLowerCase());
      if (id == null) {
             throw new OperationAbortedEx("Metadata record with uuid "+uuid+" doesn't exist");
      }

      // -- check download permissions (should be ok since admin but...)
      try {
        Lib.resource.checkPrivilege(context, id, ReservedOperation.download);
      }
            catch (Exception e) {
             throw new OperationAbortedEx("Download access not available on metadata record with uuid "+uuid);
      }

      // -- get metadata
            boolean forEditing = false, withValidationErrors = false, keepXlinkAttributes = false;
            Element elMd = dm.getMetadata(context, id, forEditing, withValidationErrors, keepXlinkAttributes);

      if (elMd == null) {
             throw new OperationAbortedEx("Metadata record "+uuid+" doesn't exist");
      }

      // -- transform record into brief version
      Element elBrief = dm.extractSummary(elMd);

      // -- find link using XPath and create URL for further processing
      XPath xp = XPath.newInstance ("link[contains(@protocol,'metadata-schema')]");
      List<?> elems = xp.selectNodes(elBrief);
      try {
        url = getMetadataSchemaUrl(elems);
      }
            catch (MalformedURLException mu) {
        throw new OperationAbortedEx("Metadata schema URL link for metadata record "+uuid+" is malformed : "+mu.getMessage());
      }

      if (url == null) {
        throw new OperationAbortedEx("Unable to find metadata schema URL link for metadata record "+uuid);
      }
    }

    // -- get the schema zip archive from the net
    if (url != null) {
View Full Code Here

    long fsize = 0;
    if (zipArchive.exists()) {
      fsize = zipArchive.length();
    } else {
       throw new OperationAbortedEx("Zip Archive doesn't exist");
    }

    // -- check that the archive actually has something in it
    if (fsize == 0) {
       throw new OperationAbortedEx("Schema archive has zero size");
    }

    InputStream inputStream = new BufferedInputStream(new FileInputStream(zipArchive));

    // -- supply the stream containing the schema zip archive to the schema
    // -- manager
    try {
      if (add) {
        scm.addPluginSchema(context.getApplicationContext(), schema, inputStream);
      } else {
        scm.updatePluginSchema(context.getApplicationContext(), schema, inputStream);
      }
       response.setAttribute("status", "ok");
       response.setAttribute("message", "Schema "+schema+" has been added/updated");
    } catch (Exception e) {
      e.printStackTrace();
       throw new OperationAbortedEx("Schema add/update failed: "+e.getMessage());
    }

    return response;
  }
View Full Code Here

            throws Exception {

        XmlFile xf = scm.getSchemaInfo(schema).get(fileName);

        if (xf == null) {
            throw new OperationAbortedEx("File not found for : " + schema + "/" + fileName);
        }

        Element entries = xf.exec(new Element("junk"), context);

        Element result = checkEntries(scm, schema, entries, xpath, name, isoType, true);
View Full Code Here

        }
      } else {
        try {
          url = new URL(urlStr);
        } catch (MalformedURLException mu) {
           throw new OperationAbortedEx("URL "+urlStr+" is malformed: "+mu.getMessage());
        }
      }
    }

    // -- test if schema already exists, if so then chuck a fit and exit
    if (scm.existsSchema(schema)) {
     throw new OperationAbortedEx("Schema already exists");
    }

    SchemaUtils su = new SchemaUtils();
    return su.addSchema(context, schema, fname, url, uuid, scm);
  }
View Full Code Here

            // delete online resource
            File dir  = new File(Lib.resource.getDir(context, access, metadataId));
            File file = new File(dir, fileName);

            if (file.exists() && !file.delete())
                throw new OperationAbortedEx("unable to delete resource");

            storeFileUploadDeleteRequest(context, metadataId, fileName);

        } catch (Exception ex) {
            Log.error(Geonet.RESOURCES, "DefaultResourceRemoveHandler (onDelete): " + ex.getMessage());
View Full Code Here

TOP

Related Classes of org.fao.geonet.exceptions.OperationAbortedEx

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.