Exemplo n.º 1
0
  /**
   * Gets the xML schema.
   *
   * @param partMeta the part meta
   * @return the xML schema
   * @throws Exception the exception
   */
  private static File getXMLSchema(ObjectPartType partMeta) throws Exception {
    final String FILE_SEPARATOR = System.getProperty("file.separator");
    final String XML_SCHEMA_EXTENSION = ".xsd";
    final String SCHEMAS_DIR = "schemas";

    File schemaFile = null;

    //
    // Look for an XML Schema (.xsd) file for the incoming part payload
    //
    String serverRoot = ServiceMain.getInstance().getServerRootDir();
    String schemasDir = serverRoot + FILE_SEPARATOR + SCHEMAS_DIR + FILE_SEPARATOR;
    //
    // Send a warning to the log file if the XML Schema file is missing
    //
    String schemaName = schemasDir + partMeta.getLabel() + XML_SCHEMA_EXTENSION;
    try {
      schemaFile = new File(schemaName);
    } catch (Exception e) {
      if (logger.isWarnEnabled() == true) {
        logger.warn("Missing schema file for incoming payload: " + schemaName);
      }
    }

    return schemaFile;
  }
  @Override
  public RelationsCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc)
      throws Exception {
    RelationsCommonList relList = this.extractPagingInfo(new RelationsCommonList(), wrapDoc);
    relList.setFieldsReturned(
        "subjectCsid|relationshipType|predicateDisplayName|objectCsid|uri|csid|subject|object");
    ServiceContext ctx = getServiceContext();
    String serviceContextPath = getServiceContextPath();

    TenantBindingConfigReaderImpl tReader =
        ServiceMain.getInstance().getTenantBindingConfigReader();
    String serviceName = getServiceContext().getServiceName().toLowerCase();
    ServiceBindingType sbt = tReader.getServiceBinding(ctx.getTenantId(), serviceName);

    Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
    while (iter.hasNext()) {
      DocumentModel docModel = iter.next();
      RelationListItem relListItem =
          getRelationListItem(ctx, sbt, tReader, docModel, serviceContextPath);
      relList.getRelationListItem().add(relListItem);
    }
    return relList;
  }