Changeset 38192
- Timestamp:
- Apr 27, 2015, 11:19:54 AM (11 years ago)
- Location:
- tags/ipp-20141024
- Files:
-
- 16 edited
- 2 copied
-
PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm (modified) (2 diffs)
-
dbconfig/pstamp.md (modified) (1 diff)
-
dbconfig/release.md (modified) (1 diff)
-
ippTools/share/Makefile.am (modified) (2 diffs, 1 prop)
-
ippTools/share/pstamptool_addaccesslevel.sql (copied) (copied from trunk/ippTools/share/pstamptool_addaccesslevel.sql ) (1 prop)
-
ippTools/share/pstamptool_listuser.sql (copied) (copied from trunk/ippTools/share/pstamptool_listuser.sql ) (1 prop)
-
ippTools/src/pstamptool.c (modified) (4 diffs, 1 prop)
-
ippTools/src/pstamptool.h (modified) (1 diff, 1 prop)
-
ippTools/src/pstamptoolConfig.c (modified) (3 diffs, 1 prop)
-
ippTools/src/releasetool.c (modified) (4 diffs, 1 prop)
-
ippTools/src/releasetoolConfig.c (modified) (2 diffs, 1 prop)
-
pstamp (modified) (1 prop)
-
pstamp/scripts/psmkreq (modified) (4 diffs)
-
pstamp/scripts/pstamp_checkdependent.pl (modified) (1 prop)
-
pstamp/scripts/pstamp_finish.pl (modified) (1 prop)
-
pstamp/scripts/pstamp_job_run.pl (modified) (1 prop)
-
pstamp/scripts/pstampparse.pl (modified) (24 diffs, 1 prop)
-
pstamp/scripts/request_finish.pl (modified) (1 prop)
Legend:
- Unmodified
- Added
- Removed
-
tags/ipp-20141024/PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm
r38163 r38192 1195 1195 my $command; 1196 1196 my $using_camtool = 0; 1197 if ($release_name or $survey) {1197 if ($release_name or ($survey and $survey ne 'bypass')) { 1198 1198 $command = "$releasetool -dbname $imagedb -listrelexp"; 1199 1199 if ($survey) { … … 1534 1534 1535 1535 if ($mjd < 54000) { 1536 print STDERR "MJD value too small minimum is 54000\n";1537 return undef;1536 # print STDERR "MJD value too small minimum is 54000\n"; 1537 $mjd = 54000; 1538 1538 } 1539 1539 -
tags/ipp-20141024/dbconfig/pstamp.md
r35295 r38192 69 69 END 70 70 71 pstampWebRequest METADATA71 pstampWebRequest METADATA 72 72 num S64 0 # Primary Key AUTO_INCREMENT 73 73 END 74 74 75 pstampFile METADATA75 pstampFile METADATA 76 76 file_id S64 0 # Primary Key AUTO_INCREMENT 77 77 job_id S64 0 78 78 path STR 255 79 end 79 END 80 81 pstampUserDomain METADATA 82 domainName STR 64 83 accessLevel S32 0 84 defaultProduct STR 255 85 defaultLabel STR 64 86 END 87 88 pstampUser METADATA 89 userName STR 64 # Primary Key (userName, domainName) 90 domainName STR 64 91 accessLevel S32 0 92 defaultProduct STR 255 93 defaultLabel STR 64 94 END 95 96 pstampAccessLevel METADATA 97 proj_id S64 0 # Primary Key (proj_id, accessLevel) fkey(proj_id) 98 accessLevel S32 0 99 mjd_min F32 0 100 mjd_max F32 0 101 END 102 -
tags/ipp-20141024/dbconfig/release.md
r35897 r38192 14 14 dvodb STR 255 15 15 ubercal_file STR 255 16 accessLevelMin S32 0 16 17 END 17 18 -
tags/ipp-20141024/ippTools/share/Makefile.am
- Property svn:mergeinfo set to
r37384 r38192 335 335 pstamptool_listjob.sql \ 336 336 pstamptool_listfile.sql \ 337 pstamptool_listuser.sql \ 337 338 pstamptool_pendingcleanup.sql \ 338 339 pstamptool_pendingdependent.sql \ … … 346 347 pstamptool_stopdependentjob.sql \ 347 348 pstamptool_updatejob.sql \ 349 pstamptool_addaccesslevel.sql \ 348 350 pxadmin_create_tables.sql \ 349 351 pxadmin_create_mirror_tables.sql \ -
tags/ipp-20141024/ippTools/share/pstamptool_addaccesslevel.sql
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/eam_branches/ipp-20150112/ippTools/share/pstamptool_addaccesslevel.sql 37839-38061 /branches/eam_branches/ipp-20150405/ippTools/share/pstamptool_addaccesslevel.sql 38084-38152
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
tags/ipp-20141024/ippTools/share/pstamptool_listuser.sql
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/eam_branches/ipp-20150405/ippTools/share/pstamptool_listuser.sql merged eligible /branches/eam_branches/ipp-20150112/ippTools/share/pstamptool_listuser.sql 37839-38061
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
tags/ipp-20141024/ippTools/src/pstamptool.c
- Property svn:mergeinfo set to
r35955 r38192 60 60 static bool listfileMode(pxConfig *config); 61 61 static bool deletefileMode(pxConfig *config); 62 63 static bool adddomainMode(pxConfig * config); 64 static bool updatedomainMode(pxConfig * config); 65 static bool listdomainMode(pxConfig *config); 66 static bool adduserMode(pxConfig * config); 67 static bool updateuserMode(pxConfig * config); 68 static bool listuserMode(pxConfig * config); 69 static bool addaccesslevelMode(pxConfig * config); 70 static bool updateaccesslevelMode(pxConfig * config); 71 static bool listaccesslevelMode(pxConfig * config); 62 72 63 73 # define MODECASE(caseName, func) \ … … 111 121 MODECASE(PSTAMPTOOL_MODE_DELETEFILE, deletefileMode); 112 122 123 MODECASE(PSTAMPTOOL_MODE_ADDDOMAIN, adddomainMode); 124 MODECASE(PSTAMPTOOL_MODE_UPDATEDOMAIN, updatedomainMode); 125 MODECASE(PSTAMPTOOL_MODE_LISTDOMAIN, listdomainMode); 126 MODECASE(PSTAMPTOOL_MODE_ADDUSER, adduserMode); 127 MODECASE(PSTAMPTOOL_MODE_UPDATEUSER, updateuserMode); 128 MODECASE(PSTAMPTOOL_MODE_LISTUSER, listuserMode); 129 MODECASE(PSTAMPTOOL_MODE_ADDACCESSLEVEL, addaccesslevelMode); 130 MODECASE(PSTAMPTOOL_MODE_UPDATEACCESSLEVEL, updateaccesslevelMode); 131 MODECASE(PSTAMPTOOL_MODE_LISTACCESSLEVEL, listaccesslevelMode); 132 113 133 default: 114 134 psAbort("invalid option (this should not happen)"); … … 1180 1200 1181 1201 // negative simple so the default is true 1182 if (!ippdbPrintMetadatas(stdout, output, "pstamp DataStore", !simple)) {1202 if (!ippdbPrintMetadatas(stdout, output, "pstampProject", !simple)) { 1183 1203 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1184 1204 psFree(output); … … 1702 1722 return true; 1703 1723 } 1724 1725 static bool adddomainMode(pxConfig *config) 1726 { 1727 PS_ASSERT_PTR_NON_NULL(config, false); 1728 1729 PXOPT_LOOKUP_STR(domainName, config->args, "-set_domain", true, false); 1730 PXOPT_LOOKUP_S32(accessLevel, config->args, "-set_accessLevel", true, false); 1731 PXOPT_LOOKUP_STR(defaultProduct, config->args, "-set_defaultProduct", false, false); 1732 PXOPT_LOOKUP_STR(defaultLabel, config->args, "-set_defaultLabel", false, false); 1733 1734 if (!pstampUserDomainInsert(config->dbh, 1735 domainName, 1736 accessLevel, 1737 defaultProduct, 1738 defaultLabel 1739 )) { 1740 psError(PS_ERR_UNKNOWN, false, "failed to insert domain"); 1741 return false; 1742 } 1743 1744 return true; 1745 } 1746 static bool updatedomainMode(pxConfig *config) 1747 { 1748 PS_ASSERT_PTR_NON_NULL(config, false); 1749 1750 PXOPT_LOOKUP_STR(domainName, config->args, "-domain", true, false); 1751 PXOPT_LOOKUP_S32(accessLevel, config->args, "-set_accessLevel", false, false); 1752 PXOPT_LOOKUP_STR(defaultProduct, config->args, "-set_defaultProduct", false, false); 1753 PXOPT_LOOKUP_STR(defaultLabel, config->args, "-set_defaultLabel", false, false); 1754 1755 if (!accessLevel && !defaultProduct && !defaultLabel) { 1756 psError(PS_ERR_UNKNOWN, true, "at least one set option is required"); 1757 return false; 1758 } 1759 1760 psMetadata *where = psMetadataAlloc(); 1761 PXOPT_COPY_STR(config->args, where, "-domain", "domainName", "=="); 1762 if (!psListLength(where->list)) { 1763 psFree(where); 1764 psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required"); 1765 return false; 1766 } 1767 1768 psString query = psStringCopy("UPDATE pstampUserDomain SET"); 1769 1770 char * sep = ""; 1771 if (accessLevel) { 1772 psStringAppend(&query, "%s accessLevel = '%d'", sep, accessLevel); 1773 sep = ", "; 1774 } 1775 if (defaultProduct) { 1776 psStringAppend(&query, "%s defaultProduct = '%s'", sep, defaultProduct); 1777 sep = ", "; 1778 } 1779 if (defaultLabel) { 1780 psStringAppend(&query, "%s defaultLabel = '%s'", sep, defaultLabel); 1781 sep = ", "; 1782 } 1783 1784 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1785 psStringAppend(&query, "\nWHERE %s", whereClause); 1786 psFree(whereClause); 1787 psFree(where); 1788 1789 if (!p_psDBRunQuery(config->dbh, query)) { 1790 psError(PS_ERR_UNKNOWN, false, "database error"); 1791 psFree(query); 1792 return false; 1793 } 1794 1795 // psU64 affected = psDBAffectedRows(config->dbh); 1796 // psLogMsg("pstamptool", PS_LOG_INFO, "Updated %" PRIu64 " pstampRequests", affected); 1797 1798 return true; 1799 } 1800 1801 static bool listdomainMode(pxConfig *config) 1802 { 1803 PS_ASSERT_PTR_NON_NULL(config, false); 1804 1805 psMetadata *where = psMetadataAlloc(); 1806 PXOPT_COPY_STR(config->args, where, "-domain", "domainName", "="); 1807 PXOPT_COPY_S32(config->args, where, "-accessLevel", "accessLevel", "="); 1808 1809 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1810 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1811 1812 psString query = psStringCopy("SELECT * from pstampUserDomain"); 1813 1814 if (psListLength(where->list)) { 1815 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1816 psStringAppend(&query, " WHERE %s", whereClause); 1817 psFree(whereClause); 1818 } 1819 psFree(where); 1820 1821 // treat limit == 0 as "no limit" 1822 if (limit) { 1823 psString limitString = psDBGenerateLimitSQL(limit); 1824 psStringAppend(&query, " %s", limitString); 1825 psFree(limitString); 1826 } 1827 1828 if (!p_psDBRunQuery(config->dbh, query)) { 1829 psError(PS_ERR_UNKNOWN, false, "database error"); 1830 psFree(query); 1831 return false; 1832 } 1833 psFree(query); 1834 1835 psArray *output = p_psDBFetchResult(config->dbh); 1836 if (!output) { 1837 psError(PS_ERR_UNKNOWN, false, "database error"); 1838 return false; 1839 } 1840 if (!psArrayLength(output)) { 1841 psFree(output); 1842 return true; 1843 } 1844 1845 // negative simple so the default is true 1846 if (!ippdbPrintMetadatas(stdout, output, "pstampUserDomain", !simple)) { 1847 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1848 psFree(output); 1849 return false; 1850 } 1851 1852 psFree(output); 1853 1854 return true; 1855 } 1856 static bool adduserMode(pxConfig *config) 1857 { 1858 PS_ASSERT_PTR_NON_NULL(config, false); 1859 1860 PXOPT_LOOKUP_STR(userName, config->args, "-set_user", true, false); 1861 PXOPT_LOOKUP_STR(domainName, config->args, "-set_domain", true, false); 1862 PXOPT_LOOKUP_S32(accessLevel, config->args, "-set_accessLevel", false, false); 1863 PXOPT_LOOKUP_STR(defaultProduct, config->args, "-set_defaultProduct", false, false); 1864 PXOPT_LOOKUP_STR(defaultLabel, config->args, "-set_defaultLabel", false, false); 1865 1866 if (!pstampUserInsert(config->dbh, 1867 userName, 1868 domainName, 1869 accessLevel, 1870 defaultProduct, 1871 defaultLabel 1872 )) { 1873 psError(PS_ERR_UNKNOWN, false, "failed to insert user"); 1874 return false; 1875 } 1876 1877 return true; 1878 } 1879 static bool updateuserMode(pxConfig *config) 1880 { 1881 PS_ASSERT_PTR_NON_NULL(config, false); 1882 1883 PXOPT_LOOKUP_STR(userName, config->args, "-user", true, false); 1884 PXOPT_LOOKUP_STR(domainName, config->args, "-domain", true, false); 1885 PXOPT_LOOKUP_S32(accessLevel, config->args, "-set_accessLevel", false, false); 1886 PXOPT_LOOKUP_STR(defaultProduct, config->args, "-set_defaultProduct", false, false); 1887 PXOPT_LOOKUP_STR(defaultLabel, config->args, "-set_defaultLabel", false, false); 1888 1889 if (!accessLevel && !defaultProduct && !defaultLabel) { 1890 psError(PS_ERR_UNKNOWN, true, "at least one set option is required"); 1891 return false; 1892 } 1893 1894 psMetadata *where = psMetadataAlloc(); 1895 PXOPT_COPY_STR(config->args, where, "-user", "userName", "=="); 1896 PXOPT_COPY_STR(config->args, where, "-domain", "domainName", "=="); 1897 if (!psListLength(where->list)) { 1898 psFree(where); 1899 psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required"); 1900 return false; 1901 } 1902 1903 psString query = psStringCopy("UPDATE pstampUser SET"); 1904 1905 char * sep = ""; 1906 if (accessLevel) { 1907 psStringAppend(&query, "%s accessLevel = '%d'", sep, accessLevel); 1908 sep = ", "; 1909 } 1910 if (defaultProduct) { 1911 psStringAppend(&query, "%s defaultProduct = '%s'", sep, defaultProduct); 1912 sep = ", "; 1913 } 1914 if (defaultLabel) { 1915 psStringAppend(&query, "%s defaultLabel = '%s'", sep, defaultLabel); 1916 sep = ", "; 1917 } 1918 1919 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1920 psStringAppend(&query, "\nWHERE %s", whereClause); 1921 psFree(whereClause); 1922 psFree(where); 1923 1924 if (!p_psDBRunQuery(config->dbh, query)) { 1925 psError(PS_ERR_UNKNOWN, false, "database error"); 1926 psFree(query); 1927 return false; 1928 } 1929 1930 // psU64 affected = psDBAffectedRows(config->dbh); 1931 // psLogMsg("pstamptool", PS_LOG_INFO, "Updated %" PRIu64 " pstampRequests", affected); 1932 1933 return true; 1934 } 1935 static bool listuserMode(pxConfig *config) 1936 { 1937 PS_ASSERT_PTR_NON_NULL(config, false); 1938 1939 psMetadata *where = psMetadataAlloc(); 1940 PXOPT_COPY_STR(config->args, where, "-user", "userName", "="); 1941 PXOPT_COPY_STR(config->args, where, "-domain", "domainName", "="); 1942 PXOPT_COPY_S32(config->args, where, "-accessLevel", "pstampUser.accessLevel", "="); 1943 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1944 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1945 1946 if (!psListLength(where->list)) { 1947 psError(PS_ERR_UNKNOWN, true, "search paramters are required"); 1948 return false; 1949 } 1950 1951 psString query = pxDataGet("pstamptool_listuser.sql"); 1952 1953 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1954 psStringAppend(&query, " WHERE %s", whereClause); 1955 psFree(whereClause); 1956 psFree(where); 1957 1958 // treat limit == 0 as "no limit" 1959 if (limit) { 1960 psString limitString = psDBGenerateLimitSQL(limit); 1961 psStringAppend(&query, " %s", limitString); 1962 psFree(limitString); 1963 } 1964 1965 if (!p_psDBRunQuery(config->dbh, query)) { 1966 psError(PS_ERR_UNKNOWN, false, "database error"); 1967 psFree(query); 1968 return false; 1969 } 1970 psFree(query); 1971 1972 psArray *output = p_psDBFetchResult(config->dbh); 1973 if (!output) { 1974 psError(PS_ERR_UNKNOWN, false, "database error"); 1975 return false; 1976 } 1977 if (!psArrayLength(output)) { 1978 psFree(output); 1979 return true; 1980 } 1981 1982 // negative simple so the default is true 1983 if (!ippdbPrintMetadatas(stdout, output, "pstampUser", !simple)) { 1984 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1985 psFree(output); 1986 return false; 1987 } 1988 1989 psFree(output); 1990 1991 return true; 1992 } 1993 1994 static bool addaccesslevelMode(pxConfig *config) 1995 { 1996 PS_ASSERT_PTR_NON_NULL(config, false); 1997 1998 PXOPT_LOOKUP_S64(proj_id, config->args, "-set_proj_id", false, false); 1999 PXOPT_LOOKUP_STR(project_name, config->args, "-set_project_name", false, false); 2000 PXOPT_LOOKUP_S32(accessLevel, config->args, "-set_accessLevel", true, false); 2001 PXOPT_LOOKUP_F32(mjd_min, config->args, "-set_mjd_min", false, false); 2002 PXOPT_LOOKUP_F32(mjd_max, config->args, "-set_mjd_max", false, false); 2003 2004 if (proj_id) { 2005 if (!pstampAccessLevelInsert(config->dbh, 2006 proj_id, 2007 accessLevel, 2008 mjd_min, 2009 mjd_max 2010 )) { 2011 psError(PS_ERR_UNKNOWN, false, "failed to insert accessLevel"); 2012 return false; 2013 } 2014 } else if (project_name) { 2015 // use select insert getting proj_id from pstampProject 2016 psString query = pxDataGet("pstamptool_addaccesslevel.sql"); 2017 if (!p_psDBRunQueryF(config->dbh, query, accessLevel, mjd_min, mjd_max, project_name)) { 2018 psError(PS_ERR_UNKNOWN, false, "database error"); 2019 psFree(query); 2020 return false; 2021 } 2022 psFree(query); 2023 } else { 2024 psError(PS_ERR_UNKNOWN, true, "proj_id or project_name is required"); 2025 return false; 2026 } 2027 2028 return true; 2029 } 2030 static bool updateaccesslevelMode(pxConfig *config) 2031 { 2032 return false; 2033 } 2034 static bool listaccesslevelMode(pxConfig *config) 2035 { 2036 PS_ASSERT_PTR_NON_NULL(config, false); 2037 2038 psMetadata *where = psMetadataAlloc(); 2039 PXOPT_COPY_STR(config->args, where, "-project_name", "pstampProject.name", "="); 2040 PXOPT_COPY_S64(config->args, where, "-proj_id", "proj_id", "="); 2041 PXOPT_COPY_S32(config->args, where, "-accessLevel", "accessLevel", "="); 2042 2043 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 2044 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 2045 2046 psString query = psStringCopy("SELECT * from pstampAccessLevel join pstampProject USING(proj_id)"); 2047 2048 if (psListLength(where->list)) { 2049 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 2050 psStringAppend(&query, " WHERE %s", whereClause); 2051 psFree(whereClause); 2052 } 2053 psFree(where); 2054 2055 // treat limit == 0 as "no limit" 2056 if (limit) { 2057 psString limitString = psDBGenerateLimitSQL(limit); 2058 psStringAppend(&query, " %s", limitString); 2059 psFree(limitString); 2060 } 2061 2062 if (!p_psDBRunQuery(config->dbh, query)) { 2063 psError(PS_ERR_UNKNOWN, false, "database error"); 2064 psFree(query); 2065 return false; 2066 } 2067 psFree(query); 2068 2069 psArray *output = p_psDBFetchResult(config->dbh); 2070 if (!output) { 2071 psError(PS_ERR_UNKNOWN, false, "database error"); 2072 return false; 2073 } 2074 if (!psArrayLength(output)) { 2075 psFree(output); 2076 return true; 2077 } 2078 2079 // negative simple so the default is true 2080 if (!ippdbPrintMetadatas(stdout, output, "pstampAccessLevel", !simple)) { 2081 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 2082 psFree(output); 2083 return false; 2084 } 2085 2086 psFree(output); 2087 2088 return true; 2089 } 1704 2090 # endif -
tags/ipp-20141024/ippTools/src/pstamptool.h
- Property svn:mergeinfo set to
r32786 r38192 53 53 PSTAMPTOOL_MODE_LISTFILE, 54 54 PSTAMPTOOL_MODE_DELETEFILE, 55 56 PSTAMPTOOL_MODE_ADDUSER, 57 PSTAMPTOOL_MODE_UPDATEUSER, 58 PSTAMPTOOL_MODE_LISTUSER, 59 // PSTAMPTOOL_MODE_GETUSERINFO, 60 61 PSTAMPTOOL_MODE_ADDDOMAIN, 62 PSTAMPTOOL_MODE_UPDATEDOMAIN, 63 PSTAMPTOOL_MODE_LISTDOMAIN, 64 65 PSTAMPTOOL_MODE_ADDACCESSLEVEL, 66 PSTAMPTOOL_MODE_UPDATEACCESSLEVEL, 67 PSTAMPTOOL_MODE_LISTACCESSLEVEL, 55 68 } pstamptoolMode; 56 69 -
tags/ipp-20141024/ippTools/src/pstamptoolConfig.c
- Property svn:mergeinfo set to
r35673 r38192 277 277 // -project 278 278 psMetadata *projectArgs = psMetadataAlloc(); 279 psMetadataAddStr(projectArgs, PS_LIST_TAIL, "-name", 0, "define project name to list (required)", NULL);279 psMetadataAddStr(projectArgs, PS_LIST_TAIL, "-name", 0, "define project name to list", NULL); 280 280 psMetadataAddBool(projectArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 281 281 … … 303 303 psMetadataAddS64(deletefileArgs, PS_LIST_TAIL, "-job_id", 0, "select by job ID (required)", 0); 304 304 305 // Access control tables 306 307 // -adddomain 308 psMetadata *adddomainArgs = psMetadataAlloc(); 309 psMetadataAddStr(adddomainArgs, PS_LIST_TAIL, "-set_domain", 0, "define domain name (required)", NULL); 310 psMetadataAddS32(adddomainArgs, PS_LIST_TAIL, "-set_accessLevel", 0, "define access level for this domain (required)", 0); 311 psMetadataAddStr(adddomainArgs, PS_LIST_TAIL, "-set_defaultProduct", 0, "define default product", NULL); 312 psMetadataAddStr(adddomainArgs, PS_LIST_TAIL, "-set_defaultLabel", 0, "define default Label", NULL); 313 314 // -updatedomain 315 psMetadata *updatedomainArgs = psMetadataAlloc(); 316 psMetadataAddStr(updatedomainArgs, PS_LIST_TAIL, "-domain", 0, "define domain name (required)", NULL); 317 psMetadataAddS32(updatedomainArgs, PS_LIST_TAIL, "-set_accessLevel", 0, "define access level for this domain", 0); 318 psMetadataAddStr(updatedomainArgs, PS_LIST_TAIL, "-set_defaultProduct", 0, "define default product", NULL); 319 psMetadataAddStr(updatedomainArgs, PS_LIST_TAIL, "-set_defaultLabel", 0, "define default Label", NULL); 320 321 // -listdomain 322 psMetadata *listdomainArgs = psMetadataAlloc(); 323 psMetadataAddStr(listdomainArgs, PS_LIST_TAIL, "-domain", 0, "define domain name", NULL); 324 psMetadataAddS32(listdomainArgs, PS_LIST_TAIL, "-accessLevel", 0, "select by access level", 0); 325 psMetadataAddU64(listdomainArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 326 psMetadataAddBool(listdomainArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 327 328 // -adduser 329 psMetadata *adduserArgs = psMetadataAlloc(); 330 psMetadataAddStr(adduserArgs, PS_LIST_TAIL, "-set_user", 0, "define user name (required)", NULL); 331 psMetadataAddStr(adduserArgs, PS_LIST_TAIL, "-set_domain", 0, "define user's domain name (required)", NULL); 332 psMetadataAddS32(adduserArgs, PS_LIST_TAIL, "-set_accessLevel", 0, "define maximum access level for this user", 0); 333 psMetadataAddStr(adduserArgs, PS_LIST_TAIL, "-set_defaultProduct", 0, "define default data store product for this user", NULL); 334 psMetadataAddStr(adduserArgs, PS_LIST_TAIL, "-set_defaultLabel", 0, "define default label for requests from this user", NULL); 335 336 // -updateuser 337 psMetadata *updateuserArgs = psMetadataAlloc(); 338 psMetadataAddStr(updateuserArgs, PS_LIST_TAIL, "-user", 0, "select user to update (required)", NULL); 339 psMetadataAddStr(updateuserArgs, PS_LIST_TAIL, "-domain", 0, "select domain of user to update (required)", NULL); 340 psMetadataAddS32(updateuserArgs, PS_LIST_TAIL, "-set_accessLevel", 0, "define access level for this domain", 0); 341 psMetadataAddStr(updateuserArgs, PS_LIST_TAIL, "-set_defaultProduct", 0, "define default product", NULL); 342 psMetadataAddStr(updateuserArgs, PS_LIST_TAIL, "-set_defaultLabel", 0, "define default Label", NULL); 343 344 // -listuser 345 psMetadata *listuserArgs = psMetadataAlloc(); 346 psMetadataAddStr(listuserArgs, PS_LIST_TAIL, "-user", 0, "select by user name", NULL); 347 psMetadataAddStr(listuserArgs, PS_LIST_TAIL, "-domain", 0, "select by user's domain name", NULL); 348 psMetadataAddS32(listuserArgs, PS_LIST_TAIL, "-accessLevel", 0, "select by maximum access level", 0); 349 psMetadataAddU64(listuserArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 350 psMetadataAddBool(listuserArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 351 352 // -addaccesslevel 353 psMetadata *addaccesslevelArgs = psMetadataAlloc(); 354 psMetadataAddStr(addaccesslevelArgs, PS_LIST_TAIL, "-set_project_name", 0, "define project name", NULL); 355 psMetadataAddS64(addaccesslevelArgs, PS_LIST_TAIL, "-set_proj_id", 0, "define project ID", 0); 356 psMetadataAddS32(addaccesslevelArgs, PS_LIST_TAIL, "-set_accessLevel", 0, "define access level (required)", 0); 357 psMetadataAddF32(addaccesslevelArgs, PS_LIST_TAIL, "-set_mjd_min", 0, "define mjd_min", 0.0); 358 psMetadataAddF32(addaccesslevelArgs, PS_LIST_TAIL, "-set_mjd_max", 0, "define mjd_max", 0.0); 359 360 // -listaccesslevel 361 psMetadata *listaccesslevelArgs = psMetadataAlloc(); 362 psMetadataAddStr(listaccesslevelArgs, PS_LIST_TAIL, "-project_name", 0, "search by project name", NULL); 363 psMetadataAddS64(listaccesslevelArgs, PS_LIST_TAIL, "-proj_id", 0, "select by project ID", 0); 364 psMetadataAddS32(listaccesslevelArgs, PS_LIST_TAIL, "-accessLevel", 0, "select by access level", 0); 365 psMetadataAddU64(listaccesslevelArgs, PS_LIST_TAIL, "-limit", 0, "limit result set to N items", 0); 366 psMetadataAddBool(listaccesslevelArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false); 367 368 // -updateaccesslevel 369 psMetadata *updateaccesslevelArgs = psMetadataAlloc(); 370 psMetadataAddStr(updateaccesslevelArgs, PS_LIST_TAIL, "-project_name", 0, "select by project name", NULL); 371 psMetadataAddS64(updateaccesslevelArgs, PS_LIST_TAIL, "-proj_id", 0, "select by project ID", 0); 372 psMetadataAddS32(updateaccesslevelArgs, PS_LIST_TAIL, "-accessLevel", 0, "select by access level (required)", 0); 373 psMetadataAddF32(updateaccesslevelArgs, PS_LIST_TAIL, "-set_mjd_min", 0, "define new mjd_min", NAN); 374 psMetadataAddF32(updateaccesslevelArgs, PS_LIST_TAIL, "-set_mjd_max", 0, "define new mjd_max", NAN); 375 305 376 PXOPT_ADD_MODE("-addreq", "", PSTAMPTOOL_MODE_ADDREQ, addreqArgs); 306 377 PXOPT_ADD_MODE("-pendingreq", "", PSTAMPTOOL_MODE_PENDINGREQ, pendingreqArgs); … … 334 405 PXOPT_ADD_MODE("-listfile", "", PSTAMPTOOL_MODE_LISTFILE, listfileArgs); 335 406 PXOPT_ADD_MODE("-deletefile", "", PSTAMPTOOL_MODE_DELETEFILE, deletefileArgs); 407 408 PXOPT_ADD_MODE("-adddomain", "", PSTAMPTOOL_MODE_ADDDOMAIN, adddomainArgs); 409 PXOPT_ADD_MODE("-updatedomain", "", PSTAMPTOOL_MODE_UPDATEDOMAIN, updatedomainArgs); 410 PXOPT_ADD_MODE("-listdomain", "", PSTAMPTOOL_MODE_LISTDOMAIN, listdomainArgs); 411 PXOPT_ADD_MODE("-adduser", "", PSTAMPTOOL_MODE_ADDUSER, adduserArgs); 412 PXOPT_ADD_MODE("-updateuser", "", PSTAMPTOOL_MODE_UPDATEUSER, updateuserArgs); 413 PXOPT_ADD_MODE("-listuser", "", PSTAMPTOOL_MODE_LISTUSER, listuserArgs); 414 PXOPT_ADD_MODE("-addaccesslevel", "", PSTAMPTOOL_MODE_ADDACCESSLEVEL, addaccesslevelArgs); 415 PXOPT_ADD_MODE("-listaccesslevel", "", PSTAMPTOOL_MODE_LISTACCESSLEVEL, listaccesslevelArgs); 336 416 337 417 if (!pxGetOptions(stderr, argc, argv, config, modes, argSets)) { -
tags/ipp-20141024/ippTools/src/releasetool.c
- Property svn:mergeinfo set to
r37165 r38192 195 195 PXOPT_LOOKUP_STR(dvodb, config->args, "-set_dvodb", false, false); 196 196 PXOPT_LOOKUP_STR(ubercal_file, config->args, "-set_ubercal_file", false, false); 197 PXOPT_LOOKUP_S32(accessLevelMin, config->args, "-set_accessLevelMin", false, false); 197 198 198 199 if (!ippReleaseInsert(config->dbh, … … 204 205 priority, 205 206 dvodb, 206 ubercal_file 207 ubercal_file, 208 accessLevelMin 207 209 )) { 208 210 psError(PS_ERR_UNKNOWN, false, "failed to insert ippRelease"); … … 229 231 PXOPT_LOOKUP_STR(dvodb, config->args, "-set_dvodb", false, false); 230 232 PXOPT_LOOKUP_STR(ubercal_file, config->args, "-set_ubercal_file", false, false); 231 if (!release_state && priority == 0 && dataRelease == -1 && !dvodb && !ubercal_file) { 233 PXOPT_LOOKUP_S32(accessLevelMin, config->args, "-set_accessLevelMin", false, false); 234 if (!release_state && priority == 0 && dataRelease == -1 && !dvodb && !ubercal_file && accessLevelMin < 0) { 232 235 psError(PXTOOLS_ERR_CONFIG, true, "at least one of -set_release_state -set_priority -set_dvodb -set_ubercal_file and -set_dataRelease is required\n"); 233 236 return false; … … 252 255 if (dataRelease != -1) { 253 256 psStringAppend(&query, "%s dataRelease = %d", sep, dataRelease); 257 sep = comma; 258 } 259 if (accessLevelMin != -1) { 260 psStringAppend(&query, "%s accessLevelMin = %d", sep, accessLevelMin); 254 261 sep = comma; 255 262 } -
tags/ipp-20141024/ippTools/src/releasetoolConfig.c
- Property svn:mergeinfo set to
r37165 r38192 62 62 psMetadataAddStr(definereleaseArgs, PS_LIST_TAIL, "-set_release_name", 0, "define release name (required)", NULL); 63 63 psMetadataAddS32(definereleaseArgs, PS_LIST_TAIL, "-set_dataRelease", 0, "define dataRelease", -1); 64 psMetadataAddS32(definereleaseArgs, PS_LIST_TAIL, "-set_accessLevelMin", 0, "define accessLevelMin", 0); 64 65 psMetadataAddStr(definereleaseArgs, PS_LIST_TAIL, "-set_release_state", 0, "define release state", NULL); 65 66 psMetadataAddS32(definereleaseArgs, PS_LIST_TAIL, "-set_priority", 0, "define release priority", 0); … … 77 78 psMetadataAddS32(updatereleaseArgs, PS_LIST_TAIL, "-set_priority", 0, "define new release priority", 0); 78 79 psMetadataAddS32(updatereleaseArgs, PS_LIST_TAIL, "-set_dataRelease", 0, "define data release", -1); 80 psMetadataAddS32(updatereleaseArgs, PS_LIST_TAIL, "-set_accessLevelMin", 0, "define accessLevelMin", -1); 79 81 psMetadataAddStr(updatereleaseArgs, PS_LIST_TAIL, "-set_dvodb", 0, "define new dvo db name", NULL); 80 82 psMetadataAddStr(updatereleaseArgs, PS_LIST_TAIL, "-set_ubercal_file", 0, "define new ubercal file name", NULL); -
tags/ipp-20141024/pstamp
- Property svn:mergeinfo set to
-
tags/ipp-20141024/pstamp/scripts/psmkreq
r36821 r38192 1 #!/ bin/env perl1 #!/usr/bin/env perl 2 2 ### 3 3 ### psmkreq … … 30 30 31 31 my ($image, $mask, $variance, $jpeg, $cmf, $psf, $backmdl, $inverse, $restorebackground); 32 my ($exptime, $expnum, $exptimejpeg, $expnumjpeg); 32 33 my ($convolved, $unconvolved, $uncompressed, $use_imfile_id, $no_wait); 33 34 … … 116 117 'psf' => \$psf, 117 118 'backmdl' => \$backmdl, 119 'exptime' => \$exptime, 120 'expnum' => \$expnum, 121 'exptimejpeg' => \$exptimejpeg, 122 'expnumjpeg' => \$expnumjpeg, 118 123 'inverse' => \$inverse, 119 124 'unconvolved' => \$unconvolved, … … 217 222 $option_mask = $PSTAMP_SELECT_IMAGE if $option_mask == 0; 218 223 219 220 224 $option_mask |= $PSTAMP_SELECT_CMF if $cmf; 221 225 $option_mask |= $PSTAMP_SELECT_PSF if $psf; 222 226 $option_mask |= $PSTAMP_SELECT_BACKMDL if $backmdl; 227 $option_mask |= $PSTAMP_SELECT_EXP if $exptime; 228 $option_mask |= $PSTAMP_SELECT_NUM if $expnum; 229 $option_mask |= $PSTAMP_SELECT_EXPJPEG if $exptimejpeg; 230 $option_mask |= $PSTAMP_SELECT_NUMJPEG if $expnumjpeg; 223 231 $option_mask |= $PSTAMP_SELECT_UNCOMPRESSED if $uncompressed; 224 232 $option_mask |= $PSTAMP_SELECT_UNCONV if $unconvolved; -
tags/ipp-20141024/pstamp/scripts/pstamp_checkdependent.pl
- Property svn:mergeinfo deleted
-
tags/ipp-20141024/pstamp/scripts/pstamp_finish.pl
- Property svn:mergeinfo deleted
-
tags/ipp-20141024/pstamp/scripts/pstamp_job_run.pl
- Property svn:mergeinfo deleted
-
tags/ipp-20141024/pstamp/scripts/pstampparse.pl
- Property svn:mergeinfo deleted
r38006 r38192 18 18 use POSIX; 19 19 use Time::HiRes qw(gettimeofday); 20 use Time::Local; 20 21 21 22 my $verbose; … … 32 33 my $dest_requires_magic; 33 34 my $dump_params = 0; 35 my $new_email; 36 37 my %accessLevelCache; 34 38 35 39 # set this to true to disable update processing … … 42 46 'product=s' => \$product, 43 47 'label=s' => \$label, 48 'new_email=s' => \$new_email, 44 49 'mode=s' => \$mode, 45 50 'need_magic'=> \$dest_requires_magic, … … 54 59 die "invalid mode '$mode'" unless ($mode eq "list_uri") or ($mode eq "queue_job"); 55 60 die "--file is required" unless defined($request_file_name); 56 57 if ($mode ne "list_uri") { 58 die "req_id is required" if !$req_id; 61 die "req_id is required" unless defined $req_id; 62 if ($mode ne 'list_uri') { 59 63 die "outdir is required" if !$outdir; 60 die "product is required" if !$product;61 64 } else { 62 # mode eq 'list_uri' (used for parser testing) 63 # these values won't be used for anything but should be defined to avoid errors 64 $req_id = 0; 65 $outdir = "nowhere"; 66 $product = "dummy"; 65 $outdir = "somewhere" if !$outdir 67 66 } 68 67 … … 94 93 # do not update the database 95 94 $no_update = 1 if $mode ne "queue_job"; 95 96 $product = 'NULL' unless $product; 97 98 99 # look up some defaults 100 my $defaultAccessLevel = metadataLookupS32($ipprc->{_siteConfig}, 'PSTAMP_DEFAULT_ACCESS_LEVEL'); 101 if (!defined $defaultAccessLevel) { 102 warn("cannot find 'PSTAMP_DEFAULT_ACCESS_LEVEL' in site config"); 103 exit ($PS_EXIT_CONFIG_ERROR); 104 } 105 106 # look up the default data store product. 107 my $defaultDSProduct = metadataLookupStr($ipprc->{_siteConfig}, 'PSTAMP_DATA_STORE_PRODUCT'); 108 if (!defined $defaultDSProduct) { 109 # Don't panic yet that it's not defined. 110 # exit ($PS_EXIT_CONFIG_ERROR); 111 $defaultDSProduct = ''; # set to empty string to simplify some comparisions below 112 print STDERR "Warning PSTAMP_DATA_STORE_PRODUCT not found in the site config.\n" if $product eq 'NULL'; 113 } 114 115 my $productIsDefault = 0; 116 if ($product and $defaultDSProduct) { 117 $productIsDefault = ($product eq $defaultDSProduct); 118 } 96 119 97 120 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files … … 123 146 print STDERR "Note that EMAIL will not be optional\n"; 124 147 148 # if need be we can hack Peter Veres' email in here if label = 'WEB.UP' and req_name like 'Peter_Veres%' 149 125 150 } elsif (!$email) { 126 151 my_die("ERROR: Required parameter EMAIL not found in request file header.\n", $PSTAMP_INVALID_REQUEST) 127 152 } 153 154 128 155 129 156 … … 139 166 my_die("email not supplied in version $extver request file $request_file_name\n", $PSTAMP_INVALID_REQUEST) 140 167 unless $email; 141 142 # XXX check for "valid" $email143 168 } else { 144 169 # for version 1 file the action is process and email is not used … … 148 173 149 174 print "Request Header Keywords EXTVER: $extver REQ_NAME: $req_name ACTION: $action EMAIL: $email\n"; 175 176 if ($new_email) { 177 # this is primarily for ease in testing 178 print "Setting email to command line provided value $new_email\n"; 179 $email = $new_email 180 } 150 181 151 182 # check for duplicate request name … … 158 189 my $exitStatus = $error_code >> 8; 159 190 if ($success) { 160 # -listreq succeeded duplicate requestname191 # -listreq succeeded there is already a request in the database with this name 161 192 print STDERR "REQ_NAME $req_name has already been used\n"; 162 193 insertFakeJobForRow(undef, 0, $PSTAMP_DUP_REQUEST); … … 169 200 170 201 171 # Adjust the label for requests coming in over the web interface172 202 173 203 my $label_changed = 0; 204 if (0) { 205 # Adjust the label for requests coming in over the web upload interface 206 # XXX: do this later based on the user information 207 # We now use the access tabels to set the label. 174 208 if ($label and $label eq "WEB.UP") { 175 209 my $lcname = lc($req_name); … … 198 232 print "Setting label for $req_name to $label\n" if $label_changed; 199 233 } 200 234 } 235 236 # based on the user's email address get the accessLevel, default label and data store product 237 my $productForUser; 238 my $labelForUser = $label; # XXX: for now I pass the current label for use in hacking permissions for V1 requests. 239 240 my $accessLevel = getUsersAccessLevel($email, \$labelForUser, \$productForUser); 241 if ($accessLevel < 0) { 242 print STDERR "Data access is forbidden for $email.\n"; 243 insertFakeJobForRow(undef, 0, $PSTAMP_NOT_AUTHORIZED); 244 } 245 246 # if the request came through the request table upload channel, change it to the user's specific label 247 # if any is known. Do we want to do this for any other channels? 248 # requests from data store will have those values. 249 if ($label and $label eq 'WEB.UP') { 250 if ($labelForUser) { 251 $label = $labelForUser; 252 $label_changed = 1; 253 } 254 } 255 256 # If the product is the system default, set it to the product for the user@domain. That way 257 # if the request came through a data store that target will be used. 258 # We really only need to redirect the results with greater access level than the default. 259 # note that for most users productForUser will be undef so the default will be used. 260 if ($productIsDefault or $product eq 'NULL') { 261 if ($productForUser) { 262 $product = $productForUser; 263 } 264 } else { 265 # if we don't have a product use default 266 if ($product eq 'NULL') { 267 $product = $defaultDSProduct; 268 } 269 } 270 271 if (!$product or $product eq 'NULL') { 272 # this will only happen if the site.config variable is missing. 273 my_die("No product found.\n", $PS_EXIT_CONFIG_ERROR); 274 } 201 275 202 276 { 203 # update the database with the request name. This will be used as the204 # the fileset name in the output data store277 # update the request's row with the new parameters. 278 # The requset name will be used to set the output fileset name in the output data store. 205 279 my $command = "$pstamptool -updatereq -req_id $req_id -set_name $req_name"; 206 280 $command .= " -set_username $email" if $email ne 'null'; … … 218 292 } 219 293 294 # in these two error conditions we are done. The invoking script will finish up. 220 295 if ($duplicate_req_name) { 221 296 exit 0; 222 297 } 298 299 if ($accessLevel < 0) { 300 exit 0; 301 } 302 223 303 224 304 # … … 270 350 my $num_jobs = 0; 271 351 352 272 353 foreach my $row (@$rows) { 273 354 … … 281 362 $row->{job_num} = 0; 282 363 $row->{error_code} = 0; 364 $row->{accessLevel} = $accessLevel; 283 365 284 366 $num_jobs += processRow($action, $row); … … 292 374 293 375 if (($action eq 'LIST' or $mode eq "queue_job") and ($num_jobs eq 0)) { 294 # this should not happen. The function aboveis required to insert a fake job for any376 # this should not happen. The processRow is required to insert a fake job for any 295 377 # rows that did not yield any jobs. 296 378 print STDERR "ERROR: zero jobs created for $req_name\n"; … … 508 590 my $rownum = $row->{ROWNUM}; 509 591 592 my $mjd_max; 593 my $adjustedDateCuts = adjustDateCuts($row, \$mjd_max); 594 if ($adjustedDateCuts and $mjd_max < 0) { 595 print STDERR "User is not authorized for data from this project.\n"; 596 insertFakeJobForRow($row, 1, $PSTAMP_NOT_AUTHORIZED); 597 $num_jobs++; 598 return $num_jobs; 599 } 600 510 601 # Since user can get unmagicked data "by coordinate" requests can go back in time 511 602 # to dredge unusable data from the "dark days"... … … 519 610 # avoid error from print below if $id isn't needed 520 611 $row->{ID} = "" if !$row->{ID}; 612 613 # if this user does not have unlimited access rights adjust the date cut 614 # to avoid more recent data 615 # We do not adjust dates for stacks since they are not well defined enough. 616 # We'll need to filter them by accessLevel during the lookup 617 my $stage = $row->{IMG_TYPE}; 618 if ($stage ne 'stack' and $adjustedDateCuts) { 619 # if lower limit was supplied by user we can leave the value alone 620 if ($row->{MJD_MAX}) { 621 if ($row->{MJD_MAX} > $mjd_max) { 622 print STDERR "Access rights require limiting MJD_MAX to $mjd_max\n"; 623 $row->{MJD_MAX} = $mjd_max; 624 } 625 } else { 626 # no limit supplied we silently adjust it 627 $row->{MJD_MAX} = $mjd_max; 628 } 629 } 521 630 } 522 631 … … 547 656 } 548 657 549 sub processRows {550 my $action = shift;551 my $rowList = shift;552 my $num_jobs = 0;553 554 if ($action eq 'LIST') {555 # LIST is not allowed by caller. Can't get here.556 return list_targets($rowList);557 }558 559 # all rows in the list are compatible560 my $row = $rowList->[0];561 562 my $project = $row->{PROJECT};563 564 # note: resolve_project avoids running pstamptool every time by remembering the565 # last project resolved566 my $proj_hash = resolve_project($ipprc, $project, $dbname, $dbserver);567 if (!$proj_hash) {568 foreach my $r (@$rowList) {569 insertFakeJobForRow($r, 1, $PSTAMP_UNKNOWN_PRODUCT);570 $num_jobs++;571 }572 return $num_jobs;573 }574 my $req_type = $row->{REQ_TYPE};575 my $stage = $row->{IMG_TYPE};576 my $id = $row->{ID};577 my $component = $row->{COMPONENT};578 my $tess_id = $row->{TESS_ID};579 580 my $filter = $row->{REQFILT};581 my $mjd_min = $row->{MJD_MIN};582 my $mjd_max = $row->{MJD_MAX};583 my $data_group = $row->{DATA_GROUP};584 585 my $rownum = $row->{ROWNUM};586 my $job_type = $row->{JOB_TYPE};587 my $option_mask= $row->{OPTION_MASK};588 589 my $image_db = $proj_hash->{dbname};590 my $camera = $proj_hash->{camera};591 my $need_magic = $proj_hash->{need_magic};592 # Since user can get unmagicked data "by coordinate" requests can go back in time593 # to dredge unusable data from the "dark days"...594 if ($req_type eq 'bycoord' and $mjd_min eq 0) {595 # ... so unless the user sets mjd_min clamp it to 2009-04-01596 # XXX: This value should live in the pstampProject table not be hardcoded here597 $mjd_min = 54922;598 }599 600 $need_magic = 0 if $stage eq 'stack';601 602 # XXX: magic is dead603 $need_magic = 0;604 605 my $numRows = scalar @$rowList;606 607 if (($req_type eq 'byskycell') or ($req_type eq 'bycoord')) {608 # avoid error from print below if $id isn't needed609 $id = "" if !$id;610 }611 print "Collected $numRows rows beginning with row $rownum. $req_type $stage $id $tess_id $component\n";612 613 # Call PS::IPP::PStamp::Job locate_images subroutine to get the images for this614 # request specification. An array reference is returned.615 my $start_locate = gettimeofday();616 617 # XXX: perhaps we should get rid of most of this argument list.618 # Now that we are passing down compatible rows all of the619 # information required is contained there620 621 my $imageList = locate_images($ipprc, $image_db, $rowList, $req_type, $stage, $id, $tess_id, $component,622 $option_mask, $need_magic, $mjd_min, $mjd_max, $filter, $data_group, $verbose);623 624 my $dtime_locate = gettimeofday() - $start_locate;625 print "Time to locate_images for row $rownum $dtime_locate\n";626 627 # handle this628 # XXX: what did I mean by that comment?629 $row->{need_magic} = $need_magic;630 631 $num_jobs += queueJobs($action, $rowList, $imageList);632 633 # if a row slipped through with no jobs add a faulted one634 foreach my $row (@$rowList) {635 if ($row->{job_num} == 0) {636 print "row $row->{ROWNUM} produced no jobs\n";637 print STDERR "row $row->{ROWNUM} produced no jobs\n";638 my $error_code = $row->{error_code};639 $error_code = $PSTAMP_NO_IMAGE_MATCH if !$error_code;640 insertFakeJobForRow($row, ++$row->{job_num}, $error_code);641 }642 }643 644 return $num_jobs;645 }646 647 658 sub queueJobForImage 648 659 { … … 658 669 659 670 $option_mask |= $PSTAMP_NO_WAIT_FOR_UPDATE if $no_updates_allowed; 671 672 # determine if there is a cut off date for data access for this user 673 my $mjd_max; 674 my $adjustedDateCuts = adjustDateCuts($row, \$mjd_max); 660 675 661 676 my $roi_string; … … 702 717 703 718 my $imagefile = $image->{image}; 704 if (($stage ne "stack") and ($need_magic and !$image->{magicked})) { 705 # XXX: should we add a faulted job so the client can know what happened if no images come back? 706 # The test for destreaked is made in locate_images now so this code never runs. This leads to no feedback 707 # to users, but speeds up processing significantly 708 print STDERR "skipping non-magicked image $imagefile\n" if $verbose; 709 710 # for now assume yes. 711 712 insertFakeJobForRow($row, $job_num, $PSTAMP_NOT_DESTREAKED); 713 return 1; 714 } elsif ($stage eq "stack") { 719 720 if ($stage eq "stack") { 715 721 # unconvolved stack images weren't available prior to some point in time. 716 722 # XXX: handle this more correctly by examining the stack run's config dump file. … … 723 729 insertFakeJobForRow($row, $job_num, $PSTAMP_NOT_AVAILABLE); 724 730 return 1; 731 } 732 } else { 733 if ($need_magic and !$image->{magicked}) { 734 # XXX: should we add a faulted job so the client can know what happened if no images come back? 735 # The test for destreaked is made in locate_images now so this code never runs. This leads to no feedback 736 # to users, but speeds up processing significantly 737 print STDERR "skipping non-magicked image $imagefile\n" if $verbose; 738 739 # for now assume yes. 740 741 insertFakeJobForRow($row, $job_num, $PSTAMP_NOT_DESTREAKED); 742 return 1; 743 } 744 745 if ($adjustedDateCuts) { 746 my $mjd = 0; 747 my $exp_id; 748 if ($stage eq 'diff') { 749 # diff stage doesn't have a dateobs so we need to hack it. 750 # Extract dateobs from the exp_name_1 751 if ($row->{PROJECT} eq 'gpc1') { 752 my $exp_name = $image->{exp_name_1}; 753 if ($exp_name ne 'NULL') { 754 $mjd = 50000 + (substr($exp_name, 1, 4)); 755 $exp_id = $image->{exp_id_1}; 756 } else { 757 # it's stack-stack diff just let it go with mjd = 0 758 # XXX: deal with this 759 } 760 } 761 } else { 762 $exp_id = $image->{exp_id}; 763 $mjd = dateobsToMJD($image->{dateobs}); 764 } 765 766 if ($mjd > $mjd_max) { 767 print "User is not authorized for stamps from this exposure exp_id $exp_id.\n"; 768 print STDERR "User is not authorized for stamps from this exposure exp_id $exp_id.\n"; 769 insertFakeJobForRow($row, $job_num, $PSTAMP_NOT_AUTHORIZED, $exp_id); 770 return 1; 771 } 725 772 } 726 773 } … … 953 1000 my $job_num = shift; 954 1001 my $fault = shift; 1002 my $exp_id = shift; 955 1003 956 1004 my ($job_type, $rownum); … … 975 1023 my $command = "$pstamptool -addjob -req_id $req_id -job_type $job_type" 976 1024 . " -rownum $rownum -state stop -fault $fault"; 1025 $command .= " -exp_id $exp_id" if $exp_id and $exp_id ne 'NULL'; 977 1026 978 1027 if (!$no_update) { … … 1230 1279 } 1231 1280 1281 # get user's access level default label and output product 1282 sub getUsersAccessLevel { 1283 my $email = shift; 1284 my $r_label = shift; 1285 my $r_product = shift; 1286 1287 # $r_label is a copy of the initial label. We change it to a user specific one 1288 # if one is found. 1289 my $label = $$r_label; 1290 1291 # default settings 1292 $$r_label = undef; 1293 $$r_product = undef; 1294 my $level = -1; 1295 1296 if (!$email) { 1297 # No email provided. 1298 # For now in order to temporarily continue to support the version 1 request format. 1299 # set the access rights based on the assigned label. 1300 # Before deployment this will be forbidden. 1301 if ($label eq 'IFA' or $label eq 'QUB' or $label =~ 'MOPS') { 1302 $level = 2; 1303 } else { 1304 $level = $defaultAccessLevel; 1305 } 1306 return $level 1307 } 1308 1309 # we've got an email check the domain 1310 my ($user, $domain) = split '@', $email; 1311 unless ($user and $domain) { 1312 print STDERR "Error $email is not an acceptable email adddress.\n"; 1313 return -1; 1314 } 1315 1316 my $cmd = "$pstamptool -listuser -user $user -domain $domain"; 1317 my $results = runToolAndParse($cmd, $verbose); 1318 my $userinfo = $results->[0]; 1319 if ($userinfo) { 1320 $level = $userinfo->{accessLevel}; 1321 if ($userinfo->{userProduct}) { 1322 $$r_product = $userinfo->{userProduct}; 1323 } elsif ($userinfo->{domainProduct}) { 1324 $$r_product = $userinfo->{domainProduct}; 1325 } 1326 if ($userinfo->{userLabel}) { 1327 $$r_label = $userinfo->{userLabel}; 1328 } elsif ($userinfo->{domainLabel}) { 1329 $$r_label = $userinfo->{domainLabel}; 1330 } 1331 } else { 1332 my $cmd = "$pstamptool -listdomain -domain $domain"; 1333 my $results = runToolAndParse($cmd, $verbose); 1334 my $domaininfo = $results->[0]; 1335 if ($domaininfo) { 1336 $level = $domaininfo->{accessLevel}; 1337 if ($domaininfo->{defaultProduct}) { 1338 $$r_product = $domaininfo->{defaultProduct}; 1339 } 1340 if ($domaininfo->{defaultLabel}) { 1341 $$r_label = $domaininfo->{defaultLabel}; 1342 } 1343 } else { 1344 # no specific user or domain information found in the database. Use the defaults 1345 $level = $defaultAccessLevel; 1346 $$r_label = undef; 1347 $$r_product = undef; 1348 } 1349 } 1350 1351 return $level; 1352 } 1353 1354 1355 # determine the latest exposure date that a user may have access to 1356 # based on the user's accessLevel. 1357 sub adjustDateCuts { 1358 my $row = shift; 1359 my $r_mjd_max = shift; 1360 my $adjusted = 0; 1361 1362 my $accessLevel = $row->{accessLevel}; 1363 my $project = $row->{PROJECT}; 1364 my $mjd_max_user = $row->{MJD_MAX}; 1365 1366 my $key = "$project.$accessLevel"; 1367 1368 my $levelInfo = $accessLevelCache{$key}; 1369 1370 if (!$levelInfo) { 1371 my $cmd = "$pstamptool -listaccesslevel -accessLevel $accessLevel -project_name $project"; 1372 my $results = runToolAndParse($cmd, $verbose); 1373 if (!$results or !$results->[0]) { 1374 my_die("failed to find accessLevel info for project: $project level: $accessLevel\n", $PS_EXIT_CONFIG_ERROR); 1375 } 1376 $levelInfo = $results->[0]; 1377 $accessLevelCache{$key} = $levelInfo; 1378 } 1379 1380 my $mjd_max_thisLevel = $levelInfo->{mjd_max}; 1381 if ($mjd_max_thisLevel) { 1382 # This project has a limit for this level 1383 # adjust the user supplied limit unless it is less than the maximum 1384 1385 if (!$mjd_max_user or ($mjd_max_user > $mjd_max_thisLevel)) { 1386 $$r_mjd_max = $mjd_max_thisLevel; 1387 $adjusted = 1; 1388 } 1389 } 1390 1391 return $adjusted; 1392 } 1393 1394 sub dateobsToMJD { 1395 my $dateobs = shift; 1396 1397 my ($date, $time) = split "T", $dateobs; 1398 1399 my ($year, $mon, $day) = split "-", $date; 1400 1401 my ($hr, $min, $sec) = split ":", $time; 1402 my $fraction = $sec - int($sec); 1403 $sec = int($sec); 1404 1405 my $ticks = timegm($sec, $min, $hr, $day, $mon-1, $year-1900); 1406 $ticks += $fraction; 1407 1408 # I'm not allowing for leap seconds here but for our purposes here that is ok 1409 my $mjd = 40587.0 + ($ticks / 86400.); 1410 return $mjd; 1411 } 1412 1232 1413 sub my_die 1233 1414 { -
tags/ipp-20141024/pstamp/scripts/request_finish.pl
- Property svn:mergeinfo deleted
Note:
See TracChangeset
for help on using the changeset viewer.
